diff --git a/sdk/consumption/azure-mgmt-consumption/_meta.json b/sdk/consumption/azure-mgmt-consumption/_meta.json new file mode 100644 index 000000000000..b2508234f730 --- /dev/null +++ b/sdk/consumption/azure-mgmt-consumption/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "8fd5124f1866ebf7698fd292d8f66931e9de13c5", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/consumption/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/consumption/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/__init__.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/__init__.py index 2bdfad84041a..a8ec29fea571 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/__init__.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ConsumptionManagementClient'] -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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_configuration.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_configuration.py index 23d380af7ac4..0fa38bf0ec13 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_configuration.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,15 +40,15 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(ConsumptionManagementClientConfiguration, 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(ConsumptionManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-10-01" + self.api_version = "2021-10-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-consumption/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +68,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py index bd8acadb67e7..a84d9c812888 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py @@ -6,38 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import ConsumptionManagementClientConfiguration +from .operations import AggregatedCostOperations, BalancesOperations, BudgetsOperations, ChargesOperations, CreditsOperations, EventsOperations, LotsOperations, MarketplacesOperations, Operations, PriceSheetOperations, ReservationRecommendationDetailsOperations, ReservationRecommendationsOperations, ReservationTransactionsOperations, ReservationsDetailsOperations, ReservationsSummariesOperations, TagsOperations, UsageDetailsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - -from ._configuration import ConsumptionManagementClientConfiguration -from .operations import UsageDetailsOperations -from .operations import MarketplacesOperations -from .operations import BudgetsOperations -from .operations import TagsOperations -from .operations import ChargesOperations -from .operations import BalancesOperations -from .operations import ReservationsSummariesOperations -from .operations import ReservationsDetailsOperations -from .operations import ReservationRecommendationsOperations -from .operations import ReservationRecommendationDetailsOperations -from .operations import ReservationTransactionsOperations -from .operations import PriceSheetOperations -from .operations import ForecastsOperations -from .operations import Operations -from .operations import AggregatedCostOperations -from .operations import EventsOperations -from .operations import LotsOperations -from .operations import CreditsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class ConsumptionManagementClient(object): """Consumption management client provides access to consumption resources for Azure Enterprise Subscriptions. @@ -55,19 +39,21 @@ class ConsumptionManagementClient(object): :ivar balances: BalancesOperations operations :vartype balances: azure.mgmt.consumption.operations.BalancesOperations :ivar reservations_summaries: ReservationsSummariesOperations operations - :vartype reservations_summaries: azure.mgmt.consumption.operations.ReservationsSummariesOperations + :vartype reservations_summaries: + azure.mgmt.consumption.operations.ReservationsSummariesOperations :ivar reservations_details: ReservationsDetailsOperations operations :vartype reservations_details: azure.mgmt.consumption.operations.ReservationsDetailsOperations :ivar reservation_recommendations: ReservationRecommendationsOperations operations - :vartype reservation_recommendations: azure.mgmt.consumption.operations.ReservationRecommendationsOperations + :vartype reservation_recommendations: + azure.mgmt.consumption.operations.ReservationRecommendationsOperations :ivar reservation_recommendation_details: ReservationRecommendationDetailsOperations operations - :vartype reservation_recommendation_details: azure.mgmt.consumption.operations.ReservationRecommendationDetailsOperations + :vartype reservation_recommendation_details: + azure.mgmt.consumption.operations.ReservationRecommendationDetailsOperations :ivar reservation_transactions: ReservationTransactionsOperations operations - :vartype reservation_transactions: azure.mgmt.consumption.operations.ReservationTransactionsOperations + :vartype reservation_transactions: + azure.mgmt.consumption.operations.ReservationTransactionsOperations :ivar price_sheet: PriceSheetOperations operations :vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations - :ivar forecasts: ForecastsOperations operations - :vartype forecasts: azure.mgmt.consumption.operations.ForecastsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.consumption.operations.Operations :ivar aggregated_cost: AggregatedCostOperations operations @@ -82,63 +68,70 @@ class ConsumptionManagementClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure Subscription ID. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ConsumptionManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ConsumptionManagementClientConfiguration(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.usage_details = UsageDetailsOperations(self._client, self._config, self._serialize, self._deserialize) + self.marketplaces = MarketplacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.budgets = BudgetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.charges = ChargesOperations(self._client, self._config, self._serialize, self._deserialize) + self.balances = BalancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservations_summaries = ReservationsSummariesOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservations_details = ReservationsDetailsOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservation_recommendations = ReservationRecommendationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservation_recommendation_details = ReservationRecommendationDetailsOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservation_transactions = ReservationTransactionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.price_sheet = PriceSheetOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.aggregated_cost = AggregatedCostOperations(self._client, self._config, self._serialize, self._deserialize) + self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize) + self.lots = LotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.credits = CreditsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> 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.usage_details = UsageDetailsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.marketplaces = MarketplacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.budgets = BudgetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.charges = ChargesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.balances = BalancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservations_summaries = ReservationsSummariesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservations_details = ReservationsDetailsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservation_recommendations = ReservationRecommendationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservation_recommendation_details = ReservationRecommendationDetailsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservation_transactions = ReservationTransactionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.price_sheet = PriceSheetOperations( - self._client, self._config, self._serialize, self._deserialize) - self.forecasts = ForecastsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.aggregated_cost = AggregatedCostOperations( - self._client, self._config, self._serialize, self._deserialize) - self.events = EventsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.lots = LotsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.credits = CreditsOperations( - 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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_metadata.json b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_metadata.json new file mode 100644 index 000000000000..6cba7ea11366 --- /dev/null +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_metadata.json @@ -0,0 +1,118 @@ +{ + "chosen_version": "2021-10-01", + "total_api_version_list": ["2021-10-01"], + "client": { + "name": "ConsumptionManagementClient", + "filename": "_consumption_management_client", + "description": "Consumption management client provides access to consumption resources for Azure Enterprise Subscriptions.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConsumptionManagementClientConfiguration\"]}}, \"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\": [\"ConsumptionManagementClientConfiguration\"]}}, \"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": "Azure Subscription ID.", + "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": "Azure Subscription ID.", + "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": { + "usage_details": "UsageDetailsOperations", + "marketplaces": "MarketplacesOperations", + "budgets": "BudgetsOperations", + "tags": "TagsOperations", + "charges": "ChargesOperations", + "balances": "BalancesOperations", + "reservations_summaries": "ReservationsSummariesOperations", + "reservations_details": "ReservationsDetailsOperations", + "reservation_recommendations": "ReservationRecommendationsOperations", + "reservation_recommendation_details": "ReservationRecommendationDetailsOperations", + "reservation_transactions": "ReservationTransactionsOperations", + "price_sheet": "PriceSheetOperations", + "operations": "Operations", + "aggregated_cost": "AggregatedCostOperations", + "events": "EventsOperations", + "lots": "LotsOperations", + "credits": "CreditsOperations" + } +} \ No newline at end of file diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_patch.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_vendor.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py index 142a0420b39b..e5754a47ce68 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/__init__.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/__init__.py index 9894be2c5458..e17a29ecce4e 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/__init__.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/__init__.py @@ -8,3 +8,8 @@ from ._consumption_management_client import ConsumptionManagementClient __all__ = ['ConsumptionManagementClient'] + +# `._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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_configuration.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_configuration.py index 35ea926982d4..3a6a9f371adc 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_configuration.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ConsumptionManagementClientConfiguration, 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(ConsumptionManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-10-01" + self.api_version = "2021-10-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-consumption/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_consumption_management_client.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_consumption_management_client.py index c709a3e4f1e9..db2099a12566 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_consumption_management_client.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_consumption_management_client.py @@ -6,38 +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 ConsumptionManagementClientConfiguration +from .operations import AggregatedCostOperations, BalancesOperations, BudgetsOperations, ChargesOperations, CreditsOperations, EventsOperations, LotsOperations, MarketplacesOperations, Operations, PriceSheetOperations, ReservationRecommendationDetailsOperations, ReservationRecommendationsOperations, ReservationTransactionsOperations, ReservationsDetailsOperations, ReservationsSummariesOperations, TagsOperations, UsageDetailsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import ConsumptionManagementClientConfiguration -from .operations import UsageDetailsOperations -from .operations import MarketplacesOperations -from .operations import BudgetsOperations -from .operations import TagsOperations -from .operations import ChargesOperations -from .operations import BalancesOperations -from .operations import ReservationsSummariesOperations -from .operations import ReservationsDetailsOperations -from .operations import ReservationRecommendationsOperations -from .operations import ReservationRecommendationDetailsOperations -from .operations import ReservationTransactionsOperations -from .operations import PriceSheetOperations -from .operations import ForecastsOperations -from .operations import Operations -from .operations import AggregatedCostOperations -from .operations import EventsOperations -from .operations import LotsOperations -from .operations import CreditsOperations -from .. import models - - -class ConsumptionManagementClient(object): +class ConsumptionManagementClient: """Consumption management client provides access to consumption resources for Azure Enterprise Subscriptions. :ivar usage_details: UsageDetailsOperations operations @@ -53,19 +37,22 @@ class ConsumptionManagementClient(object): :ivar balances: BalancesOperations operations :vartype balances: azure.mgmt.consumption.aio.operations.BalancesOperations :ivar reservations_summaries: ReservationsSummariesOperations operations - :vartype reservations_summaries: azure.mgmt.consumption.aio.operations.ReservationsSummariesOperations + :vartype reservations_summaries: + azure.mgmt.consumption.aio.operations.ReservationsSummariesOperations :ivar reservations_details: ReservationsDetailsOperations operations - :vartype reservations_details: azure.mgmt.consumption.aio.operations.ReservationsDetailsOperations + :vartype reservations_details: + azure.mgmt.consumption.aio.operations.ReservationsDetailsOperations :ivar reservation_recommendations: ReservationRecommendationsOperations operations - :vartype reservation_recommendations: azure.mgmt.consumption.aio.operations.ReservationRecommendationsOperations + :vartype reservation_recommendations: + azure.mgmt.consumption.aio.operations.ReservationRecommendationsOperations :ivar reservation_recommendation_details: ReservationRecommendationDetailsOperations operations - :vartype reservation_recommendation_details: azure.mgmt.consumption.aio.operations.ReservationRecommendationDetailsOperations + :vartype reservation_recommendation_details: + azure.mgmt.consumption.aio.operations.ReservationRecommendationDetailsOperations :ivar reservation_transactions: ReservationTransactionsOperations operations - :vartype reservation_transactions: azure.mgmt.consumption.aio.operations.ReservationTransactionsOperations + :vartype reservation_transactions: + azure.mgmt.consumption.aio.operations.ReservationTransactionsOperations :ivar price_sheet: PriceSheetOperations operations :vartype price_sheet: azure.mgmt.consumption.aio.operations.PriceSheetOperations - :ivar forecasts: ForecastsOperations operations - :vartype forecasts: azure.mgmt.consumption.aio.operations.ForecastsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.consumption.aio.operations.Operations :ivar aggregated_cost: AggregatedCostOperations operations @@ -80,62 +67,68 @@ class ConsumptionManagementClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure Subscription ID. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ConsumptionManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = ConsumptionManagementClientConfiguration(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.usage_details = UsageDetailsOperations(self._client, self._config, self._serialize, self._deserialize) + self.marketplaces = MarketplacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.budgets = BudgetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tags = TagsOperations(self._client, self._config, self._serialize, self._deserialize) + self.charges = ChargesOperations(self._client, self._config, self._serialize, self._deserialize) + self.balances = BalancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservations_summaries = ReservationsSummariesOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservations_details = ReservationsDetailsOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservation_recommendations = ReservationRecommendationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservation_recommendation_details = ReservationRecommendationDetailsOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservation_transactions = ReservationTransactionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.price_sheet = PriceSheetOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.aggregated_cost = AggregatedCostOperations(self._client, self._config, self._serialize, self._deserialize) + self.events = EventsOperations(self._client, self._config, self._serialize, self._deserialize) + self.lots = LotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.credits = CreditsOperations(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.usage_details = UsageDetailsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.marketplaces = MarketplacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.budgets = BudgetsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.tags = TagsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.charges = ChargesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.balances = BalancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservations_summaries = ReservationsSummariesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservations_details = ReservationsDetailsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservation_recommendations = ReservationRecommendationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservation_recommendation_details = ReservationRecommendationDetailsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservation_transactions = ReservationTransactionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.price_sheet = PriceSheetOperations( - self._client, self._config, self._serialize, self._deserialize) - self.forecasts = ForecastsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.aggregated_cost = AggregatedCostOperations( - self._client, self._config, self._serialize, self._deserialize) - self.events = EventsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.lots = LotsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.credits = CreditsOperations( - 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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_patch.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/__init__.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/__init__.py index 9736d77b0f1e..b9f9e177168f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/__init__.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/__init__.py @@ -18,7 +18,6 @@ from ._reservation_recommendation_details_operations import ReservationRecommendationDetailsOperations from ._reservation_transactions_operations import ReservationTransactionsOperations from ._price_sheet_operations import PriceSheetOperations -from ._forecasts_operations import ForecastsOperations from ._operations import Operations from ._aggregated_cost_operations import AggregatedCostOperations from ._events_operations import EventsOperations @@ -38,7 +37,6 @@ 'ReservationRecommendationDetailsOperations', 'ReservationTransactionsOperations', 'PriceSheetOperations', - 'ForecastsOperations', 'Operations', 'AggregatedCostOperations', 'EventsOperations', diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_aggregated_cost_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_aggregated_cost_operations.py index b601898dfeea..e37b43fe879f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_aggregated_cost_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_aggregated_cost_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._aggregated_cost_operations import build_get_by_management_group_request, build_get_for_billing_period_by_management_group_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_management_group( self, management_group_id: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.ManagementGroupAggregatedCostResult": """Provides the aggregate cost of a management group and all child management groups by current billing period. @@ -66,33 +71,22 @@ async def get_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_by_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = build_get_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=self.get_by_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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('ManagementGroupAggregatedCostResult', pipeline_response) @@ -101,13 +95,16 @@ async def get_by_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost'} # type: ignore + + @distributed_trace_async async def get_for_billing_period_by_management_group( self, management_group_id: str, billing_period_name: str, - **kwargs + **kwargs: Any ) -> "_models.ManagementGroupAggregatedCostResult": """Provides the aggregate cost of a management group and all child management groups by specified billing period. @@ -126,32 +123,22 @@ async def get_for_billing_period_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_for_billing_period_by_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_for_billing_period_by_management_group_request( + management_group_id=management_group_id, + billing_period_name=billing_period_name, + template_url=self.get_for_billing_period_by_management_group.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('ManagementGroupAggregatedCostResult', pipeline_response) @@ -160,4 +147,6 @@ async def get_for_billing_period_by_management_group( return cls(pipeline_response, deserialized, {}) return deserialized - get_for_billing_period_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/Microsoft.Consumption/aggregatedcost'} # type: ignore + + get_for_billing_period_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_balances_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_balances_operations.py index 1183848b2622..c82e7d22142a 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_balances_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_balances_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._balances_operations import build_get_by_billing_account_request, build_get_for_billing_period_by_billing_account_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,10 +44,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_billing_account( self, billing_account_id: str, - **kwargs + **kwargs: Any ) -> "_models.Balance": """Gets the balances for a scope by billingAccountId. Balances are available via this API only for May 1, 2014 or later. @@ -60,31 +65,21 @@ async def get_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_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 = build_get_by_billing_account_request( + billing_account_id=billing_account_id, + template_url=self.get_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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('Balance', pipeline_response) @@ -93,13 +88,16 @@ async def get_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances'} # type: ignore + + @distributed_trace_async async def get_for_billing_period_by_billing_account( self, billing_account_id: str, billing_period_name: str, - **kwargs + **kwargs: Any ) -> "_models.Balance": """Gets the balances for a scope by billing period and billingAccountId. Balances are available via this API only for May 1, 2014 or later. @@ -118,32 +116,22 @@ async def get_for_billing_period_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_for_billing_period_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_for_billing_period_by_billing_account_request( + billing_account_id=billing_account_id, + billing_period_name=billing_period_name, + template_url=self.get_for_billing_period_by_billing_account.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('Balance', pipeline_response) @@ -152,4 +140,6 @@ async def get_for_billing_period_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized - get_for_billing_period_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'} # type: ignore + + get_for_billing_period_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_budgets_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_budgets_operations.py index 7d802a0352a9..a48eae0e327e 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_budgets_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_budgets_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._budgets_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,10 +46,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BudgetsListResult"]: """Lists all budgets for the defined scope. @@ -65,7 +71,8 @@ def list( :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either BudgetsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.BudgetsListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.BudgetsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BudgetsListResult"] @@ -73,34 +80,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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( + scope=scope, + 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( + scope=scope, + 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('BudgetsListResult', pipeline_response) + deserialized = self._deserialize("BudgetsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,22 +115,24 @@ 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': '/{scope}/providers/Microsoft.Consumption/budgets'} # type: ignore + @distributed_trace_async async def get( self, scope: str, budget_name: str, - **kwargs + **kwargs: Any ) -> "_models.Budget": """Gets the budget for the scope by budget name. @@ -159,32 +163,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'budgetName': self._serialize.url("budget_name", budget_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + budget_name=budget_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('Budget', pipeline_response) @@ -193,18 +187,21 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, scope: str, budget_name: str, parameters: "_models.Budget", - **kwargs + **kwargs: Any ) -> "_models.Budget": - """The operation to create or update a budget. Update operation requires latest eTag to be set in - the request mandatorily. You may obtain the latest eTag by performing a get operation. Create - operation does not require eTag. + """The operation to create or update a budget. You can optionally provide an eTag if desired as a + form of concurrency control. To obtain the latest eTag for a given budget, perform a get + operation prior to your put operation. :param scope: The scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, @@ -235,37 +232,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'budgetName': self._serialize.url("budget_name", budget_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Budget') - # 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_or_update_request( + scope=scope, + budget_name=budget_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Budget') - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -278,13 +265,16 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + + @distributed_trace_async async def delete( self, scope: str, budget_name: str, - **kwargs + **kwargs: Any ) -> None: """The operation to delete a budget. @@ -315,35 +305,26 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'budgetName': self._serialize.url("budget_name", budget_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + budget_name=budget_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]: 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: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_charges_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_charges_operations.py index 11aedcb34bc1..9299c6302b02 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_charges_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_charges_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._charges_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, scope: str, @@ -47,7 +52,7 @@ async def list( end_date: Optional[str] = None, filter: Optional[str] = None, apply: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.ChargesListResult": """Lists the charges based for the defined scope. @@ -91,39 +96,25 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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') - if start_date is not None: - query_parameters['startDate'] = self._serialize.query("start_date", start_date, 'str') - if end_date is not None: - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if apply is not None: - query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + start_date=start_date, + end_date=end_date, + filter=filter, + apply=apply, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ChargesListResult', pipeline_response) @@ -132,4 +123,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/charges'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_credits_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_credits_operations.py index a02204f3ecfa..d55db2f7170d 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_credits_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_credits_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._credits_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,12 +44,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, billing_account_id: str, billing_profile_id: str, - **kwargs - ) -> "_models.CreditSummary": + **kwargs: Any + ) -> Optional["_models.CreditSummary"]: """The credit summary by billingAccountId and billingProfileId. :param billing_account_id: BillingAccount ID. @@ -54,46 +59,40 @@ async def get( :type billing_profile_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CreditSummary, or the result of cls(response) - :rtype: ~azure.mgmt.consumption.models.CreditSummary + :rtype: ~azure.mgmt.consumption.models.CreditSummary or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CreditSummary"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CreditSummary"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingProfileId': self._serialize.url("billing_profile_id", billing_profile_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_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + 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]: + 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) - deserialized = self._deserialize('CreditSummary', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CreditSummary', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_events_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_events_operations.py index e77643642dbd..53baf5f4d6a5 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_events_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_events_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._events_operations import build_list_by_billing_account_request, build_list_by_billing_profile_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 - def list( + @distributed_trace + def list_by_billing_profile( self, billing_account_id: str, billing_profile_id: str, start_date: str, end_date: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.Events"]: - """Lists the events by billingAccountId and billingProfileId for given start and end date. + """Lists the events that decrements Azure credits or Microsoft Azure consumption commitment for a + billing account or a billing profile for a given start and end date. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -69,37 +76,110 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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: + + request = build_list_by_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + start_date=start_date, + end_date=end_date, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + start_date=start_date, + end_date=end_date, + 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("Events", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events'} # type: ignore + + @distributed_trace + def list_by_billing_account( + self, + billing_account_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Events"]: + """Lists the events that decrements Azure credits or Microsoft Azure consumption commitment for a + billing account or a billing profile for a given start and end date. + + :param billing_account_id: BillingAccount ID. + :type billing_account_id: str + :param filter: May be used to filter the events by lotId, lotSource etc. The filter supports + 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + Tag filter is a key value pair string where key and value is separated by a colon (:). + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Events or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Events] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Events"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingProfileId': self._serialize.url("billing_profile_id", billing_profile_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') - query_parameters['startDate'] = self._serialize.query("start_date", start_date, 'str') - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_id=billing_account_id, + filter=filter, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_id=billing_account_id, + filter=filter, + 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('Events', pipeline_response) + deserialized = self._deserialize("Events", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,13 +192,14 @@ 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': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events'} # type: ignore + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events'} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_forecasts_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_forecasts_operations.py deleted file mode 100644 index 3e0e3c744c1d..000000000000 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_forecasts_operations.py +++ /dev/null @@ -1,116 +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 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.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ForecastsOperations: - """ForecastsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.consumption.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ForecastsListResult"]: - """Lists the forecast charges by subscriptionId. - - :param filter: May be used to filter forecasts by properties/usageDate (Utc time), - properties/chargeType or properties/grain. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', - and 'and'. It does not currently support 'ne', 'or', or 'not'. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ForecastsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ForecastsListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForecastsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - 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) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ForecastsListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.Consumption/forecasts'} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py index 67a4242e7980..bf8185fc2cd3 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_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._lots_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,16 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list( + @distributed_trace + def list_by_billing_profile( self, billing_account_id: str, billing_profile_id: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.Lots"]: - """Lists the lots by billingAccountId and billingProfileId. + """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a + billing profile. Microsoft Azure consumption commitments are only supported for the billing + account scope. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -63,35 +71,107 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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: + + request = build_list_by_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_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("Lots", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots'} # type: ignore + + @distributed_trace + def list_by_billing_account( + self, + billing_account_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Lots"]: + """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a + billing profile. Microsoft Azure consumption commitments are only supported for the billing + account scope. + + :param billing_account_id: BillingAccount ID. + :type billing_account_id: str + :param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq', + 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag + filter is a key value pair string where key and value is separated by a colon (:). + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Lots or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Lots] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingProfileId': self._serialize.url("billing_profile_id", billing_profile_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_billing_account_request( + billing_account_id=billing_account_id, + filter=filter, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_id=billing_account_id, + filter=filter, + 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('Lots', pipeline_response) + deserialized = self._deserialize("Lots", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,13 +184,14 @@ 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': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots'} # type: ignore + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots'} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_marketplaces_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_marketplaces_operations.py index ecee0de3e21c..48e202474ecd 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_marketplaces_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_marketplaces_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._marketplaces_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope: str, filter: Optional[str] = None, top: Optional[int] = None, skiptoken: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.MarketplacesListResult"]: """Lists the marketplaces for a scope at the defined scope. Marketplaces are available via this API only for May 1, 2014 or later. @@ -76,8 +82,10 @@ def list( a skiptoken parameter that specifies a starting point to use for subsequent calls. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MarketplacesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.MarketplacesListResult] + :return: An iterator like instance of either MarketplacesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.MarketplacesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MarketplacesListResult"] @@ -85,40 +93,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - 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( + scope=scope, + filter=filter, + top=top, + skiptoken=skiptoken, + 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( + scope=scope, + filter=filter, + top=top, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('MarketplacesListResult', pipeline_response) + deserialized = self._deserialize("MarketplacesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -131,12 +134,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_operations.py index f00db289824f..911dcd6cace9 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/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 consumption 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.consumption.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.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 = "2019-10-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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_price_sheet_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_price_sheet_operations.py index 5401fa5f599f..a9c72e9a256f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_price_sheet_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_price_sheet_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._price_sheet_operations import build_get_by_billing_period_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,15 +44,16 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, expand: Optional[str] = None, skiptoken: Optional[str] = None, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> "_models.PriceSheetResult": - """Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only - for May 1, 2014 or later. + """Gets the price sheet for a subscription. Price sheet is available via this API only for May 1, + 2014 or later. :param expand: May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. @@ -69,37 +74,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - 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 = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + subscription_id=self._config.subscription_id, + expand=expand, + skiptoken=skiptoken, + top=top, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('PriceSheetResult', pipeline_response) @@ -108,15 +100,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default'} # type: ignore + + @distributed_trace_async async def get_by_billing_period( self, billing_period_name: str, expand: Optional[str] = None, skiptoken: Optional[str] = None, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> "_models.PriceSheetResult": """Get the price sheet for a scope by subscriptionId and billing period. Price sheet is available via this API only for May 1, 2014 or later. @@ -142,38 +137,25 @@ async def get_by_billing_period( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_period.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - 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 = self._client.get(url, query_parameters, header_parameters) + + + request = build_get_by_billing_period_request( + subscription_id=self._config.subscription_id, + billing_period_name=billing_period_name, + expand=expand, + skiptoken=skiptoken, + top=top, + template_url=self.get_by_billing_period.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PriceSheetResult', pipeline_response) @@ -182,4 +164,6 @@ async def get_by_billing_period( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_period.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendation_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendation_details_operations.py index 549bdc224285..9cc6837324c5 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendation_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendation_details_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._reservation_recommendation_details_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,27 +44,25 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, - billing_scope: str, - scope: Union[str, "_models.Scope"], + scope: str, region: str, term: Union[str, "_models.Term"], look_back_period: Union[str, "_models.LookBackPeriod"], product: str, - **kwargs + **kwargs: Any ) -> Optional["_models.ReservationRecommendationDetailsModel"]: """Details of a reservation recommendation for what-if analysis of reserved instances. - :param billing_scope: The scope associated with reservation recommendation details operations. - This includes '/subscriptions/{subscriptionId}/' for subscription scope, + :param scope: The scope associated with reservation recommendation details operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope. - :type billing_scope: str - :param scope: Scope of the reservation. - :type scope: str or ~azure.mgmt.consumption.models.Scope + :type scope: str :param region: Used to select the region the recommendation should be generated for. :type region: str :param term: Specify length of reservation recommendation term. @@ -81,36 +83,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingScope': self._serialize.url("billing_scope", billing_scope, 'str', skip_quote=True), - } - 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') - query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - query_parameters['region'] = self._serialize.query("region", region, 'str') - query_parameters['term'] = self._serialize.query("term", term, 'str') - query_parameters['lookBackPeriod'] = self._serialize.query("look_back_period", look_back_period, 'str') - query_parameters['product'] = self._serialize.query("product", product, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + region=region, + term=term, + look_back_period=look_back_period, + product=product, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 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.HighCasedErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -121,4 +112,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{billingScope}/providers/Microsoft.Consumption/reservationRecommendationDetails'} # type: ignore + + get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationRecommendationDetails'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendations_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendations_operations.py index 09d049fac676..1e1cefed53f4 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendations_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendations_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._reservation_recommendations_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationRecommendationsListResult"]: """List of recommendations for purchasing reserved instances. @@ -65,8 +71,10 @@ def list( default value 'Last7Days'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationRecommendationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationRecommendationsListResultor None] + :return: An iterator like instance of either ReservationRecommendationsListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationRecommendationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationRecommendationsListResult"] @@ -74,36 +82,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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( + scope=scope, + filter=filter, + 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( + scope=scope, + filter=filter, + 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('ReservationRecommendationsListResult', pipeline_response) + deserialized = self._deserialize("ReservationRecommendationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,12 +119,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200, 204]: - 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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_transactions_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_transactions_operations.py index c6f5f7abcb98..cae35efb82f8 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_transactions_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_transactions_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._reservation_transactions_operations import build_list_by_billing_profile_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, billing_account_id: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationTransactionsListResult"]: """List of transactions for reserved instances on billing account scope. @@ -55,8 +61,10 @@ def list( start date and end date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationTransactionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationTransactionsListResult] + :return: An iterator like instance of either ReservationTransactionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationTransactionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationTransactionsListResult"] @@ -64,36 +72,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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( + billing_account_id=billing_account_id, + filter=filter, + 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( + billing_account_id=billing_account_id, + filter=filter, + 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('ReservationTransactionsListResult', pipeline_response) + deserialized = self._deserialize("ReservationTransactionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,23 +109,25 @@ 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': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_id: str, billing_profile_id: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ModernReservationTransactionsListResult"]: """List of transactions for reserved instances on billing account scope. @@ -134,8 +139,10 @@ def list_by_billing_profile( start date and end date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ModernReservationTransactionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ModernReservationTransactionsListResult] + :return: An iterator like instance of either ModernReservationTransactionsListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ModernReservationTransactionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ModernReservationTransactionsListResult"] @@ -143,37 +150,33 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingProfileId': self._serialize.url("billing_profile_id", billing_profile_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + filter=filter, + template_url=self.list_by_billing_profile.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_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + filter=filter, + 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('ModernReservationTransactionsListResult', pipeline_response) + deserialized = self._deserialize("ModernReservationTransactionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -186,12 +189,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_details_operations.py index caa00e154eb2..a5c894333b6f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_details_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._reservations_details_operations import build_list_by_reservation_order_and_reservation_request, build_list_by_reservation_order_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_reservation_order( self, reservation_order_id: str, filter: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationDetailsListResult"]: """Lists the reservations details for provided date range. @@ -55,8 +61,10 @@ def list_by_reservation_order( date and end date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationDetailsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] + :return: An iterator like instance of either ReservationDetailsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] @@ -64,35 +72,31 @@ def list_by_reservation_order( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_reservation_order.metadata['url'] # type: ignore - path_format_arguments = { - 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_reservation_order_request( + reservation_order_id=reservation_order_id, + filter=filter, + template_url=self.list_by_reservation_order.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_reservation_order_request( + reservation_order_id=reservation_order_id, + filter=filter, + 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('ReservationDetailsListResult', pipeline_response) + deserialized = self._deserialize("ReservationDetailsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,23 +109,25 @@ 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_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + @distributed_trace def list_by_reservation_order_and_reservation( self, reservation_order_id: str, reservation_id: str, filter: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationDetailsListResult"]: """Lists the reservations details for provided date range. @@ -133,8 +139,10 @@ def list_by_reservation_order_and_reservation( date and end date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationDetailsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] + :return: An iterator like instance of either ReservationDetailsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] @@ -142,36 +150,33 @@ def list_by_reservation_order_and_reservation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_reservation_order_and_reservation.metadata['url'] # type: ignore - path_format_arguments = { - 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), - 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_reservation_order_and_reservation_request( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + filter=filter, + template_url=self.list_by_reservation_order_and_reservation.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_reservation_order_and_reservation_request( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + filter=filter, + 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('ReservationDetailsListResult', pipeline_response) + deserialized = self._deserialize("ReservationDetailsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,17 +189,19 @@ 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_reservation_order_and_reservation.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + @distributed_trace def list( self, scope: str, @@ -203,7 +210,7 @@ def list( filter: Optional[str] = None, reservation_id: Optional[str] = None, reservation_order_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationDetailsListResult"]: """Lists the reservations details for the defined scope and provided date range. @@ -228,8 +235,10 @@ def list( Filter to a specific reservation order. :type reservation_order_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationDetailsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] + :return: An iterator like instance of either ReservationDetailsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] @@ -237,44 +246,39 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if start_date is not None: - query_parameters['startDate'] = self._serialize.query("start_date", start_date, 'str') - if end_date is not None: - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if reservation_id is not None: - query_parameters['reservationId'] = self._serialize.query("reservation_id", reservation_id, 'str') - if reservation_order_id is not None: - query_parameters['reservationOrderId'] = self._serialize.query("reservation_order_id", reservation_order_id, 'str') - 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( + scope=scope, + start_date=start_date, + end_date=end_date, + filter=filter, + reservation_id=reservation_id, + reservation_order_id=reservation_order_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( + scope=scope, + start_date=start_date, + end_date=end_date, + filter=filter, + reservation_id=reservation_id, + reservation_order_id=reservation_order_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('ReservationDetailsListResult', pipeline_response) + deserialized = self._deserialize("ReservationDetailsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -287,12 +291,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_summaries_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_summaries_operations.py index 29209bda5139..7842a6354a4c 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_summaries_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_summaries_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._reservations_summaries_operations import build_list_by_reservation_order_and_reservation_request, build_list_by_reservation_order_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_reservation_order( self, reservation_order_id: str, grain: Union[str, "_models.Datagrain"], filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationSummariesListResult"]: """Lists the reservations summaries for daily or monthly grain. @@ -58,8 +64,10 @@ def list_by_reservation_order( date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationSummariesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] + :return: An iterator like instance of either ReservationSummariesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] @@ -67,37 +75,33 @@ def list_by_reservation_order( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_reservation_order.metadata['url'] # type: ignore - path_format_arguments = { - 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['grain'] = self._serialize.query("grain", grain, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_reservation_order_request( + reservation_order_id=reservation_order_id, + grain=grain, + filter=filter, + template_url=self.list_by_reservation_order.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_reservation_order_request( + reservation_order_id=reservation_order_id, + grain=grain, + filter=filter, + 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('ReservationSummariesListResult', pipeline_response) + deserialized = self._deserialize("ReservationSummariesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,24 +114,26 @@ 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_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + @distributed_trace def list_by_reservation_order_and_reservation( self, reservation_order_id: str, reservation_id: str, grain: Union[str, "_models.Datagrain"], filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationSummariesListResult"]: """Lists the reservations summaries for daily or monthly grain. @@ -141,8 +147,10 @@ def list_by_reservation_order_and_reservation( date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationSummariesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] + :return: An iterator like instance of either ReservationSummariesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] @@ -150,38 +158,35 @@ def list_by_reservation_order_and_reservation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_reservation_order_and_reservation.metadata['url'] # type: ignore - path_format_arguments = { - 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), - 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['grain'] = self._serialize.query("grain", grain, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_reservation_order_and_reservation_request( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + grain=grain, + filter=filter, + template_url=self.list_by_reservation_order_and_reservation.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_reservation_order_and_reservation_request( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + grain=grain, + filter=filter, + 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('ReservationSummariesListResult', pipeline_response) + deserialized = self._deserialize("ReservationSummariesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -194,17 +199,19 @@ 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_reservation_order_and_reservation.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + @distributed_trace def list( self, scope: str, @@ -214,7 +221,7 @@ def list( filter: Optional[str] = None, reservation_id: Optional[str] = None, reservation_order_id: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationSummariesListResult"]: """Lists the reservations summaries for the defined scope daily or monthly grain. @@ -240,8 +247,10 @@ def list( Filter to a specific reservation order. :type reservation_order_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationSummariesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] + :return: An iterator like instance of either ReservationSummariesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] @@ -249,45 +258,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['grain'] = self._serialize.query("grain", grain, 'str') - if start_date is not None: - query_parameters['startDate'] = self._serialize.query("start_date", start_date, 'str') - if end_date is not None: - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if reservation_id is not None: - query_parameters['reservationId'] = self._serialize.query("reservation_id", reservation_id, 'str') - if reservation_order_id is not None: - query_parameters['reservationOrderId'] = self._serialize.query("reservation_order_id", reservation_order_id, 'str') - 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( + scope=scope, + grain=grain, + start_date=start_date, + end_date=end_date, + filter=filter, + reservation_id=reservation_id, + reservation_order_id=reservation_order_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( + scope=scope, + grain=grain, + start_date=start_date, + end_date=end_date, + filter=filter, + reservation_id=reservation_id, + reservation_order_id=reservation_order_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('ReservationSummariesListResult', pipeline_response) + deserialized = self._deserialize("ReservationSummariesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -300,12 +305,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_tags_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_tags_operations.py index a2f7be0f3a48..d40873679d09 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_tags_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_tags_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._tags_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, - **kwargs - ) -> "_models.TagsResult": + **kwargs: Any + ) -> Optional["_models.TagsResult"]: """Get all available tag keys for the defined scope. :param scope: The scope associated with tags operations. This includes @@ -60,45 +65,39 @@ async def get( :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagsResult, or the result of cls(response) - :rtype: ~azure.mgmt.consumption.models.TagsResult + :rtype: ~azure.mgmt.consumption.models.TagsResult or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.TagsResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 = build_get_request( + scope=scope, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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]: + 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) - deserialized = self._deserialize('TagsResult', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagsResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/tags'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_usage_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_usage_details_operations.py index b2642f737faf..39855ebabfe8 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_usage_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_usage_details_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._usage_details_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope: str, @@ -49,7 +55,7 @@ def list( skiptoken: Optional[str] = None, top: Optional[int] = None, metric: Optional[Union[str, "_models.Metrictype"]] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.UsageDetailsListResult"]: """Lists the usage details for the defined scope. Usage details are available via this API only for May 1, 2014 or later. @@ -95,8 +101,10 @@ def list( :param metric: Allows to select different type of cost/usage records. :type metric: str or ~azure.mgmt.consumption.models.Metrictype :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageDetailsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.UsageDetailsListResult] + :return: An iterator like instance of either UsageDetailsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.UsageDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageDetailsListResult"] @@ -104,44 +112,39 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if metric is not None: - query_parameters['metric'] = self._serialize.query("metric", metric, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + expand=expand, + filter=filter, + skiptoken=skiptoken, + top=top, + metric=metric, + 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( + scope=scope, + expand=expand, + filter=filter, + skiptoken=skiptoken, + top=top, + metric=metric, + 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('UsageDetailsListResult', pipeline_response) + deserialized = self._deserialize("UsageDetailsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -153,13 +156,14 @@ async def get_next(next_link=None): pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py index 5683bcba3659..2319c64c4b88 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py @@ -8,6 +8,7 @@ try: from ._models_py3 import Amount + from ._models_py3 import AmountWithExchangeRate from ._models_py3 import Balance from ._models_py3 import BalancePropertiesAdjustmentDetailsItem from ._models_py3 import BalancePropertiesNewPurchasesDetailsItem @@ -22,16 +23,20 @@ from ._models_py3 import CreditBalanceSummary from ._models_py3 import CreditSummary from ._models_py3 import CurrentSpend + from ._models_py3 import DownloadProperties from ._models_py3 import ErrorDetails from ._models_py3 import ErrorResponse from ._models_py3 import EventSummary from ._models_py3 import Events - from ._models_py3 import Forecast - from ._models_py3 import ForecastPropertiesConfidenceLevelsItem - from ._models_py3 import ForecastsListResult + from ._models_py3 import ForecastSpend + from ._models_py3 import HighCasedErrorDetails + from ._models_py3 import HighCasedErrorResponse from ._models_py3 import LegacyChargeSummary from ._models_py3 import LegacyReservationRecommendation + from ._models_py3 import LegacyReservationRecommendationProperties from ._models_py3 import LegacyReservationTransaction + from ._models_py3 import LegacySharedScopeReservationRecommendationProperties + from ._models_py3 import LegacySingleScopeReservationRecommendationProperties from ._models_py3 import LegacyUsageDetail from ._models_py3 import LotSummary from ._models_py3 import Lots @@ -52,6 +57,7 @@ from ._models_py3 import PriceSheetProperties from ._models_py3 import PriceSheetResult from ._models_py3 import ProxyResource + from ._models_py3 import Reseller from ._models_py3 import ReservationDetail from ._models_py3 import ReservationDetailsListResult from ._models_py3 import ReservationRecommendation @@ -75,6 +81,7 @@ from ._models_py3 import UsageDetailsListResult except (SyntaxError, ImportError): from ._models import Amount # type: ignore + from ._models import AmountWithExchangeRate # type: ignore from ._models import Balance # type: ignore from ._models import BalancePropertiesAdjustmentDetailsItem # type: ignore from ._models import BalancePropertiesNewPurchasesDetailsItem # type: ignore @@ -89,16 +96,20 @@ from ._models import CreditBalanceSummary # type: ignore from ._models import CreditSummary # type: ignore from ._models import CurrentSpend # type: ignore + from ._models import DownloadProperties # type: ignore from ._models import ErrorDetails # type: ignore from ._models import ErrorResponse # type: ignore from ._models import EventSummary # type: ignore from ._models import Events # type: ignore - from ._models import Forecast # type: ignore - from ._models import ForecastPropertiesConfidenceLevelsItem # type: ignore - from ._models import ForecastsListResult # type: ignore + from ._models import ForecastSpend # type: ignore + from ._models import HighCasedErrorDetails # type: ignore + from ._models import HighCasedErrorResponse # type: ignore from ._models import LegacyChargeSummary # type: ignore from ._models import LegacyReservationRecommendation # type: ignore + from ._models import LegacyReservationRecommendationProperties # type: ignore from ._models import LegacyReservationTransaction # type: ignore + from ._models import LegacySharedScopeReservationRecommendationProperties # type: ignore + from ._models import LegacySingleScopeReservationRecommendationProperties # type: ignore from ._models import LegacyUsageDetail # type: ignore from ._models import LotSummary # type: ignore from ._models import Lots # type: ignore @@ -119,6 +130,7 @@ from ._models import PriceSheetProperties # type: ignore from ._models import PriceSheetResult # type: ignore from ._models import ProxyResource # type: ignore + from ._models import Reseller # type: ignore from ._models import ReservationDetail # type: ignore from ._models import ReservationDetailsListResult # type: ignore from ._models import ReservationRecommendation # type: ignore @@ -143,20 +155,20 @@ from ._consumption_management_client_enums import ( BillingFrequency, - Bound, BudgetOperatorType, CategoryType, ChargeSummaryKind, - ChargeType, + CultureCode, Datagrain, EventType, - Grain, LookBackPeriod, LotSource, Metrictype, OperatorType, + PricingModelType, ReservationRecommendationKind, Scope, + Status, Term, ThresholdType, TimeGrainType, @@ -165,6 +177,7 @@ __all__ = [ 'Amount', + 'AmountWithExchangeRate', 'Balance', 'BalancePropertiesAdjustmentDetailsItem', 'BalancePropertiesNewPurchasesDetailsItem', @@ -179,16 +192,20 @@ 'CreditBalanceSummary', 'CreditSummary', 'CurrentSpend', + 'DownloadProperties', 'ErrorDetails', 'ErrorResponse', 'EventSummary', 'Events', - 'Forecast', - 'ForecastPropertiesConfidenceLevelsItem', - 'ForecastsListResult', + 'ForecastSpend', + 'HighCasedErrorDetails', + 'HighCasedErrorResponse', 'LegacyChargeSummary', 'LegacyReservationRecommendation', + 'LegacyReservationRecommendationProperties', 'LegacyReservationTransaction', + 'LegacySharedScopeReservationRecommendationProperties', + 'LegacySingleScopeReservationRecommendationProperties', 'LegacyUsageDetail', 'LotSummary', 'Lots', @@ -209,6 +226,7 @@ 'PriceSheetProperties', 'PriceSheetResult', 'ProxyResource', + 'Reseller', 'ReservationDetail', 'ReservationDetailsListResult', 'ReservationRecommendation', @@ -231,20 +249,20 @@ 'UsageDetail', 'UsageDetailsListResult', 'BillingFrequency', - 'Bound', 'BudgetOperatorType', 'CategoryType', 'ChargeSummaryKind', - 'ChargeType', + 'CultureCode', 'Datagrain', 'EventType', - 'Grain', 'LookBackPeriod', 'LotSource', 'Metrictype', 'OperatorType', + 'PricingModelType', 'ReservationRecommendationKind', 'Scope', + 'Status', 'Term', 'ThresholdType', 'TimeGrainType', diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_consumption_management_client_enums.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_consumption_management_client_enums.py index cd7ad1ca77c1..7bd9077e6fe8 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_consumption_management_client_enums.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_consumption_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class BillingFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BillingFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing frequency. """ @@ -34,46 +19,60 @@ class BillingFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): QUARTER = "Quarter" YEAR = "Year" -class Bound(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The boundary of the percentage, values could be 'Upper' or 'Lower' - """ - - UPPER = "Upper" - LOWER = "Lower" - -class BudgetOperatorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BudgetOperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operator to use for comparison. """ IN_ENUM = "In" -class CategoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The category of the budget, whether the budget tracks cost or usage. """ COST = "Cost" -class ChargeSummaryKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChargeSummaryKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the kind of charge summary. """ LEGACY = "legacy" MODERN = "modern" -class ChargeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the charge. Could be actual or forecast +class CultureCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Language in which the recipient will receive the notification """ - ACTUAL = "Actual" - FORECAST = "Forecast" - -class Datagrain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - DAILY_GRAIN = "daily" #: Daily grain of data. - MONTHLY_GRAIN = "monthly" #: Monthly grain of data. - -class EventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of event. + EN_US = "en-us" + JA_JP = "ja-jp" + ZH_CN = "zh-cn" + DE_DE = "de-de" + ES_ES = "es-es" + FR_FR = "fr-fr" + IT_IT = "it-it" + KO_KR = "ko-kr" + PT_BR = "pt-br" + RU_RU = "ru-ru" + ZH_TW = "zh-tw" + CS_CZ = "cs-cz" + PL_PL = "pl-pl" + TR_TR = "tr-tr" + DA_DK = "da-dk" + EN_GB = "en-gb" + HU_HU = "hu-hu" + NB_NO = "nb-no" + NL_NL = "nl-nl" + PT_PT = "pt-pt" + SV_SE = "sv-se" + +class Datagrain(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + #: Daily grain of data. + DAILY_GRAIN = "daily" + #: Monthly grain of data. + MONTHLY_GRAIN = "monthly" + +class EventType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Identifies the type of the event. """ SETTLED_CHARGES = "SettledCharges" @@ -84,34 +83,33 @@ class EventType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UN_KNOWN = "UnKnown" NEW_CREDIT = "NewCredit" -class Grain(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The granularity of forecast. - """ +class LookBackPeriod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - DAILY = "Daily" - MONTHLY = "Monthly" - YEARLY = "Yearly" - -class LookBackPeriod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - LAST07_DAYS = "Last7Days" #: Use 7 days of data for recommendations. - LAST30_DAYS = "Last30Days" #: Use 30 days of data for recommendations. - LAST60_DAYS = "Last60Days" #: Use 60 days of data for recommendations. + #: Use 7 days of data for recommendations. + LAST07_DAYS = "Last7Days" + #: Use 30 days of data for recommendations. + LAST30_DAYS = "Last30Days" + #: Use 60 days of data for recommendations. + LAST60_DAYS = "Last60Days" -class LotSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Lot source. +class LotSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The source of the lot. """ PURCHASED_CREDIT = "PurchasedCredit" PROMOTIONAL_CREDIT = "PromotionalCredit" + CONSUMPTION_COMMITMENT = "ConsumptionCommitment" -class Metrictype(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Metrictype(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - ACTUAL_COST_METRIC_TYPE = "actualcost" #: Actual cost data. - AMORTIZED_COST_METRIC_TYPE = "amortizedcost" #: Amortized cost data. - USAGE_METRIC_TYPE = "usage" #: Usage data. + #: Actual cost data. + ACTUAL_COST_METRIC_TYPE = "actualcost" + #: Amortized cost data. + AMORTIZED_COST_METRIC_TYPE = "amortizedcost" + #: Usage data. + USAGE_METRIC_TYPE = "usage" -class OperatorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The comparison operator. """ @@ -119,30 +117,52 @@ class OperatorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GREATER_THAN = "GreaterThan" GREATER_THAN_OR_EQUAL_TO = "GreaterThanOrEqualTo" -class ReservationRecommendationKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PricingModelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Identifier that indicates how the meter is priced. + """ + + ON_DEMAND = "On Demand" + RESERVATION = "Reservation" + SPOT = "Spot" + +class ReservationRecommendationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the kind of reservation recommendation. """ LEGACY = "legacy" MODERN = "modern" -class Scope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Scope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SINGLE = "Single" SHARED = "Shared" -class Term(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Status(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The status of the lot. + """ + + NONE = "None" + ACTIVE = "Active" + INACTIVE = "Inactive" + EXPIRED = "Expired" + COMPLETE = "Complete" + CANCELED = "Canceled" + +class Term(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - P1_Y = "P1Y" #: 1 year reservation term. - P3_Y = "P3Y" #: 3 year reservation term. + #: 1 year reservation term. + P1_Y = "P1Y" + #: 3 year reservation term. + P3_Y = "P3Y" -class ThresholdType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ThresholdType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of threshold """ ACTUAL = "Actual" + FORECASTED = "Forecasted" -class TimeGrainType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TimeGrainType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The time covered by a budget. Tracking of the amount will be reset based on the time grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD customers """ @@ -154,7 +174,7 @@ class TimeGrainType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BILLING_QUARTER = "BillingQuarter" BILLING_ANNUAL = "BillingAnnual" -class UsageDetailsKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UsageDetailsKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the kind of usage details. """ diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models.py index ba7caff4e715..5bd6a679a9a0 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models.py @@ -35,22 +35,66 @@ def __init__( self, **kwargs ): + """ + """ super(Amount, self).__init__(**kwargs) self.currency = None self.value = None +class AmountWithExchangeRate(Amount): + """The amount with exchange rate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar currency: Amount currency. + :vartype currency: str + :ivar value: Amount. + :vartype value: float + :ivar exchange_rate: The exchange rate. + :vartype exchange_rate: float + :ivar exchange_rate_month: The exchange rate month. + :vartype exchange_rate_month: int + """ + + _validation = { + 'currency': {'readonly': True}, + 'value': {'readonly': True}, + 'exchange_rate': {'readonly': True}, + 'exchange_rate_month': {'readonly': True}, + } + + _attribute_map = { + 'currency': {'key': 'currency', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + 'exchange_rate': {'key': 'exchangeRate', 'type': 'float'}, + 'exchange_rate_month': {'key': 'exchangeRateMonth', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AmountWithExchangeRate, self).__init__(**kwargs) + self.exchange_rate = None + self.exchange_rate_month = None + + class Resource(msrest.serialization.Model): """The Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] """ @@ -59,6 +103,7 @@ class Resource(msrest.serialization.Model): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, } @@ -66,6 +111,7 @@ class Resource(msrest.serialization.Model): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, } @@ -73,10 +119,13 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None + self.etag = None self.tags = None @@ -85,12 +134,14 @@ class Balance(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar currency: The ISO currency in which the meter is charged, for example, USD. @@ -116,9 +167,9 @@ class Balance(Resource): :vartype total_usage: float :ivar azure_marketplace_service_charges: Total charges for Azure Marketplace. :vartype azure_marketplace_service_charges: float - :param billing_frequency: The billing frequency. Possible values include: "Month", "Quarter", + :ivar billing_frequency: The billing frequency. Possible values include: "Month", "Quarter", "Year". - :type billing_frequency: str or ~azure.mgmt.consumption.models.BillingFrequency + :vartype billing_frequency: str or ~azure.mgmt.consumption.models.BillingFrequency :ivar price_hidden: Price is hidden or not. :vartype price_hidden: bool :ivar new_purchases_details: List of new purchases. @@ -133,6 +184,7 @@ class Balance(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'currency': {'readonly': True}, 'beginning_balance': {'readonly': True}, @@ -154,6 +206,7 @@ class Balance(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'currency': {'key': 'properties.currency', 'type': 'str'}, 'beginning_balance': {'key': 'properties.beginningBalance', 'type': 'float'}, @@ -176,6 +229,11 @@ def __init__( self, **kwargs ): + """ + :keyword billing_frequency: The billing frequency. Possible values include: "Month", "Quarter", + "Year". + :paramtype billing_frequency: str or ~azure.mgmt.consumption.models.BillingFrequency + """ super(Balance, self).__init__(**kwargs) self.currency = None self.beginning_balance = None @@ -219,6 +277,8 @@ def __init__( self, **kwargs ): + """ + """ super(BalancePropertiesAdjustmentDetailsItem, self).__init__(**kwargs) self.name = None self.value = None @@ -249,6 +309,8 @@ def __init__( self, **kwargs ): + """ + """ super(BalancePropertiesNewPurchasesDetailsItem, self).__init__(**kwargs) self.name = None self.value = None @@ -265,9 +327,9 @@ class ProxyResource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. - :type e_tag: str + :vartype e_tag: str """ _validation = { @@ -287,6 +349,11 @@ def __init__( self, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -305,31 +372,33 @@ class Budget(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. - :type e_tag: str - :param category: The category of the budget, whether the budget tracks cost or usage. Possible + :vartype e_tag: str + :ivar category: The category of the budget, whether the budget tracks cost or usage. Possible values include: "Cost". - :type category: str or ~azure.mgmt.consumption.models.CategoryType - :param amount: The total amount of cost to track with the budget. - :type amount: float - :param time_grain: The time covered by a budget. Tracking of the amount will be reset based on + :vartype category: str or ~azure.mgmt.consumption.models.CategoryType + :ivar amount: The total amount of cost to track with the budget. + :vartype amount: float + :ivar time_grain: The time covered by a budget. Tracking of the amount will be reset based on the time grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD customers. Possible values include: "Monthly", "Quarterly", "Annually", "BillingMonth", "BillingQuarter", "BillingAnnual". - :type time_grain: str or ~azure.mgmt.consumption.models.TimeGrainType - :param time_period: Has start and end date of the budget. The start date must be first of the + :vartype time_grain: str or ~azure.mgmt.consumption.models.TimeGrainType + :ivar time_period: Has start and end date of the budget. The start date must be first of the month and should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should not be more than twelve months. Past start date should be selected within the timegrain period. There are no restrictions on the end date. - :type time_period: ~azure.mgmt.consumption.models.BudgetTimePeriod - :param filter: May be used to filter budgets by resource group, resource, or meter. - :type filter: ~azure.mgmt.consumption.models.BudgetFilter + :vartype time_period: ~azure.mgmt.consumption.models.BudgetTimePeriod + :ivar filter: May be used to filter budgets by user-specified dimensions and/or tags. + :vartype filter: ~azure.mgmt.consumption.models.BudgetFilter :ivar current_spend: The current amount of cost which is being tracked for a budget. :vartype current_spend: ~azure.mgmt.consumption.models.CurrentSpend - :param notifications: Dictionary of notifications associated with the budget. Budget can have - up to five notifications. - :type notifications: dict[str, ~azure.mgmt.consumption.models.Notification] + :ivar notifications: Dictionary of notifications associated with the budget. Budget can have up + to five notifications. + :vartype notifications: dict[str, ~azure.mgmt.consumption.models.Notification] + :ivar forecast_spend: The forecasted cost which is being tracked for a budget. + :vartype forecast_spend: ~azure.mgmt.consumption.models.ForecastSpend """ _validation = { @@ -337,6 +406,7 @@ class Budget(ProxyResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'current_spend': {'readonly': True}, + 'forecast_spend': {'readonly': True}, } _attribute_map = { @@ -351,12 +421,38 @@ class Budget(ProxyResource): 'filter': {'key': 'properties.filter', 'type': 'BudgetFilter'}, 'current_spend': {'key': 'properties.currentSpend', 'type': 'CurrentSpend'}, 'notifications': {'key': 'properties.notifications', 'type': '{Notification}'}, + 'forecast_spend': {'key': 'properties.forecastSpend', 'type': 'ForecastSpend'}, } def __init__( self, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + :keyword category: The category of the budget, whether the budget tracks cost or usage. + Possible values include: "Cost". + :paramtype category: str or ~azure.mgmt.consumption.models.CategoryType + :keyword amount: The total amount of cost to track with the budget. + :paramtype amount: float + :keyword time_grain: The time covered by a budget. Tracking of the amount will be reset based + on the time grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD + customers. Possible values include: "Monthly", "Quarterly", "Annually", "BillingMonth", + "BillingQuarter", "BillingAnnual". + :paramtype time_grain: str or ~azure.mgmt.consumption.models.TimeGrainType + :keyword time_period: Has start and end date of the budget. The start date must be first of the + month and should be less than the end date. Budget start date must be on or after June 1, 2017. + Future start date should not be more than twelve months. Past start date should be selected + within the timegrain period. There are no restrictions on the end date. + :paramtype time_period: ~azure.mgmt.consumption.models.BudgetTimePeriod + :keyword filter: May be used to filter budgets by user-specified dimensions and/or tags. + :paramtype filter: ~azure.mgmt.consumption.models.BudgetFilter + :keyword notifications: Dictionary of notifications associated with the budget. Budget can have + up to five notifications. + :paramtype notifications: dict[str, ~azure.mgmt.consumption.models.Notification] + """ super(Budget, self).__init__(**kwargs) self.category = kwargs.get('category', None) self.amount = kwargs.get('amount', None) @@ -365,6 +461,7 @@ def __init__( self.filter = kwargs.get('filter', None) self.current_spend = None self.notifications = kwargs.get('notifications', None) + self.forecast_spend = None class BudgetComparisonExpression(msrest.serialization.Model): @@ -372,18 +469,18 @@ class BudgetComparisonExpression(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the column to use in comparison. - :type name: str - :param operator: Required. The operator to use for comparison. Possible values include: "In". - :type operator: str or ~azure.mgmt.consumption.models.BudgetOperatorType - :param values: Required. Array of values to use for comparison. - :type values: list[str] + :ivar name: Required. The name of the column to use in comparison. + :vartype name: str + :ivar operator: Required. The operator to use for comparison. Possible values include: "In". + :vartype operator: str or ~azure.mgmt.consumption.models.BudgetOperatorType + :ivar values: Required. Array of values to use for comparison. + :vartype values: list[str] """ _validation = { 'name': {'required': True}, 'operator': {'required': True}, - 'values': {'required': True, 'min_items': 1}, + 'values': {'required': True}, } _attribute_map = { @@ -396,6 +493,14 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the column to use in comparison. + :paramtype name: str + :keyword operator: Required. The operator to use for comparison. Possible values include: "In". + :paramtype operator: str or ~azure.mgmt.consumption.models.BudgetOperatorType + :keyword values: Required. Array of values to use for comparison. + :paramtype values: list[str] + """ super(BudgetComparisonExpression, self).__init__(**kwargs) self.name = kwargs['name'] self.operator = kwargs['operator'] @@ -405,20 +510,16 @@ def __init__( class BudgetFilter(msrest.serialization.Model): """May be used to filter budgets by resource group, resource, or meter. - :param and_property: The logical "AND" expression. Must have at least 2 items. - :type and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] - :param not_property: The logical "NOT" expression. - :type not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :ivar and_property: The logical "AND" expression. Must have at least 2 items. + :vartype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] + :ivar not_property: The logical "NOT" expression. + :vartype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties + :ivar dimensions: Has comparison expression for a dimension. + :vartype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :ivar tags: A set of tags. Has comparison expression for a tag. + :vartype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression """ - _validation = { - 'and_property': {'min_items': 2}, - } - _attribute_map = { 'and_property': {'key': 'and', 'type': '[BudgetFilterProperties]'}, 'not_property': {'key': 'not', 'type': 'BudgetFilterProperties'}, @@ -430,6 +531,16 @@ def __init__( self, **kwargs ): + """ + :keyword and_property: The logical "AND" expression. Must have at least 2 items. + :paramtype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] + :keyword not_property: The logical "NOT" expression. + :paramtype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties + :keyword dimensions: Has comparison expression for a dimension. + :paramtype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :keyword tags: A set of tags. Has comparison expression for a tag. + :paramtype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression + """ super(BudgetFilter, self).__init__(**kwargs) self.and_property = kwargs.get('and_property', None) self.not_property = kwargs.get('not_property', None) @@ -440,10 +551,10 @@ def __init__( class BudgetFilterProperties(msrest.serialization.Model): """The Dimensions or Tags to filter a budget by. - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :ivar dimensions: Has comparison expression for a dimension. + :vartype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :ivar tags: A set of tags. Has comparison expression for a tag. + :vartype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression """ _attribute_map = { @@ -455,6 +566,12 @@ def __init__( self, **kwargs ): + """ + :keyword dimensions: Has comparison expression for a dimension. + :paramtype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :keyword tags: A set of tags. Has comparison expression for a tag. + :paramtype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression + """ super(BudgetFilterProperties, self).__init__(**kwargs) self.dimensions = kwargs.get('dimensions', None) self.tags = kwargs.get('tags', None) @@ -485,6 +602,8 @@ def __init__( self, **kwargs ): + """ + """ super(BudgetsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -495,11 +614,11 @@ class BudgetTimePeriod(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param start_date: Required. The start date for the budget. - :type start_date: ~datetime.datetime - :param end_date: The end date for the budget. If not provided, we default this to 10 years from + :ivar start_date: Required. The start date for the budget. + :vartype start_date: ~datetime.datetime + :ivar end_date: The end date for the budget. If not provided, we default this to 10 years from the start date. - :type end_date: ~datetime.datetime + :vartype end_date: ~datetime.datetime """ _validation = { @@ -515,6 +634,13 @@ def __init__( self, **kwargs ): + """ + :keyword start_date: Required. The start date for the budget. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The end date for the budget. If not provided, we default this to 10 years + from the start date. + :paramtype end_date: ~datetime.datetime + """ super(BudgetTimePeriod, self).__init__(**kwargs) self.start_date = kwargs['start_date'] self.end_date = kwargs.get('end_date', None) @@ -541,11 +667,13 @@ def __init__( self, **kwargs ): + """ + """ super(ChargesListResult, self).__init__(**kwargs) self.value = None -class ChargeSummary(Resource): +class ChargeSummary(ProxyResource): """A charge summary resource. You probably want to use the sub-classes and not this class directly. Known @@ -561,18 +689,18 @@ class ChargeSummary(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of charge summary.Constant filled by server. - Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar kind: Required. Specifies the kind of charge summary.Constant filled by server. Possible + values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'kind': {'required': True}, } @@ -580,7 +708,7 @@ class ChargeSummary(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'kind': {'key': 'kind', 'type': 'str'}, } @@ -592,6 +720,11 @@ def __init__( self, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ super(ChargeSummary, self).__init__(**kwargs) self.kind = 'ChargeSummary' # type: str @@ -605,25 +738,33 @@ class CreditBalanceSummary(msrest.serialization.Model): :vartype estimated_balance: ~azure.mgmt.consumption.models.Amount :ivar current_balance: Current balance. :vartype current_balance: ~azure.mgmt.consumption.models.Amount + :ivar estimated_balance_in_billing_currency: Estimated balance in billing currency. + :vartype estimated_balance_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate """ _validation = { 'estimated_balance': {'readonly': True}, 'current_balance': {'readonly': True}, + 'estimated_balance_in_billing_currency': {'readonly': True}, } _attribute_map = { 'estimated_balance': {'key': 'estimatedBalance', 'type': 'Amount'}, 'current_balance': {'key': 'currentBalance', 'type': 'Amount'}, + 'estimated_balance_in_billing_currency': {'key': 'estimatedBalanceInBillingCurrency', 'type': 'AmountWithExchangeRate'}, } def __init__( self, **kwargs ): + """ + """ super(CreditBalanceSummary, self).__init__(**kwargs) self.estimated_balance = None self.current_balance = None + self.estimated_balance_in_billing_currency = None class CreditSummary(Resource): @@ -631,12 +772,14 @@ class CreditSummary(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar balance_summary: Summary of balances associated with this credit summary. @@ -647,39 +790,63 @@ class CreditSummary(Resource): :vartype expired_credit: ~azure.mgmt.consumption.models.Amount :ivar pending_eligible_charges: Pending eligible charges. :vartype pending_eligible_charges: ~azure.mgmt.consumption.models.Amount + :ivar credit_currency: The credit currency. + :vartype credit_currency: str + :ivar billing_currency: The billing currency. + :vartype billing_currency: str + :ivar reseller: Credit's reseller. + :vartype reseller: ~azure.mgmt.consumption.models.Reseller + :ivar e_tag: The eTag for the resource. + :vartype e_tag: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'balance_summary': {'readonly': True}, 'pending_credit_adjustments': {'readonly': True}, 'expired_credit': {'readonly': True}, 'pending_eligible_charges': {'readonly': True}, + 'credit_currency': {'readonly': True}, + 'billing_currency': {'readonly': True}, + 'reseller': {'readonly': True}, + 'e_tag': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'balance_summary': {'key': 'properties.balanceSummary', 'type': 'CreditBalanceSummary'}, 'pending_credit_adjustments': {'key': 'properties.pendingCreditAdjustments', 'type': 'Amount'}, 'expired_credit': {'key': 'properties.expiredCredit', 'type': 'Amount'}, 'pending_eligible_charges': {'key': 'properties.pendingEligibleCharges', 'type': 'Amount'}, + 'credit_currency': {'key': 'properties.creditCurrency', 'type': 'str'}, + 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + 'e_tag': {'key': 'properties.eTag', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(CreditSummary, self).__init__(**kwargs) self.balance_summary = None self.pending_credit_adjustments = None self.expired_credit = None self.pending_eligible_charges = None + self.credit_currency = None + self.billing_currency = None + self.reseller = None + self.e_tag = None class CurrentSpend(msrest.serialization.Model): @@ -707,11 +874,45 @@ def __init__( self, **kwargs ): + """ + """ super(CurrentSpend, self).__init__(**kwargs) self.amount = None self.unit = None +class DownloadProperties(msrest.serialization.Model): + """The properties of the price sheet download. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar download_url: The link (url) to download the pricesheet. + :vartype download_url: str + :ivar valid_till: Download link validity. + :vartype valid_till: str + """ + + _validation = { + 'download_url': {'readonly': True}, + 'valid_till': {'readonly': True}, + } + + _attribute_map = { + 'download_url': {'key': 'downloadUrl', 'type': 'str'}, + 'valid_till': {'key': 'validTill', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(DownloadProperties, self).__init__(**kwargs) + self.download_url = None + self.valid_till = None + + class ErrorDetails(msrest.serialization.Model): """The details of the error. @@ -737,6 +938,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -754,8 +957,8 @@ class ErrorResponse(msrest.serialization.Model): * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header. - :param error: The details of the error. - :type error: ~azure.mgmt.consumption.models.ErrorDetails + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.consumption.models.ErrorDetails """ _attribute_map = { @@ -766,6 +969,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.consumption.models.ErrorDetails + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -795,12 +1002,14 @@ def __init__( self, **kwargs ): + """ + """ super(Events, self).__init__(**kwargs) self.value = None self.next_link = None -class EventSummary(Resource): +class EventSummary(ProxyResource): """An event summary resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -811,35 +1020,76 @@ class EventSummary(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :ivar transaction_date: Transaction date. + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar transaction_date: The date of the event. :vartype transaction_date: ~datetime.datetime - :ivar description: Transaction description. + :ivar description: The description of the event. :vartype description: str - :ivar new_credit: New Credit. + :ivar new_credit: The amount of new credit or commitment for NewCredit or SettleCharges event. :vartype new_credit: ~azure.mgmt.consumption.models.Amount - :ivar adjustments: Adjustments amount. + :ivar adjustments: The amount of balance adjustment. The property is not available for + ConsumptionCommitment lots. :vartype adjustments: ~azure.mgmt.consumption.models.Amount - :ivar credit_expired: Credit expired. + :ivar credit_expired: The amount of expired credit or commitment for NewCredit or SettleCharges + event. :vartype credit_expired: ~azure.mgmt.consumption.models.Amount - :ivar charges: Charges amount. + :ivar charges: The amount of charges for events of type SettleCharges and + PendingEligibleCharges. :vartype charges: ~azure.mgmt.consumption.models.Amount - :ivar closed_balance: Closed balance. + :ivar closed_balance: The balance after the event. :vartype closed_balance: ~azure.mgmt.consumption.models.Amount - :param event_type: The type of event. Possible values include: "SettledCharges", + :ivar event_type: Identifies the type of the event. Possible values include: "SettledCharges", "PendingCharges", "PendingAdjustments", "PendingNewCredit", "PendingExpiredCredit", "UnKnown", "NewCredit". - :type event_type: str or ~azure.mgmt.consumption.models.EventType - :ivar invoice_number: Invoice number. + :vartype event_type: str or ~azure.mgmt.consumption.models.EventType + :ivar invoice_number: The number which uniquely identifies the invoice on which the event was + billed. This will be empty for unbilled events. :vartype invoice_number: str + :ivar billing_profile_id: The ID that uniquely identifies the billing profile for which the + event happened. The property is only available for billing account of type + MicrosoftCustomerAgreement. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The display name of the billing profile for which the event + happened. The property is only available for billing account of type + MicrosoftCustomerAgreement. + :vartype billing_profile_display_name: str + :ivar lot_id: The ID that uniquely identifies the lot for which the event happened. + :vartype lot_id: str + :ivar lot_source: Identifies the source of the lot for which the event happened. + :vartype lot_source: str + :ivar canceled_credit: Amount of canceled credit. + :vartype canceled_credit: ~azure.mgmt.consumption.models.Amount + :ivar credit_currency: The credit currency of the event. + :vartype credit_currency: str + :ivar billing_currency: The billing currency of the event. + :vartype billing_currency: str + :ivar reseller: The reseller of the event. + :vartype reseller: ~azure.mgmt.consumption.models.Reseller + :ivar credit_expired_in_billing_currency: The amount of expired credit or commitment for + NewCredit or SettleCharges event in billing currency. + :vartype credit_expired_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar new_credit_in_billing_currency: The amount of new credit or commitment for NewCredit or + SettleCharges event in billing currency. + :vartype new_credit_in_billing_currency: ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar adjustments_in_billing_currency: The amount of balance adjustment in billing currency. + :vartype adjustments_in_billing_currency: ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar charges_in_billing_currency: The amount of charges for events of type SettleCharges and + PendingEligibleCharges in billing currency. + :vartype charges_in_billing_currency: ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar closed_balance_in_billing_currency: The balance in billing currency after the event. + :vartype closed_balance_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar e_tag_properties_e_tag: The eTag for the resource. + :vartype e_tag_properties_e_tag: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'transaction_date': {'readonly': True}, 'description': {'readonly': True}, 'new_credit': {'readonly': True}, @@ -848,13 +1098,27 @@ class EventSummary(Resource): 'charges': {'readonly': True}, 'closed_balance': {'readonly': True}, 'invoice_number': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'lot_id': {'readonly': True}, + 'lot_source': {'readonly': True}, + 'canceled_credit': {'readonly': True}, + 'credit_currency': {'readonly': True}, + 'billing_currency': {'readonly': True}, + 'reseller': {'readonly': True}, + 'credit_expired_in_billing_currency': {'readonly': True}, + 'new_credit_in_billing_currency': {'readonly': True}, + 'adjustments_in_billing_currency': {'readonly': True}, + 'charges_in_billing_currency': {'readonly': True}, + 'closed_balance_in_billing_currency': {'readonly': True}, + 'e_tag_properties_e_tag': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'transaction_date': {'key': 'properties.transactionDate', 'type': 'iso-8601'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'new_credit': {'key': 'properties.newCredit', 'type': 'Amount'}, @@ -864,12 +1128,35 @@ class EventSummary(Resource): 'closed_balance': {'key': 'properties.closedBalance', 'type': 'Amount'}, 'event_type': {'key': 'properties.eventType', 'type': 'str'}, 'invoice_number': {'key': 'properties.invoiceNumber', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'lot_id': {'key': 'properties.lotId', 'type': 'str'}, + 'lot_source': {'key': 'properties.lotSource', 'type': 'str'}, + 'canceled_credit': {'key': 'properties.canceledCredit', 'type': 'Amount'}, + 'credit_currency': {'key': 'properties.creditCurrency', 'type': 'str'}, + 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + 'credit_expired_in_billing_currency': {'key': 'properties.creditExpiredInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'new_credit_in_billing_currency': {'key': 'properties.newCreditInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'adjustments_in_billing_currency': {'key': 'properties.adjustmentsInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'charges_in_billing_currency': {'key': 'properties.chargesInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'closed_balance_in_billing_currency': {'key': 'properties.closedBalanceInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'e_tag_properties_e_tag': {'key': 'properties.eTag', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + :keyword event_type: Identifies the type of the event. Possible values include: + "SettledCharges", "PendingCharges", "PendingAdjustments", "PendingNewCredit", + "PendingExpiredCredit", "UnKnown", "NewCredit". + :paramtype event_type: str or ~azure.mgmt.consumption.models.EventType + """ super(EventSummary, self).__init__(**kwargs) self.transaction_date = None self.description = None @@ -880,134 +1167,117 @@ def __init__( self.closed_balance = None self.event_type = kwargs.get('event_type', None) self.invoice_number = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.lot_id = None + self.lot_source = None + self.canceled_credit = None + self.credit_currency = None + self.billing_currency = None + self.reseller = None + self.credit_expired_in_billing_currency = None + self.new_credit_in_billing_currency = None + self.adjustments_in_billing_currency = None + self.charges_in_billing_currency = None + self.closed_balance_in_billing_currency = None + self.e_tag_properties_e_tag = None -class Forecast(Resource): - """A forecast resource. +class ForecastSpend(msrest.serialization.Model): + """The forecasted cost which is being tracked for a budget. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :ivar usage_date: The usage date of the forecast. - :vartype usage_date: str - :param grain: The granularity of forecast. Possible values include: "Daily", "Monthly", - "Yearly". - :type grain: str or ~azure.mgmt.consumption.models.Grain - :ivar charge: The amount of charge. - :vartype charge: float - :ivar currency: The ISO currency in which the meter is charged, for example, USD. - :vartype currency: str - :param charge_type: The type of the charge. Could be actual or forecast. Possible values - include: "Actual", "Forecast". - :type charge_type: str or ~azure.mgmt.consumption.models.ChargeType - :ivar confidence_levels: The details about the forecast confidence levels. This is populated - only when chargeType is Forecast. - :vartype confidence_levels: - list[~azure.mgmt.consumption.models.ForecastPropertiesConfidenceLevelsItem] + :ivar amount: The forecasted cost for the total time period which is being tracked by the + budget. This value is only provided if the budget contains a forecast alert type. + :vartype amount: float + :ivar unit: The unit of measure for the budget amount. + :vartype unit: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'tags': {'readonly': True}, - 'usage_date': {'readonly': True}, - 'charge': {'readonly': True}, - 'currency': {'readonly': True}, - 'confidence_levels': {'readonly': True}, + 'amount': {'readonly': True}, + 'unit': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'usage_date': {'key': 'properties.usageDate', 'type': 'str'}, - 'grain': {'key': 'properties.grain', 'type': 'str'}, - 'charge': {'key': 'properties.charge', 'type': 'float'}, - 'currency': {'key': 'properties.currency', 'type': 'str'}, - 'charge_type': {'key': 'properties.chargeType', 'type': 'str'}, - 'confidence_levels': {'key': 'properties.confidenceLevels', 'type': '[ForecastPropertiesConfidenceLevelsItem]'}, + 'amount': {'key': 'amount', 'type': 'float'}, + 'unit': {'key': 'unit', 'type': 'str'}, } def __init__( self, **kwargs ): - super(Forecast, self).__init__(**kwargs) - self.usage_date = None - self.grain = kwargs.get('grain', None) - self.charge = None - self.currency = None - self.charge_type = kwargs.get('charge_type', None) - self.confidence_levels = None + """ + """ + super(ForecastSpend, self).__init__(**kwargs) + self.amount = None + self.unit = None -class ForecastPropertiesConfidenceLevelsItem(msrest.serialization.Model): - """ForecastPropertiesConfidenceLevelsItem. +class HighCasedErrorDetails(msrest.serialization.Model): + """The details of the error. Variables are only populated by the server, and will be ignored when sending a request. - :ivar percentage: The percentage level of the confidence. - :vartype percentage: float - :param bound: The boundary of the percentage, values could be 'Upper' or 'Lower'. Possible - values include: "Upper", "Lower". - :type bound: str or ~azure.mgmt.consumption.models.Bound - :ivar value: The amount of forecast within the percentage level. - :vartype value: float + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _validation = { - 'percentage': {'readonly': True}, - 'value': {'readonly': True}, + 'code': {'readonly': True}, + 'message': {'readonly': True}, } _attribute_map = { - 'percentage': {'key': 'percentage', 'type': 'float'}, - 'bound': {'key': 'bound', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, } def __init__( self, **kwargs ): - super(ForecastPropertiesConfidenceLevelsItem, self).__init__(**kwargs) - self.percentage = None - self.bound = kwargs.get('bound', None) - self.value = None + """ + """ + super(HighCasedErrorDetails, self).__init__(**kwargs) + self.code = None + self.message = None -class ForecastsListResult(msrest.serialization.Model): - """Result of listing forecasts. It contains a list of available forecasts. +class HighCasedErrorResponse(msrest.serialization.Model): + """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. - Variables are only populated by the server, and will be ignored when sending a request. +Some Error responses: - :ivar value: The list of forecasts. - :vartype value: list[~azure.mgmt.consumption.models.Forecast] - """ - _validation = { - 'value': {'readonly': True}, - } +* + 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" header. + +* + 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header. + + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.consumption.models.HighCasedErrorDetails + """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Forecast]'}, + 'error': {'key': 'error', 'type': 'HighCasedErrorDetails'}, } def __init__( self, **kwargs ): - super(ForecastsListResult, self).__init__(**kwargs) - self.value = None + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.consumption.models.HighCasedErrorDetails + """ + super(HighCasedErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) class LegacyChargeSummary(ChargeSummary): @@ -1023,11 +1293,12 @@ class LegacyChargeSummary(ChargeSummary): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of charge summary.Constant filled by server. - Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar kind: Required. Specifies the kind of charge summary.Constant filled by server. Possible + values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind :ivar billing_period_id: The id of the billing period resource that the charge belongs to. :vartype billing_period_id: str :ivar usage_start: Usage start date. @@ -1048,7 +1319,6 @@ class LegacyChargeSummary(ChargeSummary): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'kind': {'required': True}, 'billing_period_id': {'readonly': True}, 'usage_start': {'readonly': True}, @@ -1063,7 +1333,7 @@ class LegacyChargeSummary(ChargeSummary): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'kind': {'key': 'kind', 'type': 'str'}, 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, 'usage_start': {'key': 'properties.usageStart', 'type': 'str'}, @@ -1078,6 +1348,11 @@ def __init__( self, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ super(LegacyChargeSummary, self).__init__(**kwargs) self.kind = 'legacy' # type: str self.billing_period_id = None @@ -1114,6 +1389,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceAttributes, self).__init__(**kwargs) self.location = None self.sku = None @@ -1133,17 +1410,19 @@ class ReservationRecommendation(Resource, ResourceAttributes): :vartype location: str :ivar sku: Resource sku. :vartype sku: str - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of reservation recommendation.Constant filled by - server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind + :ivar kind: Required. Specifies the kind of reservation recommendation.Constant filled by + server. Possible values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind """ _validation = { @@ -1152,6 +1431,7 @@ class ReservationRecommendation(Resource, ResourceAttributes): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, } @@ -1162,6 +1442,7 @@ class ReservationRecommendation(Resource, ResourceAttributes): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, } @@ -1174,6 +1455,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationRecommendation, self).__init__(**kwargs) self.location = None self.sku = None @@ -1181,6 +1464,7 @@ def __init__( self.id = None self.name = None self.type = None + self.etag = None self.tags = None self.kind = 'ReservationRecommendation' # type: str @@ -1196,21 +1480,23 @@ class LegacyReservationRecommendation(ReservationRecommendation): :vartype location: str :ivar sku: Resource sku. :vartype sku: str - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of reservation recommendation.Constant filled by - server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind + :ivar kind: Required. Specifies the kind of reservation recommendation.Constant filled by + server. Possible values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind :ivar look_back_period: The number of days of usage to look back for recommendation. :vartype look_back_period: str :ivar instance_flexibility_ratio: The instance Flexibility Ratio. - :vartype instance_flexibility_ratio: int + :vartype instance_flexibility_ratio: float :ivar instance_flexibility_group: The instance Flexibility Group. :vartype instance_flexibility_group: str :ivar normalized_size: The normalized Size. @@ -1219,6 +1505,8 @@ class LegacyReservationRecommendation(ReservationRecommendation): :vartype recommended_quantity_normalized: float :ivar meter_id: The meter id (GUID). :vartype meter_id: str + :ivar resource_type: The azure resource type. + :vartype resource_type: str :ivar term: RI recommendations in one or three year terms. :vartype term: str :ivar cost_with_no_reserved_instances: The total amount of cost without reserved instances. @@ -1231,7 +1519,7 @@ class LegacyReservationRecommendation(ReservationRecommendation): :vartype net_savings: float :ivar first_usage_date: The usage date for looking back. :vartype first_usage_date: ~datetime.datetime - :ivar scope: Shared or single recommendation. + :ivar scope: Required. Shared or single recommendation.Constant filled by server. :vartype scope: str :ivar sku_properties: List of sku properties. :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] @@ -1243,6 +1531,7 @@ class LegacyReservationRecommendation(ReservationRecommendation): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, 'look_back_period': {'readonly': True}, @@ -1251,13 +1540,14 @@ class LegacyReservationRecommendation(ReservationRecommendation): 'normalized_size': {'readonly': True}, 'recommended_quantity_normalized': {'readonly': True}, 'meter_id': {'readonly': True}, + 'resource_type': {'readonly': True}, 'term': {'readonly': True}, 'cost_with_no_reserved_instances': {'readonly': True}, 'recommended_quantity': {'readonly': True}, 'total_cost_with_reserved_instances': {'readonly': True}, 'net_savings': {'readonly': True}, 'first_usage_date': {'readonly': True}, - 'scope': {'readonly': True}, + 'scope': {'required': True}, 'sku_properties': {'readonly': True}, } @@ -1267,14 +1557,16 @@ class LegacyReservationRecommendation(ReservationRecommendation): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, 'look_back_period': {'key': 'properties.lookBackPeriod', 'type': 'str'}, - 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'int'}, + 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'float'}, 'instance_flexibility_group': {'key': 'properties.instanceFlexibilityGroup', 'type': 'str'}, 'normalized_size': {'key': 'properties.normalizedSize', 'type': 'str'}, 'recommended_quantity_normalized': {'key': 'properties.recommendedQuantityNormalized', 'type': 'float'}, 'meter_id': {'key': 'properties.meterId', 'type': 'str'}, + 'resource_type': {'key': 'properties.resourceType', 'type': 'str'}, 'term': {'key': 'properties.term', 'type': 'str'}, 'cost_with_no_reserved_instances': {'key': 'properties.costWithNoReservedInstances', 'type': 'float'}, 'recommended_quantity': {'key': 'properties.recommendedQuantity', 'type': 'float'}, @@ -1289,6 +1581,8 @@ def __init__( self, **kwargs ): + """ + """ super(LegacyReservationRecommendation, self).__init__(**kwargs) self.kind = 'legacy' # type: str self.look_back_period = None @@ -1297,13 +1591,120 @@ def __init__( self.normalized_size = None self.recommended_quantity_normalized = None self.meter_id = None + self.resource_type = None self.term = None self.cost_with_no_reserved_instances = None self.recommended_quantity = None self.total_cost_with_reserved_instances = None self.net_savings = None self.first_usage_date = None - self.scope = None + self.scope = 'legacy' # type: str + self.sku_properties = None + + +class LegacyReservationRecommendationProperties(msrest.serialization.Model): + """The properties of the reservation recommendation. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: LegacySharedScopeReservationRecommendationProperties, LegacySingleScopeReservationRecommendationProperties. + + 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 look_back_period: The number of days of usage to look back for recommendation. + :vartype look_back_period: str + :ivar instance_flexibility_ratio: The instance Flexibility Ratio. + :vartype instance_flexibility_ratio: float + :ivar instance_flexibility_group: The instance Flexibility Group. + :vartype instance_flexibility_group: str + :ivar normalized_size: The normalized Size. + :vartype normalized_size: str + :ivar recommended_quantity_normalized: The recommended Quantity Normalized. + :vartype recommended_quantity_normalized: float + :ivar meter_id: The meter id (GUID). + :vartype meter_id: str + :ivar resource_type: The azure resource type. + :vartype resource_type: str + :ivar term: RI recommendations in one or three year terms. + :vartype term: str + :ivar cost_with_no_reserved_instances: The total amount of cost without reserved instances. + :vartype cost_with_no_reserved_instances: float + :ivar recommended_quantity: Recommended quality for reserved instances. + :vartype recommended_quantity: float + :ivar total_cost_with_reserved_instances: The total amount of cost with reserved instances. + :vartype total_cost_with_reserved_instances: float + :ivar net_savings: Total estimated savings with reserved instances. + :vartype net_savings: float + :ivar first_usage_date: The usage date for looking back. + :vartype first_usage_date: ~datetime.datetime + :ivar scope: Required. Shared or single recommendation.Constant filled by server. + :vartype scope: str + :ivar sku_properties: List of sku properties. + :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] + """ + + _validation = { + 'look_back_period': {'readonly': True}, + 'instance_flexibility_ratio': {'readonly': True}, + 'instance_flexibility_group': {'readonly': True}, + 'normalized_size': {'readonly': True}, + 'recommended_quantity_normalized': {'readonly': True}, + 'meter_id': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'term': {'readonly': True}, + 'cost_with_no_reserved_instances': {'readonly': True}, + 'recommended_quantity': {'readonly': True}, + 'total_cost_with_reserved_instances': {'readonly': True}, + 'net_savings': {'readonly': True}, + 'first_usage_date': {'readonly': True}, + 'scope': {'required': True}, + 'sku_properties': {'readonly': True}, + } + + _attribute_map = { + 'look_back_period': {'key': 'lookBackPeriod', 'type': 'str'}, + 'instance_flexibility_ratio': {'key': 'instanceFlexibilityRatio', 'type': 'float'}, + 'instance_flexibility_group': {'key': 'instanceFlexibilityGroup', 'type': 'str'}, + 'normalized_size': {'key': 'normalizedSize', 'type': 'str'}, + 'recommended_quantity_normalized': {'key': 'recommendedQuantityNormalized', 'type': 'float'}, + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'term': {'key': 'term', 'type': 'str'}, + 'cost_with_no_reserved_instances': {'key': 'costWithNoReservedInstances', 'type': 'float'}, + 'recommended_quantity': {'key': 'recommendedQuantity', 'type': 'float'}, + 'total_cost_with_reserved_instances': {'key': 'totalCostWithReservedInstances', 'type': 'float'}, + 'net_savings': {'key': 'netSavings', 'type': 'float'}, + 'first_usage_date': {'key': 'firstUsageDate', 'type': 'iso-8601'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'sku_properties': {'key': 'skuProperties', 'type': '[SkuProperty]'}, + } + + _subtype_map = { + 'scope': {'Shared': 'LegacySharedScopeReservationRecommendationProperties', 'Single': 'LegacySingleScopeReservationRecommendationProperties'} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LegacyReservationRecommendationProperties, self).__init__(**kwargs) + self.look_back_period = None + self.instance_flexibility_ratio = None + self.instance_flexibility_group = None + self.normalized_size = None + self.recommended_quantity_normalized = None + self.meter_id = None + self.resource_type = None + self.term = None + self.cost_with_no_reserved_instances = None + self.recommended_quantity = None + self.total_cost_with_reserved_instances = None + self.net_savings = None + self.first_usage_date = None + self.scope = None # type: Optional[str] self.sku_properties = None @@ -1340,6 +1741,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationTransactionResource, self).__init__(**kwargs) self.id = None self.name = None @@ -1405,6 +1808,12 @@ class ReservationTransaction(ReservationTransactionResource): :vartype current_enrollment: str :ivar billing_frequency: The billing frequency, which can be either one-time or recurring. :vartype billing_frequency: str + :ivar billing_month: The billing month(yyyyMMdd), on which the event initiated. + :vartype billing_month: int + :ivar monetary_commitment: The monetary commitment amount at the enrollment scope. + :vartype monetary_commitment: float + :ivar overage: The overage amount at the enrollment scope. + :vartype overage: float """ _validation = { @@ -1432,6 +1841,9 @@ class ReservationTransaction(ReservationTransactionResource): 'cost_center': {'readonly': True}, 'current_enrollment': {'readonly': True}, 'billing_frequency': {'readonly': True}, + 'billing_month': {'readonly': True}, + 'monetary_commitment': {'readonly': True}, + 'overage': {'readonly': True}, } _attribute_map = { @@ -1459,12 +1871,17 @@ class ReservationTransaction(ReservationTransactionResource): 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, 'current_enrollment': {'key': 'properties.currentEnrollment', 'type': 'str'}, 'billing_frequency': {'key': 'properties.billingFrequency', 'type': 'str'}, + 'billing_month': {'key': 'properties.billingMonth', 'type': 'int'}, + 'monetary_commitment': {'key': 'properties.monetaryCommitment', 'type': 'float'}, + 'overage': {'key': 'properties.overage', 'type': 'float'}, } def __init__( self, **kwargs ): + """ + """ super(ReservationTransaction, self).__init__(**kwargs) self.event_date = None self.reservation_order_id = None @@ -1486,6 +1903,9 @@ def __init__( self.cost_center = None self.current_enrollment = None self.billing_frequency = None + self.billing_month = None + self.monetary_commitment = None + self.overage = None class LegacyReservationTransaction(ReservationTransaction): @@ -1546,6 +1966,12 @@ class LegacyReservationTransaction(ReservationTransaction): :vartype current_enrollment: str :ivar billing_frequency: The billing frequency, which can be either one-time or recurring. :vartype billing_frequency: str + :ivar billing_month: The billing month(yyyyMMdd), on which the event initiated. + :vartype billing_month: int + :ivar monetary_commitment: The monetary commitment amount at the enrollment scope. + :vartype monetary_commitment: float + :ivar overage: The overage amount at the enrollment scope. + :vartype overage: float """ _validation = { @@ -1573,6 +1999,9 @@ class LegacyReservationTransaction(ReservationTransaction): 'cost_center': {'readonly': True}, 'current_enrollment': {'readonly': True}, 'billing_frequency': {'readonly': True}, + 'billing_month': {'readonly': True}, + 'monetary_commitment': {'readonly': True}, + 'overage': {'readonly': True}, } _attribute_map = { @@ -1600,15 +2029,195 @@ class LegacyReservationTransaction(ReservationTransaction): 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, 'current_enrollment': {'key': 'properties.currentEnrollment', 'type': 'str'}, 'billing_frequency': {'key': 'properties.billingFrequency', 'type': 'str'}, + 'billing_month': {'key': 'properties.billingMonth', 'type': 'int'}, + 'monetary_commitment': {'key': 'properties.monetaryCommitment', 'type': 'float'}, + 'overage': {'key': 'properties.overage', 'type': 'float'}, } def __init__( self, **kwargs ): + """ + """ super(LegacyReservationTransaction, self).__init__(**kwargs) +class LegacySharedScopeReservationRecommendationProperties(LegacyReservationRecommendationProperties): + """The properties of the legacy reservation recommendation for shared scope. + + 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 look_back_period: The number of days of usage to look back for recommendation. + :vartype look_back_period: str + :ivar instance_flexibility_ratio: The instance Flexibility Ratio. + :vartype instance_flexibility_ratio: float + :ivar instance_flexibility_group: The instance Flexibility Group. + :vartype instance_flexibility_group: str + :ivar normalized_size: The normalized Size. + :vartype normalized_size: str + :ivar recommended_quantity_normalized: The recommended Quantity Normalized. + :vartype recommended_quantity_normalized: float + :ivar meter_id: The meter id (GUID). + :vartype meter_id: str + :ivar resource_type: The azure resource type. + :vartype resource_type: str + :ivar term: RI recommendations in one or three year terms. + :vartype term: str + :ivar cost_with_no_reserved_instances: The total amount of cost without reserved instances. + :vartype cost_with_no_reserved_instances: float + :ivar recommended_quantity: Recommended quality for reserved instances. + :vartype recommended_quantity: float + :ivar total_cost_with_reserved_instances: The total amount of cost with reserved instances. + :vartype total_cost_with_reserved_instances: float + :ivar net_savings: Total estimated savings with reserved instances. + :vartype net_savings: float + :ivar first_usage_date: The usage date for looking back. + :vartype first_usage_date: ~datetime.datetime + :ivar scope: Required. Shared or single recommendation.Constant filled by server. + :vartype scope: str + :ivar sku_properties: List of sku properties. + :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] + """ + + _validation = { + 'look_back_period': {'readonly': True}, + 'instance_flexibility_ratio': {'readonly': True}, + 'instance_flexibility_group': {'readonly': True}, + 'normalized_size': {'readonly': True}, + 'recommended_quantity_normalized': {'readonly': True}, + 'meter_id': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'term': {'readonly': True}, + 'cost_with_no_reserved_instances': {'readonly': True}, + 'recommended_quantity': {'readonly': True}, + 'total_cost_with_reserved_instances': {'readonly': True}, + 'net_savings': {'readonly': True}, + 'first_usage_date': {'readonly': True}, + 'scope': {'required': True}, + 'sku_properties': {'readonly': True}, + } + + _attribute_map = { + 'look_back_period': {'key': 'lookBackPeriod', 'type': 'str'}, + 'instance_flexibility_ratio': {'key': 'instanceFlexibilityRatio', 'type': 'float'}, + 'instance_flexibility_group': {'key': 'instanceFlexibilityGroup', 'type': 'str'}, + 'normalized_size': {'key': 'normalizedSize', 'type': 'str'}, + 'recommended_quantity_normalized': {'key': 'recommendedQuantityNormalized', 'type': 'float'}, + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'term': {'key': 'term', 'type': 'str'}, + 'cost_with_no_reserved_instances': {'key': 'costWithNoReservedInstances', 'type': 'float'}, + 'recommended_quantity': {'key': 'recommendedQuantity', 'type': 'float'}, + 'total_cost_with_reserved_instances': {'key': 'totalCostWithReservedInstances', 'type': 'float'}, + 'net_savings': {'key': 'netSavings', 'type': 'float'}, + 'first_usage_date': {'key': 'firstUsageDate', 'type': 'iso-8601'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'sku_properties': {'key': 'skuProperties', 'type': '[SkuProperty]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LegacySharedScopeReservationRecommendationProperties, self).__init__(**kwargs) + self.scope = 'Shared' # type: str + + +class LegacySingleScopeReservationRecommendationProperties(LegacyReservationRecommendationProperties): + """The properties of the legacy reservation recommendation for single scope. + + 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 look_back_period: The number of days of usage to look back for recommendation. + :vartype look_back_period: str + :ivar instance_flexibility_ratio: The instance Flexibility Ratio. + :vartype instance_flexibility_ratio: float + :ivar instance_flexibility_group: The instance Flexibility Group. + :vartype instance_flexibility_group: str + :ivar normalized_size: The normalized Size. + :vartype normalized_size: str + :ivar recommended_quantity_normalized: The recommended Quantity Normalized. + :vartype recommended_quantity_normalized: float + :ivar meter_id: The meter id (GUID). + :vartype meter_id: str + :ivar resource_type: The azure resource type. + :vartype resource_type: str + :ivar term: RI recommendations in one or three year terms. + :vartype term: str + :ivar cost_with_no_reserved_instances: The total amount of cost without reserved instances. + :vartype cost_with_no_reserved_instances: float + :ivar recommended_quantity: Recommended quality for reserved instances. + :vartype recommended_quantity: float + :ivar total_cost_with_reserved_instances: The total amount of cost with reserved instances. + :vartype total_cost_with_reserved_instances: float + :ivar net_savings: Total estimated savings with reserved instances. + :vartype net_savings: float + :ivar first_usage_date: The usage date for looking back. + :vartype first_usage_date: ~datetime.datetime + :ivar scope: Required. Shared or single recommendation.Constant filled by server. + :vartype scope: str + :ivar sku_properties: List of sku properties. + :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] + :ivar subscription_id: Subscription id associated with single scoped recommendation. + :vartype subscription_id: str + """ + + _validation = { + 'look_back_period': {'readonly': True}, + 'instance_flexibility_ratio': {'readonly': True}, + 'instance_flexibility_group': {'readonly': True}, + 'normalized_size': {'readonly': True}, + 'recommended_quantity_normalized': {'readonly': True}, + 'meter_id': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'term': {'readonly': True}, + 'cost_with_no_reserved_instances': {'readonly': True}, + 'recommended_quantity': {'readonly': True}, + 'total_cost_with_reserved_instances': {'readonly': True}, + 'net_savings': {'readonly': True}, + 'first_usage_date': {'readonly': True}, + 'scope': {'required': True}, + 'sku_properties': {'readonly': True}, + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'look_back_period': {'key': 'lookBackPeriod', 'type': 'str'}, + 'instance_flexibility_ratio': {'key': 'instanceFlexibilityRatio', 'type': 'float'}, + 'instance_flexibility_group': {'key': 'instanceFlexibilityGroup', 'type': 'str'}, + 'normalized_size': {'key': 'normalizedSize', 'type': 'str'}, + 'recommended_quantity_normalized': {'key': 'recommendedQuantityNormalized', 'type': 'float'}, + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'term': {'key': 'term', 'type': 'str'}, + 'cost_with_no_reserved_instances': {'key': 'costWithNoReservedInstances', 'type': 'float'}, + 'recommended_quantity': {'key': 'recommendedQuantity', 'type': 'float'}, + 'total_cost_with_reserved_instances': {'key': 'totalCostWithReservedInstances', 'type': 'float'}, + 'net_savings': {'key': 'netSavings', 'type': 'float'}, + 'first_usage_date': {'key': 'firstUsageDate', 'type': 'iso-8601'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'sku_properties': {'key': 'skuProperties', 'type': '[SkuProperty]'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LegacySingleScopeReservationRecommendationProperties, self).__init__(**kwargs) + self.scope = 'Single' # type: str + self.subscription_id = None + + class UsageDetail(Resource): """An usage detail resource. @@ -1619,23 +2228,26 @@ class UsageDetail(Resource): All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of usage details.Constant filled by server. Possible + :ivar kind: Required. Specifies the kind of usage details.Constant filled by server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind + :vartype kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, } @@ -1644,6 +2256,7 @@ class UsageDetail(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, } @@ -1656,6 +2269,8 @@ def __init__( self, **kwargs ): + """ + """ super(UsageDetail, self).__init__(**kwargs) self.kind = 'UsageDetail' # type: str @@ -1667,17 +2282,19 @@ class LegacyUsageDetail(UsageDetail): All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of usage details.Constant filled by server. Possible + :ivar kind: Required. Specifies the kind of usage details.Constant filled by server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind + :vartype kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind :ivar billing_account_id: Billing Account identifier. :vartype billing_account_id: str :ivar billing_account_name: Billing Account Name. @@ -1728,13 +2345,13 @@ class LegacyUsageDetail(UsageDetail): :ivar consumed_service: Consumed service name. Name of the azure resource provider that emits the usage or was purchased. This value is not provided for marketplace usage. :vartype consumed_service: str - :ivar resource_id: Azure resource manager resource identifier. + :ivar resource_id: Unique identifier of the Azure Resource Manager usage detail resource. :vartype resource_id: str :ivar resource_name: Resource Name. :vartype resource_name: str - :ivar service_info1: Service Info 1. + :ivar service_info1: Service-specific metadata. :vartype service_info1: str - :ivar service_info2: Service Info 2. + :ivar service_info2: Legacy field with optional service-specific metadata. :vartype service_info2: str :ivar additional_info: Additional details of this usage item. By default this is not populated, unless it's specified in $expand. Use this field to get usage line item specific details such @@ -1779,12 +2396,22 @@ class LegacyUsageDetail(UsageDetail): only happen once, Monthly for fees which recur every month, and UsageBased for charges based on how much a service is used. :vartype frequency: str + :ivar pay_g_price: Retail price for the resource. + :vartype pay_g_price: float + :ivar benefit_id: Unique identifier for the applicable benefit. + :vartype benefit_id: str + :ivar benefit_name: Name of the applicable benefit. + :vartype benefit_name: str + :ivar pricing_model: Identifier that indicates how the meter is priced. Possible values + include: "On Demand", "Reservation", "Spot". + :vartype pricing_model: str or ~azure.mgmt.consumption.models.PricingModelType """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, 'billing_account_id': {'readonly': True}, @@ -1829,12 +2456,17 @@ class LegacyUsageDetail(UsageDetail): 'plan_name': {'readonly': True}, 'charge_type': {'readonly': True}, 'frequency': {'readonly': True}, + 'pay_g_price': {'readonly': True}, + 'benefit_id': {'readonly': True}, + 'benefit_name': {'readonly': True}, + 'pricing_model': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, 'billing_account_id': {'key': 'properties.billingAccountId', 'type': 'str'}, @@ -1879,12 +2511,18 @@ class LegacyUsageDetail(UsageDetail): 'plan_name': {'key': 'properties.planName', 'type': 'str'}, 'charge_type': {'key': 'properties.chargeType', 'type': 'str'}, 'frequency': {'key': 'properties.frequency', 'type': 'str'}, + 'pay_g_price': {'key': 'properties.payGPrice', 'type': 'float'}, + 'benefit_id': {'key': 'properties.benefitId', 'type': 'str'}, + 'benefit_name': {'key': 'properties.benefitName', 'type': 'str'}, + 'pricing_model': {'key': 'properties.pricingModel', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(LegacyUsageDetail, self).__init__(**kwargs) self.kind = 'legacy' # type: str self.billing_account_id = None @@ -1929,6 +2567,10 @@ def __init__( self.plan_name = None self.charge_type = None self.frequency = None + self.pay_g_price = None + self.benefit_id = None + self.benefit_name = None + self.pricing_model = None class Lots(msrest.serialization.Model): @@ -1956,12 +2598,14 @@ def __init__( self, **kwargs ): + """ + """ super(Lots, self).__init__(**kwargs) self.value = None self.next_link = None -class LotSummary(Resource): +class LotSummary(ProxyResource): """A lot summary resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1972,52 +2616,95 @@ class LotSummary(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :ivar original_amount: Original amount. + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar original_amount: The original amount of a lot. :vartype original_amount: ~azure.mgmt.consumption.models.Amount - :ivar closed_balance: Closed balance. + :ivar closed_balance: The balance as of the last invoice. :vartype closed_balance: ~azure.mgmt.consumption.models.Amount - :ivar source: Lot source. Possible values include: "PurchasedCredit", "PromotionalCredit". + :ivar source: The source of the lot. Possible values include: "PurchasedCredit", + "PromotionalCredit", "ConsumptionCommitment". :vartype source: str or ~azure.mgmt.consumption.models.LotSource - :ivar start_date: Start date. + :ivar start_date: The date when the lot became effective. :vartype start_date: ~datetime.datetime - :ivar expiration_date: Expiration date. + :ivar expiration_date: The expiration date of a lot. :vartype expiration_date: ~datetime.datetime - :ivar po_number: PO number. + :ivar po_number: The po number of the invoice on which the lot was added. This property is not + available for ConsumptionCommitment lots. :vartype po_number: str + :ivar purchased_date: The date when the lot was added. + :vartype purchased_date: ~datetime.datetime + :ivar status: The status of the lot. Possible values include: "None", "Active", "Inactive", + "Expired", "Complete", "Canceled". + :vartype status: str or ~azure.mgmt.consumption.models.Status + :ivar credit_currency: The currency of the lot. + :vartype credit_currency: str + :ivar billing_currency: The billing currency of the lot. + :vartype billing_currency: str + :ivar original_amount_in_billing_currency: The original amount of a lot in billing currency. + :vartype original_amount_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar closed_balance_in_billing_currency: The balance as of the last invoice in billing + currency. + :vartype closed_balance_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar reseller: The reseller of the lot. + :vartype reseller: ~azure.mgmt.consumption.models.Reseller + :ivar e_tag_properties_e_tag: The eTag for the resource. + :vartype e_tag_properties_e_tag: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'original_amount': {'readonly': True}, 'closed_balance': {'readonly': True}, 'source': {'readonly': True}, 'start_date': {'readonly': True}, 'expiration_date': {'readonly': True}, 'po_number': {'readonly': True}, + 'purchased_date': {'readonly': True}, + 'status': {'readonly': True}, + 'credit_currency': {'readonly': True}, + 'billing_currency': {'readonly': True}, + 'original_amount_in_billing_currency': {'readonly': True}, + 'closed_balance_in_billing_currency': {'readonly': True}, + 'reseller': {'readonly': True}, + 'e_tag_properties_e_tag': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'original_amount': {'key': 'properties.originalAmount', 'type': 'Amount'}, 'closed_balance': {'key': 'properties.closedBalance', 'type': 'Amount'}, 'source': {'key': 'properties.source', 'type': 'str'}, 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, 'po_number': {'key': 'properties.poNumber', 'type': 'str'}, + 'purchased_date': {'key': 'properties.purchasedDate', 'type': 'iso-8601'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'credit_currency': {'key': 'properties.creditCurrency', 'type': 'str'}, + 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, + 'original_amount_in_billing_currency': {'key': 'properties.originalAmountInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'closed_balance_in_billing_currency': {'key': 'properties.closedBalanceInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + 'e_tag_properties_e_tag': {'key': 'properties.eTag', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ super(LotSummary, self).__init__(**kwargs) self.original_amount = None self.closed_balance = None @@ -2025,6 +2712,14 @@ def __init__( self.start_date = None self.expiration_date = None self.po_number = None + self.purchased_date = None + self.status = None + self.credit_currency = None + self.billing_currency = None + self.original_amount_in_billing_currency = None + self.closed_balance_in_billing_currency = None + self.reseller = None + self.e_tag_properties_e_tag = None class ManagementGroupAggregatedCostResult(Resource): @@ -2032,12 +2727,14 @@ class ManagementGroupAggregatedCostResult(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar billing_period_id: The id of the billing period resource that the aggregated cost belongs @@ -2055,20 +2752,21 @@ class ManagementGroupAggregatedCostResult(Resource): :vartype charges_billed_separately: float :ivar currency: The ISO currency in which the meter is charged, for example, USD. :vartype currency: str - :param children: Children of a management group. - :type children: list[~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult] - :param included_subscriptions: List of subscription Guids included in the calculation of + :ivar children: Children of a management group. + :vartype children: list[~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult] + :ivar included_subscriptions: List of subscription Guids included in the calculation of aggregated cost. - :type included_subscriptions: list[str] - :param excluded_subscriptions: List of subscription Guids excluded from the calculation of + :vartype included_subscriptions: list[str] + :ivar excluded_subscriptions: List of subscription Guids excluded from the calculation of aggregated cost. - :type excluded_subscriptions: list[str] + :vartype excluded_subscriptions: list[str] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'billing_period_id': {'readonly': True}, 'usage_start': {'readonly': True}, @@ -2083,6 +2781,7 @@ class ManagementGroupAggregatedCostResult(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, 'usage_start': {'key': 'properties.usageStart', 'type': 'iso-8601'}, @@ -2100,6 +2799,16 @@ def __init__( self, **kwargs ): + """ + :keyword children: Children of a management group. + :paramtype children: list[~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult] + :keyword included_subscriptions: List of subscription Guids included in the calculation of + aggregated cost. + :paramtype included_subscriptions: list[str] + :keyword excluded_subscriptions: List of subscription Guids excluded from the calculation of + aggregated cost. + :paramtype excluded_subscriptions: list[str] + """ super(ManagementGroupAggregatedCostResult, self).__init__(**kwargs) self.billing_period_id = None self.usage_start = None @@ -2114,16 +2823,18 @@ def __init__( class Marketplace(Resource): - """An marketplace resource. + """A marketplace resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar billing_period_id: The id of the billing period resource that the usage belongs to. @@ -2138,6 +2849,8 @@ class Marketplace(Resource): :vartype offer_name: str :ivar resource_group: The name of resource group. :vartype resource_group: str + :ivar additional_info: Additional information. + :vartype additional_info: str :ivar order_number: The order number. :vartype order_number: str :ivar instance_name: The name of the resource instance that the usage is about. @@ -2184,6 +2897,7 @@ class Marketplace(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'billing_period_id': {'readonly': True}, 'usage_start': {'readonly': True}, @@ -2191,6 +2905,7 @@ class Marketplace(Resource): 'resource_rate': {'readonly': True}, 'offer_name': {'readonly': True}, 'resource_group': {'readonly': True}, + 'additional_info': {'readonly': True}, 'order_number': {'readonly': True}, 'instance_name': {'readonly': True}, 'instance_id': {'readonly': True}, @@ -2216,6 +2931,7 @@ class Marketplace(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, 'usage_start': {'key': 'properties.usageStart', 'type': 'iso-8601'}, @@ -2223,6 +2939,7 @@ class Marketplace(Resource): 'resource_rate': {'key': 'properties.resourceRate', 'type': 'float'}, 'offer_name': {'key': 'properties.offerName', 'type': 'str'}, 'resource_group': {'key': 'properties.resourceGroup', 'type': 'str'}, + 'additional_info': {'key': 'properties.additionalInfo', 'type': 'str'}, 'order_number': {'key': 'properties.orderNumber', 'type': 'str'}, 'instance_name': {'key': 'properties.instanceName', 'type': 'str'}, 'instance_id': {'key': 'properties.instanceId', 'type': 'str'}, @@ -2248,6 +2965,8 @@ def __init__( self, **kwargs ): + """ + """ super(Marketplace, self).__init__(**kwargs) self.billing_period_id = None self.usage_start = None @@ -2255,6 +2974,7 @@ def __init__( self.resource_rate = None self.offer_name = None self.resource_group = None + self.additional_info = None self.order_number = None self.instance_name = None self.instance_id = None @@ -2301,6 +3021,8 @@ def __init__( self, **kwargs ): + """ + """ super(MarketplacesListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2362,6 +3084,8 @@ def __init__( self, **kwargs ): + """ + """ super(MeterDetails, self).__init__(**kwargs) self.meter_name = None self.meter_category = None @@ -2414,6 +3138,8 @@ def __init__( self, **kwargs ): + """ + """ super(MeterDetailsResponse, self).__init__(**kwargs) self.meter_name = None self.meter_category = None @@ -2435,11 +3161,12 @@ class ModernChargeSummary(ChargeSummary): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of charge summary.Constant filled by server. - Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar kind: Required. Specifies the kind of charge summary.Constant filled by server. Possible + values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind :ivar billing_period_id: The id of the billing period resource that the charge belongs to. :vartype billing_period_id: str :ivar usage_start: Usage start date. @@ -2468,7 +3195,6 @@ class ModernChargeSummary(ChargeSummary): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'kind': {'required': True}, 'billing_period_id': {'readonly': True}, 'usage_start': {'readonly': True}, @@ -2487,7 +3213,7 @@ class ModernChargeSummary(ChargeSummary): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'kind': {'key': 'kind', 'type': 'str'}, 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, 'usage_start': {'key': 'properties.usageStart', 'type': 'str'}, @@ -2506,6 +3232,11 @@ def __init__( self, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ super(ModernChargeSummary, self).__init__(**kwargs) self.kind = 'modern' # type: str self.billing_period_id = None @@ -2532,21 +3263,25 @@ class ModernReservationRecommendation(ReservationRecommendation): :vartype location: str :ivar sku: Resource sku. :vartype sku: str - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of reservation recommendation.Constant filled by - server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind + :ivar kind: Required. Specifies the kind of reservation recommendation.Constant filled by + server. Possible values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind + :ivar location_properties_location: Resource Location. + :vartype location_properties_location: str :ivar look_back_period: The number of days of usage to look back for recommendation. - :vartype look_back_period: str + :vartype look_back_period: int :ivar instance_flexibility_ratio: The instance Flexibility Ratio. - :vartype instance_flexibility_ratio: int + :vartype instance_flexibility_ratio: float :ivar instance_flexibility_group: The instance Flexibility Group. :vartype instance_flexibility_group: str :ivar normalized_size: The normalized Size. @@ -2571,6 +3306,8 @@ class ModernReservationRecommendation(ReservationRecommendation): :vartype scope: str :ivar sku_properties: List of sku properties. :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] + :ivar sku_name: This is the ARM Sku name. + :vartype sku_name: str """ _validation = { @@ -2579,8 +3316,10 @@ class ModernReservationRecommendation(ReservationRecommendation): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, + 'location_properties_location': {'readonly': True}, 'look_back_period': {'readonly': True}, 'instance_flexibility_ratio': {'readonly': True}, 'instance_flexibility_group': {'readonly': True}, @@ -2595,6 +3334,7 @@ class ModernReservationRecommendation(ReservationRecommendation): 'first_usage_date': {'readonly': True}, 'scope': {'readonly': True}, 'sku_properties': {'readonly': True}, + 'sku_name': {'readonly': True}, } _attribute_map = { @@ -2603,10 +3343,12 @@ class ModernReservationRecommendation(ReservationRecommendation): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, - 'look_back_period': {'key': 'properties.lookBackPeriod', 'type': 'str'}, - 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'int'}, + 'location_properties_location': {'key': 'properties.location', 'type': 'str'}, + 'look_back_period': {'key': 'properties.lookBackPeriod', 'type': 'int'}, + 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'float'}, 'instance_flexibility_group': {'key': 'properties.instanceFlexibilityGroup', 'type': 'str'}, 'normalized_size': {'key': 'properties.normalizedSize', 'type': 'str'}, 'recommended_quantity_normalized': {'key': 'properties.recommendedQuantityNormalized', 'type': 'float'}, @@ -2619,14 +3361,18 @@ class ModernReservationRecommendation(ReservationRecommendation): 'first_usage_date': {'key': 'properties.firstUsageDate', 'type': 'iso-8601'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, 'sku_properties': {'key': 'properties.skuProperties', 'type': '[SkuProperty]'}, + 'sku_name': {'key': 'properties.skuName', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(ModernReservationRecommendation, self).__init__(**kwargs) self.kind = 'modern' # type: str + self.location_properties_location = None self.look_back_period = None self.instance_flexibility_ratio = None self.instance_flexibility_group = None @@ -2641,6 +3387,7 @@ def __init__( self.first_usage_date = None self.scope = None self.sku_properties = None + self.sku_name = None class ModernReservationTransaction(ReservationTransactionResource): @@ -2760,6 +3507,8 @@ def __init__( self, **kwargs ): + """ + """ super(ModernReservationTransaction, self).__init__(**kwargs) self.amount = None self.arm_sku_name = None @@ -2808,6 +3557,8 @@ def __init__( self, **kwargs ): + """ + """ super(ModernReservationTransactionsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2820,19 +3571,26 @@ class ModernUsageDetail(UsageDetail): All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of usage details.Constant filled by server. Possible + :ivar kind: Required. Specifies the kind of usage details.Constant filled by server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind + :vartype kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind :ivar billing_account_id: Billing Account identifier. :vartype billing_account_id: str + :ivar effective_price: Effective Price that's charged for the usage. + :vartype effective_price: float + :ivar pricing_model: Identifier that indicates how the meter is priced. Possible values + include: "On Demand", "Reservation", "Spot". + :vartype pricing_model: str or ~azure.mgmt.consumption.models.PricingModelType :ivar billing_account_name: Name of the Billing Account. :vartype billing_account_name: str :ivar billing_period_start_date: Billing Period Start Date as in the invoice. @@ -2894,9 +3652,9 @@ class ModernUsageDetail(UsageDetail): :ivar consumed_service: Consumed service name. Name of the azure resource provider that emits the usage or was purchased. This value is not provided for marketplace usage. :vartype consumed_service: str - :ivar service_info1: Service Info 1. + :ivar service_info1: Service-specific metadata. :vartype service_info1: str - :ivar service_info2: Service Info 2. + :ivar service_info2: Legacy field with optional service-specific metadata. :vartype service_info2: str :ivar additional_info: Additional details of this usage item. Use this field to get usage line item specific details such as the actual VM Size (ServiceType) or the ratio in which the @@ -2966,8 +3724,8 @@ class ModernUsageDetail(UsageDetail): :vartype previous_invoice_id: str :ivar pricing_currency_code: Pricing Billing Currency. :vartype pricing_currency_code: str - :ivar product_identifier: Identifer for the product that has accrued charges by consumption or - purchase . This is the concatenated key of productId and SKuId in partner center. + :ivar product_identifier: Identifier for the product that has accrued charges by consumption or + purchase . This is the concatenated key of productId and SkuId in partner center. :vartype product_identifier: str :ivar resource_location_normalized: Resource Location Normalized. :vartype resource_location_normalized: str @@ -3006,15 +3764,29 @@ class ModernUsageDetail(UsageDetail): :ivar partner_earned_credit_applied: Flag to indicate if partner earned credit has been applied or not. :vartype partner_earned_credit_applied: str + :ivar pay_g_price: Retail price for the resource. + :vartype pay_g_price: float + :ivar benefit_id: Unique identifier for the applicable benefit. + :vartype benefit_id: str + :ivar benefit_name: Name of the applicable benefit. + :vartype benefit_name: str + :ivar provider: Identifier for Product Category or Line Of Business, Ex - Azure, Microsoft 365, + AWS e.t.c. + :vartype provider: str + :ivar cost_allocation_rule_name: Name for Cost Allocation Rule. + :vartype cost_allocation_rule_name: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, 'billing_account_id': {'readonly': True}, + 'effective_price': {'readonly': True}, + 'pricing_model': {'readonly': True}, 'billing_account_name': {'readonly': True}, 'billing_period_start_date': {'readonly': True}, 'billing_period_end_date': {'readonly': True}, @@ -3079,15 +3851,23 @@ class ModernUsageDetail(UsageDetail): 'payg_cost_in_usd': {'readonly': True}, 'partner_earned_credit_rate': {'readonly': True}, 'partner_earned_credit_applied': {'readonly': True}, + 'pay_g_price': {'readonly': True}, + 'benefit_id': {'readonly': True}, + 'benefit_name': {'readonly': True}, + 'provider': {'readonly': True}, + 'cost_allocation_rule_name': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, 'billing_account_id': {'key': 'properties.billingAccountId', 'type': 'str'}, + 'effective_price': {'key': 'properties.effectivePrice', 'type': 'float'}, + 'pricing_model': {'key': 'properties.pricingModel', 'type': 'str'}, 'billing_account_name': {'key': 'properties.billingAccountName', 'type': 'str'}, 'billing_period_start_date': {'key': 'properties.billingPeriodStartDate', 'type': 'iso-8601'}, 'billing_period_end_date': {'key': 'properties.billingPeriodEndDate', 'type': 'iso-8601'}, @@ -3152,15 +3932,24 @@ class ModernUsageDetail(UsageDetail): 'payg_cost_in_usd': {'key': 'properties.paygCostInUSD', 'type': 'float'}, 'partner_earned_credit_rate': {'key': 'properties.partnerEarnedCreditRate', 'type': 'float'}, 'partner_earned_credit_applied': {'key': 'properties.partnerEarnedCreditApplied', 'type': 'str'}, + 'pay_g_price': {'key': 'properties.payGPrice', 'type': 'float'}, + 'benefit_id': {'key': 'properties.benefitId', 'type': 'str'}, + 'benefit_name': {'key': 'properties.benefitName', 'type': 'str'}, + 'provider': {'key': 'properties.provider', 'type': 'str'}, + 'cost_allocation_rule_name': {'key': 'properties.costAllocationRuleName', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(ModernUsageDetail, self).__init__(**kwargs) self.kind = 'modern' # type: str self.billing_account_id = None + self.effective_price = None + self.pricing_model = None self.billing_account_name = None self.billing_period_start_date = None self.billing_period_end_date = None @@ -3225,6 +4014,11 @@ def __init__( self.payg_cost_in_usd = None self.partner_earned_credit_rate = None self.partner_earned_credit_applied = None + self.pay_g_price = None + self.benefit_id = None + self.benefit_name = None + self.provider = None + self.cost_allocation_rule_name = None class Notification(msrest.serialization.Model): @@ -3232,33 +4026,41 @@ class Notification(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. The notification is enabled or not. - :type enabled: bool - :param operator: Required. The comparison operator. Possible values include: "EqualTo", + :ivar enabled: Required. The notification is enabled or not. + :vartype enabled: bool + :ivar operator: Required. The comparison operator. Possible values include: "EqualTo", "GreaterThan", "GreaterThanOrEqualTo". - :type operator: str or ~azure.mgmt.consumption.models.OperatorType - :param threshold: Required. Threshold value associated with a notification. Notification is - sent when the cost exceeded the threshold. It is always percent and has to be between 0 and - 1000. - :type threshold: float - :param contact_emails: Required. Email addresses to send the budget notification to when the - threshold is exceeded. - :type contact_emails: list[str] - :param contact_roles: Contact roles to send the budget notification to when the threshold is + :vartype operator: str or ~azure.mgmt.consumption.models.OperatorType + :ivar threshold: Required. Threshold value associated with a notification. Notification is sent + when the cost exceeded the threshold. It is always percent and has to be between 0 and 1000. + :vartype threshold: float + :ivar contact_emails: Required. Email addresses to send the budget notification to when the + threshold is exceeded. Must have at least one contact email or contact group specified at the + Subscription or Resource Group scopes. All other scopes must have at least one contact email + specified. + :vartype contact_emails: list[str] + :ivar contact_roles: Contact roles to send the budget notification to when the threshold is exceeded. - :type contact_roles: list[str] - :param contact_groups: Action groups to send the budget notification to when the threshold is - exceeded. - :type contact_groups: list[str] - :param threshold_type: The type of threshold. Possible values include: "Actual". - :type threshold_type: str or ~azure.mgmt.consumption.models.ThresholdType + :vartype contact_roles: list[str] + :ivar contact_groups: Action groups to send the budget notification to when the threshold is + exceeded. Must be provided as a fully qualified Azure resource id. Only supported at + Subscription or Resource Group scopes. + :vartype contact_groups: list[str] + :ivar threshold_type: The type of threshold. Possible values include: "Actual", "Forecasted". + Default value: "Actual". + :vartype threshold_type: str or ~azure.mgmt.consumption.models.ThresholdType + :ivar locale: Language in which the recipient will receive the notification. Possible values + include: "en-us", "ja-jp", "zh-cn", "de-de", "es-es", "fr-fr", "it-it", "ko-kr", "pt-br", + "ru-ru", "zh-tw", "cs-cz", "pl-pl", "tr-tr", "da-dk", "en-gb", "hu-hu", "nb-no", "nl-nl", + "pt-pt", "sv-se". + :vartype locale: str or ~azure.mgmt.consumption.models.CultureCode """ _validation = { 'enabled': {'required': True}, 'operator': {'required': True}, 'threshold': {'required': True}, - 'contact_emails': {'required': True, 'max_items': 50, 'min_items': 1}, + 'contact_emails': {'required': True, 'max_items': 50, 'min_items': 0}, 'contact_groups': {'max_items': 50, 'min_items': 0}, } @@ -3270,12 +4072,44 @@ class Notification(msrest.serialization.Model): 'contact_roles': {'key': 'contactRoles', 'type': '[str]'}, 'contact_groups': {'key': 'contactGroups', 'type': '[str]'}, 'threshold_type': {'key': 'thresholdType', 'type': 'str'}, + 'locale': {'key': 'locale', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + :keyword enabled: Required. The notification is enabled or not. + :paramtype enabled: bool + :keyword operator: Required. The comparison operator. Possible values include: "EqualTo", + "GreaterThan", "GreaterThanOrEqualTo". + :paramtype operator: str or ~azure.mgmt.consumption.models.OperatorType + :keyword threshold: Required. Threshold value associated with a notification. Notification is + sent when the cost exceeded the threshold. It is always percent and has to be between 0 and + 1000. + :paramtype threshold: float + :keyword contact_emails: Required. Email addresses to send the budget notification to when the + threshold is exceeded. Must have at least one contact email or contact group specified at the + Subscription or Resource Group scopes. All other scopes must have at least one contact email + specified. + :paramtype contact_emails: list[str] + :keyword contact_roles: Contact roles to send the budget notification to when the threshold is + exceeded. + :paramtype contact_roles: list[str] + :keyword contact_groups: Action groups to send the budget notification to when the threshold is + exceeded. Must be provided as a fully qualified Azure resource id. Only supported at + Subscription or Resource Group scopes. + :paramtype contact_groups: list[str] + :keyword threshold_type: The type of threshold. Possible values include: "Actual", + "Forecasted". Default value: "Actual". + :paramtype threshold_type: str or ~azure.mgmt.consumption.models.ThresholdType + :keyword locale: Language in which the recipient will receive the notification. Possible values + include: "en-us", "ja-jp", "zh-cn", "de-de", "es-es", "fr-fr", "it-it", "ko-kr", "pt-br", + "ru-ru", "zh-tw", "cs-cz", "pl-pl", "tr-tr", "da-dk", "en-gb", "hu-hu", "nb-no", "nl-nl", + "pt-pt", "sv-se". + :paramtype locale: str or ~azure.mgmt.consumption.models.CultureCode + """ super(Notification, self).__init__(**kwargs) self.enabled = kwargs['enabled'] self.operator = kwargs['operator'] @@ -3283,7 +4117,8 @@ def __init__( self.contact_emails = kwargs['contact_emails'] self.contact_roles = kwargs.get('contact_roles', None) self.contact_groups = kwargs.get('contact_groups', None) - self.threshold_type = kwargs.get('threshold_type', None) + self.threshold_type = kwargs.get('threshold_type', "Actual") + self.locale = kwargs.get('locale', None) class Operation(msrest.serialization.Model): @@ -3291,17 +4126,21 @@ class Operation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. + :ivar id: Operation Id. + :vartype id: str :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.consumption.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.consumption.models.OperationDisplay """ _validation = { + 'id': {'readonly': True}, 'name': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, } @@ -3310,7 +4149,12 @@ def __init__( self, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.consumption.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) + self.id = None self.name = None self.display = kwargs.get('display', None) @@ -3326,28 +4170,35 @@ class OperationDisplay(msrest.serialization.Model): :vartype resource: str :ivar operation: Operation type: Read, write, delete, etc. :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _validation = { 'provider': {'readonly': True}, 'resource': {'readonly': True}, 'operation': {'readonly': True}, + 'description': {'readonly': True}, } _attribute_map = { 'provider': {'key': 'provider', 'type': 'str'}, 'resource': {'key': 'resource', 'type': 'str'}, 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None self.operation = None + self.description = None class OperationListResult(msrest.serialization.Model): @@ -3376,6 +4227,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3435,6 +4288,8 @@ def __init__( self, **kwargs ): + """ + """ super(PriceSheetProperties, self).__init__(**kwargs) self.billing_period_id = None self.meter_id = None @@ -3452,45 +4307,88 @@ class PriceSheetResult(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar pricesheets: Price sheet. :vartype pricesheets: list[~azure.mgmt.consumption.models.PriceSheetProperties] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str + :ivar download: Pricesheet download details. + :vartype download: ~azure.mgmt.consumption.models.MeterDetails """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'pricesheets': {'readonly': True}, 'next_link': {'readonly': True}, + 'download': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'pricesheets': {'key': 'properties.pricesheets', 'type': '[PriceSheetProperties]'}, 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + 'download': {'key': 'properties.download', 'type': 'MeterDetails'}, } def __init__( self, **kwargs ): + """ + """ super(PriceSheetResult, self).__init__(**kwargs) self.pricesheets = None self.next_link = None + self.download = None + + +class Reseller(msrest.serialization.Model): + """The reseller properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar reseller_id: The reseller property ID. + :vartype reseller_id: str + :ivar reseller_description: The reseller property description. + :vartype reseller_description: str + """ + + _validation = { + 'reseller_id': {'readonly': True}, + 'reseller_description': {'readonly': True}, + } + + _attribute_map = { + 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'reseller_description': {'key': 'resellerDescription', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Reseller, self).__init__(**kwargs) + self.reseller_id = None + self.reseller_description = None class ReservationDetail(Resource): @@ -3498,12 +4396,14 @@ class ReservationDetail(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar reservation_order_id: The reservation order ID is the identifier for a reservation @@ -3544,6 +4444,7 @@ class ReservationDetail(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'reservation_order_id': {'readonly': True}, 'instance_flexibility_ratio': {'readonly': True}, @@ -3562,6 +4463,7 @@ class ReservationDetail(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'reservation_order_id': {'key': 'properties.reservationOrderId', 'type': 'str'}, 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'str'}, @@ -3580,6 +4482,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationDetail, self).__init__(**kwargs) self.reservation_order_id = None self.instance_flexibility_ratio = None @@ -3619,6 +4523,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationDetailsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3639,9 +4545,9 @@ class ReservationRecommendationDetailsCalculatedSavingsProperties(msrest.seriali :vartype reservation_cost: float :ivar total_reservation_cost: The cost of the suggested quantity. :vartype total_reservation_cost: float - :param reserved_unit_count: The number of reserved units used to calculate savings. Always 1 - for virtual machines. - :type reserved_unit_count: float + :ivar reserved_unit_count: The number of reserved units used to calculate savings. Always 1 for + virtual machines. + :vartype reserved_unit_count: float :ivar savings: The amount saved by purchasing the recommended quantity of reservation. :vartype savings: float """ @@ -3669,6 +4575,11 @@ def __init__( self, **kwargs ): + """ + :keyword reserved_unit_count: The number of reserved units used to calculate savings. Always 1 + for virtual machines. + :paramtype reserved_unit_count: float + """ super(ReservationRecommendationDetailsCalculatedSavingsProperties, self).__init__(**kwargs) self.on_demand_cost = None self.overage_cost = None @@ -3684,18 +4595,20 @@ class ReservationRecommendationDetailsModel(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param location: Resource Location. - :type location: str - :param sku: Resource sku. - :type sku: str + :ivar location: Resource Location. + :vartype location: str + :ivar sku: Resource sku. + :vartype sku: str :ivar currency: An ISO 4217 currency code identifier for the costs and savings. :vartype currency: str :ivar resource: Resource specific properties. @@ -3716,6 +4629,7 @@ class ReservationRecommendationDetailsModel(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'currency': {'readonly': True}, 'resource': {'readonly': True}, @@ -3729,6 +4643,7 @@ class ReservationRecommendationDetailsModel(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'str'}, @@ -3744,6 +4659,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Resource Location. + :paramtype location: str + :keyword sku: Resource sku. + :paramtype sku: str + """ super(ReservationRecommendationDetailsModel, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.sku = kwargs.get('sku', None) @@ -3796,6 +4717,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationRecommendationDetailsResourceProperties, self).__init__(**kwargs) self.applied_scopes = None self.on_demand_rate = None @@ -3810,8 +4733,8 @@ class ReservationRecommendationDetailsSavingsProperties(msrest.serialization.Mod Variables are only populated by the server, and will be ignored when sending a request. - :param calculated_savings: List of calculated savings. - :type calculated_savings: + :ivar calculated_savings: List of calculated savings. + :vartype calculated_savings: list[~azure.mgmt.consumption.models.ReservationRecommendationDetailsCalculatedSavingsProperties] :ivar look_back_period: Number of days of usage to look back used for computing the recommendation. @@ -3847,6 +4770,11 @@ def __init__( self, **kwargs ): + """ + :keyword calculated_savings: List of calculated savings. + :paramtype calculated_savings: + list[~azure.mgmt.consumption.models.ReservationRecommendationDetailsCalculatedSavingsProperties] + """ super(ReservationRecommendationDetailsSavingsProperties, self).__init__(**kwargs) self.calculated_savings = kwargs.get('calculated_savings', None) self.look_back_period = None @@ -3896,6 +4824,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationRecommendationDetailsUsageProperties, self).__init__(**kwargs) self.first_consumption_date = None self.last_consumption_date = None @@ -3913,25 +4843,32 @@ class ReservationRecommendationsListResult(msrest.serialization.Model): :vartype value: list[~azure.mgmt.consumption.models.ReservationRecommendation] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str + :ivar previous_link: The link (url) to the previous page of results. + :vartype previous_link: str """ _validation = { 'value': {'readonly': True}, 'next_link': {'readonly': True}, + 'previous_link': {'readonly': True}, } _attribute_map = { 'value': {'key': 'value', 'type': '[ReservationRecommendation]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'previous_link': {'key': 'previousLink', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(ReservationRecommendationsListResult, self).__init__(**kwargs) self.value = None self.next_link = None + self.previous_link = None class ReservationSummariesListResult(msrest.serialization.Model): @@ -3959,6 +4896,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationSummariesListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3969,12 +4908,14 @@ class ReservationSummary(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar reservation_order_id: The reservation order ID is the identifier for a reservation @@ -4027,6 +4968,7 @@ class ReservationSummary(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'reservation_order_id': {'readonly': True}, 'reservation_id': {'readonly': True}, @@ -4049,6 +4991,7 @@ class ReservationSummary(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'reservation_order_id': {'key': 'properties.reservationOrderId', 'type': 'str'}, 'reservation_id': {'key': 'properties.reservationId', 'type': 'str'}, @@ -4071,6 +5014,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationSummary, self).__init__(**kwargs) self.reservation_order_id = None self.reservation_id = None @@ -4114,6 +5059,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationTransactionsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -4144,6 +5091,8 @@ def __init__( self, **kwargs ): + """ + """ super(SkuProperty, self).__init__(**kwargs) self.name = None self.value = None @@ -4152,20 +5101,30 @@ def __init__( class Tag(msrest.serialization.Model): """The tag resource. - :param key: Tag key. - :type key: str + :ivar key: Tag key. + :vartype key: str + :ivar value: Tag values. + :vartype value: list[str] """ _attribute_map = { 'key': {'key': 'key', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[str]'}, } def __init__( self, **kwargs ): + """ + :keyword key: Tag key. + :paramtype key: str + :keyword value: Tag values. + :paramtype value: list[str] + """ super(Tag, self).__init__(**kwargs) self.key = kwargs.get('key', None) + self.value = kwargs.get('value', None) class TagsResult(ProxyResource): @@ -4179,17 +5138,23 @@ class TagsResult(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. - :type e_tag: str - :param tags: A set of tags. A list of Tag. - :type tags: list[~azure.mgmt.consumption.models.Tag] + :vartype e_tag: str + :ivar tags: A set of tags. A list of Tag. + :vartype tags: list[~azure.mgmt.consumption.models.Tag] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + :ivar previous_link: The link (url) to the previous page of results. + :vartype previous_link: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'next_link': {'readonly': True}, + 'previous_link': {'readonly': True}, } _attribute_map = { @@ -4198,14 +5163,25 @@ class TagsResult(ProxyResource): 'type': {'key': 'type', 'type': 'str'}, 'e_tag': {'key': 'eTag', 'type': 'str'}, 'tags': {'key': 'properties.tags', 'type': '[Tag]'}, + 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + 'previous_link': {'key': 'properties.previousLink', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + :keyword tags: A set of tags. A list of Tag. + :paramtype tags: list[~azure.mgmt.consumption.models.Tag] + """ super(TagsResult, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) + self.next_link = None + self.previous_link = None class UsageDetailsListResult(msrest.serialization.Model): @@ -4233,6 +5209,8 @@ def __init__( self, **kwargs ): + """ + """ super(UsageDetailsListResult, self).__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py index aacfd19b6a23..e5e45e6f8c92 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py @@ -40,22 +40,66 @@ def __init__( self, **kwargs ): + """ + """ super(Amount, self).__init__(**kwargs) self.currency = None self.value = None +class AmountWithExchangeRate(Amount): + """The amount with exchange rate. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar currency: Amount currency. + :vartype currency: str + :ivar value: Amount. + :vartype value: float + :ivar exchange_rate: The exchange rate. + :vartype exchange_rate: float + :ivar exchange_rate_month: The exchange rate month. + :vartype exchange_rate_month: int + """ + + _validation = { + 'currency': {'readonly': True}, + 'value': {'readonly': True}, + 'exchange_rate': {'readonly': True}, + 'exchange_rate_month': {'readonly': True}, + } + + _attribute_map = { + 'currency': {'key': 'currency', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'float'}, + 'exchange_rate': {'key': 'exchangeRate', 'type': 'float'}, + 'exchange_rate_month': {'key': 'exchangeRateMonth', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AmountWithExchangeRate, self).__init__(**kwargs) + self.exchange_rate = None + self.exchange_rate_month = None + + class Resource(msrest.serialization.Model): """The Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] """ @@ -64,6 +108,7 @@ class Resource(msrest.serialization.Model): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, } @@ -71,6 +116,7 @@ class Resource(msrest.serialization.Model): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, } @@ -78,10 +124,13 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None + self.etag = None self.tags = None @@ -90,12 +139,14 @@ class Balance(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar currency: The ISO currency in which the meter is charged, for example, USD. @@ -121,9 +172,9 @@ class Balance(Resource): :vartype total_usage: float :ivar azure_marketplace_service_charges: Total charges for Azure Marketplace. :vartype azure_marketplace_service_charges: float - :param billing_frequency: The billing frequency. Possible values include: "Month", "Quarter", + :ivar billing_frequency: The billing frequency. Possible values include: "Month", "Quarter", "Year". - :type billing_frequency: str or ~azure.mgmt.consumption.models.BillingFrequency + :vartype billing_frequency: str or ~azure.mgmt.consumption.models.BillingFrequency :ivar price_hidden: Price is hidden or not. :vartype price_hidden: bool :ivar new_purchases_details: List of new purchases. @@ -138,6 +189,7 @@ class Balance(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'currency': {'readonly': True}, 'beginning_balance': {'readonly': True}, @@ -159,6 +211,7 @@ class Balance(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'currency': {'key': 'properties.currency', 'type': 'str'}, 'beginning_balance': {'key': 'properties.beginningBalance', 'type': 'float'}, @@ -183,6 +236,11 @@ def __init__( billing_frequency: Optional[Union[str, "BillingFrequency"]] = None, **kwargs ): + """ + :keyword billing_frequency: The billing frequency. Possible values include: "Month", "Quarter", + "Year". + :paramtype billing_frequency: str or ~azure.mgmt.consumption.models.BillingFrequency + """ super(Balance, self).__init__(**kwargs) self.currency = None self.beginning_balance = None @@ -226,6 +284,8 @@ def __init__( self, **kwargs ): + """ + """ super(BalancePropertiesAdjustmentDetailsItem, self).__init__(**kwargs) self.name = None self.value = None @@ -256,6 +316,8 @@ def __init__( self, **kwargs ): + """ + """ super(BalancePropertiesNewPurchasesDetailsItem, self).__init__(**kwargs) self.name = None self.value = None @@ -272,9 +334,9 @@ class ProxyResource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :param e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. - :type e_tag: str + :vartype e_tag: str """ _validation = { @@ -296,6 +358,11 @@ def __init__( e_tag: Optional[str] = None, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -314,31 +381,33 @@ class Budget(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. - :type e_tag: str - :param category: The category of the budget, whether the budget tracks cost or usage. Possible + :vartype e_tag: str + :ivar category: The category of the budget, whether the budget tracks cost or usage. Possible values include: "Cost". - :type category: str or ~azure.mgmt.consumption.models.CategoryType - :param amount: The total amount of cost to track with the budget. - :type amount: float - :param time_grain: The time covered by a budget. Tracking of the amount will be reset based on + :vartype category: str or ~azure.mgmt.consumption.models.CategoryType + :ivar amount: The total amount of cost to track with the budget. + :vartype amount: float + :ivar time_grain: The time covered by a budget. Tracking of the amount will be reset based on the time grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD customers. Possible values include: "Monthly", "Quarterly", "Annually", "BillingMonth", "BillingQuarter", "BillingAnnual". - :type time_grain: str or ~azure.mgmt.consumption.models.TimeGrainType - :param time_period: Has start and end date of the budget. The start date must be first of the + :vartype time_grain: str or ~azure.mgmt.consumption.models.TimeGrainType + :ivar time_period: Has start and end date of the budget. The start date must be first of the month and should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should not be more than twelve months. Past start date should be selected within the timegrain period. There are no restrictions on the end date. - :type time_period: ~azure.mgmt.consumption.models.BudgetTimePeriod - :param filter: May be used to filter budgets by resource group, resource, or meter. - :type filter: ~azure.mgmt.consumption.models.BudgetFilter + :vartype time_period: ~azure.mgmt.consumption.models.BudgetTimePeriod + :ivar filter: May be used to filter budgets by user-specified dimensions and/or tags. + :vartype filter: ~azure.mgmt.consumption.models.BudgetFilter :ivar current_spend: The current amount of cost which is being tracked for a budget. :vartype current_spend: ~azure.mgmt.consumption.models.CurrentSpend - :param notifications: Dictionary of notifications associated with the budget. Budget can have - up to five notifications. - :type notifications: dict[str, ~azure.mgmt.consumption.models.Notification] + :ivar notifications: Dictionary of notifications associated with the budget. Budget can have up + to five notifications. + :vartype notifications: dict[str, ~azure.mgmt.consumption.models.Notification] + :ivar forecast_spend: The forecasted cost which is being tracked for a budget. + :vartype forecast_spend: ~azure.mgmt.consumption.models.ForecastSpend """ _validation = { @@ -346,6 +415,7 @@ class Budget(ProxyResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'current_spend': {'readonly': True}, + 'forecast_spend': {'readonly': True}, } _attribute_map = { @@ -360,6 +430,7 @@ class Budget(ProxyResource): 'filter': {'key': 'properties.filter', 'type': 'BudgetFilter'}, 'current_spend': {'key': 'properties.currentSpend', 'type': 'CurrentSpend'}, 'notifications': {'key': 'properties.notifications', 'type': '{Notification}'}, + 'forecast_spend': {'key': 'properties.forecastSpend', 'type': 'ForecastSpend'}, } def __init__( @@ -374,6 +445,31 @@ def __init__( notifications: Optional[Dict[str, "Notification"]] = None, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + :keyword category: The category of the budget, whether the budget tracks cost or usage. + Possible values include: "Cost". + :paramtype category: str or ~azure.mgmt.consumption.models.CategoryType + :keyword amount: The total amount of cost to track with the budget. + :paramtype amount: float + :keyword time_grain: The time covered by a budget. Tracking of the amount will be reset based + on the time grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD + customers. Possible values include: "Monthly", "Quarterly", "Annually", "BillingMonth", + "BillingQuarter", "BillingAnnual". + :paramtype time_grain: str or ~azure.mgmt.consumption.models.TimeGrainType + :keyword time_period: Has start and end date of the budget. The start date must be first of the + month and should be less than the end date. Budget start date must be on or after June 1, 2017. + Future start date should not be more than twelve months. Past start date should be selected + within the timegrain period. There are no restrictions on the end date. + :paramtype time_period: ~azure.mgmt.consumption.models.BudgetTimePeriod + :keyword filter: May be used to filter budgets by user-specified dimensions and/or tags. + :paramtype filter: ~azure.mgmt.consumption.models.BudgetFilter + :keyword notifications: Dictionary of notifications associated with the budget. Budget can have + up to five notifications. + :paramtype notifications: dict[str, ~azure.mgmt.consumption.models.Notification] + """ super(Budget, self).__init__(e_tag=e_tag, **kwargs) self.category = category self.amount = amount @@ -382,6 +478,7 @@ def __init__( self.filter = filter self.current_spend = None self.notifications = notifications + self.forecast_spend = None class BudgetComparisonExpression(msrest.serialization.Model): @@ -389,18 +486,18 @@ class BudgetComparisonExpression(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the column to use in comparison. - :type name: str - :param operator: Required. The operator to use for comparison. Possible values include: "In". - :type operator: str or ~azure.mgmt.consumption.models.BudgetOperatorType - :param values: Required. Array of values to use for comparison. - :type values: list[str] + :ivar name: Required. The name of the column to use in comparison. + :vartype name: str + :ivar operator: Required. The operator to use for comparison. Possible values include: "In". + :vartype operator: str or ~azure.mgmt.consumption.models.BudgetOperatorType + :ivar values: Required. Array of values to use for comparison. + :vartype values: list[str] """ _validation = { 'name': {'required': True}, 'operator': {'required': True}, - 'values': {'required': True, 'min_items': 1}, + 'values': {'required': True}, } _attribute_map = { @@ -417,6 +514,14 @@ def __init__( values: List[str], **kwargs ): + """ + :keyword name: Required. The name of the column to use in comparison. + :paramtype name: str + :keyword operator: Required. The operator to use for comparison. Possible values include: "In". + :paramtype operator: str or ~azure.mgmt.consumption.models.BudgetOperatorType + :keyword values: Required. Array of values to use for comparison. + :paramtype values: list[str] + """ super(BudgetComparisonExpression, self).__init__(**kwargs) self.name = name self.operator = operator @@ -426,20 +531,16 @@ def __init__( class BudgetFilter(msrest.serialization.Model): """May be used to filter budgets by resource group, resource, or meter. - :param and_property: The logical "AND" expression. Must have at least 2 items. - :type and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] - :param not_property: The logical "NOT" expression. - :type not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :ivar and_property: The logical "AND" expression. Must have at least 2 items. + :vartype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] + :ivar not_property: The logical "NOT" expression. + :vartype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties + :ivar dimensions: Has comparison expression for a dimension. + :vartype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :ivar tags: A set of tags. Has comparison expression for a tag. + :vartype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression """ - _validation = { - 'and_property': {'min_items': 2}, - } - _attribute_map = { 'and_property': {'key': 'and', 'type': '[BudgetFilterProperties]'}, 'not_property': {'key': 'not', 'type': 'BudgetFilterProperties'}, @@ -456,6 +557,16 @@ def __init__( tags: Optional["BudgetComparisonExpression"] = None, **kwargs ): + """ + :keyword and_property: The logical "AND" expression. Must have at least 2 items. + :paramtype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] + :keyword not_property: The logical "NOT" expression. + :paramtype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties + :keyword dimensions: Has comparison expression for a dimension. + :paramtype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :keyword tags: A set of tags. Has comparison expression for a tag. + :paramtype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression + """ super(BudgetFilter, self).__init__(**kwargs) self.and_property = and_property self.not_property = not_property @@ -466,10 +577,10 @@ def __init__( class BudgetFilterProperties(msrest.serialization.Model): """The Dimensions or Tags to filter a budget by. - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :ivar dimensions: Has comparison expression for a dimension. + :vartype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :ivar tags: A set of tags. Has comparison expression for a tag. + :vartype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression """ _attribute_map = { @@ -484,6 +595,12 @@ def __init__( tags: Optional["BudgetComparisonExpression"] = None, **kwargs ): + """ + :keyword dimensions: Has comparison expression for a dimension. + :paramtype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression + :keyword tags: A set of tags. Has comparison expression for a tag. + :paramtype tags: ~azure.mgmt.consumption.models.BudgetComparisonExpression + """ super(BudgetFilterProperties, self).__init__(**kwargs) self.dimensions = dimensions self.tags = tags @@ -514,6 +631,8 @@ def __init__( self, **kwargs ): + """ + """ super(BudgetsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -524,11 +643,11 @@ class BudgetTimePeriod(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param start_date: Required. The start date for the budget. - :type start_date: ~datetime.datetime - :param end_date: The end date for the budget. If not provided, we default this to 10 years from + :ivar start_date: Required. The start date for the budget. + :vartype start_date: ~datetime.datetime + :ivar end_date: The end date for the budget. If not provided, we default this to 10 years from the start date. - :type end_date: ~datetime.datetime + :vartype end_date: ~datetime.datetime """ _validation = { @@ -547,6 +666,13 @@ def __init__( end_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword start_date: Required. The start date for the budget. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The end date for the budget. If not provided, we default this to 10 years + from the start date. + :paramtype end_date: ~datetime.datetime + """ super(BudgetTimePeriod, self).__init__(**kwargs) self.start_date = start_date self.end_date = end_date @@ -573,11 +699,13 @@ def __init__( self, **kwargs ): + """ + """ super(ChargesListResult, self).__init__(**kwargs) self.value = None -class ChargeSummary(Resource): +class ChargeSummary(ProxyResource): """A charge summary resource. You probably want to use the sub-classes and not this class directly. Known @@ -593,18 +721,18 @@ class ChargeSummary(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of charge summary.Constant filled by server. - Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar kind: Required. Specifies the kind of charge summary.Constant filled by server. Possible + values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'kind': {'required': True}, } @@ -612,7 +740,7 @@ class ChargeSummary(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'kind': {'key': 'kind', 'type': 'str'}, } @@ -622,9 +750,16 @@ class ChargeSummary(Resource): def __init__( self, + *, + e_tag: Optional[str] = None, **kwargs ): - super(ChargeSummary, self).__init__(**kwargs) + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ + super(ChargeSummary, self).__init__(e_tag=e_tag, **kwargs) self.kind = 'ChargeSummary' # type: str @@ -637,25 +772,33 @@ class CreditBalanceSummary(msrest.serialization.Model): :vartype estimated_balance: ~azure.mgmt.consumption.models.Amount :ivar current_balance: Current balance. :vartype current_balance: ~azure.mgmt.consumption.models.Amount + :ivar estimated_balance_in_billing_currency: Estimated balance in billing currency. + :vartype estimated_balance_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate """ _validation = { 'estimated_balance': {'readonly': True}, 'current_balance': {'readonly': True}, + 'estimated_balance_in_billing_currency': {'readonly': True}, } _attribute_map = { 'estimated_balance': {'key': 'estimatedBalance', 'type': 'Amount'}, 'current_balance': {'key': 'currentBalance', 'type': 'Amount'}, + 'estimated_balance_in_billing_currency': {'key': 'estimatedBalanceInBillingCurrency', 'type': 'AmountWithExchangeRate'}, } def __init__( self, **kwargs ): + """ + """ super(CreditBalanceSummary, self).__init__(**kwargs) self.estimated_balance = None self.current_balance = None + self.estimated_balance_in_billing_currency = None class CreditSummary(Resource): @@ -663,12 +806,14 @@ class CreditSummary(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar balance_summary: Summary of balances associated with this credit summary. @@ -679,39 +824,63 @@ class CreditSummary(Resource): :vartype expired_credit: ~azure.mgmt.consumption.models.Amount :ivar pending_eligible_charges: Pending eligible charges. :vartype pending_eligible_charges: ~azure.mgmt.consumption.models.Amount + :ivar credit_currency: The credit currency. + :vartype credit_currency: str + :ivar billing_currency: The billing currency. + :vartype billing_currency: str + :ivar reseller: Credit's reseller. + :vartype reseller: ~azure.mgmt.consumption.models.Reseller + :ivar e_tag: The eTag for the resource. + :vartype e_tag: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'balance_summary': {'readonly': True}, 'pending_credit_adjustments': {'readonly': True}, 'expired_credit': {'readonly': True}, 'pending_eligible_charges': {'readonly': True}, + 'credit_currency': {'readonly': True}, + 'billing_currency': {'readonly': True}, + 'reseller': {'readonly': True}, + 'e_tag': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'balance_summary': {'key': 'properties.balanceSummary', 'type': 'CreditBalanceSummary'}, 'pending_credit_adjustments': {'key': 'properties.pendingCreditAdjustments', 'type': 'Amount'}, 'expired_credit': {'key': 'properties.expiredCredit', 'type': 'Amount'}, 'pending_eligible_charges': {'key': 'properties.pendingEligibleCharges', 'type': 'Amount'}, + 'credit_currency': {'key': 'properties.creditCurrency', 'type': 'str'}, + 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + 'e_tag': {'key': 'properties.eTag', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(CreditSummary, self).__init__(**kwargs) self.balance_summary = None self.pending_credit_adjustments = None self.expired_credit = None self.pending_eligible_charges = None + self.credit_currency = None + self.billing_currency = None + self.reseller = None + self.e_tag = None class CurrentSpend(msrest.serialization.Model): @@ -739,11 +908,45 @@ def __init__( self, **kwargs ): + """ + """ super(CurrentSpend, self).__init__(**kwargs) self.amount = None self.unit = None +class DownloadProperties(msrest.serialization.Model): + """The properties of the price sheet download. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar download_url: The link (url) to download the pricesheet. + :vartype download_url: str + :ivar valid_till: Download link validity. + :vartype valid_till: str + """ + + _validation = { + 'download_url': {'readonly': True}, + 'valid_till': {'readonly': True}, + } + + _attribute_map = { + 'download_url': {'key': 'downloadUrl', 'type': 'str'}, + 'valid_till': {'key': 'validTill', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(DownloadProperties, self).__init__(**kwargs) + self.download_url = None + self.valid_till = None + + class ErrorDetails(msrest.serialization.Model): """The details of the error. @@ -769,6 +972,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -786,8 +991,8 @@ class ErrorResponse(msrest.serialization.Model): * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header. - :param error: The details of the error. - :type error: ~azure.mgmt.consumption.models.ErrorDetails + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.consumption.models.ErrorDetails """ _attribute_map = { @@ -800,6 +1005,10 @@ def __init__( error: Optional["ErrorDetails"] = None, **kwargs ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.consumption.models.ErrorDetails + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -829,12 +1038,14 @@ def __init__( self, **kwargs ): + """ + """ super(Events, self).__init__(**kwargs) self.value = None self.next_link = None -class EventSummary(Resource): +class EventSummary(ProxyResource): """An event summary resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -845,35 +1056,76 @@ class EventSummary(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :ivar transaction_date: Transaction date. + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar transaction_date: The date of the event. :vartype transaction_date: ~datetime.datetime - :ivar description: Transaction description. + :ivar description: The description of the event. :vartype description: str - :ivar new_credit: New Credit. + :ivar new_credit: The amount of new credit or commitment for NewCredit or SettleCharges event. :vartype new_credit: ~azure.mgmt.consumption.models.Amount - :ivar adjustments: Adjustments amount. + :ivar adjustments: The amount of balance adjustment. The property is not available for + ConsumptionCommitment lots. :vartype adjustments: ~azure.mgmt.consumption.models.Amount - :ivar credit_expired: Credit expired. + :ivar credit_expired: The amount of expired credit or commitment for NewCredit or SettleCharges + event. :vartype credit_expired: ~azure.mgmt.consumption.models.Amount - :ivar charges: Charges amount. + :ivar charges: The amount of charges for events of type SettleCharges and + PendingEligibleCharges. :vartype charges: ~azure.mgmt.consumption.models.Amount - :ivar closed_balance: Closed balance. + :ivar closed_balance: The balance after the event. :vartype closed_balance: ~azure.mgmt.consumption.models.Amount - :param event_type: The type of event. Possible values include: "SettledCharges", + :ivar event_type: Identifies the type of the event. Possible values include: "SettledCharges", "PendingCharges", "PendingAdjustments", "PendingNewCredit", "PendingExpiredCredit", "UnKnown", "NewCredit". - :type event_type: str or ~azure.mgmt.consumption.models.EventType - :ivar invoice_number: Invoice number. + :vartype event_type: str or ~azure.mgmt.consumption.models.EventType + :ivar invoice_number: The number which uniquely identifies the invoice on which the event was + billed. This will be empty for unbilled events. :vartype invoice_number: str + :ivar billing_profile_id: The ID that uniquely identifies the billing profile for which the + event happened. The property is only available for billing account of type + MicrosoftCustomerAgreement. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The display name of the billing profile for which the event + happened. The property is only available for billing account of type + MicrosoftCustomerAgreement. + :vartype billing_profile_display_name: str + :ivar lot_id: The ID that uniquely identifies the lot for which the event happened. + :vartype lot_id: str + :ivar lot_source: Identifies the source of the lot for which the event happened. + :vartype lot_source: str + :ivar canceled_credit: Amount of canceled credit. + :vartype canceled_credit: ~azure.mgmt.consumption.models.Amount + :ivar credit_currency: The credit currency of the event. + :vartype credit_currency: str + :ivar billing_currency: The billing currency of the event. + :vartype billing_currency: str + :ivar reseller: The reseller of the event. + :vartype reseller: ~azure.mgmt.consumption.models.Reseller + :ivar credit_expired_in_billing_currency: The amount of expired credit or commitment for + NewCredit or SettleCharges event in billing currency. + :vartype credit_expired_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar new_credit_in_billing_currency: The amount of new credit or commitment for NewCredit or + SettleCharges event in billing currency. + :vartype new_credit_in_billing_currency: ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar adjustments_in_billing_currency: The amount of balance adjustment in billing currency. + :vartype adjustments_in_billing_currency: ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar charges_in_billing_currency: The amount of charges for events of type SettleCharges and + PendingEligibleCharges in billing currency. + :vartype charges_in_billing_currency: ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar closed_balance_in_billing_currency: The balance in billing currency after the event. + :vartype closed_balance_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar e_tag_properties_e_tag: The eTag for the resource. + :vartype e_tag_properties_e_tag: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'transaction_date': {'readonly': True}, 'description': {'readonly': True}, 'new_credit': {'readonly': True}, @@ -882,13 +1134,27 @@ class EventSummary(Resource): 'charges': {'readonly': True}, 'closed_balance': {'readonly': True}, 'invoice_number': {'readonly': True}, + 'billing_profile_id': {'readonly': True}, + 'billing_profile_display_name': {'readonly': True}, + 'lot_id': {'readonly': True}, + 'lot_source': {'readonly': True}, + 'canceled_credit': {'readonly': True}, + 'credit_currency': {'readonly': True}, + 'billing_currency': {'readonly': True}, + 'reseller': {'readonly': True}, + 'credit_expired_in_billing_currency': {'readonly': True}, + 'new_credit_in_billing_currency': {'readonly': True}, + 'adjustments_in_billing_currency': {'readonly': True}, + 'charges_in_billing_currency': {'readonly': True}, + 'closed_balance_in_billing_currency': {'readonly': True}, + 'e_tag_properties_e_tag': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'transaction_date': {'key': 'properties.transactionDate', 'type': 'iso-8601'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'new_credit': {'key': 'properties.newCredit', 'type': 'Amount'}, @@ -898,15 +1164,39 @@ class EventSummary(Resource): 'closed_balance': {'key': 'properties.closedBalance', 'type': 'Amount'}, 'event_type': {'key': 'properties.eventType', 'type': 'str'}, 'invoice_number': {'key': 'properties.invoiceNumber', 'type': 'str'}, + 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, + 'lot_id': {'key': 'properties.lotId', 'type': 'str'}, + 'lot_source': {'key': 'properties.lotSource', 'type': 'str'}, + 'canceled_credit': {'key': 'properties.canceledCredit', 'type': 'Amount'}, + 'credit_currency': {'key': 'properties.creditCurrency', 'type': 'str'}, + 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + 'credit_expired_in_billing_currency': {'key': 'properties.creditExpiredInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'new_credit_in_billing_currency': {'key': 'properties.newCreditInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'adjustments_in_billing_currency': {'key': 'properties.adjustmentsInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'charges_in_billing_currency': {'key': 'properties.chargesInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'closed_balance_in_billing_currency': {'key': 'properties.closedBalanceInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'e_tag_properties_e_tag': {'key': 'properties.eTag', 'type': 'str'}, } def __init__( self, *, + e_tag: Optional[str] = None, event_type: Optional[Union[str, "EventType"]] = None, **kwargs ): - super(EventSummary, self).__init__(**kwargs) + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + :keyword event_type: Identifies the type of the event. Possible values include: + "SettledCharges", "PendingCharges", "PendingAdjustments", "PendingNewCredit", + "PendingExpiredCredit", "UnKnown", "NewCredit". + :paramtype event_type: str or ~azure.mgmt.consumption.models.EventType + """ + super(EventSummary, self).__init__(e_tag=e_tag, **kwargs) self.transaction_date = None self.description = None self.new_credit = None @@ -916,139 +1206,119 @@ def __init__( self.closed_balance = None self.event_type = event_type self.invoice_number = None + self.billing_profile_id = None + self.billing_profile_display_name = None + self.lot_id = None + self.lot_source = None + self.canceled_credit = None + self.credit_currency = None + self.billing_currency = None + self.reseller = None + self.credit_expired_in_billing_currency = None + self.new_credit_in_billing_currency = None + self.adjustments_in_billing_currency = None + self.charges_in_billing_currency = None + self.closed_balance_in_billing_currency = None + self.e_tag_properties_e_tag = None -class Forecast(Resource): - """A forecast resource. +class ForecastSpend(msrest.serialization.Model): + """The forecasted cost which is being tracked for a budget. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :ivar usage_date: The usage date of the forecast. - :vartype usage_date: str - :param grain: The granularity of forecast. Possible values include: "Daily", "Monthly", - "Yearly". - :type grain: str or ~azure.mgmt.consumption.models.Grain - :ivar charge: The amount of charge. - :vartype charge: float - :ivar currency: The ISO currency in which the meter is charged, for example, USD. - :vartype currency: str - :param charge_type: The type of the charge. Could be actual or forecast. Possible values - include: "Actual", "Forecast". - :type charge_type: str or ~azure.mgmt.consumption.models.ChargeType - :ivar confidence_levels: The details about the forecast confidence levels. This is populated - only when chargeType is Forecast. - :vartype confidence_levels: - list[~azure.mgmt.consumption.models.ForecastPropertiesConfidenceLevelsItem] + :ivar amount: The forecasted cost for the total time period which is being tracked by the + budget. This value is only provided if the budget contains a forecast alert type. + :vartype amount: float + :ivar unit: The unit of measure for the budget amount. + :vartype unit: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'tags': {'readonly': True}, - 'usage_date': {'readonly': True}, - 'charge': {'readonly': True}, - 'currency': {'readonly': True}, - 'confidence_levels': {'readonly': True}, + 'amount': {'readonly': True}, + 'unit': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'usage_date': {'key': 'properties.usageDate', 'type': 'str'}, - 'grain': {'key': 'properties.grain', 'type': 'str'}, - 'charge': {'key': 'properties.charge', 'type': 'float'}, - 'currency': {'key': 'properties.currency', 'type': 'str'}, - 'charge_type': {'key': 'properties.chargeType', 'type': 'str'}, - 'confidence_levels': {'key': 'properties.confidenceLevels', 'type': '[ForecastPropertiesConfidenceLevelsItem]'}, + 'amount': {'key': 'amount', 'type': 'float'}, + 'unit': {'key': 'unit', 'type': 'str'}, } def __init__( self, - *, - grain: Optional[Union[str, "Grain"]] = None, - charge_type: Optional[Union[str, "ChargeType"]] = None, **kwargs ): - super(Forecast, self).__init__(**kwargs) - self.usage_date = None - self.grain = grain - self.charge = None - self.currency = None - self.charge_type = charge_type - self.confidence_levels = None + """ + """ + super(ForecastSpend, self).__init__(**kwargs) + self.amount = None + self.unit = None -class ForecastPropertiesConfidenceLevelsItem(msrest.serialization.Model): - """ForecastPropertiesConfidenceLevelsItem. +class HighCasedErrorDetails(msrest.serialization.Model): + """The details of the error. Variables are only populated by the server, and will be ignored when sending a request. - :ivar percentage: The percentage level of the confidence. - :vartype percentage: float - :param bound: The boundary of the percentage, values could be 'Upper' or 'Lower'. Possible - values include: "Upper", "Lower". - :type bound: str or ~azure.mgmt.consumption.models.Bound - :ivar value: The amount of forecast within the percentage level. - :vartype value: float + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _validation = { - 'percentage': {'readonly': True}, - 'value': {'readonly': True}, + 'code': {'readonly': True}, + 'message': {'readonly': True}, } _attribute_map = { - 'percentage': {'key': 'percentage', 'type': 'float'}, - 'bound': {'key': 'bound', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, } def __init__( self, - *, - bound: Optional[Union[str, "Bound"]] = None, **kwargs ): - super(ForecastPropertiesConfidenceLevelsItem, self).__init__(**kwargs) - self.percentage = None - self.bound = bound - self.value = None + """ + """ + super(HighCasedErrorDetails, self).__init__(**kwargs) + self.code = None + self.message = None + +class HighCasedErrorResponse(msrest.serialization.Model): + """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. -class ForecastsListResult(msrest.serialization.Model): - """Result of listing forecasts. It contains a list of available forecasts. +Some Error responses: - Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of forecasts. - :vartype value: list[~azure.mgmt.consumption.models.Forecast] - """ +* + 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" header. - _validation = { - 'value': {'readonly': True}, - } +* + 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header. + + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.consumption.models.HighCasedErrorDetails + """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Forecast]'}, + 'error': {'key': 'error', 'type': 'HighCasedErrorDetails'}, } def __init__( self, + *, + error: Optional["HighCasedErrorDetails"] = None, **kwargs ): - super(ForecastsListResult, self).__init__(**kwargs) - self.value = None + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.consumption.models.HighCasedErrorDetails + """ + super(HighCasedErrorResponse, self).__init__(**kwargs) + self.error = error class LegacyChargeSummary(ChargeSummary): @@ -1064,11 +1334,12 @@ class LegacyChargeSummary(ChargeSummary): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of charge summary.Constant filled by server. - Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar kind: Required. Specifies the kind of charge summary.Constant filled by server. Possible + values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind :ivar billing_period_id: The id of the billing period resource that the charge belongs to. :vartype billing_period_id: str :ivar usage_start: Usage start date. @@ -1089,7 +1360,6 @@ class LegacyChargeSummary(ChargeSummary): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'kind': {'required': True}, 'billing_period_id': {'readonly': True}, 'usage_start': {'readonly': True}, @@ -1104,7 +1374,7 @@ class LegacyChargeSummary(ChargeSummary): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'kind': {'key': 'kind', 'type': 'str'}, 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, 'usage_start': {'key': 'properties.usageStart', 'type': 'str'}, @@ -1117,9 +1387,16 @@ class LegacyChargeSummary(ChargeSummary): def __init__( self, + *, + e_tag: Optional[str] = None, **kwargs ): - super(LegacyChargeSummary, self).__init__(**kwargs) + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ + super(LegacyChargeSummary, self).__init__(e_tag=e_tag, **kwargs) self.kind = 'legacy' # type: str self.billing_period_id = None self.usage_start = None @@ -1155,6 +1432,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceAttributes, self).__init__(**kwargs) self.location = None self.sku = None @@ -1174,17 +1453,19 @@ class ReservationRecommendation(Resource, ResourceAttributes): :vartype location: str :ivar sku: Resource sku. :vartype sku: str - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of reservation recommendation.Constant filled by - server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind + :ivar kind: Required. Specifies the kind of reservation recommendation.Constant filled by + server. Possible values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind """ _validation = { @@ -1193,6 +1474,7 @@ class ReservationRecommendation(Resource, ResourceAttributes): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, } @@ -1203,6 +1485,7 @@ class ReservationRecommendation(Resource, ResourceAttributes): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, } @@ -1215,6 +1498,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationRecommendation, self).__init__(**kwargs) self.location = None self.sku = None @@ -1222,6 +1507,7 @@ def __init__( self.id = None self.name = None self.type = None + self.etag = None self.tags = None self.kind = 'ReservationRecommendation' # type: str @@ -1237,21 +1523,23 @@ class LegacyReservationRecommendation(ReservationRecommendation): :vartype location: str :ivar sku: Resource sku. :vartype sku: str - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of reservation recommendation.Constant filled by - server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind + :ivar kind: Required. Specifies the kind of reservation recommendation.Constant filled by + server. Possible values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind :ivar look_back_period: The number of days of usage to look back for recommendation. :vartype look_back_period: str :ivar instance_flexibility_ratio: The instance Flexibility Ratio. - :vartype instance_flexibility_ratio: int + :vartype instance_flexibility_ratio: float :ivar instance_flexibility_group: The instance Flexibility Group. :vartype instance_flexibility_group: str :ivar normalized_size: The normalized Size. @@ -1260,6 +1548,8 @@ class LegacyReservationRecommendation(ReservationRecommendation): :vartype recommended_quantity_normalized: float :ivar meter_id: The meter id (GUID). :vartype meter_id: str + :ivar resource_type: The azure resource type. + :vartype resource_type: str :ivar term: RI recommendations in one or three year terms. :vartype term: str :ivar cost_with_no_reserved_instances: The total amount of cost without reserved instances. @@ -1272,7 +1562,7 @@ class LegacyReservationRecommendation(ReservationRecommendation): :vartype net_savings: float :ivar first_usage_date: The usage date for looking back. :vartype first_usage_date: ~datetime.datetime - :ivar scope: Shared or single recommendation. + :ivar scope: Required. Shared or single recommendation.Constant filled by server. :vartype scope: str :ivar sku_properties: List of sku properties. :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] @@ -1284,6 +1574,7 @@ class LegacyReservationRecommendation(ReservationRecommendation): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, 'look_back_period': {'readonly': True}, @@ -1292,13 +1583,14 @@ class LegacyReservationRecommendation(ReservationRecommendation): 'normalized_size': {'readonly': True}, 'recommended_quantity_normalized': {'readonly': True}, 'meter_id': {'readonly': True}, + 'resource_type': {'readonly': True}, 'term': {'readonly': True}, 'cost_with_no_reserved_instances': {'readonly': True}, 'recommended_quantity': {'readonly': True}, 'total_cost_with_reserved_instances': {'readonly': True}, 'net_savings': {'readonly': True}, 'first_usage_date': {'readonly': True}, - 'scope': {'readonly': True}, + 'scope': {'required': True}, 'sku_properties': {'readonly': True}, } @@ -1308,14 +1600,16 @@ class LegacyReservationRecommendation(ReservationRecommendation): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, 'look_back_period': {'key': 'properties.lookBackPeriod', 'type': 'str'}, - 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'int'}, + 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'float'}, 'instance_flexibility_group': {'key': 'properties.instanceFlexibilityGroup', 'type': 'str'}, 'normalized_size': {'key': 'properties.normalizedSize', 'type': 'str'}, 'recommended_quantity_normalized': {'key': 'properties.recommendedQuantityNormalized', 'type': 'float'}, 'meter_id': {'key': 'properties.meterId', 'type': 'str'}, + 'resource_type': {'key': 'properties.resourceType', 'type': 'str'}, 'term': {'key': 'properties.term', 'type': 'str'}, 'cost_with_no_reserved_instances': {'key': 'properties.costWithNoReservedInstances', 'type': 'float'}, 'recommended_quantity': {'key': 'properties.recommendedQuantity', 'type': 'float'}, @@ -1330,6 +1624,8 @@ def __init__( self, **kwargs ): + """ + """ super(LegacyReservationRecommendation, self).__init__(**kwargs) self.kind = 'legacy' # type: str self.look_back_period = None @@ -1338,13 +1634,120 @@ def __init__( self.normalized_size = None self.recommended_quantity_normalized = None self.meter_id = None + self.resource_type = None self.term = None self.cost_with_no_reserved_instances = None self.recommended_quantity = None self.total_cost_with_reserved_instances = None self.net_savings = None self.first_usage_date = None - self.scope = None + self.scope = 'legacy' # type: str + self.sku_properties = None + + +class LegacyReservationRecommendationProperties(msrest.serialization.Model): + """The properties of the reservation recommendation. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: LegacySharedScopeReservationRecommendationProperties, LegacySingleScopeReservationRecommendationProperties. + + 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 look_back_period: The number of days of usage to look back for recommendation. + :vartype look_back_period: str + :ivar instance_flexibility_ratio: The instance Flexibility Ratio. + :vartype instance_flexibility_ratio: float + :ivar instance_flexibility_group: The instance Flexibility Group. + :vartype instance_flexibility_group: str + :ivar normalized_size: The normalized Size. + :vartype normalized_size: str + :ivar recommended_quantity_normalized: The recommended Quantity Normalized. + :vartype recommended_quantity_normalized: float + :ivar meter_id: The meter id (GUID). + :vartype meter_id: str + :ivar resource_type: The azure resource type. + :vartype resource_type: str + :ivar term: RI recommendations in one or three year terms. + :vartype term: str + :ivar cost_with_no_reserved_instances: The total amount of cost without reserved instances. + :vartype cost_with_no_reserved_instances: float + :ivar recommended_quantity: Recommended quality for reserved instances. + :vartype recommended_quantity: float + :ivar total_cost_with_reserved_instances: The total amount of cost with reserved instances. + :vartype total_cost_with_reserved_instances: float + :ivar net_savings: Total estimated savings with reserved instances. + :vartype net_savings: float + :ivar first_usage_date: The usage date for looking back. + :vartype first_usage_date: ~datetime.datetime + :ivar scope: Required. Shared or single recommendation.Constant filled by server. + :vartype scope: str + :ivar sku_properties: List of sku properties. + :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] + """ + + _validation = { + 'look_back_period': {'readonly': True}, + 'instance_flexibility_ratio': {'readonly': True}, + 'instance_flexibility_group': {'readonly': True}, + 'normalized_size': {'readonly': True}, + 'recommended_quantity_normalized': {'readonly': True}, + 'meter_id': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'term': {'readonly': True}, + 'cost_with_no_reserved_instances': {'readonly': True}, + 'recommended_quantity': {'readonly': True}, + 'total_cost_with_reserved_instances': {'readonly': True}, + 'net_savings': {'readonly': True}, + 'first_usage_date': {'readonly': True}, + 'scope': {'required': True}, + 'sku_properties': {'readonly': True}, + } + + _attribute_map = { + 'look_back_period': {'key': 'lookBackPeriod', 'type': 'str'}, + 'instance_flexibility_ratio': {'key': 'instanceFlexibilityRatio', 'type': 'float'}, + 'instance_flexibility_group': {'key': 'instanceFlexibilityGroup', 'type': 'str'}, + 'normalized_size': {'key': 'normalizedSize', 'type': 'str'}, + 'recommended_quantity_normalized': {'key': 'recommendedQuantityNormalized', 'type': 'float'}, + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'term': {'key': 'term', 'type': 'str'}, + 'cost_with_no_reserved_instances': {'key': 'costWithNoReservedInstances', 'type': 'float'}, + 'recommended_quantity': {'key': 'recommendedQuantity', 'type': 'float'}, + 'total_cost_with_reserved_instances': {'key': 'totalCostWithReservedInstances', 'type': 'float'}, + 'net_savings': {'key': 'netSavings', 'type': 'float'}, + 'first_usage_date': {'key': 'firstUsageDate', 'type': 'iso-8601'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'sku_properties': {'key': 'skuProperties', 'type': '[SkuProperty]'}, + } + + _subtype_map = { + 'scope': {'Shared': 'LegacySharedScopeReservationRecommendationProperties', 'Single': 'LegacySingleScopeReservationRecommendationProperties'} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LegacyReservationRecommendationProperties, self).__init__(**kwargs) + self.look_back_period = None + self.instance_flexibility_ratio = None + self.instance_flexibility_group = None + self.normalized_size = None + self.recommended_quantity_normalized = None + self.meter_id = None + self.resource_type = None + self.term = None + self.cost_with_no_reserved_instances = None + self.recommended_quantity = None + self.total_cost_with_reserved_instances = None + self.net_savings = None + self.first_usage_date = None + self.scope = None # type: Optional[str] self.sku_properties = None @@ -1381,6 +1784,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationTransactionResource, self).__init__(**kwargs) self.id = None self.name = None @@ -1446,6 +1851,12 @@ class ReservationTransaction(ReservationTransactionResource): :vartype current_enrollment: str :ivar billing_frequency: The billing frequency, which can be either one-time or recurring. :vartype billing_frequency: str + :ivar billing_month: The billing month(yyyyMMdd), on which the event initiated. + :vartype billing_month: int + :ivar monetary_commitment: The monetary commitment amount at the enrollment scope. + :vartype monetary_commitment: float + :ivar overage: The overage amount at the enrollment scope. + :vartype overage: float """ _validation = { @@ -1473,6 +1884,9 @@ class ReservationTransaction(ReservationTransactionResource): 'cost_center': {'readonly': True}, 'current_enrollment': {'readonly': True}, 'billing_frequency': {'readonly': True}, + 'billing_month': {'readonly': True}, + 'monetary_commitment': {'readonly': True}, + 'overage': {'readonly': True}, } _attribute_map = { @@ -1500,12 +1914,17 @@ class ReservationTransaction(ReservationTransactionResource): 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, 'current_enrollment': {'key': 'properties.currentEnrollment', 'type': 'str'}, 'billing_frequency': {'key': 'properties.billingFrequency', 'type': 'str'}, + 'billing_month': {'key': 'properties.billingMonth', 'type': 'int'}, + 'monetary_commitment': {'key': 'properties.monetaryCommitment', 'type': 'float'}, + 'overage': {'key': 'properties.overage', 'type': 'float'}, } def __init__( self, **kwargs ): + """ + """ super(ReservationTransaction, self).__init__(**kwargs) self.event_date = None self.reservation_order_id = None @@ -1527,6 +1946,9 @@ def __init__( self.cost_center = None self.current_enrollment = None self.billing_frequency = None + self.billing_month = None + self.monetary_commitment = None + self.overage = None class LegacyReservationTransaction(ReservationTransaction): @@ -1587,6 +2009,12 @@ class LegacyReservationTransaction(ReservationTransaction): :vartype current_enrollment: str :ivar billing_frequency: The billing frequency, which can be either one-time or recurring. :vartype billing_frequency: str + :ivar billing_month: The billing month(yyyyMMdd), on which the event initiated. + :vartype billing_month: int + :ivar monetary_commitment: The monetary commitment amount at the enrollment scope. + :vartype monetary_commitment: float + :ivar overage: The overage amount at the enrollment scope. + :vartype overage: float """ _validation = { @@ -1614,6 +2042,9 @@ class LegacyReservationTransaction(ReservationTransaction): 'cost_center': {'readonly': True}, 'current_enrollment': {'readonly': True}, 'billing_frequency': {'readonly': True}, + 'billing_month': {'readonly': True}, + 'monetary_commitment': {'readonly': True}, + 'overage': {'readonly': True}, } _attribute_map = { @@ -1641,15 +2072,195 @@ class LegacyReservationTransaction(ReservationTransaction): 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, 'current_enrollment': {'key': 'properties.currentEnrollment', 'type': 'str'}, 'billing_frequency': {'key': 'properties.billingFrequency', 'type': 'str'}, + 'billing_month': {'key': 'properties.billingMonth', 'type': 'int'}, + 'monetary_commitment': {'key': 'properties.monetaryCommitment', 'type': 'float'}, + 'overage': {'key': 'properties.overage', 'type': 'float'}, } def __init__( self, **kwargs ): + """ + """ super(LegacyReservationTransaction, self).__init__(**kwargs) +class LegacySharedScopeReservationRecommendationProperties(LegacyReservationRecommendationProperties): + """The properties of the legacy reservation recommendation for shared scope. + + 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 look_back_period: The number of days of usage to look back for recommendation. + :vartype look_back_period: str + :ivar instance_flexibility_ratio: The instance Flexibility Ratio. + :vartype instance_flexibility_ratio: float + :ivar instance_flexibility_group: The instance Flexibility Group. + :vartype instance_flexibility_group: str + :ivar normalized_size: The normalized Size. + :vartype normalized_size: str + :ivar recommended_quantity_normalized: The recommended Quantity Normalized. + :vartype recommended_quantity_normalized: float + :ivar meter_id: The meter id (GUID). + :vartype meter_id: str + :ivar resource_type: The azure resource type. + :vartype resource_type: str + :ivar term: RI recommendations in one or three year terms. + :vartype term: str + :ivar cost_with_no_reserved_instances: The total amount of cost without reserved instances. + :vartype cost_with_no_reserved_instances: float + :ivar recommended_quantity: Recommended quality for reserved instances. + :vartype recommended_quantity: float + :ivar total_cost_with_reserved_instances: The total amount of cost with reserved instances. + :vartype total_cost_with_reserved_instances: float + :ivar net_savings: Total estimated savings with reserved instances. + :vartype net_savings: float + :ivar first_usage_date: The usage date for looking back. + :vartype first_usage_date: ~datetime.datetime + :ivar scope: Required. Shared or single recommendation.Constant filled by server. + :vartype scope: str + :ivar sku_properties: List of sku properties. + :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] + """ + + _validation = { + 'look_back_period': {'readonly': True}, + 'instance_flexibility_ratio': {'readonly': True}, + 'instance_flexibility_group': {'readonly': True}, + 'normalized_size': {'readonly': True}, + 'recommended_quantity_normalized': {'readonly': True}, + 'meter_id': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'term': {'readonly': True}, + 'cost_with_no_reserved_instances': {'readonly': True}, + 'recommended_quantity': {'readonly': True}, + 'total_cost_with_reserved_instances': {'readonly': True}, + 'net_savings': {'readonly': True}, + 'first_usage_date': {'readonly': True}, + 'scope': {'required': True}, + 'sku_properties': {'readonly': True}, + } + + _attribute_map = { + 'look_back_period': {'key': 'lookBackPeriod', 'type': 'str'}, + 'instance_flexibility_ratio': {'key': 'instanceFlexibilityRatio', 'type': 'float'}, + 'instance_flexibility_group': {'key': 'instanceFlexibilityGroup', 'type': 'str'}, + 'normalized_size': {'key': 'normalizedSize', 'type': 'str'}, + 'recommended_quantity_normalized': {'key': 'recommendedQuantityNormalized', 'type': 'float'}, + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'term': {'key': 'term', 'type': 'str'}, + 'cost_with_no_reserved_instances': {'key': 'costWithNoReservedInstances', 'type': 'float'}, + 'recommended_quantity': {'key': 'recommendedQuantity', 'type': 'float'}, + 'total_cost_with_reserved_instances': {'key': 'totalCostWithReservedInstances', 'type': 'float'}, + 'net_savings': {'key': 'netSavings', 'type': 'float'}, + 'first_usage_date': {'key': 'firstUsageDate', 'type': 'iso-8601'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'sku_properties': {'key': 'skuProperties', 'type': '[SkuProperty]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LegacySharedScopeReservationRecommendationProperties, self).__init__(**kwargs) + self.scope = 'Shared' # type: str + + +class LegacySingleScopeReservationRecommendationProperties(LegacyReservationRecommendationProperties): + """The properties of the legacy reservation recommendation for single scope. + + 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 look_back_period: The number of days of usage to look back for recommendation. + :vartype look_back_period: str + :ivar instance_flexibility_ratio: The instance Flexibility Ratio. + :vartype instance_flexibility_ratio: float + :ivar instance_flexibility_group: The instance Flexibility Group. + :vartype instance_flexibility_group: str + :ivar normalized_size: The normalized Size. + :vartype normalized_size: str + :ivar recommended_quantity_normalized: The recommended Quantity Normalized. + :vartype recommended_quantity_normalized: float + :ivar meter_id: The meter id (GUID). + :vartype meter_id: str + :ivar resource_type: The azure resource type. + :vartype resource_type: str + :ivar term: RI recommendations in one or three year terms. + :vartype term: str + :ivar cost_with_no_reserved_instances: The total amount of cost without reserved instances. + :vartype cost_with_no_reserved_instances: float + :ivar recommended_quantity: Recommended quality for reserved instances. + :vartype recommended_quantity: float + :ivar total_cost_with_reserved_instances: The total amount of cost with reserved instances. + :vartype total_cost_with_reserved_instances: float + :ivar net_savings: Total estimated savings with reserved instances. + :vartype net_savings: float + :ivar first_usage_date: The usage date for looking back. + :vartype first_usage_date: ~datetime.datetime + :ivar scope: Required. Shared or single recommendation.Constant filled by server. + :vartype scope: str + :ivar sku_properties: List of sku properties. + :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] + :ivar subscription_id: Subscription id associated with single scoped recommendation. + :vartype subscription_id: str + """ + + _validation = { + 'look_back_period': {'readonly': True}, + 'instance_flexibility_ratio': {'readonly': True}, + 'instance_flexibility_group': {'readonly': True}, + 'normalized_size': {'readonly': True}, + 'recommended_quantity_normalized': {'readonly': True}, + 'meter_id': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'term': {'readonly': True}, + 'cost_with_no_reserved_instances': {'readonly': True}, + 'recommended_quantity': {'readonly': True}, + 'total_cost_with_reserved_instances': {'readonly': True}, + 'net_savings': {'readonly': True}, + 'first_usage_date': {'readonly': True}, + 'scope': {'required': True}, + 'sku_properties': {'readonly': True}, + 'subscription_id': {'readonly': True}, + } + + _attribute_map = { + 'look_back_period': {'key': 'lookBackPeriod', 'type': 'str'}, + 'instance_flexibility_ratio': {'key': 'instanceFlexibilityRatio', 'type': 'float'}, + 'instance_flexibility_group': {'key': 'instanceFlexibilityGroup', 'type': 'str'}, + 'normalized_size': {'key': 'normalizedSize', 'type': 'str'}, + 'recommended_quantity_normalized': {'key': 'recommendedQuantityNormalized', 'type': 'float'}, + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'term': {'key': 'term', 'type': 'str'}, + 'cost_with_no_reserved_instances': {'key': 'costWithNoReservedInstances', 'type': 'float'}, + 'recommended_quantity': {'key': 'recommendedQuantity', 'type': 'float'}, + 'total_cost_with_reserved_instances': {'key': 'totalCostWithReservedInstances', 'type': 'float'}, + 'net_savings': {'key': 'netSavings', 'type': 'float'}, + 'first_usage_date': {'key': 'firstUsageDate', 'type': 'iso-8601'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'sku_properties': {'key': 'skuProperties', 'type': '[SkuProperty]'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LegacySingleScopeReservationRecommendationProperties, self).__init__(**kwargs) + self.scope = 'Single' # type: str + self.subscription_id = None + + class UsageDetail(Resource): """An usage detail resource. @@ -1660,23 +2271,26 @@ class UsageDetail(Resource): All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of usage details.Constant filled by server. Possible + :ivar kind: Required. Specifies the kind of usage details.Constant filled by server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind + :vartype kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, } @@ -1685,6 +2299,7 @@ class UsageDetail(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, } @@ -1697,6 +2312,8 @@ def __init__( self, **kwargs ): + """ + """ super(UsageDetail, self).__init__(**kwargs) self.kind = 'UsageDetail' # type: str @@ -1708,17 +2325,19 @@ class LegacyUsageDetail(UsageDetail): All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of usage details.Constant filled by server. Possible + :ivar kind: Required. Specifies the kind of usage details.Constant filled by server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind + :vartype kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind :ivar billing_account_id: Billing Account identifier. :vartype billing_account_id: str :ivar billing_account_name: Billing Account Name. @@ -1769,13 +2388,13 @@ class LegacyUsageDetail(UsageDetail): :ivar consumed_service: Consumed service name. Name of the azure resource provider that emits the usage or was purchased. This value is not provided for marketplace usage. :vartype consumed_service: str - :ivar resource_id: Azure resource manager resource identifier. + :ivar resource_id: Unique identifier of the Azure Resource Manager usage detail resource. :vartype resource_id: str :ivar resource_name: Resource Name. :vartype resource_name: str - :ivar service_info1: Service Info 1. + :ivar service_info1: Service-specific metadata. :vartype service_info1: str - :ivar service_info2: Service Info 2. + :ivar service_info2: Legacy field with optional service-specific metadata. :vartype service_info2: str :ivar additional_info: Additional details of this usage item. By default this is not populated, unless it's specified in $expand. Use this field to get usage line item specific details such @@ -1820,12 +2439,22 @@ class LegacyUsageDetail(UsageDetail): only happen once, Monthly for fees which recur every month, and UsageBased for charges based on how much a service is used. :vartype frequency: str + :ivar pay_g_price: Retail price for the resource. + :vartype pay_g_price: float + :ivar benefit_id: Unique identifier for the applicable benefit. + :vartype benefit_id: str + :ivar benefit_name: Name of the applicable benefit. + :vartype benefit_name: str + :ivar pricing_model: Identifier that indicates how the meter is priced. Possible values + include: "On Demand", "Reservation", "Spot". + :vartype pricing_model: str or ~azure.mgmt.consumption.models.PricingModelType """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, 'billing_account_id': {'readonly': True}, @@ -1870,12 +2499,17 @@ class LegacyUsageDetail(UsageDetail): 'plan_name': {'readonly': True}, 'charge_type': {'readonly': True}, 'frequency': {'readonly': True}, + 'pay_g_price': {'readonly': True}, + 'benefit_id': {'readonly': True}, + 'benefit_name': {'readonly': True}, + 'pricing_model': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, 'billing_account_id': {'key': 'properties.billingAccountId', 'type': 'str'}, @@ -1920,12 +2554,18 @@ class LegacyUsageDetail(UsageDetail): 'plan_name': {'key': 'properties.planName', 'type': 'str'}, 'charge_type': {'key': 'properties.chargeType', 'type': 'str'}, 'frequency': {'key': 'properties.frequency', 'type': 'str'}, + 'pay_g_price': {'key': 'properties.payGPrice', 'type': 'float'}, + 'benefit_id': {'key': 'properties.benefitId', 'type': 'str'}, + 'benefit_name': {'key': 'properties.benefitName', 'type': 'str'}, + 'pricing_model': {'key': 'properties.pricingModel', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(LegacyUsageDetail, self).__init__(**kwargs) self.kind = 'legacy' # type: str self.billing_account_id = None @@ -1970,6 +2610,10 @@ def __init__( self.plan_name = None self.charge_type = None self.frequency = None + self.pay_g_price = None + self.benefit_id = None + self.benefit_name = None + self.pricing_model = None class Lots(msrest.serialization.Model): @@ -1997,12 +2641,14 @@ def __init__( self, **kwargs ): + """ + """ super(Lots, self).__init__(**kwargs) self.value = None self.next_link = None -class LotSummary(Resource): +class LotSummary(ProxyResource): """A lot summary resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2013,59 +2659,112 @@ class LotSummary(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :ivar original_amount: Original amount. + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar original_amount: The original amount of a lot. :vartype original_amount: ~azure.mgmt.consumption.models.Amount - :ivar closed_balance: Closed balance. + :ivar closed_balance: The balance as of the last invoice. :vartype closed_balance: ~azure.mgmt.consumption.models.Amount - :ivar source: Lot source. Possible values include: "PurchasedCredit", "PromotionalCredit". + :ivar source: The source of the lot. Possible values include: "PurchasedCredit", + "PromotionalCredit", "ConsumptionCommitment". :vartype source: str or ~azure.mgmt.consumption.models.LotSource - :ivar start_date: Start date. + :ivar start_date: The date when the lot became effective. :vartype start_date: ~datetime.datetime - :ivar expiration_date: Expiration date. + :ivar expiration_date: The expiration date of a lot. :vartype expiration_date: ~datetime.datetime - :ivar po_number: PO number. + :ivar po_number: The po number of the invoice on which the lot was added. This property is not + available for ConsumptionCommitment lots. :vartype po_number: str + :ivar purchased_date: The date when the lot was added. + :vartype purchased_date: ~datetime.datetime + :ivar status: The status of the lot. Possible values include: "None", "Active", "Inactive", + "Expired", "Complete", "Canceled". + :vartype status: str or ~azure.mgmt.consumption.models.Status + :ivar credit_currency: The currency of the lot. + :vartype credit_currency: str + :ivar billing_currency: The billing currency of the lot. + :vartype billing_currency: str + :ivar original_amount_in_billing_currency: The original amount of a lot in billing currency. + :vartype original_amount_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar closed_balance_in_billing_currency: The balance as of the last invoice in billing + currency. + :vartype closed_balance_in_billing_currency: + ~azure.mgmt.consumption.models.AmountWithExchangeRate + :ivar reseller: The reseller of the lot. + :vartype reseller: ~azure.mgmt.consumption.models.Reseller + :ivar e_tag_properties_e_tag: The eTag for the resource. + :vartype e_tag_properties_e_tag: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'original_amount': {'readonly': True}, 'closed_balance': {'readonly': True}, 'source': {'readonly': True}, 'start_date': {'readonly': True}, 'expiration_date': {'readonly': True}, 'po_number': {'readonly': True}, + 'purchased_date': {'readonly': True}, + 'status': {'readonly': True}, + 'credit_currency': {'readonly': True}, + 'billing_currency': {'readonly': True}, + 'original_amount_in_billing_currency': {'readonly': True}, + 'closed_balance_in_billing_currency': {'readonly': True}, + 'reseller': {'readonly': True}, + 'e_tag_properties_e_tag': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'original_amount': {'key': 'properties.originalAmount', 'type': 'Amount'}, 'closed_balance': {'key': 'properties.closedBalance', 'type': 'Amount'}, 'source': {'key': 'properties.source', 'type': 'str'}, 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, 'po_number': {'key': 'properties.poNumber', 'type': 'str'}, + 'purchased_date': {'key': 'properties.purchasedDate', 'type': 'iso-8601'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'credit_currency': {'key': 'properties.creditCurrency', 'type': 'str'}, + 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, + 'original_amount_in_billing_currency': {'key': 'properties.originalAmountInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'closed_balance_in_billing_currency': {'key': 'properties.closedBalanceInBillingCurrency', 'type': 'AmountWithExchangeRate'}, + 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, + 'e_tag_properties_e_tag': {'key': 'properties.eTag', 'type': 'str'}, } def __init__( self, + *, + e_tag: Optional[str] = None, **kwargs ): - super(LotSummary, self).__init__(**kwargs) + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ + super(LotSummary, self).__init__(e_tag=e_tag, **kwargs) self.original_amount = None self.closed_balance = None self.source = None self.start_date = None self.expiration_date = None self.po_number = None + self.purchased_date = None + self.status = None + self.credit_currency = None + self.billing_currency = None + self.original_amount_in_billing_currency = None + self.closed_balance_in_billing_currency = None + self.reseller = None + self.e_tag_properties_e_tag = None class ManagementGroupAggregatedCostResult(Resource): @@ -2073,12 +2772,14 @@ class ManagementGroupAggregatedCostResult(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar billing_period_id: The id of the billing period resource that the aggregated cost belongs @@ -2096,20 +2797,21 @@ class ManagementGroupAggregatedCostResult(Resource): :vartype charges_billed_separately: float :ivar currency: The ISO currency in which the meter is charged, for example, USD. :vartype currency: str - :param children: Children of a management group. - :type children: list[~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult] - :param included_subscriptions: List of subscription Guids included in the calculation of + :ivar children: Children of a management group. + :vartype children: list[~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult] + :ivar included_subscriptions: List of subscription Guids included in the calculation of aggregated cost. - :type included_subscriptions: list[str] - :param excluded_subscriptions: List of subscription Guids excluded from the calculation of + :vartype included_subscriptions: list[str] + :ivar excluded_subscriptions: List of subscription Guids excluded from the calculation of aggregated cost. - :type excluded_subscriptions: list[str] + :vartype excluded_subscriptions: list[str] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'billing_period_id': {'readonly': True}, 'usage_start': {'readonly': True}, @@ -2124,6 +2826,7 @@ class ManagementGroupAggregatedCostResult(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, 'usage_start': {'key': 'properties.usageStart', 'type': 'iso-8601'}, @@ -2145,6 +2848,16 @@ def __init__( excluded_subscriptions: Optional[List[str]] = None, **kwargs ): + """ + :keyword children: Children of a management group. + :paramtype children: list[~azure.mgmt.consumption.models.ManagementGroupAggregatedCostResult] + :keyword included_subscriptions: List of subscription Guids included in the calculation of + aggregated cost. + :paramtype included_subscriptions: list[str] + :keyword excluded_subscriptions: List of subscription Guids excluded from the calculation of + aggregated cost. + :paramtype excluded_subscriptions: list[str] + """ super(ManagementGroupAggregatedCostResult, self).__init__(**kwargs) self.billing_period_id = None self.usage_start = None @@ -2159,16 +2872,18 @@ def __init__( class Marketplace(Resource): - """An marketplace resource. + """A marketplace resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar billing_period_id: The id of the billing period resource that the usage belongs to. @@ -2183,6 +2898,8 @@ class Marketplace(Resource): :vartype offer_name: str :ivar resource_group: The name of resource group. :vartype resource_group: str + :ivar additional_info: Additional information. + :vartype additional_info: str :ivar order_number: The order number. :vartype order_number: str :ivar instance_name: The name of the resource instance that the usage is about. @@ -2229,6 +2946,7 @@ class Marketplace(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'billing_period_id': {'readonly': True}, 'usage_start': {'readonly': True}, @@ -2236,6 +2954,7 @@ class Marketplace(Resource): 'resource_rate': {'readonly': True}, 'offer_name': {'readonly': True}, 'resource_group': {'readonly': True}, + 'additional_info': {'readonly': True}, 'order_number': {'readonly': True}, 'instance_name': {'readonly': True}, 'instance_id': {'readonly': True}, @@ -2261,6 +2980,7 @@ class Marketplace(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, 'usage_start': {'key': 'properties.usageStart', 'type': 'iso-8601'}, @@ -2268,6 +2988,7 @@ class Marketplace(Resource): 'resource_rate': {'key': 'properties.resourceRate', 'type': 'float'}, 'offer_name': {'key': 'properties.offerName', 'type': 'str'}, 'resource_group': {'key': 'properties.resourceGroup', 'type': 'str'}, + 'additional_info': {'key': 'properties.additionalInfo', 'type': 'str'}, 'order_number': {'key': 'properties.orderNumber', 'type': 'str'}, 'instance_name': {'key': 'properties.instanceName', 'type': 'str'}, 'instance_id': {'key': 'properties.instanceId', 'type': 'str'}, @@ -2293,6 +3014,8 @@ def __init__( self, **kwargs ): + """ + """ super(Marketplace, self).__init__(**kwargs) self.billing_period_id = None self.usage_start = None @@ -2300,6 +3023,7 @@ def __init__( self.resource_rate = None self.offer_name = None self.resource_group = None + self.additional_info = None self.order_number = None self.instance_name = None self.instance_id = None @@ -2346,6 +3070,8 @@ def __init__( self, **kwargs ): + """ + """ super(MarketplacesListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2407,6 +3133,8 @@ def __init__( self, **kwargs ): + """ + """ super(MeterDetails, self).__init__(**kwargs) self.meter_name = None self.meter_category = None @@ -2459,6 +3187,8 @@ def __init__( self, **kwargs ): + """ + """ super(MeterDetailsResponse, self).__init__(**kwargs) self.meter_name = None self.meter_category = None @@ -2480,11 +3210,12 @@ class ModernChargeSummary(ChargeSummary): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of charge summary.Constant filled by server. - Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :vartype e_tag: str + :ivar kind: Required. Specifies the kind of charge summary.Constant filled by server. Possible + values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ChargeSummaryKind :ivar billing_period_id: The id of the billing period resource that the charge belongs to. :vartype billing_period_id: str :ivar usage_start: Usage start date. @@ -2513,7 +3244,6 @@ class ModernChargeSummary(ChargeSummary): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'kind': {'required': True}, 'billing_period_id': {'readonly': True}, 'usage_start': {'readonly': True}, @@ -2532,7 +3262,7 @@ class ModernChargeSummary(ChargeSummary): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'kind': {'key': 'kind', 'type': 'str'}, 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, 'usage_start': {'key': 'properties.usageStart', 'type': 'str'}, @@ -2549,9 +3279,16 @@ class ModernChargeSummary(ChargeSummary): def __init__( self, + *, + e_tag: Optional[str] = None, **kwargs ): - super(ModernChargeSummary, self).__init__(**kwargs) + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + """ + super(ModernChargeSummary, self).__init__(e_tag=e_tag, **kwargs) self.kind = 'modern' # type: str self.billing_period_id = None self.usage_start = None @@ -2577,21 +3314,25 @@ class ModernReservationRecommendation(ReservationRecommendation): :vartype location: str :ivar sku: Resource sku. :vartype sku: str - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of reservation recommendation.Constant filled by - server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind + :ivar kind: Required. Specifies the kind of reservation recommendation.Constant filled by + server. Possible values include: "legacy", "modern". + :vartype kind: str or ~azure.mgmt.consumption.models.ReservationRecommendationKind + :ivar location_properties_location: Resource Location. + :vartype location_properties_location: str :ivar look_back_period: The number of days of usage to look back for recommendation. - :vartype look_back_period: str + :vartype look_back_period: int :ivar instance_flexibility_ratio: The instance Flexibility Ratio. - :vartype instance_flexibility_ratio: int + :vartype instance_flexibility_ratio: float :ivar instance_flexibility_group: The instance Flexibility Group. :vartype instance_flexibility_group: str :ivar normalized_size: The normalized Size. @@ -2616,6 +3357,8 @@ class ModernReservationRecommendation(ReservationRecommendation): :vartype scope: str :ivar sku_properties: List of sku properties. :vartype sku_properties: list[~azure.mgmt.consumption.models.SkuProperty] + :ivar sku_name: This is the ARM Sku name. + :vartype sku_name: str """ _validation = { @@ -2624,8 +3367,10 @@ class ModernReservationRecommendation(ReservationRecommendation): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, + 'location_properties_location': {'readonly': True}, 'look_back_period': {'readonly': True}, 'instance_flexibility_ratio': {'readonly': True}, 'instance_flexibility_group': {'readonly': True}, @@ -2640,6 +3385,7 @@ class ModernReservationRecommendation(ReservationRecommendation): 'first_usage_date': {'readonly': True}, 'scope': {'readonly': True}, 'sku_properties': {'readonly': True}, + 'sku_name': {'readonly': True}, } _attribute_map = { @@ -2648,10 +3394,12 @@ class ModernReservationRecommendation(ReservationRecommendation): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, - 'look_back_period': {'key': 'properties.lookBackPeriod', 'type': 'str'}, - 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'int'}, + 'location_properties_location': {'key': 'properties.location', 'type': 'str'}, + 'look_back_period': {'key': 'properties.lookBackPeriod', 'type': 'int'}, + 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'float'}, 'instance_flexibility_group': {'key': 'properties.instanceFlexibilityGroup', 'type': 'str'}, 'normalized_size': {'key': 'properties.normalizedSize', 'type': 'str'}, 'recommended_quantity_normalized': {'key': 'properties.recommendedQuantityNormalized', 'type': 'float'}, @@ -2664,14 +3412,18 @@ class ModernReservationRecommendation(ReservationRecommendation): 'first_usage_date': {'key': 'properties.firstUsageDate', 'type': 'iso-8601'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, 'sku_properties': {'key': 'properties.skuProperties', 'type': '[SkuProperty]'}, + 'sku_name': {'key': 'properties.skuName', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(ModernReservationRecommendation, self).__init__(**kwargs) self.kind = 'modern' # type: str + self.location_properties_location = None self.look_back_period = None self.instance_flexibility_ratio = None self.instance_flexibility_group = None @@ -2686,6 +3438,7 @@ def __init__( self.first_usage_date = None self.scope = None self.sku_properties = None + self.sku_name = None class ModernReservationTransaction(ReservationTransactionResource): @@ -2805,6 +3558,8 @@ def __init__( self, **kwargs ): + """ + """ super(ModernReservationTransaction, self).__init__(**kwargs) self.amount = None self.arm_sku_name = None @@ -2853,6 +3608,8 @@ def __init__( self, **kwargs ): + """ + """ super(ModernReservationTransactionsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2865,19 +3622,26 @@ class ModernUsageDetail(UsageDetail): All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param kind: Required. Specifies the kind of usage details.Constant filled by server. Possible + :ivar kind: Required. Specifies the kind of usage details.Constant filled by server. Possible values include: "legacy", "modern". - :type kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind + :vartype kind: str or ~azure.mgmt.consumption.models.UsageDetailsKind :ivar billing_account_id: Billing Account identifier. :vartype billing_account_id: str + :ivar effective_price: Effective Price that's charged for the usage. + :vartype effective_price: float + :ivar pricing_model: Identifier that indicates how the meter is priced. Possible values + include: "On Demand", "Reservation", "Spot". + :vartype pricing_model: str or ~azure.mgmt.consumption.models.PricingModelType :ivar billing_account_name: Name of the Billing Account. :vartype billing_account_name: str :ivar billing_period_start_date: Billing Period Start Date as in the invoice. @@ -2939,9 +3703,9 @@ class ModernUsageDetail(UsageDetail): :ivar consumed_service: Consumed service name. Name of the azure resource provider that emits the usage or was purchased. This value is not provided for marketplace usage. :vartype consumed_service: str - :ivar service_info1: Service Info 1. + :ivar service_info1: Service-specific metadata. :vartype service_info1: str - :ivar service_info2: Service Info 2. + :ivar service_info2: Legacy field with optional service-specific metadata. :vartype service_info2: str :ivar additional_info: Additional details of this usage item. Use this field to get usage line item specific details such as the actual VM Size (ServiceType) or the ratio in which the @@ -3011,8 +3775,8 @@ class ModernUsageDetail(UsageDetail): :vartype previous_invoice_id: str :ivar pricing_currency_code: Pricing Billing Currency. :vartype pricing_currency_code: str - :ivar product_identifier: Identifer for the product that has accrued charges by consumption or - purchase . This is the concatenated key of productId and SKuId in partner center. + :ivar product_identifier: Identifier for the product that has accrued charges by consumption or + purchase . This is the concatenated key of productId and SkuId in partner center. :vartype product_identifier: str :ivar resource_location_normalized: Resource Location Normalized. :vartype resource_location_normalized: str @@ -3051,15 +3815,29 @@ class ModernUsageDetail(UsageDetail): :ivar partner_earned_credit_applied: Flag to indicate if partner earned credit has been applied or not. :vartype partner_earned_credit_applied: str + :ivar pay_g_price: Retail price for the resource. + :vartype pay_g_price: float + :ivar benefit_id: Unique identifier for the applicable benefit. + :vartype benefit_id: str + :ivar benefit_name: Name of the applicable benefit. + :vartype benefit_name: str + :ivar provider: Identifier for Product Category or Line Of Business, Ex - Azure, Microsoft 365, + AWS e.t.c. + :vartype provider: str + :ivar cost_allocation_rule_name: Name for Cost Allocation Rule. + :vartype cost_allocation_rule_name: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'kind': {'required': True}, 'billing_account_id': {'readonly': True}, + 'effective_price': {'readonly': True}, + 'pricing_model': {'readonly': True}, 'billing_account_name': {'readonly': True}, 'billing_period_start_date': {'readonly': True}, 'billing_period_end_date': {'readonly': True}, @@ -3124,15 +3902,23 @@ class ModernUsageDetail(UsageDetail): 'payg_cost_in_usd': {'readonly': True}, 'partner_earned_credit_rate': {'readonly': True}, 'partner_earned_credit_applied': {'readonly': True}, + 'pay_g_price': {'readonly': True}, + 'benefit_id': {'readonly': True}, + 'benefit_name': {'readonly': True}, + 'provider': {'readonly': True}, + 'cost_allocation_rule_name': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'kind': {'key': 'kind', 'type': 'str'}, 'billing_account_id': {'key': 'properties.billingAccountId', 'type': 'str'}, + 'effective_price': {'key': 'properties.effectivePrice', 'type': 'float'}, + 'pricing_model': {'key': 'properties.pricingModel', 'type': 'str'}, 'billing_account_name': {'key': 'properties.billingAccountName', 'type': 'str'}, 'billing_period_start_date': {'key': 'properties.billingPeriodStartDate', 'type': 'iso-8601'}, 'billing_period_end_date': {'key': 'properties.billingPeriodEndDate', 'type': 'iso-8601'}, @@ -3197,15 +3983,24 @@ class ModernUsageDetail(UsageDetail): 'payg_cost_in_usd': {'key': 'properties.paygCostInUSD', 'type': 'float'}, 'partner_earned_credit_rate': {'key': 'properties.partnerEarnedCreditRate', 'type': 'float'}, 'partner_earned_credit_applied': {'key': 'properties.partnerEarnedCreditApplied', 'type': 'str'}, + 'pay_g_price': {'key': 'properties.payGPrice', 'type': 'float'}, + 'benefit_id': {'key': 'properties.benefitId', 'type': 'str'}, + 'benefit_name': {'key': 'properties.benefitName', 'type': 'str'}, + 'provider': {'key': 'properties.provider', 'type': 'str'}, + 'cost_allocation_rule_name': {'key': 'properties.costAllocationRuleName', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(ModernUsageDetail, self).__init__(**kwargs) self.kind = 'modern' # type: str self.billing_account_id = None + self.effective_price = None + self.pricing_model = None self.billing_account_name = None self.billing_period_start_date = None self.billing_period_end_date = None @@ -3270,6 +4065,11 @@ def __init__( self.payg_cost_in_usd = None self.partner_earned_credit_rate = None self.partner_earned_credit_applied = None + self.pay_g_price = None + self.benefit_id = None + self.benefit_name = None + self.provider = None + self.cost_allocation_rule_name = None class Notification(msrest.serialization.Model): @@ -3277,33 +4077,41 @@ class Notification(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. The notification is enabled or not. - :type enabled: bool - :param operator: Required. The comparison operator. Possible values include: "EqualTo", + :ivar enabled: Required. The notification is enabled or not. + :vartype enabled: bool + :ivar operator: Required. The comparison operator. Possible values include: "EqualTo", "GreaterThan", "GreaterThanOrEqualTo". - :type operator: str or ~azure.mgmt.consumption.models.OperatorType - :param threshold: Required. Threshold value associated with a notification. Notification is - sent when the cost exceeded the threshold. It is always percent and has to be between 0 and - 1000. - :type threshold: float - :param contact_emails: Required. Email addresses to send the budget notification to when the - threshold is exceeded. - :type contact_emails: list[str] - :param contact_roles: Contact roles to send the budget notification to when the threshold is - exceeded. - :type contact_roles: list[str] - :param contact_groups: Action groups to send the budget notification to when the threshold is + :vartype operator: str or ~azure.mgmt.consumption.models.OperatorType + :ivar threshold: Required. Threshold value associated with a notification. Notification is sent + when the cost exceeded the threshold. It is always percent and has to be between 0 and 1000. + :vartype threshold: float + :ivar contact_emails: Required. Email addresses to send the budget notification to when the + threshold is exceeded. Must have at least one contact email or contact group specified at the + Subscription or Resource Group scopes. All other scopes must have at least one contact email + specified. + :vartype contact_emails: list[str] + :ivar contact_roles: Contact roles to send the budget notification to when the threshold is exceeded. - :type contact_groups: list[str] - :param threshold_type: The type of threshold. Possible values include: "Actual". - :type threshold_type: str or ~azure.mgmt.consumption.models.ThresholdType + :vartype contact_roles: list[str] + :ivar contact_groups: Action groups to send the budget notification to when the threshold is + exceeded. Must be provided as a fully qualified Azure resource id. Only supported at + Subscription or Resource Group scopes. + :vartype contact_groups: list[str] + :ivar threshold_type: The type of threshold. Possible values include: "Actual", "Forecasted". + Default value: "Actual". + :vartype threshold_type: str or ~azure.mgmt.consumption.models.ThresholdType + :ivar locale: Language in which the recipient will receive the notification. Possible values + include: "en-us", "ja-jp", "zh-cn", "de-de", "es-es", "fr-fr", "it-it", "ko-kr", "pt-br", + "ru-ru", "zh-tw", "cs-cz", "pl-pl", "tr-tr", "da-dk", "en-gb", "hu-hu", "nb-no", "nl-nl", + "pt-pt", "sv-se". + :vartype locale: str or ~azure.mgmt.consumption.models.CultureCode """ _validation = { 'enabled': {'required': True}, 'operator': {'required': True}, 'threshold': {'required': True}, - 'contact_emails': {'required': True, 'max_items': 50, 'min_items': 1}, + 'contact_emails': {'required': True, 'max_items': 50, 'min_items': 0}, 'contact_groups': {'max_items': 50, 'min_items': 0}, } @@ -3315,6 +4123,7 @@ class Notification(msrest.serialization.Model): 'contact_roles': {'key': 'contactRoles', 'type': '[str]'}, 'contact_groups': {'key': 'contactGroups', 'type': '[str]'}, 'threshold_type': {'key': 'thresholdType', 'type': 'str'}, + 'locale': {'key': 'locale', 'type': 'str'}, } def __init__( @@ -3326,9 +4135,41 @@ def __init__( contact_emails: List[str], contact_roles: Optional[List[str]] = None, contact_groups: Optional[List[str]] = None, - threshold_type: Optional[Union[str, "ThresholdType"]] = None, + threshold_type: Optional[Union[str, "ThresholdType"]] = "Actual", + locale: Optional[Union[str, "CultureCode"]] = None, **kwargs ): + """ + :keyword enabled: Required. The notification is enabled or not. + :paramtype enabled: bool + :keyword operator: Required. The comparison operator. Possible values include: "EqualTo", + "GreaterThan", "GreaterThanOrEqualTo". + :paramtype operator: str or ~azure.mgmt.consumption.models.OperatorType + :keyword threshold: Required. Threshold value associated with a notification. Notification is + sent when the cost exceeded the threshold. It is always percent and has to be between 0 and + 1000. + :paramtype threshold: float + :keyword contact_emails: Required. Email addresses to send the budget notification to when the + threshold is exceeded. Must have at least one contact email or contact group specified at the + Subscription or Resource Group scopes. All other scopes must have at least one contact email + specified. + :paramtype contact_emails: list[str] + :keyword contact_roles: Contact roles to send the budget notification to when the threshold is + exceeded. + :paramtype contact_roles: list[str] + :keyword contact_groups: Action groups to send the budget notification to when the threshold is + exceeded. Must be provided as a fully qualified Azure resource id. Only supported at + Subscription or Resource Group scopes. + :paramtype contact_groups: list[str] + :keyword threshold_type: The type of threshold. Possible values include: "Actual", + "Forecasted". Default value: "Actual". + :paramtype threshold_type: str or ~azure.mgmt.consumption.models.ThresholdType + :keyword locale: Language in which the recipient will receive the notification. Possible values + include: "en-us", "ja-jp", "zh-cn", "de-de", "es-es", "fr-fr", "it-it", "ko-kr", "pt-br", + "ru-ru", "zh-tw", "cs-cz", "pl-pl", "tr-tr", "da-dk", "en-gb", "hu-hu", "nb-no", "nl-nl", + "pt-pt", "sv-se". + :paramtype locale: str or ~azure.mgmt.consumption.models.CultureCode + """ super(Notification, self).__init__(**kwargs) self.enabled = enabled self.operator = operator @@ -3337,6 +4178,7 @@ def __init__( self.contact_roles = contact_roles self.contact_groups = contact_groups self.threshold_type = threshold_type + self.locale = locale class Operation(msrest.serialization.Model): @@ -3344,17 +4186,21 @@ class Operation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. + :ivar id: Operation Id. + :vartype id: str :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.consumption.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.consumption.models.OperationDisplay """ _validation = { + 'id': {'readonly': True}, 'name': {'readonly': True}, } _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'display': {'key': 'display', 'type': 'OperationDisplay'}, } @@ -3365,7 +4211,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.consumption.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) + self.id = None self.name = None self.display = display @@ -3381,28 +4232,35 @@ class OperationDisplay(msrest.serialization.Model): :vartype resource: str :ivar operation: Operation type: Read, write, delete, etc. :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _validation = { 'provider': {'readonly': True}, 'resource': {'readonly': True}, 'operation': {'readonly': True}, + 'description': {'readonly': True}, } _attribute_map = { 'provider': {'key': 'provider', 'type': 'str'}, 'resource': {'key': 'resource', 'type': 'str'}, 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None self.operation = None + self.description = None class OperationListResult(msrest.serialization.Model): @@ -3431,6 +4289,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3490,6 +4350,8 @@ def __init__( self, **kwargs ): + """ + """ super(PriceSheetProperties, self).__init__(**kwargs) self.billing_period_id = None self.meter_id = None @@ -3507,45 +4369,88 @@ class PriceSheetResult(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar pricesheets: Price sheet. :vartype pricesheets: list[~azure.mgmt.consumption.models.PriceSheetProperties] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str + :ivar download: Pricesheet download details. + :vartype download: ~azure.mgmt.consumption.models.MeterDetails """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'pricesheets': {'readonly': True}, 'next_link': {'readonly': True}, + 'download': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'pricesheets': {'key': 'properties.pricesheets', 'type': '[PriceSheetProperties]'}, 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + 'download': {'key': 'properties.download', 'type': 'MeterDetails'}, } def __init__( self, **kwargs ): + """ + """ super(PriceSheetResult, self).__init__(**kwargs) self.pricesheets = None self.next_link = None + self.download = None + + +class Reseller(msrest.serialization.Model): + """The reseller properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar reseller_id: The reseller property ID. + :vartype reseller_id: str + :ivar reseller_description: The reseller property description. + :vartype reseller_description: str + """ + + _validation = { + 'reseller_id': {'readonly': True}, + 'reseller_description': {'readonly': True}, + } + + _attribute_map = { + 'reseller_id': {'key': 'resellerId', 'type': 'str'}, + 'reseller_description': {'key': 'resellerDescription', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Reseller, self).__init__(**kwargs) + self.reseller_id = None + self.reseller_description = None class ReservationDetail(Resource): @@ -3553,12 +4458,14 @@ class ReservationDetail(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar reservation_order_id: The reservation order ID is the identifier for a reservation @@ -3599,6 +4506,7 @@ class ReservationDetail(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'reservation_order_id': {'readonly': True}, 'instance_flexibility_ratio': {'readonly': True}, @@ -3617,6 +4525,7 @@ class ReservationDetail(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'reservation_order_id': {'key': 'properties.reservationOrderId', 'type': 'str'}, 'instance_flexibility_ratio': {'key': 'properties.instanceFlexibilityRatio', 'type': 'str'}, @@ -3635,6 +4544,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationDetail, self).__init__(**kwargs) self.reservation_order_id = None self.instance_flexibility_ratio = None @@ -3674,6 +4585,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationDetailsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3694,9 +4607,9 @@ class ReservationRecommendationDetailsCalculatedSavingsProperties(msrest.seriali :vartype reservation_cost: float :ivar total_reservation_cost: The cost of the suggested quantity. :vartype total_reservation_cost: float - :param reserved_unit_count: The number of reserved units used to calculate savings. Always 1 - for virtual machines. - :type reserved_unit_count: float + :ivar reserved_unit_count: The number of reserved units used to calculate savings. Always 1 for + virtual machines. + :vartype reserved_unit_count: float :ivar savings: The amount saved by purchasing the recommended quantity of reservation. :vartype savings: float """ @@ -3726,6 +4639,11 @@ def __init__( reserved_unit_count: Optional[float] = None, **kwargs ): + """ + :keyword reserved_unit_count: The number of reserved units used to calculate savings. Always 1 + for virtual machines. + :paramtype reserved_unit_count: float + """ super(ReservationRecommendationDetailsCalculatedSavingsProperties, self).__init__(**kwargs) self.on_demand_cost = None self.overage_cost = None @@ -3741,18 +4659,20 @@ class ReservationRecommendationDetailsModel(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :param location: Resource Location. - :type location: str - :param sku: Resource sku. - :type sku: str + :ivar location: Resource Location. + :vartype location: str + :ivar sku: Resource sku. + :vartype sku: str :ivar currency: An ISO 4217 currency code identifier for the costs and savings. :vartype currency: str :ivar resource: Resource specific properties. @@ -3773,6 +4693,7 @@ class ReservationRecommendationDetailsModel(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'currency': {'readonly': True}, 'resource': {'readonly': True}, @@ -3786,6 +4707,7 @@ class ReservationRecommendationDetailsModel(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'str'}, @@ -3804,6 +4726,12 @@ def __init__( sku: Optional[str] = None, **kwargs ): + """ + :keyword location: Resource Location. + :paramtype location: str + :keyword sku: Resource sku. + :paramtype sku: str + """ super(ReservationRecommendationDetailsModel, self).__init__(**kwargs) self.location = location self.sku = sku @@ -3856,6 +4784,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationRecommendationDetailsResourceProperties, self).__init__(**kwargs) self.applied_scopes = None self.on_demand_rate = None @@ -3870,8 +4800,8 @@ class ReservationRecommendationDetailsSavingsProperties(msrest.serialization.Mod Variables are only populated by the server, and will be ignored when sending a request. - :param calculated_savings: List of calculated savings. - :type calculated_savings: + :ivar calculated_savings: List of calculated savings. + :vartype calculated_savings: list[~azure.mgmt.consumption.models.ReservationRecommendationDetailsCalculatedSavingsProperties] :ivar look_back_period: Number of days of usage to look back used for computing the recommendation. @@ -3909,6 +4839,11 @@ def __init__( calculated_savings: Optional[List["ReservationRecommendationDetailsCalculatedSavingsProperties"]] = None, **kwargs ): + """ + :keyword calculated_savings: List of calculated savings. + :paramtype calculated_savings: + list[~azure.mgmt.consumption.models.ReservationRecommendationDetailsCalculatedSavingsProperties] + """ super(ReservationRecommendationDetailsSavingsProperties, self).__init__(**kwargs) self.calculated_savings = calculated_savings self.look_back_period = None @@ -3958,6 +4893,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationRecommendationDetailsUsageProperties, self).__init__(**kwargs) self.first_consumption_date = None self.last_consumption_date = None @@ -3975,25 +4912,32 @@ class ReservationRecommendationsListResult(msrest.serialization.Model): :vartype value: list[~azure.mgmt.consumption.models.ReservationRecommendation] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str + :ivar previous_link: The link (url) to the previous page of results. + :vartype previous_link: str """ _validation = { 'value': {'readonly': True}, 'next_link': {'readonly': True}, + 'previous_link': {'readonly': True}, } _attribute_map = { 'value': {'key': 'value', 'type': '[ReservationRecommendation]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'previous_link': {'key': 'previousLink', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + """ super(ReservationRecommendationsListResult, self).__init__(**kwargs) self.value = None self.next_link = None + self.previous_link = None class ReservationSummariesListResult(msrest.serialization.Model): @@ -4021,6 +4965,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationSummariesListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -4031,12 +4977,14 @@ class ReservationSummary(Resource): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: The full qualified ARM ID of an event. :vartype id: str - :ivar name: Resource name. + :ivar name: The ID that uniquely identifies an event. :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar etag: The etag for the resource. + :vartype etag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar reservation_order_id: The reservation order ID is the identifier for a reservation @@ -4089,6 +5037,7 @@ class ReservationSummary(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'etag': {'readonly': True}, 'tags': {'readonly': True}, 'reservation_order_id': {'readonly': True}, 'reservation_id': {'readonly': True}, @@ -4111,6 +5060,7 @@ class ReservationSummary(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'reservation_order_id': {'key': 'properties.reservationOrderId', 'type': 'str'}, 'reservation_id': {'key': 'properties.reservationId', 'type': 'str'}, @@ -4133,6 +5083,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationSummary, self).__init__(**kwargs) self.reservation_order_id = None self.reservation_id = None @@ -4176,6 +5128,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationTransactionsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -4206,6 +5160,8 @@ def __init__( self, **kwargs ): + """ + """ super(SkuProperty, self).__init__(**kwargs) self.name = None self.value = None @@ -4214,22 +5170,33 @@ def __init__( class Tag(msrest.serialization.Model): """The tag resource. - :param key: Tag key. - :type key: str + :ivar key: Tag key. + :vartype key: str + :ivar value: Tag values. + :vartype value: list[str] """ _attribute_map = { 'key': {'key': 'key', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[str]'}, } def __init__( self, *, key: Optional[str] = None, + value: Optional[List[str]] = None, **kwargs ): + """ + :keyword key: Tag key. + :paramtype key: str + :keyword value: Tag values. + :paramtype value: list[str] + """ super(Tag, self).__init__(**kwargs) self.key = key + self.value = value class TagsResult(ProxyResource): @@ -4243,17 +5210,23 @@ class TagsResult(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + :ivar e_tag: eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. - :type e_tag: str - :param tags: A set of tags. A list of Tag. - :type tags: list[~azure.mgmt.consumption.models.Tag] + :vartype e_tag: str + :ivar tags: A set of tags. A list of Tag. + :vartype tags: list[~azure.mgmt.consumption.models.Tag] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + :ivar previous_link: The link (url) to the previous page of results. + :vartype previous_link: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'next_link': {'readonly': True}, + 'previous_link': {'readonly': True}, } _attribute_map = { @@ -4262,6 +5235,8 @@ class TagsResult(ProxyResource): 'type': {'key': 'type', 'type': 'str'}, 'e_tag': {'key': 'eTag', 'type': 'str'}, 'tags': {'key': 'properties.tags', 'type': '[Tag]'}, + 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + 'previous_link': {'key': 'properties.previousLink', 'type': 'str'}, } def __init__( @@ -4271,8 +5246,17 @@ def __init__( tags: Optional[List["Tag"]] = None, **kwargs ): + """ + :keyword e_tag: eTag of the resource. To handle concurrent update scenario, this field will be + used to determine whether the user is updating the latest version or not. + :paramtype e_tag: str + :keyword tags: A set of tags. A list of Tag. + :paramtype tags: list[~azure.mgmt.consumption.models.Tag] + """ super(TagsResult, self).__init__(e_tag=e_tag, **kwargs) self.tags = tags + self.next_link = None + self.previous_link = None class UsageDetailsListResult(msrest.serialization.Model): @@ -4300,6 +5284,8 @@ def __init__( self, **kwargs ): + """ + """ super(UsageDetailsListResult, self).__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py index 9736d77b0f1e..b9f9e177168f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py @@ -18,7 +18,6 @@ from ._reservation_recommendation_details_operations import ReservationRecommendationDetailsOperations from ._reservation_transactions_operations import ReservationTransactionsOperations from ._price_sheet_operations import PriceSheetOperations -from ._forecasts_operations import ForecastsOperations from ._operations import Operations from ._aggregated_cost_operations import AggregatedCostOperations from ._events_operations import EventsOperations @@ -38,7 +37,6 @@ 'ReservationRecommendationDetailsOperations', 'ReservationTransactionsOperations', 'PriceSheetOperations', - 'ForecastsOperations', 'Operations', 'AggregatedCostOperations', 'EventsOperations', diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_aggregated_cost_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_aggregated_cost_operations.py index ccf5e9b480db..67afab8c4852 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_aggregated_cost_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_aggregated_cost_operations.py @@ -5,23 +5,101 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_by_management_group_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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_get_for_billing_period_by_management_group_request( + management_group_id, # type: str + billing_period_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), + "billingPeriodName": _SERIALIZER.url("billing_period_name", billing_period_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class AggregatedCostOperations(object): """AggregatedCostOperations operations. @@ -44,6 +122,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_management_group( self, management_group_id, # type: str @@ -71,33 +150,22 @@ def get_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_by_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + request = build_get_by_management_group_request( + management_group_id=management_group_id, + filter=filter, + template_url=self.get_by_management_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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('ManagementGroupAggregatedCostResult', pipeline_response) @@ -106,8 +174,11 @@ def get_by_management_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost'} # type: ignore + + @distributed_trace def get_for_billing_period_by_management_group( self, management_group_id, # type: str @@ -132,32 +203,22 @@ def get_for_billing_period_by_management_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_for_billing_period_by_management_group.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str'), - 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_for_billing_period_by_management_group_request( + management_group_id=management_group_id, + billing_period_name=billing_period_name, + template_url=self.get_for_billing_period_by_management_group.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('ManagementGroupAggregatedCostResult', pipeline_response) @@ -166,4 +227,6 @@ def get_for_billing_period_by_management_group( return cls(pipeline_response, deserialized, {}) return deserialized - get_for_billing_period_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/Microsoft.Consumption/aggregatedcost'} # type: ignore + + get_for_billing_period_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_balances_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_balances_operations.py index 5556d12d355f..0317ee1ea559 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_balances_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_balances_operations.py @@ -5,23 +5,97 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_by_billing_account_request( + billing_account_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_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_get_for_billing_period_by_billing_account_request( + billing_account_id, # type: str + billing_period_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + "billingPeriodName": _SERIALIZER.url("billing_period_name", billing_period_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class BalancesOperations(object): """BalancesOperations operations. @@ -44,6 +118,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_billing_account( self, billing_account_id, # type: str @@ -65,31 +140,21 @@ def get_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_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 = build_get_by_billing_account_request( + billing_account_id=billing_account_id, + template_url=self.get_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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('Balance', pipeline_response) @@ -98,8 +163,11 @@ def get_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances'} # type: ignore + + @distributed_trace def get_for_billing_period_by_billing_account( self, billing_account_id, # type: str @@ -124,32 +192,22 @@ def get_for_billing_period_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_for_billing_period_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_for_billing_period_by_billing_account_request( + billing_account_id=billing_account_id, + billing_period_name=billing_period_name, + template_url=self.get_for_billing_period_by_billing_account.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('Balance', pipeline_response) @@ -158,4 +216,6 @@ def get_for_billing_period_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized - get_for_billing_period_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'} # type: ignore + + get_for_billing_period_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_budgets_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_budgets_operations.py index c50bf7bc303c..240847ce7a64 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_budgets_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_budgets_operations.py @@ -5,24 +5,170 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/budgets') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + scope, # type: str + budget_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "budgetName": _SERIALIZER.url("budget_name", budget_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + scope, # type: str + budget_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "budgetName": _SERIALIZER.url("budget_name", budget_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + scope, # type: str + budget_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "budgetName": _SERIALIZER.url("budget_name", budget_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class BudgetsOperations(object): """BudgetsOperations operations. @@ -45,6 +191,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope, # type: str @@ -78,34 +225,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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( + scope=scope, + 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( + scope=scope, + 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('BudgetsListResult', pipeline_response) + deserialized = self._deserialize("BudgetsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,17 +260,19 @@ 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': '/{scope}/providers/Microsoft.Consumption/budgets'} # type: ignore + @distributed_trace def get( self, scope, # type: str @@ -165,32 +309,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'budgetName': self._serialize.url("budget_name", budget_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + budget_name=budget_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('Budget', pipeline_response) @@ -199,8 +333,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + + @distributed_trace def create_or_update( self, scope, # type: str @@ -209,9 +346,9 @@ def create_or_update( **kwargs # type: Any ): # type: (...) -> "_models.Budget" - """The operation to create or update a budget. Update operation requires latest eTag to be set in - the request mandatorily. You may obtain the latest eTag by performing a get operation. Create - operation does not require eTag. + """The operation to create or update a budget. You can optionally provide an eTag if desired as a + form of concurrency control. To obtain the latest eTag for a given budget, perform a get + operation prior to your put operation. :param scope: The scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, @@ -242,37 +379,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'budgetName': self._serialize.url("budget_name", budget_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Budget') - # 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_or_update_request( + scope=scope, + budget_name=budget_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Budget') - 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -285,8 +412,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + + @distributed_trace def delete( self, scope, # type: str @@ -323,35 +453,26 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'budgetName': self._serialize.url("budget_name", budget_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + budget_name=budget_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]: 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: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_charges_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_charges_operations.py index 52fcba6f0225..dc6615b72400 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_charges_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_charges_operations.py @@ -5,23 +5,76 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + start_date = kwargs.pop('start_date', None) # type: Optional[str] + end_date = kwargs.pop('end_date', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + apply = kwargs.pop('apply', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/charges') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if start_date is not None: + query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') + if end_date is not None: + query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = _SERIALIZER.query("apply", apply, '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 + ) + +# fmt: on class ChargesOperations(object): """ChargesOperations operations. @@ -44,6 +97,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope, # type: str @@ -96,39 +150,25 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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') - if start_date is not None: - query_parameters['startDate'] = self._serialize.query("start_date", start_date, 'str') - if end_date is not None: - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if apply is not None: - query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + start_date=start_date, + end_date=end_date, + filter=filter, + apply=apply, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ChargesListResult', pipeline_response) @@ -137,4 +177,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/charges'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_credits_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_credits_operations.py index 4a66919ad61d..673997ed2d20 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_credits_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_credits_operations.py @@ -5,23 +5,65 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + billing_account_id, # type: str + billing_profile_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + "billingProfileId": _SERIALIZER.url("billing_profile_id", billing_profile_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 + ) + +# fmt: on class CreditsOperations(object): """CreditsOperations operations. @@ -44,13 +86,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, billing_account_id, # type: str billing_profile_id, # type: str **kwargs # type: Any ): - # type: (...) -> "_models.CreditSummary" + # type: (...) -> Optional["_models.CreditSummary"] """The credit summary by billingAccountId and billingProfileId. :param billing_account_id: BillingAccount ID. @@ -59,46 +102,40 @@ def get( :type billing_profile_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CreditSummary, or the result of cls(response) - :rtype: ~azure.mgmt.consumption.models.CreditSummary + :rtype: ~azure.mgmt.consumption.models.CreditSummary or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CreditSummary"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CreditSummary"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingProfileId': self._serialize.url("billing_profile_id", billing_profile_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_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + 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]: + 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) - deserialized = self._deserialize('CreditSummary', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CreditSummary', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_events_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_events_operations.py index 60491b1fa499..cf7696961d80 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_events_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_events_operations.py @@ -5,24 +5,107 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_billing_profile_request( + billing_account_id, # type: str + billing_profile_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + start_date = kwargs.pop('start_date') # type: str + end_date = kwargs.pop('end_date') # type: str + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + "billingProfileId": _SERIALIZER.url("billing_profile_id", billing_profile_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') + query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') + query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, '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_billing_account_request( + billing_account_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 + ) + +# fmt: on class EventsOperations(object): """EventsOperations operations. @@ -45,7 +128,8 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list( + @distributed_trace + def list_by_billing_profile( self, billing_account_id, # type: str billing_profile_id, # type: str @@ -54,7 +138,8 @@ def list( **kwargs # type: Any ): # type: (...) -> Iterable["_models.Events"] - """Lists the events by billingAccountId and billingProfileId for given start and end date. + """Lists the events that decrements Azure credits or Microsoft Azure consumption commitment for a + billing account or a billing profile for a given start and end date. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -74,37 +159,111 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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: + + request = build_list_by_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + start_date=start_date, + end_date=end_date, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + start_date=start_date, + end_date=end_date, + 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("Events", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events'} # type: ignore + + @distributed_trace + def list_by_billing_account( + self, + billing_account_id, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.Events"] + """Lists the events that decrements Azure credits or Microsoft Azure consumption commitment for a + billing account or a billing profile for a given start and end date. + + :param billing_account_id: BillingAccount ID. + :type billing_account_id: str + :param filter: May be used to filter the events by lotId, lotSource etc. The filter supports + 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + Tag filter is a key value pair string where key and value is separated by a colon (:). + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Events or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Events] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Events"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingProfileId': self._serialize.url("billing_profile_id", billing_profile_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') - query_parameters['startDate'] = self._serialize.query("start_date", start_date, 'str') - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_id=billing_account_id, + filter=filter, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_id=billing_account_id, + filter=filter, + 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('Events', pipeline_response) + deserialized = self._deserialize("Events", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -117,13 +276,14 @@ 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': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events'} # type: ignore + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events'} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_forecasts_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_forecasts_operations.py deleted file mode 100644 index 507a13eb386c..000000000000 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_forecasts_operations.py +++ /dev/null @@ -1,121 +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 typing import TYPE_CHECKING -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.mgmt.core.exceptions import ARMErrorFormat - -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]] - -class ForecastsOperations(object): - """ForecastsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.consumption.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ForecastsListResult"] - """Lists the forecast charges by subscriptionId. - - :param filter: May be used to filter forecasts by properties/usageDate (Utc time), - properties/chargeType or properties/grain. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', - and 'and'. It does not currently support 'ne', 'or', or 'not'. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ForecastsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ForecastsListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ForecastsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - 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) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ForecastsListResult', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - 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.Consumption/forecasts'} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py index 2ce4ec50c139..83e69209df45 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py @@ -5,24 +5,102 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_billing_profile_request( + billing_account_id, # type: str + billing_profile_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + "billingProfileId": _SERIALIZER.url("billing_profile_id", billing_profile_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_account_request( + billing_account_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 + ) + +# fmt: on class LotsOperations(object): """LotsOperations operations. @@ -45,14 +123,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list( + @distributed_trace + def list_by_billing_profile( self, billing_account_id, # type: str billing_profile_id, # type: str **kwargs # type: Any ): # type: (...) -> Iterable["_models.Lots"] - """Lists the lots by billingAccountId and billingProfileId. + """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a + billing profile. Microsoft Azure consumption commitments are only supported for the billing + account scope. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -68,35 +149,108 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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: + + request = build_list_by_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: + + request = build_list_by_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_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("Lots", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots'} # type: ignore + + @distributed_trace + def list_by_billing_account( + self, + billing_account_id, # type: str + filter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.Lots"] + """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a + billing profile. Microsoft Azure consumption commitments are only supported for the billing + account scope. + + :param billing_account_id: BillingAccount ID. + :type billing_account_id: str + :param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq', + 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag + filter is a key value pair string where key and value is separated by a colon (:). + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Lots or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Lots] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingProfileId': self._serialize.url("billing_profile_id", billing_profile_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_billing_account_request( + billing_account_id=billing_account_id, + filter=filter, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_id=billing_account_id, + filter=filter, + 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('Lots', pipeline_response) + deserialized = self._deserialize("Lots", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,13 +263,14 @@ 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': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots'} # type: ignore + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots'} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_marketplaces_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_marketplaces_operations.py index 40e846b0e68a..56b3587c4470 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_marketplaces_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_marketplaces_operations.py @@ -5,24 +5,74 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + skiptoken = kwargs.pop('skiptoken', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/marketplaces') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class MarketplacesOperations(object): """MarketplacesOperations operations. @@ -45,6 +95,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope, # type: str @@ -81,7 +132,8 @@ def list( a skiptoken parameter that specifies a starting point to use for subsequent calls. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MarketplacesListResult or the result of cls(response) + :return: An iterator like instance of either MarketplacesListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.MarketplacesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -90,40 +142,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - 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( + scope=scope, + filter=filter, + top=top, + skiptoken=skiptoken, + 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( + scope=scope, + filter=filter, + top=top, + skiptoken=skiptoken, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('MarketplacesListResult', pipeline_response) + deserialized = self._deserialize("MarketplacesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -136,12 +183,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_operations.py index 813dfd60a360..48c5149a6f3f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_operations.py @@ -5,24 +5,58 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Consumption/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -62,30 +97,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 +130,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_price_sheet_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_price_sheet_operations.py index e9a983b25ece..c506b5e4cec1 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_price_sheet_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_price_sheet_operations.py @@ -5,23 +5,117 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + skiptoken = kwargs.pop('skiptoken', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default') + 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] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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_get_by_billing_period_request( + subscription_id, # type: str + billing_period_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + skiptoken = kwargs.pop('skiptoken', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "billingPeriodName": _SERIALIZER.url("billing_period_name", billing_period_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + 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 + ) + +# fmt: on class PriceSheetOperations(object): """PriceSheetOperations operations. @@ -44,6 +138,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, expand=None, # type: Optional[str] @@ -52,8 +147,8 @@ def get( **kwargs # type: Any ): # type: (...) -> "_models.PriceSheetResult" - """Gets the price sheet for a scope by subscriptionId. Price sheet is available via this API only - for May 1, 2014 or later. + """Gets the price sheet for a subscription. Price sheet is available via this API only for May 1, + 2014 or later. :param expand: May be used to expand the properties/meterDetails within a price sheet. By default, these fields are not included when returning price sheet. @@ -74,37 +169,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - 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 = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + subscription_id=self._config.subscription_id, + expand=expand, + skiptoken=skiptoken, + top=top, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - 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('PriceSheetResult', pipeline_response) @@ -113,8 +195,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default'} # type: ignore + + @distributed_trace def get_by_billing_period( self, billing_period_name, # type: str @@ -148,38 +233,25 @@ def get_by_billing_period( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_period.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - 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 = self._client.get(url, query_parameters, header_parameters) + + + request = build_get_by_billing_period_request( + subscription_id=self._config.subscription_id, + billing_period_name=billing_period_name, + expand=expand, + skiptoken=skiptoken, + top=top, + template_url=self.get_by_billing_period.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PriceSheetResult', pipeline_response) @@ -188,4 +260,6 @@ def get_by_billing_period( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_period.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendation_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendation_details_operations.py index 103b363b2977..b6e1088d5cf5 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendation_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendation_details_operations.py @@ -5,23 +5,72 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + region = kwargs.pop('region') # type: str + term = kwargs.pop('term') # type: Union[str, "_models.Term"] + look_back_period = kwargs.pop('look_back_period') # type: Union[str, "_models.LookBackPeriod"] + product = kwargs.pop('product') # type: str + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/reservationRecommendationDetails') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['region'] = _SERIALIZER.query("region", region, 'str') + query_parameters['term'] = _SERIALIZER.query("term", term, 'str') + query_parameters['lookBackPeriod'] = _SERIALIZER.query("look_back_period", look_back_period, 'str') + query_parameters['product'] = _SERIALIZER.query("product", product, '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 + ) + +# fmt: on class ReservationRecommendationDetailsOperations(object): """ReservationRecommendationDetailsOperations operations. @@ -44,10 +93,10 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - billing_scope, # type: str - scope, # type: Union[str, "_models.Scope"] + scope, # type: str region, # type: str term, # type: Union[str, "_models.Term"] look_back_period, # type: Union[str, "_models.LookBackPeriod"] @@ -57,15 +106,13 @@ def get( # type: (...) -> Optional["_models.ReservationRecommendationDetailsModel"] """Details of a reservation recommendation for what-if analysis of reserved instances. - :param billing_scope: The scope associated with reservation recommendation details operations. - This includes '/subscriptions/{subscriptionId}/' for subscription scope, + :param scope: The scope associated with reservation recommendation details operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope. - :type billing_scope: str - :param scope: Scope of the reservation. - :type scope: str or ~azure.mgmt.consumption.models.Scope + :type scope: str :param region: Used to select the region the recommendation should be generated for. :type region: str :param term: Specify length of reservation recommendation term. @@ -86,36 +133,25 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingScope': self._serialize.url("billing_scope", billing_scope, 'str', skip_quote=True), - } - 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') - query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - query_parameters['region'] = self._serialize.query("region", region, 'str') - query_parameters['term'] = self._serialize.query("term", term, 'str') - query_parameters['lookBackPeriod'] = self._serialize.query("look_back_period", look_back_period, 'str') - query_parameters['product'] = self._serialize.query("product", product, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + region=region, + term=term, + look_back_period=look_back_period, + product=product, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 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.HighCasedErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -126,4 +162,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{billingScope}/providers/Microsoft.Consumption/reservationRecommendationDetails'} # type: ignore + + get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationRecommendationDetails'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendations_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendations_operations.py index 4ccabe6916da..0a4ea627d5e0 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendations_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendations_operations.py @@ -5,24 +5,68 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/reservationRecommendations') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ReservationRecommendationsOperations(object): """ReservationRecommendationsOperations operations. @@ -45,6 +89,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope, # type: str @@ -70,8 +115,10 @@ def list( default value 'Last7Days'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationRecommendationsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationRecommendationsListResultor None] + :return: An iterator like instance of either ReservationRecommendationsListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationRecommendationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationRecommendationsListResult"] @@ -79,36 +126,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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( + scope=scope, + filter=filter, + 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( + scope=scope, + filter=filter, + 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('ReservationRecommendationsListResult', pipeline_response) + deserialized = self._deserialize("ReservationRecommendationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,12 +163,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200, 204]: - 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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_transactions_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_transactions_operations.py index 6a880e33d835..681723c81148 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_transactions_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_transactions_operations.py @@ -5,24 +5,106 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + billing_account_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + 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_billing_profile_request( + billing_account_id, # type: str + billing_profile_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/reservationTransactions') + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + "billingProfileId": _SERIALIZER.url("billing_profile_id", billing_profile_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + 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 + ) + +# fmt: on class ReservationTransactionsOperations(object): """ReservationTransactionsOperations operations. @@ -45,6 +127,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, billing_account_id, # type: str @@ -60,8 +143,10 @@ def list( start date and end date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationTransactionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationTransactionsListResult] + :return: An iterator like instance of either ReservationTransactionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationTransactionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationTransactionsListResult"] @@ -69,36 +154,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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( + billing_account_id=billing_account_id, + filter=filter, + 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( + billing_account_id=billing_account_id, + filter=filter, + 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('ReservationTransactionsListResult', pipeline_response) + deserialized = self._deserialize("ReservationTransactionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,17 +191,19 @@ 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': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_id, # type: str @@ -140,8 +222,10 @@ def list_by_billing_profile( start date and end date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ModernReservationTransactionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ModernReservationTransactionsListResult] + :return: An iterator like instance of either ModernReservationTransactionsListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ModernReservationTransactionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ModernReservationTransactionsListResult"] @@ -149,37 +233,33 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - 'billingProfileId': self._serialize.url("billing_profile_id", billing_profile_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + filter=filter, + template_url=self.list_by_billing_profile.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_billing_profile_request( + billing_account_id=billing_account_id, + billing_profile_id=billing_profile_id, + filter=filter, + 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('ModernReservationTransactionsListResult', pipeline_response) + deserialized = self._deserialize("ModernReservationTransactionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -192,12 +272,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_details_operations.py index f36ae1dea425..11b8129a99f8 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_details_operations.py @@ -5,24 +5,152 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_reservation_order_request( + reservation_order_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter') # type: str + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails') + path_format_arguments = { + "reservationOrderId": _SERIALIZER.url("reservation_order_id", reservation_order_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_reservation_order_and_reservation_request( + reservation_order_id, # type: str + reservation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter') # type: str + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails') + path_format_arguments = { + "reservationOrderId": _SERIALIZER.url("reservation_order_id", reservation_order_id, 'str'), + "reservationId": _SERIALIZER.url("reservation_id", reservation_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + start_date = kwargs.pop('start_date', None) # type: Optional[str] + end_date = kwargs.pop('end_date', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + reservation_id = kwargs.pop('reservation_id', None) # type: Optional[str] + reservation_order_id = kwargs.pop('reservation_order_id', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/reservationDetails') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if start_date is not None: + query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') + if end_date is not None: + query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if reservation_id is not None: + query_parameters['reservationId'] = _SERIALIZER.query("reservation_id", reservation_id, 'str') + if reservation_order_id is not None: + query_parameters['reservationOrderId'] = _SERIALIZER.query("reservation_order_id", reservation_order_id, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ReservationsDetailsOperations(object): """ReservationsDetailsOperations operations. @@ -45,6 +173,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_reservation_order( self, reservation_order_id, # type: str @@ -60,8 +189,10 @@ def list_by_reservation_order( date and end date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationDetailsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] + :return: An iterator like instance of either ReservationDetailsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] @@ -69,35 +200,31 @@ def list_by_reservation_order( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_reservation_order.metadata['url'] # type: ignore - path_format_arguments = { - 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_reservation_order_request( + reservation_order_id=reservation_order_id, + filter=filter, + template_url=self.list_by_reservation_order.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_reservation_order_request( + reservation_order_id=reservation_order_id, + filter=filter, + 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('ReservationDetailsListResult', pipeline_response) + deserialized = self._deserialize("ReservationDetailsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,17 +237,19 @@ 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_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + @distributed_trace def list_by_reservation_order_and_reservation( self, reservation_order_id, # type: str @@ -139,8 +268,10 @@ def list_by_reservation_order_and_reservation( date and end date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationDetailsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] + :return: An iterator like instance of either ReservationDetailsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] @@ -148,36 +279,33 @@ def list_by_reservation_order_and_reservation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_reservation_order_and_reservation.metadata['url'] # type: ignore - path_format_arguments = { - 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), - 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_reservation_order_and_reservation_request( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + filter=filter, + template_url=self.list_by_reservation_order_and_reservation.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_reservation_order_and_reservation_request( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + filter=filter, + 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('ReservationDetailsListResult', pipeline_response) + deserialized = self._deserialize("ReservationDetailsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -190,17 +318,19 @@ 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_reservation_order_and_reservation.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + @distributed_trace def list( self, scope, # type: str @@ -235,8 +365,10 @@ def list( Filter to a specific reservation order. :type reservation_order_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationDetailsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] + :return: An iterator like instance of either ReservationDetailsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] @@ -244,44 +376,39 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if start_date is not None: - query_parameters['startDate'] = self._serialize.query("start_date", start_date, 'str') - if end_date is not None: - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if reservation_id is not None: - query_parameters['reservationId'] = self._serialize.query("reservation_id", reservation_id, 'str') - if reservation_order_id is not None: - query_parameters['reservationOrderId'] = self._serialize.query("reservation_order_id", reservation_order_id, 'str') - 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( + scope=scope, + start_date=start_date, + end_date=end_date, + filter=filter, + reservation_id=reservation_id, + reservation_order_id=reservation_order_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( + scope=scope, + start_date=start_date, + end_date=end_date, + filter=filter, + reservation_id=reservation_id, + reservation_order_id=reservation_order_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('ReservationDetailsListResult', pipeline_response) + deserialized = self._deserialize("ReservationDetailsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -294,12 +421,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_summaries_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_summaries_operations.py index 3a8ed1bb990b..0eb6f348b0fb 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_summaries_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_summaries_operations.py @@ -5,24 +5,160 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_reservation_order_request( + reservation_order_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + grain = kwargs.pop('grain') # type: Union[str, "_models.Datagrain"] + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries') + path_format_arguments = { + "reservationOrderId": _SERIALIZER.url("reservation_order_id", reservation_order_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_reservation_order_and_reservation_request( + reservation_order_id, # type: str + reservation_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + grain = kwargs.pop('grain') # type: Union[str, "_models.Datagrain"] + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries') + path_format_arguments = { + "reservationOrderId": _SERIALIZER.url("reservation_order_id", reservation_order_id, 'str'), + "reservationId": _SERIALIZER.url("reservation_id", reservation_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + grain = kwargs.pop('grain') # type: Union[str, "_models.Datagrain"] + start_date = kwargs.pop('start_date', None) # type: Optional[str] + end_date = kwargs.pop('end_date', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + reservation_id = kwargs.pop('reservation_id', None) # type: Optional[str] + reservation_order_id = kwargs.pop('reservation_order_id', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/reservationSummaries') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') + if start_date is not None: + query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') + if end_date is not None: + query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if reservation_id is not None: + query_parameters['reservationId'] = _SERIALIZER.query("reservation_id", reservation_id, 'str') + if reservation_order_id is not None: + query_parameters['reservationOrderId'] = _SERIALIZER.query("reservation_order_id", reservation_order_id, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ReservationsSummariesOperations(object): """ReservationsSummariesOperations operations. @@ -45,6 +181,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_reservation_order( self, reservation_order_id, # type: str @@ -63,8 +200,10 @@ def list_by_reservation_order( date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationSummariesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] + :return: An iterator like instance of either ReservationSummariesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] @@ -72,37 +211,33 @@ def list_by_reservation_order( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_reservation_order.metadata['url'] # type: ignore - path_format_arguments = { - 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['grain'] = self._serialize.query("grain", grain, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_reservation_order_request( + reservation_order_id=reservation_order_id, + grain=grain, + filter=filter, + template_url=self.list_by_reservation_order.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_reservation_order_request( + reservation_order_id=reservation_order_id, + grain=grain, + filter=filter, + 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('ReservationSummariesListResult', pipeline_response) + deserialized = self._deserialize("ReservationSummariesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,17 +250,19 @@ 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_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + @distributed_trace def list_by_reservation_order_and_reservation( self, reservation_order_id, # type: str @@ -147,8 +284,10 @@ def list_by_reservation_order_and_reservation( date. The filter supports 'le' and 'ge'. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationSummariesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] + :return: An iterator like instance of either ReservationSummariesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] @@ -156,38 +295,35 @@ def list_by_reservation_order_and_reservation( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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_reservation_order_and_reservation.metadata['url'] # type: ignore - path_format_arguments = { - 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), - 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['grain'] = self._serialize.query("grain", grain, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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_reservation_order_and_reservation_request( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + grain=grain, + filter=filter, + template_url=self.list_by_reservation_order_and_reservation.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_reservation_order_and_reservation_request( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + grain=grain, + filter=filter, + 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('ReservationSummariesListResult', pipeline_response) + deserialized = self._deserialize("ReservationSummariesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -200,17 +336,19 @@ 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_reservation_order_and_reservation.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + @distributed_trace def list( self, scope, # type: str @@ -247,8 +385,10 @@ def list( Filter to a specific reservation order. :type reservation_order_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationSummariesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] + :return: An iterator like instance of either ReservationSummariesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] @@ -256,45 +396,41 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['grain'] = self._serialize.query("grain", grain, 'str') - if start_date is not None: - query_parameters['startDate'] = self._serialize.query("start_date", start_date, 'str') - if end_date is not None: - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if reservation_id is not None: - query_parameters['reservationId'] = self._serialize.query("reservation_id", reservation_id, 'str') - if reservation_order_id is not None: - query_parameters['reservationOrderId'] = self._serialize.query("reservation_order_id", reservation_order_id, 'str') - 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( + scope=scope, + grain=grain, + start_date=start_date, + end_date=end_date, + filter=filter, + reservation_id=reservation_id, + reservation_order_id=reservation_order_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( + scope=scope, + grain=grain, + start_date=start_date, + end_date=end_date, + filter=filter, + reservation_id=reservation_id, + reservation_order_id=reservation_order_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('ReservationSummariesListResult', pipeline_response) + deserialized = self._deserialize("ReservationSummariesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -307,12 +443,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/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_tags_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_tags_operations.py index e6cedfb6f459..9a0a2cc26237 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_tags_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_tags_operations.py @@ -5,23 +5,63 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/tags') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class TagsOperations(object): """TagsOperations operations. @@ -44,12 +84,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, scope, # type: str **kwargs # type: Any ): - # type: (...) -> "_models.TagsResult" + # type: (...) -> Optional["_models.TagsResult"] """Get all available tag keys for the defined scope. :param scope: The scope associated with tags operations. This includes @@ -65,45 +106,39 @@ def get( :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TagsResult, or the result of cls(response) - :rtype: ~azure.mgmt.consumption.models.TagsResult + :rtype: ~azure.mgmt.consumption.models.TagsResult or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TagsResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.TagsResult"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - 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 = build_get_request( + scope=scope, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - 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]: + 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) - deserialized = self._deserialize('TagsResult', pipeline_response) + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('TagsResult', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/tags'} # type: ignore + diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_usage_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_usage_details_operations.py index ea7090e301f1..b6fe4ec97162 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_usage_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_usage_details_operations.py @@ -5,24 +5,80 @@ # 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 TYPE_CHECKING 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 +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + skiptoken = kwargs.pop('skiptoken', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + metric = kwargs.pop('metric', None) # type: Optional[Union[str, "_models.Metrictype"]] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/usageDetails') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if metric is not None: + query_parameters['metric'] = _SERIALIZER.query("metric", metric, '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 + ) + +# fmt: on class UsageDetailsOperations(object): """UsageDetailsOperations operations. @@ -45,6 +101,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope, # type: str @@ -100,7 +157,8 @@ def list( :param metric: Allows to select different type of cost/usage records. :type metric: str or ~azure.mgmt.consumption.models.Metrictype :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageDetailsListResult or the result of cls(response) + :return: An iterator like instance of either UsageDetailsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.UsageDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -109,44 +167,39 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-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 = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if metric is not None: - query_parameters['metric'] = self._serialize.query("metric", metric, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + expand=expand, + filter=filter, + skiptoken=skiptoken, + top=top, + metric=metric, + 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( + scope=scope, + expand=expand, + filter=filter, + skiptoken=skiptoken, + top=top, + metric=metric, + 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('UsageDetailsListResult', pipeline_response) + deserialized = self._deserialize("UsageDetailsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -158,13 +211,14 @@ def get_next(next_link=None): pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data )