From ae751c4b5e15bdc503e6a0bdd0103887dca3e01e Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 17 Dec 2021 02:26:17 +0000 Subject: [PATCH] CodeGen from PR 17124 in Azure/azure-rest-api-specs Revert dataset spelling change (#17124) --- .../azure-mgmt-costmanagement/_meta.json | 10 +- .../azure/mgmt/costmanagement/__init__.py | 9 +- .../mgmt/costmanagement/_configuration.py | 8 +- .../costmanagement/_cost_management_client.py | 117 +- .../azure/mgmt/costmanagement/_metadata.json | 34 +- .../azure/mgmt/costmanagement/_patch.py | 31 + .../azure/mgmt/costmanagement/_vendor.py | 27 + .../azure/mgmt/costmanagement/_version.py | 2 +- .../azure/mgmt/costmanagement/aio/__init__.py | 5 + .../mgmt/costmanagement/aio/_configuration.py | 8 +- .../aio/_cost_management_client.py | 117 +- .../azure/mgmt/costmanagement/aio/_patch.py | 31 + .../costmanagement/aio/operations/__init__.py | 14 +- .../aio/operations/_alerts_operations.py | 141 +- .../aio/operations/_dimensions_operations.py | 145 +- .../aio/operations/_exports_operations.py | 224 +- .../aio/operations/_forecast_operations.py | 105 +- ...ost_report_operation_results_operations.py | 111 + ...cost_report_operation_status_operations.py | 109 + ...enerate_detailed_cost_report_operations.py | 183 ++ ...e_reservation_details_report_operations.py | 302 --- .../aio/operations/_operations.py | 47 +- .../aio/operations/_query_operations.py | 87 +- .../aio/operations/_settings_operations.py | 273 -- .../aio/operations/_views_operations.py | 291 +-- .../mgmt/costmanagement/models/__init__.py | 57 +- .../models/_cost_management_client_enums.py | 128 +- .../mgmt/costmanagement/models/_models.py | 2131 +++++++++++----- .../mgmt/costmanagement/models/_models_py3.py | 2266 +++++++++++------ .../costmanagement/operations/__init__.py | 14 +- .../operations/_alerts_operations.py | 283 +- .../operations/_dimensions_operations.py | 236 +- .../operations/_exports_operations.py | 442 +++- .../operations/_forecast_operations.py | 189 +- ...ost_report_operation_results_operations.py | 154 ++ ...cost_report_operation_status_operations.py | 152 ++ ...enerate_detailed_cost_report_operations.py | 229 ++ ...e_reservation_details_report_operations.py | 310 --- .../costmanagement/operations/_operations.py | 73 +- .../operations/_query_operations.py | 165 +- .../operations/_settings_operations.py | 281 -- .../operations/_views_operations.py | 556 ++-- 42 files changed, 6146 insertions(+), 3951 deletions(-) create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_patch.py create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_vendor.py create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_patch.py create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operation_results_operations.py create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operation_status_operations.py create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operations.py delete mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_reservation_details_report_operations.py delete mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_settings_operations.py create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operation_results_operations.py create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operation_status_operations.py create mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operations.py delete mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_reservation_details_report_operations.py delete mode 100644 sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_settings_operations.py diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/_meta.json b/sdk/costmanagement/azure-mgmt-costmanagement/_meta.json index 8041e01d515b..2e71485759df 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/_meta.json +++ b/sdk/costmanagement/azure-mgmt-costmanagement/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "74efe54fbc55c91a1d9213afbb2723747acfddf9", + "commit": "e6d1396612965f2af8df6bb941be19681147930a", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/cost-management/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.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/cost-management/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/cost-management/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/__init__.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/__init__.py index 0e26ee2701fe..b76c817829ba 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/__init__.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['CostManagementClient'] -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/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_configuration.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_configuration.py index 0cd20f8ef97a..aa31aa4f43e7 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_configuration.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_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 @@ -37,12 +37,12 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(CostManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(CostManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2019-11-01" + self.api_version = "2021-10-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-costmanagement/{}'.format(VERSION)) self._configure(**kwargs) @@ -62,4 +62,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/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_cost_management_client.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_cost_management_client.py index 521cb5222a88..4f8367674952 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_cost_management_client.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_cost_management_client.py @@ -6,36 +6,39 @@ # 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 CostManagementClientConfiguration +from .operations import AlertsOperations, DimensionsOperations, ExportsOperations, ForecastOperations, GenerateDetailedCostReportOperationResultsOperations, GenerateDetailedCostReportOperationStatusOperations, GenerateDetailedCostReportOperations, Operations, QueryOperations, ViewsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import CostManagementClientConfiguration -from .operations import SettingsOperations -from .operations import ViewsOperations -from .operations import AlertsOperations -from .operations import ForecastOperations -from .operations import DimensionsOperations -from .operations import QueryOperations -from .operations import GenerateReservationDetailsReportOperations -from .operations import Operations -from .operations import ExportsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class CostManagementClient(object): """CostManagementClient. - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.costmanagement.operations.SettingsOperations + :ivar exports: ExportsOperations operations + :vartype exports: azure.mgmt.costmanagement.operations.ExportsOperations + :ivar generate_detailed_cost_report: GenerateDetailedCostReportOperations operations + :vartype generate_detailed_cost_report: + azure.mgmt.costmanagement.operations.GenerateDetailedCostReportOperations + :ivar generate_detailed_cost_report_operation_results: + GenerateDetailedCostReportOperationResultsOperations operations + :vartype generate_detailed_cost_report_operation_results: + azure.mgmt.costmanagement.operations.GenerateDetailedCostReportOperationResultsOperations + :ivar generate_detailed_cost_report_operation_status: + GenerateDetailedCostReportOperationStatusOperations operations + :vartype generate_detailed_cost_report_operation_status: + azure.mgmt.costmanagement.operations.GenerateDetailedCostReportOperationStatusOperations :ivar views: ViewsOperations operations :vartype views: azure.mgmt.costmanagement.operations.ViewsOperations :ivar alerts: AlertsOperations operations @@ -46,68 +49,68 @@ class CostManagementClient(object): :vartype dimensions: azure.mgmt.costmanagement.operations.DimensionsOperations :ivar query: QueryOperations operations :vartype query: azure.mgmt.costmanagement.operations.QueryOperations - :ivar generate_reservation_details_report: GenerateReservationDetailsReportOperations operations - :vartype generate_reservation_details_report: azure.mgmt.costmanagement.operations.GenerateReservationDetailsReportOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.costmanagement.operations.Operations - :ivar exports: ExportsOperations operations - :vartype exports: azure.mgmt.costmanagement.operations.ExportsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential, # type: "TokenCredential" - 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 = CostManagementClientConfiguration(credential, **kwargs) + self._config = CostManagementClientConfiguration(credential=credential, **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.settings = SettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.views = ViewsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.forecast = ForecastOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dimensions = DimensionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.query = QueryOperations( - self._client, self._config, self._serialize, self._deserialize) - self.generate_reservation_details_report = GenerateReservationDetailsReportOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.exports = ExportsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.exports = ExportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.generate_detailed_cost_report = GenerateDetailedCostReportOperations(self._client, self._config, self._serialize, self._deserialize) + self.generate_detailed_cost_report_operation_results = GenerateDetailedCostReportOperationResultsOperations(self._client, self._config, self._serialize, self._deserialize) + self.generate_detailed_cost_report_operation_status = GenerateDetailedCostReportOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.views = ViewsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.forecast = ForecastOperations(self._client, self._config, self._serialize, self._deserialize) + self.dimensions = DimensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.query = QueryOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_metadata.json b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_metadata.json index 1e323f28f6ac..87eba179231a 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_metadata.json +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2019-11-01", - "total_api_version_list": ["2019-11-01"], + "chosen_version": "2021-10-01", + "total_api_version_list": ["2021-10-01"], "client": { "name": "CostManagementClient", "filename": "_cost_management_client", "description": "CostManagementClient.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CostManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CostManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"CostManagementClientConfiguration\"]}}, \"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\": [\"CostManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,21 +79,21 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { - "settings": "SettingsOperations", + "exports": "ExportsOperations", + "generate_detailed_cost_report": "GenerateDetailedCostReportOperations", + "generate_detailed_cost_report_operation_results": "GenerateDetailedCostReportOperationResultsOperations", + "generate_detailed_cost_report_operation_status": "GenerateDetailedCostReportOperationStatusOperations", "views": "ViewsOperations", "alerts": "AlertsOperations", "forecast": "ForecastOperations", "dimensions": "DimensionsOperations", "query": "QueryOperations", - "generate_reservation_details_report": "GenerateReservationDetailsReportOperations", - "operations": "Operations", - "exports": "ExportsOperations" + "operations": "Operations" } } \ No newline at end of file diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_patch.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_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/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_vendor.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_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/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_version.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_version.py index cac9f5d10f8b..e5754a47ce68 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_version.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/__init__.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/__init__.py index 7dec206f98a6..b07c11ae6b2c 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/__init__.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/__init__.py @@ -8,3 +8,8 @@ from ._cost_management_client import CostManagementClient __all__ = ['CostManagementClient'] + +# `._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/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_configuration.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_configuration.py index 22c0705a007a..90b558be396e 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_configuration.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/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 @@ -34,12 +34,12 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(CostManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(CostManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2019-11-01" + self.api_version = "2021-10-01" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-costmanagement/{}'.format(VERSION)) self._configure(**kwargs) @@ -58,4 +58,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/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_cost_management_client.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_cost_management_client.py index ab4f0f5bdab7..be54755a82a6 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_cost_management_client.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_cost_management_client.py @@ -6,34 +6,37 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import CostManagementClientConfiguration +from .operations import AlertsOperations, DimensionsOperations, ExportsOperations, ForecastOperations, GenerateDetailedCostReportOperationResultsOperations, GenerateDetailedCostReportOperationStatusOperations, GenerateDetailedCostReportOperations, Operations, QueryOperations, ViewsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import CostManagementClientConfiguration -from .operations import SettingsOperations -from .operations import ViewsOperations -from .operations import AlertsOperations -from .operations import ForecastOperations -from .operations import DimensionsOperations -from .operations import QueryOperations -from .operations import GenerateReservationDetailsReportOperations -from .operations import Operations -from .operations import ExportsOperations -from .. import models - - -class CostManagementClient(object): +class CostManagementClient: """CostManagementClient. - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.costmanagement.aio.operations.SettingsOperations + :ivar exports: ExportsOperations operations + :vartype exports: azure.mgmt.costmanagement.aio.operations.ExportsOperations + :ivar generate_detailed_cost_report: GenerateDetailedCostReportOperations operations + :vartype generate_detailed_cost_report: + azure.mgmt.costmanagement.aio.operations.GenerateDetailedCostReportOperations + :ivar generate_detailed_cost_report_operation_results: + GenerateDetailedCostReportOperationResultsOperations operations + :vartype generate_detailed_cost_report_operation_results: + azure.mgmt.costmanagement.aio.operations.GenerateDetailedCostReportOperationResultsOperations + :ivar generate_detailed_cost_report_operation_status: + GenerateDetailedCostReportOperationStatusOperations operations + :vartype generate_detailed_cost_report_operation_status: + azure.mgmt.costmanagement.aio.operations.GenerateDetailedCostReportOperationStatusOperations :ivar views: ViewsOperations operations :vartype views: azure.mgmt.costmanagement.aio.operations.ViewsOperations :ivar alerts: AlertsOperations operations @@ -44,66 +47,66 @@ class CostManagementClient(object): :vartype dimensions: azure.mgmt.costmanagement.aio.operations.DimensionsOperations :ivar query: QueryOperations operations :vartype query: azure.mgmt.costmanagement.aio.operations.QueryOperations - :ivar generate_reservation_details_report: GenerateReservationDetailsReportOperations operations - :vartype generate_reservation_details_report: azure.mgmt.costmanagement.aio.operations.GenerateReservationDetailsReportOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.costmanagement.aio.operations.Operations - :ivar exports: ExportsOperations operations - :vartype exports: azure.mgmt.costmanagement.aio.operations.ExportsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", - 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 = CostManagementClientConfiguration(credential, **kwargs) + self._config = CostManagementClientConfiguration(credential=credential, **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.exports = ExportsOperations(self._client, self._config, self._serialize, self._deserialize) + self.generate_detailed_cost_report = GenerateDetailedCostReportOperations(self._client, self._config, self._serialize, self._deserialize) + self.generate_detailed_cost_report_operation_results = GenerateDetailedCostReportOperationResultsOperations(self._client, self._config, self._serialize, self._deserialize) + self.generate_detailed_cost_report_operation_status = GenerateDetailedCostReportOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.views = ViewsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.forecast = ForecastOperations(self._client, self._config, self._serialize, self._deserialize) + self.dimensions = DimensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.query = QueryOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.settings = SettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.views = ViewsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.forecast = ForecastOperations( - self._client, self._config, self._serialize, self._deserialize) - self.dimensions = DimensionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.query = QueryOperations( - self._client, self._config, self._serialize, self._deserialize) - self.generate_reservation_details_report = GenerateReservationDetailsReportOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.exports = ExportsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_patch.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/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/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/__init__.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/__init__.py index c70a4cb564cb..4ee0774295e4 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/__init__.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/__init__.py @@ -6,24 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._settings_operations import SettingsOperations +from ._exports_operations import ExportsOperations +from ._generate_detailed_cost_report_operations import GenerateDetailedCostReportOperations +from ._generate_detailed_cost_report_operation_results_operations import GenerateDetailedCostReportOperationResultsOperations +from ._generate_detailed_cost_report_operation_status_operations import GenerateDetailedCostReportOperationStatusOperations from ._views_operations import ViewsOperations from ._alerts_operations import AlertsOperations from ._forecast_operations import ForecastOperations from ._dimensions_operations import DimensionsOperations from ._query_operations import QueryOperations -from ._generate_reservation_details_report_operations import GenerateReservationDetailsReportOperations from ._operations import Operations -from ._exports_operations import ExportsOperations __all__ = [ - 'SettingsOperations', + 'ExportsOperations', + 'GenerateDetailedCostReportOperations', + 'GenerateDetailedCostReportOperationResultsOperations', + 'GenerateDetailedCostReportOperationStatusOperations', 'ViewsOperations', 'AlertsOperations', 'ForecastOperations', 'DimensionsOperations', 'QueryOperations', - 'GenerateReservationDetailsReportOperations', 'Operations', - 'ExportsOperations', ] diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_alerts_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_alerts_operations.py index 216d5ebc7b21..1a3c24b373e3 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_alerts_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_alerts_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._alerts_operations import build_dismiss_request, build_get_request, build_list_external_request, 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, @@ -74,31 +79,21 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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') + + request = build_list_request( + scope=scope, + template_url=self.list.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsResult', pipeline_response) @@ -107,8 +102,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, @@ -146,32 +144,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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), - 'alertId': self._serialize.url("alert_id", alert_id, '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, + alert_id=alert_id, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -180,8 +168,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}'} # type: ignore + + @distributed_trace_async async def dismiss( self, scope: str, @@ -222,37 +213,27 @@ async def dismiss( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.dismiss.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'alertId': self._serialize.url("alert_id", alert_id, '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DismissAlertPayload') - # 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_dismiss_request( + scope=scope, + alert_id=alert_id, + content_type=content_type, + json=_json, + template_url=self.dismiss.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, 'DismissAlertPayload') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -261,8 +242,11 @@ async def dismiss( return cls(pipeline_response, deserialized, {}) return deserialized + dismiss.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}'} # type: ignore + + @distributed_trace_async async def list_external( self, external_cloud_provider_type: Union[str, "_models.ExternalCloudProviderType"], @@ -274,7 +258,8 @@ async def list_external( :param external_cloud_provider_type: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. - :type external_cloud_provider_type: str or ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType :param external_cloud_provider_id: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. :type external_cloud_provider_id: str @@ -288,32 +273,22 @@ async def list_external( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.list_external.metadata['url'] # type: ignore - path_format_arguments = { - 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), - 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_external_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + template_url=self.list_external.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsResult', pipeline_response) @@ -322,4 +297,6 @@ async def list_external( return cls(pipeline_response, deserialized, {}) return deserialized + list_external.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/alerts'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_dimensions_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_dimensions_operations.py index 090f2e992e2d..ff91f6a253e1 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_dimensions_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_dimensions_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._dimensions_operations import build_by_external_cloud_provider_type_request, 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, @@ -82,8 +88,10 @@ def list( :param top: May be used to limit the number of results to the most recent N dimension data. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DimensionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.DimensionsListResultor None] + :return: An iterator like instance of either DimensionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.DimensionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DimensionsListResult"] @@ -91,42 +99,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + expand=expand, + skiptoken=skiptoken, + top=top, + 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, + expand=expand, + skiptoken=skiptoken, + top=top, + 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('DimensionsListResult', pipeline_response) + deserialized = self._deserialize("DimensionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -139,17 +142,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200, 204]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/dimensions'} # type: ignore + @distributed_trace def by_external_cloud_provider_type( self, external_cloud_provider_type: Union[str, "_models.ExternalCloudProviderType"], @@ -165,7 +170,8 @@ def by_external_cloud_provider_type( :param external_cloud_provider_type: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. - :type external_cloud_provider_type: str or ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType :param external_cloud_provider_id: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. :type external_cloud_provider_id: str @@ -182,8 +188,10 @@ def by_external_cloud_provider_type( :param top: May be used to limit the number of results to the most recent N dimension data. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DimensionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.DimensionsListResult] + :return: An iterator like instance of either DimensionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.DimensionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DimensionsListResult"] @@ -191,43 +199,39 @@ def by_external_cloud_provider_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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.by_external_cloud_provider_type.metadata['url'] # type: ignore - path_format_arguments = { - 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), - 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_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') - 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) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_by_external_cloud_provider_type_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + filter=filter, + expand=expand, + skiptoken=skiptoken, + top=top, + template_url=self.by_external_cloud_provider_type.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_by_external_cloud_provider_type_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + filter=filter, + expand=expand, + skiptoken=skiptoken, + top=top, + 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('DimensionsListResult', pipeline_response) + deserialized = self._deserialize("DimensionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -240,12 +244,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_exports_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_exports_operations.py index 2f3497eee08b..3ee74530e735 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_exports_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_exports_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._exports_operations import build_create_or_update_request, build_delete_request, build_execute_request, build_get_execution_history_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,14 +44,16 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, scope: str, + expand: Optional[str] = None, **kwargs: Any ) -> "_models.ExportListResult": """The operation to list all exports at the given scope. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -64,6 +70,9 @@ async def list( '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. :type scope: str + :param expand: May be used to expand the properties within an export. Currently only + 'runHistory' is supported and will return information for the last execution of each export. + :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ExportListResult, or the result of cls(response) :rtype: ~azure.mgmt.costmanagement.models.ExportListResult @@ -74,31 +83,22 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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') + + request = build_list_request( + scope=scope, + expand=expand, + template_url=self.list.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ExportListResult', pipeline_response) @@ -107,17 +107,21 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports'} # type: ignore + + @distributed_trace_async async def get( self, scope: str, export_name: str, + expand: Optional[str] = None, **kwargs: Any ) -> "_models.Export": """The operation to get the export for the defined scope by export name. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -136,6 +140,9 @@ async def get( :type scope: str :param export_name: Export Name. :type export_name: str + :param expand: May be used to expand the properties within an export. Currently only + 'runHistory' is supported and will return information for the last 10 executions of the export. + :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Export, or the result of cls(response) :rtype: ~azure.mgmt.costmanagement.models.Export @@ -146,32 +153,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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), - 'exportName': self._serialize.url("export_name", export_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, + export_name=export_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Export', pipeline_response) @@ -180,8 +178,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, scope: str, @@ -193,7 +194,7 @@ async def create_or_update( the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -224,37 +225,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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), - 'exportName': self._serialize.url("export_name", export_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, 'Export') - # 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, + export_name=export_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, 'Export') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -267,8 +258,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'} # type: ignore + + @distributed_trace_async async def delete( self, scope: str, @@ -277,7 +271,7 @@ async def delete( ) -> None: """The operation to delete a export. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -306,32 +300,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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), - 'exportName': self._serialize.url("export_name", export_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + scope=scope, + export_name=export_name, + template_url=self.delete.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.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -339,15 +323,17 @@ async def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'} # type: ignore + + @distributed_trace_async async def execute( self, scope: str, export_name: str, **kwargs: Any ) -> None: - """The operation to execute a export. + """The operation to execute an export. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -376,32 +362,22 @@ async def execute( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.execute.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'exportName': self._serialize.url("export_name", export_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_execute_request( + scope=scope, + export_name=export_name, + template_url=self.execute.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.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -409,15 +385,17 @@ async def execute( execute.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run'} # type: ignore + + @distributed_trace_async async def get_execution_history( self, scope: str, export_name: str, **kwargs: Any ) -> "_models.ExportExecutionListResult": - """The operation to get the execution history of an export for the defined scope by export name. + """The operation to get the execution history of an export for the defined scope and export name. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -446,32 +424,22 @@ async def get_execution_history( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get_execution_history.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'exportName': self._serialize.url("export_name", export_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_execution_history_request( + scope=scope, + export_name=export_name, + template_url=self.get_execution_history.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ExportExecutionListResult', pipeline_response) @@ -480,4 +448,6 @@ async def get_execution_history( return cls(pipeline_response, deserialized, {}) return deserialized + get_execution_history.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_forecast_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_forecast_operations.py index 8524f06621a5..f404bb475fcb 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_forecast_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_forecast_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._forecast_operations import build_external_cloud_provider_usage_request, build_usage_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 usage( self, scope: str, @@ -82,38 +87,27 @@ async def usage( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.usage.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') - - # 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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ForecastDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ForecastDefinition') + + request = build_usage_request( + scope=scope, + content_type=content_type, + json=_json, + filter=filter, + template_url=self.usage.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -124,8 +118,11 @@ async def usage( return cls(pipeline_response, deserialized, {}) return deserialized + usage.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/forecast'} # type: ignore + + @distributed_trace_async async def external_cloud_provider_usage( self, external_cloud_provider_type: Union[str, "_models.ExternalCloudProviderType"], @@ -139,7 +136,8 @@ async def external_cloud_provider_usage( :param external_cloud_provider_type: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. - :type external_cloud_provider_type: str or ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType :param external_cloud_provider_id: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. :type external_cloud_provider_id: str @@ -159,39 +157,28 @@ async def external_cloud_provider_usage( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.external_cloud_provider_usage.metadata['url'] # type: ignore - path_format_arguments = { - 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), - 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_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') - - # 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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ForecastDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ForecastDefinition') + + request = build_external_cloud_provider_usage_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + content_type=content_type, + json=_json, + filter=filter, + template_url=self.external_cloud_provider_usage.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QueryResult', pipeline_response) @@ -200,4 +187,6 @@ async def external_cloud_provider_usage( return cls(pipeline_response, deserialized, {}) return deserialized + external_cloud_provider_usage.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/forecast'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operation_results_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operation_results_operations.py new file mode 100644 index 000000000000..95116ff47700 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operation_results_operations.py @@ -0,0 +1,111 @@ +# 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. +# -------------------------------------------------------------------------- +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 +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._generate_detailed_cost_report_operation_results_operations import build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class GenerateDetailedCostReportOperationResultsOperations: + """GenerateDetailedCostReportOperationResultsOperations 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.costmanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + operation_id: str, + scope: str, + **kwargs: Any + ) -> Optional["_models.GenerateDetailedCostReportOperationResult"]: + """Get the result of the specified operation. This link is provided in the + GenerateDetailedCostReport creation request response header. + + :param operation_id: The target operation Id. + :type operation_id: str + :param scope: The scope associated with usage details operations. This includes + '/subscriptions/{subscriptionId}/' for subscription scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, + '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, + '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount + scope. Also, Modern Commerce Account scopes are + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenerateDetailedCostReportOperationResult, or the result of cls(response) + :rtype: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportOperationResult or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateDetailedCostReportOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + operation_id=operation_id, + scope=scope, + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenerateDetailedCostReportOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/operationResults/{operationId}'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operation_status_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operation_status_operations.py new file mode 100644 index 000000000000..c51c1c5a33e1 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operation_status_operations.py @@ -0,0 +1,109 @@ +# 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. +# -------------------------------------------------------------------------- +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 +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._generate_detailed_cost_report_operation_status_operations import build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class GenerateDetailedCostReportOperationStatusOperations: + """GenerateDetailedCostReportOperationStatusOperations 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.costmanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + operation_id: str, + scope: str, + **kwargs: Any + ) -> "_models.GenerateDetailedCostReportOperationStatuses": + """Get the status of the specified operation. This link is provided in the + GenerateDetailedCostReport creation request response header. + + :param operation_id: The target operation Id. + :type operation_id: str + :param scope: The scope associated with usage details operations. This includes + '/subscriptions/{subscriptionId}/' for subscription scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, + '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, + '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount + scope. Also, Modern Commerce Account scopes are + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenerateDetailedCostReportOperationStatuses, or the result of cls(response) + :rtype: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportOperationStatuses + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateDetailedCostReportOperationStatuses"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + operation_id=operation_id, + scope=scope, + 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.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenerateDetailedCostReportOperationStatuses', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/operationStatus/{operationId}'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operations.py new file mode 100644 index 000000000000..e13c25587ec8 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_detailed_cost_report_operations.py @@ -0,0 +1,183 @@ +# 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. +# -------------------------------------------------------------------------- +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._generate_detailed_cost_report_operations import build_create_operation_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class GenerateDetailedCostReportOperations: + """GenerateDetailedCostReportOperations 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.costmanagement.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 + + async def _create_operation_initial( + self, + scope: str, + parameters: "_models.GenerateDetailedCostReportDefinition", + **kwargs: Any + ) -> Optional["_models.GenerateDetailedCostReportOperationResult"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateDetailedCostReportOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenerateDetailedCostReportDefinition') + + request = build_create_operation_request_initial( + scope=scope, + content_type=content_type, + json=_json, + template_url=self._create_operation_initial.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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('GenerateDetailedCostReportOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Azure-Consumption-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-Consumption-AsyncOperation')) + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_operation_initial.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/generateDetailedCostReport'} # type: ignore + + + @distributed_trace_async + async def begin_create_operation( + self, + scope: str, + parameters: "_models.GenerateDetailedCostReportDefinition", + **kwargs: Any + ) -> AsyncLROPoller["_models.GenerateDetailedCostReportOperationResult"]: + """Generates the detailed cost report for provided date range, billing period(Only enterprise + customers) or Invoice Id asynchronously at a certain scope. Call returns a 202 with header + Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the + operation will provide the status and if the operation is completed the blob file where + generated detailed cost report is being stored. + + :param scope: The scope associated with usage details operations. This includes + '/subscriptions/{subscriptionId}/' for subscription scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, + '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, + '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount + scope. Also, Modern Commerce Account scopes are + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :param parameters: Parameters supplied to the Create detailed cost report operation. + :type parameters: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either + GenerateDetailedCostReportOperationResult or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.costmanagement.models.GenerateDetailedCostReportOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateDetailedCostReportOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_operation_initial( + scope=scope, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('GenerateDetailedCostReportOperationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_operation.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/generateDetailedCostReport'} # type: ignore diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_reservation_details_report_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_reservation_details_report_operations.py deleted file mode 100644 index 04654269eb88..000000000000 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_generate_reservation_details_report_operations.py +++ /dev/null @@ -1,302 +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, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class GenerateReservationDetailsReportOperations: - """GenerateReservationDetailsReportOperations 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.costmanagement.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 - - async def _by_billing_account_id_initial( - self, - billing_account_id: str, - start_date: str, - end_date: str, - **kwargs: Any - ) -> Optional["_models.OperationStatus"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatus"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self._by_billing_account_id_initial.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['startDate'] = self._serialize.query("start_date", start_date, 'str') - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - 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.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationStatus', pipeline_response) - - if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - _by_billing_account_id_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/generateReservationDetailsReport'} # type: ignore - - async def begin_by_billing_account_id( - self, - billing_account_id: str, - start_date: str, - end_date: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatus"]: - """Generates the reservations details report for provided date range asynchronously based on - enrollment id. - - :param billing_account_id: Enrollment ID (Legacy BillingAccount ID). - :type billing_account_id: str - :param start_date: Start Date. - :type start_date: str - :param end_date: End Date. - :type end_date: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either OperationStatus or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.costmanagement.models.OperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._by_billing_account_id_initial( - billing_account_id=billing_account_id, - start_date=start_date, - end_date=end_date, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationStatus', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_by_billing_account_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/generateReservationDetailsReport'} # type: ignore - - async def _by_billing_profile_id_initial( - self, - billing_account_id: str, - billing_profile_id: str, - start_date: str, - end_date: str, - **kwargs: Any - ) -> Optional["_models.OperationStatus"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatus"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self._by_billing_profile_id_initial.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['startDate'] = self._serialize.query("start_date", start_date, 'str') - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - 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.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationStatus', pipeline_response) - - if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - _by_billing_profile_id_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/generateReservationDetailsReport'} # type: ignore - - async def begin_by_billing_profile_id( - self, - billing_account_id: str, - billing_profile_id: str, - start_date: str, - end_date: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatus"]: - """Generates the reservations details report for provided date range asynchronously by billing - profile. - - :param billing_account_id: BillingAccount ID. - :type billing_account_id: str - :param billing_profile_id: BillingProfile ID. - :type billing_profile_id: str - :param start_date: Start Date. - :type start_date: str - :param end_date: End Date. - :type end_date: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either OperationStatus or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.costmanagement.models.OperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._by_billing_profile_id_initial( - billing_account_id=billing_account_id, - billing_profile_id=billing_profile_id, - start_date=start_date, - end_date=end_date, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationStatus', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - 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'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_by_billing_profile_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/generateReservationDetailsReport'} # type: ignore diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_operations.py index e9b536504b06..5326148fc87f 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/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,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :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.costmanagement.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.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-11-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.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_query_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_query_operations.py index 7a973c90e3c8..ebd8c5b44740 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_query_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_query_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._query_operations import build_usage_by_external_cloud_provider_type_request, build_usage_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 usage( self, scope: str, @@ -77,36 +82,26 @@ async def usage( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.usage.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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QueryDefinition') - # 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_usage_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.usage.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, 'QueryDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -117,8 +112,11 @@ async def usage( return cls(pipeline_response, deserialized, {}) return deserialized + usage.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/query'} # type: ignore + + @distributed_trace_async async def usage_by_external_cloud_provider_type( self, external_cloud_provider_type: Union[str, "_models.ExternalCloudProviderType"], @@ -131,7 +129,8 @@ async def usage_by_external_cloud_provider_type( :param external_cloud_provider_type: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. - :type external_cloud_provider_type: str or ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType :param external_cloud_provider_id: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. :type external_cloud_provider_id: str @@ -147,37 +146,27 @@ async def usage_by_external_cloud_provider_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.usage_by_external_cloud_provider_type.metadata['url'] # type: ignore - path_format_arguments = { - 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), - 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QueryDefinition') - # 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_usage_by_external_cloud_provider_type_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + content_type=content_type, + json=_json, + template_url=self.usage_by_external_cloud_provider_type.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, 'QueryDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QueryResult', pipeline_response) @@ -186,4 +175,6 @@ async def usage_by_external_cloud_provider_type( return cls(pipeline_response, deserialized, {}) return deserialized + usage_by_external_cloud_provider_type.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_settings_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_settings_operations.py deleted file mode 100644 index 2a0f8f9e272e..000000000000 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_settings_operations.py +++ /dev/null @@ -1,273 +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 SettingsOperations: - """SettingsOperations 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.costmanagement.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, - **kwargs: Any - ) -> AsyncIterable["_models.SettingsListResult"]: - """Lists all of the settings that have been customized. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SettingsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.SettingsListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SettingsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = 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('SettingsListResult', 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]: - error = self._deserialize.failsafe_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': '/providers/Microsoft.CostManagement/settings'} # type: ignore - - async def get( - self, - setting_name: str, - **kwargs: Any - ) -> "_models.Setting": - """Retrieves the current value for a specific setting. - - :param setting_name: Name of the setting. Allowed values: myscope. - :type setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Setting, or the result of cls(response) - :rtype: ~azure.mgmt.costmanagement.models.Setting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Setting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'settingName': self._serialize.url("setting_name", setting_name, 'str', max_length=32, min_length=0), - } - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Setting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/providers/Microsoft.CostManagement/settings/{settingName}'} # type: ignore - - async def create_or_update( - self, - setting_name: str, - parameters: "_models.Setting", - **kwargs: Any - ) -> "_models.Setting": - """Sets a new value for a specific setting. - - :param setting_name: Name of the setting. Allowed values: myscope. - :type setting_name: str - :param parameters: Body supplied to the CreateOrUpdate setting operation. - :type parameters: ~azure.mgmt.costmanagement.models.Setting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Setting, or the result of cls(response) - :rtype: ~azure.mgmt.costmanagement.models.Setting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Setting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = { - 'settingName': self._serialize.url("setting_name", setting_name, 'str', max_length=32, min_length=0), - } - 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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Setting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Setting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/providers/Microsoft.CostManagement/settings/{settingName}'} # type: ignore - - async def delete( - self, - setting_name: str, - **kwargs: Any - ) -> None: - """Remove the current value for a specific setting and reverts back to the default value, if - applicable. - - :param setting_name: Name of the setting. Allowed values: myscope. - :type setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'settingName': self._serialize.url("setting_name", setting_name, 'str', max_length=32, min_length=0), - } - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/providers/Microsoft.CostManagement/settings/{settingName}'} # type: ignore diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_views_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_views_operations.py index a82f547d6103..6d632d296fc8 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_views_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/aio/operations/_views_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._views_operations import build_create_or_update_by_scope_request, build_create_or_update_request, build_delete_by_scope_request, build_delete_request, build_get_by_scope_request, build_get_request, build_list_by_scope_request, 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, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ViewListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.ViewListResultor None] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.ViewListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ViewListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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('ViewListResult', pipeline_response) + deserialized = self._deserialize("ViewListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -92,18 +96,20 @@ 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, 204]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.metadata = {'url': '/providers/Microsoft.CostManagement/views'} # type: ignore + @distributed_trace def list_by_scope( self, scope: str, @@ -131,7 +137,8 @@ def list_by_scope( :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 ViewListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.ViewListResultor None] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.costmanagement.models.ViewListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ViewListResult"] @@ -139,34 +146,29 @@ def list_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, '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_scope_request( + scope=scope, + template_url=self.list_by_scope.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_scope_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('ViewListResult', pipeline_response) + deserialized = self._deserialize("ViewListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,18 +180,20 @@ 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, 204]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views'} # type: ignore + @distributed_trace_async async def get( self, view_name: str, @@ -209,31 +213,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'viewName': self._serialize.url("view_name", view_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( + view_name=view_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('View', pipeline_response) @@ -242,8 +236,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, view_name: str, @@ -268,36 +265,26 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = { - 'viewName': self._serialize.url("view_name", view_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'View') + + request = build_create_or_update_request( + view_name=view_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, 'View') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -310,8 +297,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace_async async def delete( self, view_name: str, @@ -331,31 +321,21 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'viewName': self._serialize.url("view_name", view_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( + view_name=view_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -363,6 +343,8 @@ async def delete( delete.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace_async async def get_by_scope( self, scope: str, @@ -401,32 +383,22 @@ async def get_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'viewName': self._serialize.url("view_name", view_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_by_scope_request( + scope=scope, + view_name=view_name, + template_url=self.get_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('View', pipeline_response) @@ -435,8 +407,11 @@ async def get_by_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace_async async def create_or_update_by_scope( self, scope: str, @@ -480,37 +455,27 @@ async def create_or_update_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'viewName': self._serialize.url("view_name", view_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, 'View') - # 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_by_scope_request( + scope=scope, + view_name=view_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_scope.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, 'View') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -523,8 +488,11 @@ async def create_or_update_by_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace_async async def delete_by_scope( self, scope: str, @@ -563,35 +531,26 @@ async def delete_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'viewName': self._serialize.url("view_name", view_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_by_scope_request( + scope=scope, + view_name=view_name, + template_url=self.delete_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py index c55fa14a8390..68abcd0d0b1d 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/__init__.py @@ -11,7 +11,6 @@ from ._models_py3 import AlertPropertiesDefinition from ._models_py3 import AlertPropertiesDetails from ._models_py3 import AlertsResult - from ._models_py3 import CacheItem from ._models_py3 import CommonExportProperties from ._models_py3 import Dimension from ._models_py3 import DimensionsListResult @@ -19,6 +18,8 @@ from ._models_py3 import ErrorDetails from ._models_py3 import ErrorResponse from ._models_py3 import Export + from ._models_py3 import ExportDataset + from ._models_py3 import ExportDatasetConfiguration from ._models_py3 import ExportDefinition from ._models_py3 import ExportDeliveryDestination from ._models_py3 import ExportDeliveryInfo @@ -28,24 +29,27 @@ from ._models_py3 import ExportProperties from ._models_py3 import ExportRecurrencePeriod from ._models_py3 import ExportSchedule + from ._models_py3 import ExportTimePeriod + from ._models_py3 import ForecastDataset from ._models_py3 import ForecastDefinition + from ._models_py3 import GenerateDetailedCostReportDefinition + from ._models_py3 import GenerateDetailedCostReportErrorResponse + from ._models_py3 import GenerateDetailedCostReportOperationResult + from ._models_py3 import GenerateDetailedCostReportOperationStatuses + from ._models_py3 import GenerateDetailedCostReportTimePeriod from ._models_py3 import KpiProperties from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult - from ._models_py3 import OperationStatus from ._models_py3 import PivotProperties from ._models_py3 import ProxyResource - from ._models_py3 import ProxySettingResource from ._models_py3 import QueryAggregation from ._models_py3 import QueryColumn from ._models_py3 import QueryComparisonExpression from ._models_py3 import QueryDataset - from ._models_py3 import QueryDatasetAutoGenerated from ._models_py3 import QueryDatasetConfiguration from ._models_py3 import QueryDefinition from ._models_py3 import QueryFilter - from ._models_py3 import QueryFilterAutoGenerated from ._models_py3 import QueryGrouping from ._models_py3 import QueryResult from ._models_py3 import QueryTimePeriod @@ -58,8 +62,7 @@ from ._models_py3 import ReportConfigSorting from ._models_py3 import ReportConfigTimePeriod from ._models_py3 import Resource - from ._models_py3 import Setting - from ._models_py3 import SettingsListResult + from ._models_py3 import ResourceAutoGenerated from ._models_py3 import Status from ._models_py3 import View from ._models_py3 import ViewListResult @@ -68,7 +71,6 @@ from ._models import AlertPropertiesDefinition # type: ignore from ._models import AlertPropertiesDetails # type: ignore from ._models import AlertsResult # type: ignore - from ._models import CacheItem # type: ignore from ._models import CommonExportProperties # type: ignore from ._models import Dimension # type: ignore from ._models import DimensionsListResult # type: ignore @@ -76,6 +78,8 @@ from ._models import ErrorDetails # type: ignore from ._models import ErrorResponse # type: ignore from ._models import Export # type: ignore + from ._models import ExportDataset # type: ignore + from ._models import ExportDatasetConfiguration # type: ignore from ._models import ExportDefinition # type: ignore from ._models import ExportDeliveryDestination # type: ignore from ._models import ExportDeliveryInfo # type: ignore @@ -85,24 +89,27 @@ from ._models import ExportProperties # type: ignore from ._models import ExportRecurrencePeriod # type: ignore from ._models import ExportSchedule # type: ignore + from ._models import ExportTimePeriod # type: ignore + from ._models import ForecastDataset # type: ignore from ._models import ForecastDefinition # type: ignore + from ._models import GenerateDetailedCostReportDefinition # type: ignore + from ._models import GenerateDetailedCostReportErrorResponse # type: ignore + from ._models import GenerateDetailedCostReportOperationResult # type: ignore + from ._models import GenerateDetailedCostReportOperationStatuses # type: ignore + from ._models import GenerateDetailedCostReportTimePeriod # type: ignore from ._models import KpiProperties # type: ignore from ._models import Operation # type: ignore from ._models import OperationDisplay # type: ignore from ._models import OperationListResult # type: ignore - from ._models import OperationStatus # type: ignore from ._models import PivotProperties # type: ignore from ._models import ProxyResource # type: ignore - from ._models import ProxySettingResource # type: ignore from ._models import QueryAggregation # type: ignore from ._models import QueryColumn # type: ignore from ._models import QueryComparisonExpression # type: ignore from ._models import QueryDataset # type: ignore - from ._models import QueryDatasetAutoGenerated # type: ignore from ._models import QueryDatasetConfiguration # type: ignore from ._models import QueryDefinition # type: ignore from ._models import QueryFilter # type: ignore - from ._models import QueryFilterAutoGenerated # type: ignore from ._models import QueryGrouping # type: ignore from ._models import QueryResult # type: ignore from ._models import QueryTimePeriod # type: ignore @@ -115,8 +122,7 @@ from ._models import ReportConfigSorting # type: ignore from ._models import ReportConfigTimePeriod # type: ignore from ._models import Resource # type: ignore - from ._models import Setting # type: ignore - from ._models import SettingsListResult # type: ignore + from ._models import ResourceAutoGenerated # type: ignore from ._models import Status # type: ignore from ._models import View # type: ignore from ._models import ViewListResult # type: ignore @@ -139,6 +145,7 @@ ForecastType, FormatType, FunctionType, + GenerateDetailedCostReportMetricType, GranularityType, KpiType, MetricType, @@ -146,13 +153,13 @@ OperatorType, PivotType, QueryColumnType, + QueryOperatorType, RecurrenceType, ReportConfigColumnType, ReportConfigSortingDirection, ReportGranularityType, ReportTimeframeType, ReportType, - SettingsPropertiesStartOn, StatusType, TimeframeType, ) @@ -162,7 +169,6 @@ 'AlertPropertiesDefinition', 'AlertPropertiesDetails', 'AlertsResult', - 'CacheItem', 'CommonExportProperties', 'Dimension', 'DimensionsListResult', @@ -170,6 +176,8 @@ 'ErrorDetails', 'ErrorResponse', 'Export', + 'ExportDataset', + 'ExportDatasetConfiguration', 'ExportDefinition', 'ExportDeliveryDestination', 'ExportDeliveryInfo', @@ -179,24 +187,27 @@ 'ExportProperties', 'ExportRecurrencePeriod', 'ExportSchedule', + 'ExportTimePeriod', + 'ForecastDataset', 'ForecastDefinition', + 'GenerateDetailedCostReportDefinition', + 'GenerateDetailedCostReportErrorResponse', + 'GenerateDetailedCostReportOperationResult', + 'GenerateDetailedCostReportOperationStatuses', + 'GenerateDetailedCostReportTimePeriod', 'KpiProperties', 'Operation', 'OperationDisplay', 'OperationListResult', - 'OperationStatus', 'PivotProperties', 'ProxyResource', - 'ProxySettingResource', 'QueryAggregation', 'QueryColumn', 'QueryComparisonExpression', 'QueryDataset', - 'QueryDatasetAutoGenerated', 'QueryDatasetConfiguration', 'QueryDefinition', 'QueryFilter', - 'QueryFilterAutoGenerated', 'QueryGrouping', 'QueryResult', 'QueryTimePeriod', @@ -209,8 +220,7 @@ 'ReportConfigSorting', 'ReportConfigTimePeriod', 'Resource', - 'Setting', - 'SettingsListResult', + 'ResourceAutoGenerated', 'Status', 'View', 'ViewListResult', @@ -231,6 +241,7 @@ 'ForecastType', 'FormatType', 'FunctionType', + 'GenerateDetailedCostReportMetricType', 'GranularityType', 'KpiType', 'MetricType', @@ -238,13 +249,13 @@ 'OperatorType', 'PivotType', 'QueryColumnType', + 'QueryOperatorType', 'RecurrenceType', 'ReportConfigColumnType', 'ReportConfigSortingDirection', 'ReportGranularityType', 'ReportTimeframeType', 'ReportType', - 'SettingsPropertiesStartOn', 'StatusType', 'TimeframeType', ] diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py index eac0fd7748ff..a2e2fd71b1ea 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_cost_management_client_enums.py @@ -6,34 +6,19 @@ # 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 AccumulatedType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccumulatedType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Show costs accumulated over time. """ TRUE = "true" FALSE = "false" -class AlertCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Alert category """ @@ -42,7 +27,7 @@ class AlertCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BILLING = "Billing" SYSTEM = "System" -class AlertCriteria(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertCriteria(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Criteria that triggered alert """ @@ -61,7 +46,7 @@ class AlertCriteria(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CROSS_CLOUD_COLLECTION_ERROR = "CrossCloudCollectionError" GENERAL_THRESHOLD_ERROR = "GeneralThresholdError" -class AlertOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """operator used to compare currentSpend with amount """ @@ -72,14 +57,14 @@ class AlertOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL_TO = "LessThanOrEqualTo" -class AlertSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Source of alert """ PRESET = "Preset" USER = "User" -class AlertStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """alert status """ @@ -89,7 +74,7 @@ class AlertStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RESOLVED = "Resolved" DISMISSED = "Dismissed" -class AlertTimeGrainType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertTimeGrainType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of timegrain cadence """ @@ -101,7 +86,7 @@ class AlertTimeGrainType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BILLING_QUARTER = "BillingQuarter" BILLING_ANNUAL = "BillingAnnual" -class AlertType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """type of alert """ @@ -113,7 +98,7 @@ class AlertType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): X_CLOUD = "xCloud" BUDGET_FORECAST = "BudgetForecast" -class ChartType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChartType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Chart type of the main view in Cost Analysis. Required. """ @@ -123,8 +108,8 @@ class ChartType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GROUPED_COLUMN = "GroupedColumn" TABLE = "Table" -class ExecutionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the export execution. +class ExecutionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The last known status of the export execution. """ QUEUED = "Queued" @@ -135,27 +120,28 @@ class ExecutionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NEW_DATA_NOT_AVAILABLE = "NewDataNotAvailable" DATA_NOT_AVAILABLE = "DataNotAvailable" -class ExecutionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExecutionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the export execution. """ ON_DEMAND = "OnDemand" SCHEDULED = "Scheduled" -class ExportType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the query. +class ExportType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to + exports that do not yet provide data for charges or amortization for service reservations. """ USAGE = "Usage" ACTUAL_COST = "ActualCost" AMORTIZED_COST = "AmortizedCost" -class ExternalCloudProviderType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ExternalCloudProviderType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EXTERNAL_SUBSCRIPTIONS = "externalSubscriptions" EXTERNAL_BILLING_ACCOUNTS = "externalBillingAccounts" -class ForecastTimeframeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ForecastTimeframeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The time frame for pulling data for the forecast. If custom, then a specific time period must be provided. """ @@ -167,7 +153,7 @@ class ForecastTimeframeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) WEEK_TO_DATE = "WeekToDate" CUSTOM = "Custom" -class ForecastType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ForecastType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the forecast. """ @@ -175,35 +161,39 @@ class ForecastType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ACTUAL_COST = "ActualCost" AMORTIZED_COST = "AmortizedCost" -class FormatType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The format of the export being delivered. +class FormatType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The format of the export being delivered. Currently only 'Csv' is supported. """ CSV = "Csv" -class FunctionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FunctionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the aggregation function to use. """ - AVG = "Avg" - MAX = "Max" - MIN = "Min" SUM = "Sum" -class GranularityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The granularity of rows in the query. +class GenerateDetailedCostReportMetricType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of the detailed report. By default ActualCost is provided + """ + + ACTUAL_COST = "ActualCost" + AMORTIZED_COST = "AmortizedCost" + +class GranularityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The granularity of rows in the export. Currently only 'Daily' is supported. """ DAILY = "Daily" -class KpiType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KpiType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """KPI type (Forecast, Budget). """ FORECAST = "Forecast" BUDGET = "Budget" -class MetricType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetricType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Metric to use when displaying costs. """ @@ -211,36 +201,46 @@ class MetricType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AMORTIZED_COST = "AmortizedCost" AHUB = "AHUB" -class OperationStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationStatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the long running operation. """ - RUNNING = "Running" + IN_PROGRESS = "InProgress" COMPLETED = "Completed" FAILED = "Failed" + QUEUED = "Queued" + NO_DATA_FOUND = "NoDataFound" + READY_TO_DOWNLOAD = "ReadyToDownload" + TIMED_OUT = "TimedOut" -class OperatorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operator to use for comparison. """ IN_ENUM = "In" CONTAINS = "Contains" -class PivotType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PivotType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Data type to show in view. """ DIMENSION = "Dimension" TAG_KEY = "TagKey" -class QueryColumnType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class QueryColumnType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the column in the export. """ TAG = "Tag" DIMENSION = "Dimension" -class RecurrenceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class QueryOperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The operator to use for comparison. + """ + + IN_ENUM = "In" + +class RecurrenceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The schedule recurrence. """ @@ -249,28 +249,28 @@ class RecurrenceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MONTHLY = "Monthly" ANNUALLY = "Annually" -class ReportConfigColumnType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReportConfigColumnType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the column in the report. """ TAG = "Tag" DIMENSION = "Dimension" -class ReportConfigSortingDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReportConfigSortingDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Direction of sort. """ ASCENDING = "Ascending" DESCENDING = "Descending" -class ReportGranularityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReportGranularityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The granularity of rows in the report. """ DAILY = "Daily" MONTHLY = "Monthly" -class ReportTimeframeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReportTimeframeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The time frame for pulling data for the report. If custom, then a specific time period must be provided. """ @@ -280,7 +280,7 @@ class ReportTimeframeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): YEAR_TO_DATE = "YearToDate" CUSTOM = "Custom" -class ReportType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReportType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. @@ -288,25 +288,15 @@ class ReportType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): USAGE = "Usage" -class SettingsPropertiesStartOn(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates what scope Cost Management in the Azure portal should default to. Allowed values: - LastUsed. - """ - - LAST_USED = "LastUsed" - SCOPE_PICKER = "ScopePicker" - SPECIFIC_SCOPE = "SpecificScope" - -class StatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the schedule. Whether active or not. If inactive, the export's scheduled - execution is paused. +class StatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The status of the export's schedule. If 'Inactive', the export's schedule is paused. """ ACTIVE = "Active" INACTIVE = "Inactive" -class TimeframeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The time frame for pulling data for the query. If custom, then a specific time period must be +class TimeframeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The time frame for pulling data for the export. If custom, then a specific time period must be provided. """ diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py index ffd3292fd2df..53d95649ca45 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models.py @@ -10,7 +10,7 @@ import msrest.serialization -class Resource(msrest.serialization.Model): +class ProxyResource(msrest.serialization.Model): """The Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -21,36 +21,41 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] + :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 """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'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'}, } def __init__( self, **kwargs ): - super(Resource, 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(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None self.type = None - self.tags = None + self.e_tag = kwargs.get('e_tag', None) -class Alert(Resource): +class Alert(ProxyResource): """An individual alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -61,45 +66,45 @@ class Alert(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 definition: defines the type of alert. - :type definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition - :param description: Alert description. - :type description: str - :param source: Source of alert. Possible values include: "Preset", "User". - :type source: str or ~azure.mgmt.costmanagement.models.AlertSource - :param details: Alert details. - :type details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails - :param cost_entity_id: related budget. - :type cost_entity_id: str - :param status: alert status. Possible values include: "None", "Active", "Overridden", + :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 definition: defines the type of alert. + :vartype definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :ivar description: Alert description. + :vartype description: str + :ivar source: Source of alert. Possible values include: "Preset", "User". + :vartype source: str or ~azure.mgmt.costmanagement.models.AlertSource + :ivar details: Alert details. + :vartype details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :ivar cost_entity_id: related budget. + :vartype cost_entity_id: str + :ivar status: alert status. Possible values include: "None", "Active", "Overridden", "Resolved", "Dismissed". - :type status: str or ~azure.mgmt.costmanagement.models.AlertStatus - :param creation_time: dateTime in which alert was created. - :type creation_time: str - :param close_time: dateTime in which alert was closed. - :type close_time: str - :param modification_time: dateTime in which alert was last modified. - :type modification_time: str - :param status_modification_user_name: - :type status_modification_user_name: str - :param status_modification_time: dateTime in which the alert status was last modified. - :type status_modification_time: str + :vartype status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :ivar creation_time: dateTime in which alert was created. + :vartype creation_time: str + :ivar close_time: dateTime in which alert was closed. + :vartype close_time: str + :ivar modification_time: dateTime in which alert was last modified. + :vartype modification_time: str + :ivar status_modification_user_name: User who last modified the alert. + :vartype status_modification_user_name: str + :ivar status_modification_time: dateTime in which the alert status was last modified. + :vartype status_modification_time: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'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'}, 'definition': {'key': 'properties.definition', 'type': 'AlertPropertiesDefinition'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'source': {'key': 'properties.source', 'type': 'str'}, @@ -117,6 +122,34 @@ 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 definition: defines the type of alert. + :paramtype definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :keyword description: Alert description. + :paramtype description: str + :keyword source: Source of alert. Possible values include: "Preset", "User". + :paramtype source: str or ~azure.mgmt.costmanagement.models.AlertSource + :keyword details: Alert details. + :paramtype details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :keyword cost_entity_id: related budget. + :paramtype cost_entity_id: str + :keyword status: alert status. Possible values include: "None", "Active", "Overridden", + "Resolved", "Dismissed". + :paramtype status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :keyword creation_time: dateTime in which alert was created. + :paramtype creation_time: str + :keyword close_time: dateTime in which alert was closed. + :paramtype close_time: str + :keyword modification_time: dateTime in which alert was last modified. + :paramtype modification_time: str + :keyword status_modification_user_name: User who last modified the alert. + :paramtype status_modification_user_name: str + :keyword status_modification_time: dateTime in which the alert status was last modified. + :paramtype status_modification_time: str + """ super(Alert, self).__init__(**kwargs) self.definition = kwargs.get('definition', None) self.description = kwargs.get('description', None) @@ -134,18 +167,18 @@ def __init__( class AlertPropertiesDefinition(msrest.serialization.Model): """defines the type of alert. - :param type: type of alert. Possible values include: "Budget", "Invoice", "Credit", "Quota", + :ivar type: type of alert. Possible values include: "Budget", "Invoice", "Credit", "Quota", "General", "xCloud", "BudgetForecast". - :type type: str or ~azure.mgmt.costmanagement.models.AlertType - :param category: Alert category. Possible values include: "Cost", "Usage", "Billing", "System". - :type category: str or ~azure.mgmt.costmanagement.models.AlertCategory - :param criteria: Criteria that triggered alert. Possible values include: + :vartype type: str or ~azure.mgmt.costmanagement.models.AlertType + :ivar category: Alert category. Possible values include: "Cost", "Usage", "Billing", "System". + :vartype category: str or ~azure.mgmt.costmanagement.models.AlertCategory + :ivar criteria: Criteria that triggered alert. Possible values include: "CostThresholdExceeded", "UsageThresholdExceeded", "CreditThresholdApproaching", "CreditThresholdReached", "QuotaThresholdApproaching", "QuotaThresholdReached", "MultiCurrency", "ForecastCostThresholdExceeded", "ForecastUsageThresholdExceeded", "InvoiceDueDateApproaching", "InvoiceDueDateReached", "CrossCloudNewDataAvailable", "CrossCloudCollectionError", "GeneralThresholdError". - :type criteria: str or ~azure.mgmt.costmanagement.models.AlertCriteria + :vartype criteria: str or ~azure.mgmt.costmanagement.models.AlertCriteria """ _attribute_map = { @@ -158,6 +191,21 @@ def __init__( self, **kwargs ): + """ + :keyword type: type of alert. Possible values include: "Budget", "Invoice", "Credit", "Quota", + "General", "xCloud", "BudgetForecast". + :paramtype type: str or ~azure.mgmt.costmanagement.models.AlertType + :keyword category: Alert category. Possible values include: "Cost", "Usage", "Billing", + "System". + :paramtype category: str or ~azure.mgmt.costmanagement.models.AlertCategory + :keyword criteria: Criteria that triggered alert. Possible values include: + "CostThresholdExceeded", "UsageThresholdExceeded", "CreditThresholdApproaching", + "CreditThresholdReached", "QuotaThresholdApproaching", "QuotaThresholdReached", + "MultiCurrency", "ForecastCostThresholdExceeded", "ForecastUsageThresholdExceeded", + "InvoiceDueDateApproaching", "InvoiceDueDateReached", "CrossCloudNewDataAvailable", + "CrossCloudCollectionError", "GeneralThresholdError". + :paramtype criteria: str or ~azure.mgmt.costmanagement.models.AlertCriteria + """ super(AlertPropertiesDefinition, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.category = kwargs.get('category', None) @@ -167,40 +215,52 @@ def __init__( class AlertPropertiesDetails(msrest.serialization.Model): """Alert details. - :param time_grain_type: Type of timegrain cadence. Possible values include: "None", "Monthly", + :ivar time_grain_type: Type of timegrain cadence. Possible values include: "None", "Monthly", "Quarterly", "Annually", "BillingMonth", "BillingQuarter", "BillingAnnual". - :type time_grain_type: str or ~azure.mgmt.costmanagement.models.AlertTimeGrainType - :param period_start_date: datetime of periodStartDate. - :type period_start_date: str - :param triggered_by: notificationId that triggered this alert. - :type triggered_by: str - :param resource_group_filter: array of resourceGroups to filter by. - :type resource_group_filter: list[any] - :param resource_filter: array of resources to filter by. - :type resource_filter: list[any] - :param meter_filter: array of meters to filter by. - :type meter_filter: list[any] - :param tag_filter: tags to filter by. - :type tag_filter: any - :param threshold: notification threshold percentage as a decimal which activated this alert. - :type threshold: float - :param operator: operator used to compare currentSpend with amount. Possible values include: + :vartype time_grain_type: str or ~azure.mgmt.costmanagement.models.AlertTimeGrainType + :ivar period_start_date: datetime of periodStartDate. + :vartype period_start_date: str + :ivar triggered_by: notificationId that triggered this alert. + :vartype triggered_by: str + :ivar resource_group_filter: array of resourceGroups to filter by. + :vartype resource_group_filter: list[any] + :ivar resource_filter: array of resources to filter by. + :vartype resource_filter: list[any] + :ivar meter_filter: array of meters to filter by. + :vartype meter_filter: list[any] + :ivar tag_filter: tags to filter by. + :vartype tag_filter: any + :ivar threshold: notification threshold percentage as a decimal which activated this alert. + :vartype threshold: float + :ivar operator: operator used to compare currentSpend with amount. Possible values include: "None", "EqualTo", "GreaterThan", "GreaterThanOrEqualTo", "LessThan", "LessThanOrEqualTo". - :type operator: str or ~azure.mgmt.costmanagement.models.AlertOperator - :param amount: budget threshold amount. - :type amount: float - :param unit: unit of currency being used. - :type unit: str - :param current_spend: current spend. - :type current_spend: float - :param contact_emails: list of emails to contact. - :type contact_emails: list[str] - :param contact_groups: list of action groups to broadcast to. - :type contact_groups: list[str] - :param contact_roles: list of contact roles. - :type contact_roles: list[str] - :param overriding_alert: overriding alert. - :type overriding_alert: str + :vartype operator: str or ~azure.mgmt.costmanagement.models.AlertOperator + :ivar amount: budget threshold amount. + :vartype amount: float + :ivar unit: unit of currency being used. + :vartype unit: str + :ivar current_spend: current spend. + :vartype current_spend: float + :ivar contact_emails: list of emails to contact. + :vartype contact_emails: list[str] + :ivar contact_groups: list of action groups to broadcast to. + :vartype contact_groups: list[str] + :ivar contact_roles: list of contact roles. + :vartype contact_roles: list[str] + :ivar overriding_alert: overriding alert. + :vartype overriding_alert: str + :ivar department_name: department name. + :vartype department_name: str + :ivar company_name: company name. + :vartype company_name: str + :ivar enrollment_number: enrollment number. + :vartype enrollment_number: str + :ivar enrollment_start_date: datetime of enrollmentStartDate. + :vartype enrollment_start_date: str + :ivar enrollment_end_date: datetime of enrollmentEndDate. + :vartype enrollment_end_date: str + :ivar invoicing_threshold: invoicing threshold. + :vartype invoicing_threshold: float """ _attribute_map = { @@ -220,12 +280,66 @@ class AlertPropertiesDetails(msrest.serialization.Model): 'contact_groups': {'key': 'contactGroups', 'type': '[str]'}, 'contact_roles': {'key': 'contactRoles', 'type': '[str]'}, 'overriding_alert': {'key': 'overridingAlert', 'type': 'str'}, + 'department_name': {'key': 'departmentName', 'type': 'str'}, + 'company_name': {'key': 'companyName', 'type': 'str'}, + 'enrollment_number': {'key': 'enrollmentNumber', 'type': 'str'}, + 'enrollment_start_date': {'key': 'enrollmentStartDate', 'type': 'str'}, + 'enrollment_end_date': {'key': 'enrollmentEndDate', 'type': 'str'}, + 'invoicing_threshold': {'key': 'invoicingThreshold', 'type': 'float'}, } def __init__( self, **kwargs ): + """ + :keyword time_grain_type: Type of timegrain cadence. Possible values include: "None", + "Monthly", "Quarterly", "Annually", "BillingMonth", "BillingQuarter", "BillingAnnual". + :paramtype time_grain_type: str or ~azure.mgmt.costmanagement.models.AlertTimeGrainType + :keyword period_start_date: datetime of periodStartDate. + :paramtype period_start_date: str + :keyword triggered_by: notificationId that triggered this alert. + :paramtype triggered_by: str + :keyword resource_group_filter: array of resourceGroups to filter by. + :paramtype resource_group_filter: list[any] + :keyword resource_filter: array of resources to filter by. + :paramtype resource_filter: list[any] + :keyword meter_filter: array of meters to filter by. + :paramtype meter_filter: list[any] + :keyword tag_filter: tags to filter by. + :paramtype tag_filter: any + :keyword threshold: notification threshold percentage as a decimal which activated this alert. + :paramtype threshold: float + :keyword operator: operator used to compare currentSpend with amount. Possible values include: + "None", "EqualTo", "GreaterThan", "GreaterThanOrEqualTo", "LessThan", "LessThanOrEqualTo". + :paramtype operator: str or ~azure.mgmt.costmanagement.models.AlertOperator + :keyword amount: budget threshold amount. + :paramtype amount: float + :keyword unit: unit of currency being used. + :paramtype unit: str + :keyword current_spend: current spend. + :paramtype current_spend: float + :keyword contact_emails: list of emails to contact. + :paramtype contact_emails: list[str] + :keyword contact_groups: list of action groups to broadcast to. + :paramtype contact_groups: list[str] + :keyword contact_roles: list of contact roles. + :paramtype contact_roles: list[str] + :keyword overriding_alert: overriding alert. + :paramtype overriding_alert: str + :keyword department_name: department name. + :paramtype department_name: str + :keyword company_name: company name. + :paramtype company_name: str + :keyword enrollment_number: enrollment number. + :paramtype enrollment_number: str + :keyword enrollment_start_date: datetime of enrollmentStartDate. + :paramtype enrollment_start_date: str + :keyword enrollment_end_date: datetime of enrollmentEndDate. + :paramtype enrollment_end_date: str + :keyword invoicing_threshold: invoicing threshold. + :paramtype invoicing_threshold: float + """ super(AlertPropertiesDetails, self).__init__(**kwargs) self.time_grain_type = kwargs.get('time_grain_type', None) self.period_start_date = kwargs.get('period_start_date', None) @@ -243,6 +357,12 @@ def __init__( self.contact_groups = kwargs.get('contact_groups', None) self.contact_roles = kwargs.get('contact_roles', None) self.overriding_alert = kwargs.get('overriding_alert', None) + self.department_name = kwargs.get('department_name', None) + self.company_name = kwargs.get('company_name', None) + self.enrollment_number = kwargs.get('enrollment_number', None) + self.enrollment_start_date = kwargs.get('enrollment_start_date', None) + self.enrollment_end_date = kwargs.get('enrollment_end_date', None) + self.invoicing_threshold = kwargs.get('invoicing_threshold', None) class AlertsResult(msrest.serialization.Model): @@ -270,99 +390,140 @@ def __init__( self, **kwargs ): + """ + """ super(AlertsResult, self).__init__(**kwargs) self.value = None self.next_link = None -class CacheItem(msrest.serialization.Model): - """CacheItem. +class CommonExportProperties(msrest.serialization.Model): + """The common properties of the export. + + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param id: Required. Resource ID used by Resource Manager to uniquely identify the scope. - :type id: str - :param name: Required. Display name for the scope. - :type name: str - :param channel: Required. Indicates the account type. Allowed values include: EA, PAYG, Modern, - Internal, Unknown. - :type channel: str - :param subchannel: Required. Indicates the type of modern account. Allowed values include: - Individual, Enterprise, Partner, Indirect, NotApplicable. - :type subchannel: str - :param parent: Resource ID of the parent scope. For instance, subscription's resource ID for a - resource group or a management group resource ID for a subscription. - :type parent: str - :param status: Indicates the status of the scope. Status only applies to subscriptions and - billing accounts. - :type status: str + :ivar format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :vartype format: str or ~azure.mgmt.costmanagement.models.FormatType + :ivar delivery_info: Required. Has delivery information for the export. + :vartype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :ivar definition: Required. Has the definition for the export. + :vartype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :ivar run_history: If requested, has the most recent execution history for the export. + :vartype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar partition_data: If set to true, exported data will be partitioned by size and placed in a + blob directory together with a manifest file. Note: this option is currently available only for + modern commerce scopes. + :vartype partition_data: bool + :ivar next_run_time_estimate: If the export has an active schedule, provides an estimate of the + next execution time. + :vartype next_run_time_estimate: ~datetime.datetime """ _validation = { - 'id': {'required': True}, - 'name': {'required': True}, - 'channel': {'required': True}, - 'subchannel': {'required': True}, + 'delivery_info': {'required': True}, + 'definition': {'required': True}, + 'next_run_time_estimate': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'channel': {'key': 'channel', 'type': 'str'}, - 'subchannel': {'key': 'subchannel', 'type': 'str'}, - 'parent': {'key': 'parent', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + 'format': {'key': 'format', 'type': 'str'}, + 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, + 'definition': {'key': 'definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'runHistory', 'type': 'ExportExecutionListResult'}, + 'partition_data': {'key': 'partitionData', 'type': 'bool'}, + 'next_run_time_estimate': {'key': 'nextRunTimeEstimate', 'type': 'iso-8601'}, } def __init__( self, **kwargs ): - super(CacheItem, self).__init__(**kwargs) - self.id = kwargs['id'] - self.name = kwargs['name'] - self.channel = kwargs['channel'] - self.subchannel = kwargs['subchannel'] - self.parent = kwargs.get('parent', None) - self.status = kwargs.get('status', None) + """ + :keyword format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :paramtype format: str or ~azure.mgmt.costmanagement.models.FormatType + :keyword delivery_info: Required. Has delivery information for the export. + :paramtype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :keyword definition: Required. Has the definition for the export. + :paramtype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :keyword run_history: If requested, has the most recent execution history for the export. + :paramtype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :keyword partition_data: If set to true, exported data will be partitioned by size and placed + in a blob directory together with a manifest file. Note: this option is currently available + only for modern commerce scopes. + :paramtype partition_data: bool + """ + super(CommonExportProperties, self).__init__(**kwargs) + self.format = kwargs.get('format', None) + self.delivery_info = kwargs['delivery_info'] + self.definition = kwargs['definition'] + self.run_history = kwargs.get('run_history', None) + self.partition_data = kwargs.get('partition_data', None) + self.next_run_time_estimate = None -class CommonExportProperties(msrest.serialization.Model): - """The common properties of the export. +class Resource(msrest.serialization.Model): + """The Resource model definition. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param format: The format of the export being delivered. Possible values include: "Csv". - :type format: str or ~azure.mgmt.costmanagement.models.FormatType - :param delivery_info: Required. Has delivery information for the export. - :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Required. Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Location of the resource. + :vartype location: str + :ivar sku: SKU of the resource. + :vartype sku: str + :ivar e_tag: ETag of the resource. + :vartype e_tag: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { - 'delivery_info': {'required': True}, - 'definition': {'required': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + 'sku': {'readonly': True}, + 'e_tag': {'readonly': True}, + 'tags': {'readonly': True}, } _attribute_map = { - 'format': {'key': 'format', 'type': 'str'}, - 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, - 'definition': {'key': 'definition', 'type': 'ExportDefinition'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, **kwargs ): - super(CommonExportProperties, self).__init__(**kwargs) - self.format = kwargs.get('format', None) - self.delivery_info = kwargs['delivery_info'] - self.definition = kwargs['definition'] + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = None + self.sku = None + self.e_tag = None + self.tags = None class Dimension(Resource): - """Dimension. + """List of Dimension. Variables are only populated by the server, and will be ignored when sending a request. @@ -372,6 +533,12 @@ class Dimension(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar location: Location of the resource. + :vartype location: str + :ivar sku: SKU of the resource. + :vartype sku: str + :ivar e_tag: ETag of the resource. + :vartype e_tag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar description: Dimension description. @@ -380,8 +547,8 @@ class Dimension(Resource): :vartype filter_enabled: bool :ivar grouping_enabled: Grouping enabled. :vartype grouping_enabled: bool - :param data: - :type data: list[str] + :ivar data: Dimension data. + :vartype data: list[str] :ivar total: Total number of data for the dimension. :vartype total: int :ivar category: Dimension category. @@ -398,6 +565,9 @@ class Dimension(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'location': {'readonly': True}, + 'sku': {'readonly': True}, + 'e_tag': {'readonly': True}, 'tags': {'readonly': True}, 'description': {'readonly': True}, 'filter_enabled': {'readonly': True}, @@ -413,6 +583,9 @@ class Dimension(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'filter_enabled': {'key': 'properties.filterEnabled', 'type': 'bool'}, @@ -429,6 +602,10 @@ def __init__( self, **kwargs ): + """ + :keyword data: Dimension data. + :paramtype data: list[str] + """ super(Dimension, self).__init__(**kwargs) self.description = None self.filter_enabled = None @@ -462,6 +639,8 @@ def __init__( self, **kwargs ): + """ + """ super(DimensionsListResult, self).__init__(**kwargs) self.value = None @@ -469,29 +648,29 @@ def __init__( class DismissAlertPayload(msrest.serialization.Model): """The request payload to update an alert. - :param definition: defines the type of alert. - :type definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition - :param description: Alert description. - :type description: str - :param source: Source of alert. Possible values include: "Preset", "User". - :type source: str or ~azure.mgmt.costmanagement.models.AlertSource - :param details: Alert details. - :type details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails - :param cost_entity_id: related budget. - :type cost_entity_id: str - :param status: alert status. Possible values include: "None", "Active", "Overridden", + :ivar definition: defines the type of alert. + :vartype definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :ivar description: Alert description. + :vartype description: str + :ivar source: Source of alert. Possible values include: "Preset", "User". + :vartype source: str or ~azure.mgmt.costmanagement.models.AlertSource + :ivar details: Alert details. + :vartype details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :ivar cost_entity_id: related budget. + :vartype cost_entity_id: str + :ivar status: alert status. Possible values include: "None", "Active", "Overridden", "Resolved", "Dismissed". - :type status: str or ~azure.mgmt.costmanagement.models.AlertStatus - :param creation_time: dateTime in which alert was created. - :type creation_time: str - :param close_time: dateTime in which alert was closed. - :type close_time: str - :param modification_time: dateTime in which alert was last modified. - :type modification_time: str - :param status_modification_user_name: - :type status_modification_user_name: str - :param status_modification_time: dateTime in which the alert status was last modified. - :type status_modification_time: str + :vartype status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :ivar creation_time: dateTime in which alert was created. + :vartype creation_time: str + :ivar close_time: dateTime in which alert was closed. + :vartype close_time: str + :ivar modification_time: dateTime in which alert was last modified. + :vartype modification_time: str + :ivar status_modification_user_name: User who last modified the alert. + :vartype status_modification_user_name: str + :ivar status_modification_time: dateTime in which the alert status was last modified. + :vartype status_modification_time: str """ _attribute_map = { @@ -512,6 +691,31 @@ def __init__( self, **kwargs ): + """ + :keyword definition: defines the type of alert. + :paramtype definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :keyword description: Alert description. + :paramtype description: str + :keyword source: Source of alert. Possible values include: "Preset", "User". + :paramtype source: str or ~azure.mgmt.costmanagement.models.AlertSource + :keyword details: Alert details. + :paramtype details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :keyword cost_entity_id: related budget. + :paramtype cost_entity_id: str + :keyword status: alert status. Possible values include: "None", "Active", "Overridden", + "Resolved", "Dismissed". + :paramtype status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :keyword creation_time: dateTime in which alert was created. + :paramtype creation_time: str + :keyword close_time: dateTime in which alert was closed. + :paramtype close_time: str + :keyword modification_time: dateTime in which alert was last modified. + :paramtype modification_time: str + :keyword status_modification_user_name: User who last modified the alert. + :paramtype status_modification_user_name: str + :keyword status_modification_time: dateTime in which the alert status was last modified. + :paramtype status_modification_time: str + """ super(DismissAlertPayload, self).__init__(**kwargs) self.definition = kwargs.get('definition', None) self.description = kwargs.get('description', None) @@ -551,6 +755,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -568,8 +774,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.costmanagement.models.ErrorDetails + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.costmanagement.models.ErrorDetails """ _attribute_map = { @@ -580,12 +786,16 @@ def __init__( self, **kwargs ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.costmanagement.models.ErrorDetails + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) -class ProxyResource(msrest.serialization.Model): - """The Resource model definition. +class Export(ProxyResource): + """An export resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -595,15 +805,34 @@ 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 + :ivar format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :vartype format: str or ~azure.mgmt.costmanagement.models.FormatType + :ivar delivery_info: Has delivery information for the export. + :vartype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :ivar definition: Has the definition for the export. + :vartype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :ivar run_history: If requested, has the most recent execution history for the export. + :vartype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar partition_data: If set to true, exported data will be partitioned by size and placed in a + blob directory together with a manifest file. Note: this option is currently available only for + modern commerce scopes. + :vartype partition_data: bool + :ivar next_run_time_estimate: If the export has an active schedule, provides an estimate of the + next execution time. + :vartype next_run_time_estimate: ~datetime.datetime + :ivar schedule: Has schedule information for the export. + :vartype schedule: ~azure.mgmt.costmanagement.models.ExportSchedule """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'next_run_time_estimate': {'readonly': True}, } _attribute_map = { @@ -611,87 +840,124 @@ class ProxyResource(msrest.serialization.Model): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'format': {'key': 'properties.format', 'type': 'str'}, + 'delivery_info': {'key': 'properties.deliveryInfo', 'type': 'ExportDeliveryInfo'}, + 'definition': {'key': 'properties.definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'properties.runHistory', 'type': 'ExportExecutionListResult'}, + 'partition_data': {'key': 'properties.partitionData', 'type': 'bool'}, + 'next_run_time_estimate': {'key': 'properties.nextRunTimeEstimate', 'type': 'iso-8601'}, + 'schedule': {'key': 'properties.schedule', 'type': 'ExportSchedule'}, } def __init__( self, **kwargs ): - super(ProxyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.e_tag = kwargs.get('e_tag', None) - + """ + :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 format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :paramtype format: str or ~azure.mgmt.costmanagement.models.FormatType + :keyword delivery_info: Has delivery information for the export. + :paramtype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :keyword definition: Has the definition for the export. + :paramtype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :keyword run_history: If requested, has the most recent execution history for the export. + :paramtype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :keyword partition_data: If set to true, exported data will be partitioned by size and placed + in a blob directory together with a manifest file. Note: this option is currently available + only for modern commerce scopes. + :paramtype partition_data: bool + :keyword schedule: Has schedule information for the export. + :paramtype schedule: ~azure.mgmt.costmanagement.models.ExportSchedule + """ + super(Export, self).__init__(**kwargs) + self.format = kwargs.get('format', None) + self.delivery_info = kwargs.get('delivery_info', None) + self.definition = kwargs.get('definition', None) + self.run_history = kwargs.get('run_history', None) + self.partition_data = kwargs.get('partition_data', None) + self.next_run_time_estimate = None + self.schedule = kwargs.get('schedule', None) -class Export(ProxyResource): - """A export resource. - Variables are only populated by the server, and will be ignored when sending a request. +class ExportDataset(msrest.serialization.Model): + """The definition for data in the export. - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :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 - used to determine whether the user is updating the latest version or not. - :type e_tag: str - :param format: The format of the export being delivered. Possible values include: "Csv". - :type format: str or ~azure.mgmt.costmanagement.models.FormatType - :param delivery_info: Has delivery information for the export. - :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition - :param schedule: Has schedule information for the export. - :type schedule: ~azure.mgmt.costmanagement.models.ExportSchedule + :ivar granularity: The granularity of rows in the export. Currently only 'Daily' is supported. + Possible values include: "Daily". + :vartype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :ivar configuration: The export dataset configuration. + :vartype configuration: ~azure.mgmt.costmanagement.models.ExportDatasetConfiguration """ - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'ExportDatasetConfiguration'}, } + def __init__( + self, + **kwargs + ): + """ + :keyword granularity: The granularity of rows in the export. Currently only 'Daily' is + supported. Possible values include: "Daily". + :paramtype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :keyword configuration: The export dataset configuration. + :paramtype configuration: ~azure.mgmt.costmanagement.models.ExportDatasetConfiguration + """ + super(ExportDataset, self).__init__(**kwargs) + self.granularity = kwargs.get('granularity', None) + self.configuration = kwargs.get('configuration', None) + + +class ExportDatasetConfiguration(msrest.serialization.Model): + """The export dataset configuration. Allows columns to be selected for the export. If not provided then the export will include all available columns. + + :ivar columns: Array of column names to be included in the export. If not provided then the + export will include all available columns. The available columns can vary by customer channel + (see examples). + :vartype columns: list[str] + """ + _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'format': {'key': 'properties.format', 'type': 'str'}, - 'delivery_info': {'key': 'properties.deliveryInfo', 'type': 'ExportDeliveryInfo'}, - 'definition': {'key': 'properties.definition', 'type': 'ExportDefinition'}, - 'schedule': {'key': 'properties.schedule', 'type': 'ExportSchedule'}, + 'columns': {'key': 'columns', 'type': '[str]'}, } def __init__( self, **kwargs ): - super(Export, self).__init__(**kwargs) - self.format = kwargs.get('format', None) - self.delivery_info = kwargs.get('delivery_info', None) - self.definition = kwargs.get('definition', None) - self.schedule = kwargs.get('schedule', None) + """ + :keyword columns: Array of column names to be included in the export. If not provided then the + export will include all available columns. The available columns can vary by customer channel + (see examples). + :paramtype columns: list[str] + """ + super(ExportDatasetConfiguration, self).__init__(**kwargs) + self.columns = kwargs.get('columns', None) class ExportDefinition(msrest.serialization.Model): - """The definition of a query. + """The definition of an export. All required parameters must be populated in order to send to Azure. - :param type: Required. The type of the query. Possible values include: "Usage", "ActualCost", - "AmortizedCost". - :type type: str or ~azure.mgmt.costmanagement.models.ExportType - :param timeframe: Required. The time frame for pulling data for the query. If custom, then a + :ivar type: Required. The type of the export. Note that 'Usage' is equivalent to 'ActualCost' + and is applicable to exports that do not yet provide data for charges or amortization for + service reservations. Possible values include: "Usage", "ActualCost", "AmortizedCost". + :vartype type: str or ~azure.mgmt.costmanagement.models.ExportType + :ivar timeframe: Required. The time frame for pulling data for the export. If custom, then a specific time period must be provided. Possible values include: "MonthToDate", "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". - :type timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType - :param time_period: Has time period for pulling data for the query. - :type time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod - :param data_set: Has definition for data in this query. - :type data_set: ~azure.mgmt.costmanagement.models.QueryDatasetAutoGenerated + :vartype timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :ivar time_period: Has time period for pulling data for the export. + :vartype time_period: ~azure.mgmt.costmanagement.models.ExportTimePeriod + :ivar data_set: The definition for data in the export. + :vartype data_set: ~azure.mgmt.costmanagement.models.ExportDataset """ _validation = { @@ -702,14 +968,29 @@ class ExportDefinition(msrest.serialization.Model): _attribute_map = { 'type': {'key': 'type', 'type': 'str'}, 'timeframe': {'key': 'timeframe', 'type': 'str'}, - 'time_period': {'key': 'timePeriod', 'type': 'QueryTimePeriod'}, - 'data_set': {'key': 'dataSet', 'type': 'QueryDatasetAutoGenerated'}, + 'time_period': {'key': 'timePeriod', 'type': 'ExportTimePeriod'}, + 'data_set': {'key': 'dataSet', 'type': 'ExportDataset'}, } def __init__( self, **kwargs ): + """ + :keyword type: Required. The type of the export. Note that 'Usage' is equivalent to + 'ActualCost' and is applicable to exports that do not yet provide data for charges or + amortization for service reservations. Possible values include: "Usage", "ActualCost", + "AmortizedCost". + :paramtype type: str or ~azure.mgmt.costmanagement.models.ExportType + :keyword timeframe: Required. The time frame for pulling data for the export. If custom, then a + specific time period must be provided. Possible values include: "MonthToDate", + "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". + :paramtype timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :keyword time_period: Has time period for pulling data for the export. + :paramtype time_period: ~azure.mgmt.costmanagement.models.ExportTimePeriod + :keyword data_set: The definition for data in the export. + :paramtype data_set: ~azure.mgmt.costmanagement.models.ExportDataset + """ super(ExportDefinition, self).__init__(**kwargs) self.type = kwargs['type'] self.timeframe = kwargs['timeframe'] @@ -718,21 +999,30 @@ def __init__( class ExportDeliveryDestination(msrest.serialization.Model): - """The destination information for the delivery of the export. To allow access to a storage account, you must register the account's subscription with the Microsoft.CostManagementExports resource provider. This is required once per subscription. When creating an export in the Azure portal, it is done automatically, however API users need to register the subscription. For more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services . + """This represents the blob storage account location where exports of costs will be delivered. There are two ways to configure the destination. The approach recommended for most customers is to specify the resourceId of the storage account. This requires a one-time registration of the account's subscription with the Microsoft.CostManagementExports resource provider in order to give Azure Cost Management services access to the storage. When creating an export in the Azure portal this registration is performed automatically but API users may need to register the subscription explicitly (for more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Another way to configure the destination is available ONLY to Partners with a Microsoft Partner Agreement plan who are global admins of their billing account. These Partners, instead of specifying the resourceId of a storage account, can specify the storage account name along with a SAS token for the account. This allows exports of costs to a storage account in any tenant. The SAS token should be created for the blob service with Service/Container/Object resource types and with Read/Write/Delete/List/Add/Create permissions (for more information see https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key ). All required parameters must be populated in order to send to Azure. - :param resource_id: Required. The resource id of the storage account where exports will be - delivered. - :type resource_id: str - :param container: Required. The name of the container where exports will be uploaded. - :type container: str - :param root_folder_path: The name of the directory where exports will be uploaded. - :type root_folder_path: str + :ivar resource_id: The resource id of the storage account where exports will be delivered. This + is not required if a sasToken and storageAccount are specified. + :vartype resource_id: str + :ivar container: Required. The name of the container where exports will be uploaded. If the + container does not exist it will be created. + :vartype container: str + :ivar root_folder_path: The name of the directory where exports will be uploaded. + :vartype root_folder_path: str + :ivar sas_token: A SAS token for the storage account. For a restricted set of Azure customers + this together with storageAccount can be specified instead of resourceId. Note: the value + returned by the API for this property will always be obfuscated. Returning this same obfuscated + value will not result in the SAS token being updated. To update this value a new SAS token must + be specified. + :vartype sas_token: str + :ivar storage_account: The storage account where exports will be uploaded. For a restricted set + of Azure customers this together with sasToken can be specified instead of resourceId. + :vartype storage_account: str """ _validation = { - 'resource_id': {'required': True}, 'container': {'required': True}, } @@ -740,16 +1030,39 @@ class ExportDeliveryDestination(msrest.serialization.Model): 'resource_id': {'key': 'resourceId', 'type': 'str'}, 'container': {'key': 'container', 'type': 'str'}, 'root_folder_path': {'key': 'rootFolderPath', 'type': 'str'}, + 'sas_token': {'key': 'sasToken', 'type': 'str'}, + 'storage_account': {'key': 'storageAccount', 'type': 'str'}, } def __init__( self, **kwargs ): + """ + :keyword resource_id: The resource id of the storage account where exports will be delivered. + This is not required if a sasToken and storageAccount are specified. + :paramtype resource_id: str + :keyword container: Required. The name of the container where exports will be uploaded. If the + container does not exist it will be created. + :paramtype container: str + :keyword root_folder_path: The name of the directory where exports will be uploaded. + :paramtype root_folder_path: str + :keyword sas_token: A SAS token for the storage account. For a restricted set of Azure + customers this together with storageAccount can be specified instead of resourceId. Note: the + value returned by the API for this property will always be obfuscated. Returning this same + obfuscated value will not result in the SAS token being updated. To update this value a new SAS + token must be specified. + :paramtype sas_token: str + :keyword storage_account: The storage account where exports will be uploaded. For a restricted + set of Azure customers this together with sasToken can be specified instead of resourceId. + :paramtype storage_account: str + """ super(ExportDeliveryDestination, self).__init__(**kwargs) - self.resource_id = kwargs['resource_id'] + self.resource_id = kwargs.get('resource_id', None) self.container = kwargs['container'] self.root_folder_path = kwargs.get('root_folder_path', None) + self.sas_token = kwargs.get('sas_token', None) + self.storage_account = kwargs.get('storage_account', None) class ExportDeliveryInfo(msrest.serialization.Model): @@ -757,8 +1070,8 @@ class ExportDeliveryInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param destination: Required. Has destination for the export being delivered. - :type destination: ~azure.mgmt.costmanagement.models.ExportDeliveryDestination + :ivar destination: Required. Has destination for the export being delivered. + :vartype destination: ~azure.mgmt.costmanagement.models.ExportDeliveryDestination """ _validation = { @@ -773,12 +1086,16 @@ def __init__( self, **kwargs ): + """ + :keyword destination: Required. Has destination for the export being delivered. + :paramtype destination: ~azure.mgmt.costmanagement.models.ExportDeliveryDestination + """ super(ExportDeliveryInfo, self).__init__(**kwargs) self.destination = kwargs['destination'] -class ExportExecution(Resource): - """A export execution. +class ExportExecution(ProxyResource): + """An export execution. Variables are only populated by the server, and will be ignored when sending a request. @@ -788,41 +1105,43 @@ class ExportExecution(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 execution_type: The type of the export execution. Possible values include: "OnDemand", + :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 execution_type: The type of the export execution. Possible values include: "OnDemand", "Scheduled". - :type execution_type: str or ~azure.mgmt.costmanagement.models.ExecutionType - :param status: The status of the export execution. Possible values include: "Queued", + :vartype execution_type: str or ~azure.mgmt.costmanagement.models.ExecutionType + :ivar status: The last known status of the export execution. Possible values include: "Queued", "InProgress", "Completed", "Failed", "Timeout", "NewDataNotAvailable", "DataNotAvailable". - :type status: str or ~azure.mgmt.costmanagement.models.ExecutionStatus - :param submitted_by: The identifier for the entity that executed the export. For OnDemand - executions, it is the email id. For Scheduled executions, it is the constant value - System. - :type submitted_by: str - :param submitted_time: The time when export was queued to be executed. - :type submitted_time: ~datetime.datetime - :param processing_start_time: The time when export was picked up to be executed. - :type processing_start_time: ~datetime.datetime - :param processing_end_time: The time when export execution finished. - :type processing_end_time: ~datetime.datetime - :param file_name: The name of the file export got written to. - :type file_name: str - :param run_settings: The common properties of the export. - :type run_settings: ~azure.mgmt.costmanagement.models.CommonExportProperties + :vartype status: str or ~azure.mgmt.costmanagement.models.ExecutionStatus + :ivar submitted_by: The identifier for the entity that executed the export. For OnDemand + executions it is the user email. For scheduled executions it is 'System'. + :vartype submitted_by: str + :ivar submitted_time: The time when export was queued to be executed. + :vartype submitted_time: ~datetime.datetime + :ivar processing_start_time: The time when export was picked up to be executed. + :vartype processing_start_time: ~datetime.datetime + :ivar processing_end_time: The time when the export execution finished. + :vartype processing_end_time: ~datetime.datetime + :ivar file_name: The name of the exported file. + :vartype file_name: str + :ivar run_settings: The export settings that were in effect for this execution. + :vartype run_settings: ~azure.mgmt.costmanagement.models.CommonExportProperties + :ivar error: The details of any error. + :vartype error: ~azure.mgmt.costmanagement.models.ErrorDetails """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'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'}, 'execution_type': {'key': 'properties.executionType', 'type': 'str'}, 'status': {'key': 'properties.status', 'type': 'str'}, 'submitted_by': {'key': 'properties.submittedBy', 'type': 'str'}, @@ -831,12 +1150,40 @@ class ExportExecution(Resource): 'processing_end_time': {'key': 'properties.processingEndTime', 'type': 'iso-8601'}, 'file_name': {'key': 'properties.fileName', 'type': 'str'}, 'run_settings': {'key': 'properties.runSettings', 'type': 'CommonExportProperties'}, + 'error': {'key': 'properties.error', 'type': 'ErrorDetails'}, } 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 execution_type: The type of the export execution. Possible values include: "OnDemand", + "Scheduled". + :paramtype execution_type: str or ~azure.mgmt.costmanagement.models.ExecutionType + :keyword status: The last known status of the export execution. Possible values include: + "Queued", "InProgress", "Completed", "Failed", "Timeout", "NewDataNotAvailable", + "DataNotAvailable". + :paramtype status: str or ~azure.mgmt.costmanagement.models.ExecutionStatus + :keyword submitted_by: The identifier for the entity that executed the export. For OnDemand + executions it is the user email. For scheduled executions it is 'System'. + :paramtype submitted_by: str + :keyword submitted_time: The time when export was queued to be executed. + :paramtype submitted_time: ~datetime.datetime + :keyword processing_start_time: The time when export was picked up to be executed. + :paramtype processing_start_time: ~datetime.datetime + :keyword processing_end_time: The time when the export execution finished. + :paramtype processing_end_time: ~datetime.datetime + :keyword file_name: The name of the exported file. + :paramtype file_name: str + :keyword run_settings: The export settings that were in effect for this execution. + :paramtype run_settings: ~azure.mgmt.costmanagement.models.CommonExportProperties + :keyword error: The details of any error. + :paramtype error: ~azure.mgmt.costmanagement.models.ErrorDetails + """ super(ExportExecution, self).__init__(**kwargs) self.execution_type = kwargs.get('execution_type', None) self.status = kwargs.get('status', None) @@ -846,14 +1193,15 @@ def __init__( self.processing_end_time = kwargs.get('processing_end_time', None) self.file_name = kwargs.get('file_name', None) self.run_settings = kwargs.get('run_settings', None) + self.error = kwargs.get('error', None) class ExportExecutionListResult(msrest.serialization.Model): - """Result of listing exports execution history of a export by name. + """Result of listing the execution history of an export. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of export executions. + :ivar value: A list of export executions. :vartype value: list[~azure.mgmt.costmanagement.models.ExportExecution] """ @@ -869,6 +1217,8 @@ def __init__( self, **kwargs ): + """ + """ super(ExportExecutionListResult, self).__init__(**kwargs) self.value = None @@ -894,6 +1244,8 @@ def __init__( self, **kwargs ): + """ + """ super(ExportListResult, self).__init__(**kwargs) self.value = None @@ -901,27 +1253,43 @@ def __init__( class ExportProperties(CommonExportProperties): """The properties of the export. + Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. - :param format: The format of the export being delivered. Possible values include: "Csv". - :type format: str or ~azure.mgmt.costmanagement.models.FormatType - :param delivery_info: Required. Has delivery information for the export. - :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Required. Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition - :param schedule: Has schedule information for the export. - :type schedule: ~azure.mgmt.costmanagement.models.ExportSchedule + :ivar format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :vartype format: str or ~azure.mgmt.costmanagement.models.FormatType + :ivar delivery_info: Required. Has delivery information for the export. + :vartype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :ivar definition: Required. Has the definition for the export. + :vartype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :ivar run_history: If requested, has the most recent execution history for the export. + :vartype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar partition_data: If set to true, exported data will be partitioned by size and placed in a + blob directory together with a manifest file. Note: this option is currently available only for + modern commerce scopes. + :vartype partition_data: bool + :ivar next_run_time_estimate: If the export has an active schedule, provides an estimate of the + next execution time. + :vartype next_run_time_estimate: ~datetime.datetime + :ivar schedule: Has schedule information for the export. + :vartype schedule: ~azure.mgmt.costmanagement.models.ExportSchedule """ _validation = { 'delivery_info': {'required': True}, 'definition': {'required': True}, + 'next_run_time_estimate': {'readonly': True}, } _attribute_map = { 'format': {'key': 'format', 'type': 'str'}, 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, 'definition': {'key': 'definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'runHistory', 'type': 'ExportExecutionListResult'}, + 'partition_data': {'key': 'partitionData', 'type': 'bool'}, + 'next_run_time_estimate': {'key': 'nextRunTimeEstimate', 'type': 'iso-8601'}, 'schedule': {'key': 'schedule', 'type': 'ExportSchedule'}, } @@ -929,6 +1297,23 @@ def __init__( self, **kwargs ): + """ + :keyword format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :paramtype format: str or ~azure.mgmt.costmanagement.models.FormatType + :keyword delivery_info: Required. Has delivery information for the export. + :paramtype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :keyword definition: Required. Has the definition for the export. + :paramtype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :keyword run_history: If requested, has the most recent execution history for the export. + :paramtype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :keyword partition_data: If set to true, exported data will be partitioned by size and placed + in a blob directory together with a manifest file. Note: this option is currently available + only for modern commerce scopes. + :paramtype partition_data: bool + :keyword schedule: Has schedule information for the export. + :paramtype schedule: ~azure.mgmt.costmanagement.models.ExportSchedule + """ super(ExportProperties, self).__init__(**kwargs) self.schedule = kwargs.get('schedule', None) @@ -938,10 +1323,10 @@ class ExportRecurrencePeriod(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param from_property: Required. The start date of recurrence. - :type from_property: ~datetime.datetime - :param to: The end date of recurrence. - :type to: ~datetime.datetime + :ivar from_property: Required. The start date of recurrence. + :vartype from_property: ~datetime.datetime + :ivar to: The end date of recurrence. + :vartype to: ~datetime.datetime """ _validation = { @@ -957,31 +1342,31 @@ def __init__( self, **kwargs ): + """ + :keyword from_property: Required. The start date of recurrence. + :paramtype from_property: ~datetime.datetime + :keyword to: The end date of recurrence. + :paramtype to: ~datetime.datetime + """ super(ExportRecurrencePeriod, self).__init__(**kwargs) self.from_property = kwargs['from_property'] self.to = kwargs.get('to', None) class ExportSchedule(msrest.serialization.Model): - """The schedule associated with a export. - - All required parameters must be populated in order to send to Azure. - - :param status: The status of the schedule. Whether active or not. If inactive, the export's - scheduled execution is paused. Possible values include: "Active", "Inactive". - :type status: str or ~azure.mgmt.costmanagement.models.StatusType - :param recurrence: Required. The schedule recurrence. Possible values include: "Daily", - "Weekly", "Monthly", "Annually". - :type recurrence: str or ~azure.mgmt.costmanagement.models.RecurrenceType - :param recurrence_period: Has start and end date of the recurrence. The start date must be in + """The schedule associated with the export. + + :ivar status: The status of the export's schedule. If 'Inactive', the export's schedule is + paused. Possible values include: "Active", "Inactive". + :vartype status: str or ~azure.mgmt.costmanagement.models.StatusType + :ivar recurrence: The schedule recurrence. Possible values include: "Daily", "Weekly", + "Monthly", "Annually". + :vartype recurrence: str or ~azure.mgmt.costmanagement.models.RecurrenceType + :ivar recurrence_period: Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than start date. - :type recurrence_period: ~azure.mgmt.costmanagement.models.ExportRecurrencePeriod + :vartype recurrence_period: ~azure.mgmt.costmanagement.models.ExportRecurrencePeriod """ - _validation = { - 'recurrence': {'required': True}, - } - _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, 'recurrence': {'key': 'recurrence', 'type': 'str'}, @@ -992,32 +1377,127 @@ def __init__( self, **kwargs ): + """ + :keyword status: The status of the export's schedule. If 'Inactive', the export's schedule is + paused. Possible values include: "Active", "Inactive". + :paramtype status: str or ~azure.mgmt.costmanagement.models.StatusType + :keyword recurrence: The schedule recurrence. Possible values include: "Daily", "Weekly", + "Monthly", "Annually". + :paramtype recurrence: str or ~azure.mgmt.costmanagement.models.RecurrenceType + :keyword recurrence_period: Has start and end date of the recurrence. The start date must be in + future. If present, the end date must be greater than start date. + :paramtype recurrence_period: ~azure.mgmt.costmanagement.models.ExportRecurrencePeriod + """ super(ExportSchedule, self).__init__(**kwargs) self.status = kwargs.get('status', None) - self.recurrence = kwargs['recurrence'] + self.recurrence = kwargs.get('recurrence', None) self.recurrence_period = kwargs.get('recurrence_period', None) +class ExportTimePeriod(msrest.serialization.Model): + """The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date range is 3 months. + + All required parameters must be populated in order to send to Azure. + + :ivar from_property: Required. The start date for export data. + :vartype from_property: ~datetime.datetime + :ivar to: Required. The end date for export data. + :vartype to: ~datetime.datetime + """ + + _validation = { + 'from_property': {'required': True}, + 'to': {'required': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword from_property: Required. The start date for export data. + :paramtype from_property: ~datetime.datetime + :keyword to: Required. The end date for export data. + :paramtype to: ~datetime.datetime + """ + super(ExportTimePeriod, self).__init__(**kwargs) + self.from_property = kwargs['from_property'] + self.to = kwargs['to'] + + +class ForecastDataset(msrest.serialization.Model): + """The definition of data present in the forecast. + + :ivar granularity: The granularity of rows in the forecast. Possible values include: "Daily". + :vartype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :ivar configuration: Has configuration information for the data in the export. The + configuration will be ignored if aggregation and grouping are provided. + :vartype configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :ivar aggregation: Dictionary of aggregation expression to use in the forecast. The key of each + item in the dictionary is the alias for the aggregated column. forecast can have up to 2 + aggregation clauses. + :vartype aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] + :ivar filter: Has filter expression to use in the forecast. + :vartype filter: ~azure.mgmt.costmanagement.models.QueryFilter + """ + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'QueryDatasetConfiguration'}, + 'aggregation': {'key': 'aggregation', 'type': '{QueryAggregation}'}, + 'filter': {'key': 'filter', 'type': 'QueryFilter'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword granularity: The granularity of rows in the forecast. Possible values include: + "Daily". + :paramtype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :keyword configuration: Has configuration information for the data in the export. The + configuration will be ignored if aggregation and grouping are provided. + :paramtype configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :keyword aggregation: Dictionary of aggregation expression to use in the forecast. The key of + each item in the dictionary is the alias for the aggregated column. forecast can have up to 2 + aggregation clauses. + :paramtype aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] + :keyword filter: Has filter expression to use in the forecast. + :paramtype filter: ~azure.mgmt.costmanagement.models.QueryFilter + """ + super(ForecastDataset, self).__init__(**kwargs) + self.granularity = kwargs.get('granularity', None) + self.configuration = kwargs.get('configuration', None) + self.aggregation = kwargs.get('aggregation', None) + self.filter = kwargs.get('filter', None) + + class ForecastDefinition(msrest.serialization.Model): """The definition of a forecast. All required parameters must be populated in order to send to Azure. - :param type: Required. The type of the forecast. Possible values include: "Usage", - "ActualCost", "AmortizedCost". - :type type: str or ~azure.mgmt.costmanagement.models.ForecastType - :param timeframe: Required. The time frame for pulling data for the forecast. If custom, then a + :ivar type: Required. The type of the forecast. Possible values include: "Usage", "ActualCost", + "AmortizedCost". + :vartype type: str or ~azure.mgmt.costmanagement.models.ForecastType + :ivar timeframe: Required. The time frame for pulling data for the forecast. If custom, then a specific time period must be provided. Possible values include: "MonthToDate", "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". - :type timeframe: str or ~azure.mgmt.costmanagement.models.ForecastTimeframeType - :param time_period: Has time period for pulling data for the forecast. - :type time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod - :param dataset: Required. Has definition for data in this forecast. - :type dataset: ~azure.mgmt.costmanagement.models.QueryDataset - :param include_actual_cost: a boolean determining if actualCost will be included. - :type include_actual_cost: bool - :param include_fresh_partial_cost: a boolean determining if FreshPartialCost will be included. - :type include_fresh_partial_cost: bool + :vartype timeframe: str or ~azure.mgmt.costmanagement.models.ForecastTimeframeType + :ivar time_period: Has time period for pulling data for the forecast. + :vartype time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :ivar dataset: Required. Has definition for data in this forecast. + :vartype dataset: ~azure.mgmt.costmanagement.models.ForecastDataset + :ivar include_actual_cost: a boolean determining if actualCost will be included. + :vartype include_actual_cost: bool + :ivar include_fresh_partial_cost: a boolean determining if FreshPartialCost will be included. + :vartype include_fresh_partial_cost: bool """ _validation = { @@ -1030,7 +1510,7 @@ class ForecastDefinition(msrest.serialization.Model): 'type': {'key': 'type', 'type': 'str'}, 'timeframe': {'key': 'timeframe', 'type': 'str'}, 'time_period': {'key': 'timePeriod', 'type': 'QueryTimePeriod'}, - 'dataset': {'key': 'dataset', 'type': 'QueryDataset'}, + 'dataset': {'key': 'dataset', 'type': 'ForecastDataset'}, 'include_actual_cost': {'key': 'includeActualCost', 'type': 'bool'}, 'include_fresh_partial_cost': {'key': 'includeFreshPartialCost', 'type': 'bool'}, } @@ -1039,6 +1519,24 @@ def __init__( self, **kwargs ): + """ + :keyword type: Required. The type of the forecast. Possible values include: "Usage", + "ActualCost", "AmortizedCost". + :paramtype type: str or ~azure.mgmt.costmanagement.models.ForecastType + :keyword timeframe: Required. The time frame for pulling data for the forecast. If custom, then + a specific time period must be provided. Possible values include: "MonthToDate", + "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". + :paramtype timeframe: str or ~azure.mgmt.costmanagement.models.ForecastTimeframeType + :keyword time_period: Has time period for pulling data for the forecast. + :paramtype time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :keyword dataset: Required. Has definition for data in this forecast. + :paramtype dataset: ~azure.mgmt.costmanagement.models.ForecastDataset + :keyword include_actual_cost: a boolean determining if actualCost will be included. + :paramtype include_actual_cost: bool + :keyword include_fresh_partial_cost: a boolean determining if FreshPartialCost will be + included. + :paramtype include_fresh_partial_cost: bool + """ super(ForecastDefinition, self).__init__(**kwargs) self.type = kwargs['type'] self.timeframe = kwargs['timeframe'] @@ -1048,15 +1546,260 @@ def __init__( self.include_fresh_partial_cost = kwargs.get('include_fresh_partial_cost', None) +class GenerateDetailedCostReportDefinition(msrest.serialization.Model): + """The definition of a cost detailed report. + + :ivar metric: The type of the detailed report. By default ActualCost is provided. Possible + values include: "ActualCost", "AmortizedCost". + :vartype metric: str or ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportMetricType + :ivar time_period: Has time period for pulling data for the cost detailed report. Can only have + one of either timePeriod or invoiceId or billingPeriod parameters. If none provided current + month cost is provided. + :vartype time_period: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportTimePeriod + :ivar billing_period: Billing Period in YearMonth(e.g. 202008) format. Only for legacy + enterprise customers can use this. Can only have one of either timePeriod or invoiceId or + billingPeriod parameters. If none provided current month cost is provided. + :vartype billing_period: str + :ivar invoice_id: Invoice Id for PayAsYouGo customers and Modern billing profile scope. Can + only have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided + current month cost is provided. + :vartype invoice_id: str + :ivar customer_id: Customer Id for Modern (Invoice Id and billing profile is also required for + this). + :vartype customer_id: str + """ + + _attribute_map = { + 'metric': {'key': 'metric', 'type': 'str'}, + 'time_period': {'key': 'timePeriod', 'type': 'GenerateDetailedCostReportTimePeriod'}, + 'billing_period': {'key': 'billingPeriod', 'type': 'str'}, + 'invoice_id': {'key': 'invoiceId', 'type': 'str'}, + 'customer_id': {'key': 'customerId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword metric: The type of the detailed report. By default ActualCost is provided. Possible + values include: "ActualCost", "AmortizedCost". + :paramtype metric: str or + ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportMetricType + :keyword time_period: Has time period for pulling data for the cost detailed report. Can only + have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided + current month cost is provided. + :paramtype time_period: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportTimePeriod + :keyword billing_period: Billing Period in YearMonth(e.g. 202008) format. Only for legacy + enterprise customers can use this. Can only have one of either timePeriod or invoiceId or + billingPeriod parameters. If none provided current month cost is provided. + :paramtype billing_period: str + :keyword invoice_id: Invoice Id for PayAsYouGo customers and Modern billing profile scope. Can + only have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided + current month cost is provided. + :paramtype invoice_id: str + :keyword customer_id: Customer Id for Modern (Invoice Id and billing profile is also required + for this). + :paramtype customer_id: str + """ + super(GenerateDetailedCostReportDefinition, self).__init__(**kwargs) + self.metric = kwargs.get('metric', None) + self.time_period = kwargs.get('time_period', None) + self.billing_period = kwargs.get('billing_period', None) + self.invoice_id = kwargs.get('invoice_id', None) + self.customer_id = kwargs.get('customer_id', None) + + +class GenerateDetailedCostReportErrorResponse(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. + +Some Error responses: + + +* + 413 Request Entity Too Large - Request is throttled. The amount of data required to fulfill the request exceeds the maximum size permitted of 2Gb. Please utilize our Exports feature instead. + +* + 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.costmanagement.models.ErrorDetails + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetails'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.costmanagement.models.ErrorDetails + """ + super(GenerateDetailedCostReportErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class GenerateDetailedCostReportOperationResult(msrest.serialization.Model): + """The result of the long running operation for cost detailed report. + + :ivar id: The id of the long running operation. + :vartype id: str + :ivar name: The name of the long running operation. + :vartype name: str + :ivar type: The type of the long running operation. + :vartype type: str + :ivar download_url: The URL to download the generated report. + :vartype download_url: str + :ivar valid_till: The time at which report URL becomes invalid/expires in UTC e.g. + 2020-12-08T05:55:59.4394737Z. + :vartype valid_till: ~datetime.datetime + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'download_url': {'key': 'properties.downloadUrl', 'type': 'str'}, + 'valid_till': {'key': 'properties.validTill', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword id: The id of the long running operation. + :paramtype id: str + :keyword name: The name of the long running operation. + :paramtype name: str + :keyword type: The type of the long running operation. + :paramtype type: str + :keyword download_url: The URL to download the generated report. + :paramtype download_url: str + :keyword valid_till: The time at which report URL becomes invalid/expires in UTC e.g. + 2020-12-08T05:55:59.4394737Z. + :paramtype valid_till: ~datetime.datetime + """ + super(GenerateDetailedCostReportOperationResult, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) + self.download_url = kwargs.get('download_url', None) + self.valid_till = kwargs.get('valid_till', None) + + +class GenerateDetailedCostReportOperationStatuses(msrest.serialization.Model): + """The status of the long running operation for cost detailed report. + + :ivar id: The id of the long running operation. + :vartype id: str + :ivar name: The name of the long running operation. + :vartype name: str + :ivar status: The status of the long running operation. + :vartype status: ~azure.mgmt.costmanagement.models.Status + :ivar type: The type of the long running operation. + :vartype type: str + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.costmanagement.models.ErrorDetails + :ivar download_url: The URL to download the generated report. + :vartype download_url: str + :ivar valid_till: The time at which report URL becomes invalid/expires in UTC e.g. + 2020-12-08T05:55:59.4394737Z. + :vartype valid_till: ~datetime.datetime + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'Status'}, + 'type': {'key': 'type', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorDetails'}, + 'download_url': {'key': 'properties.downloadUrl', 'type': 'str'}, + 'valid_till': {'key': 'properties.validTill', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword id: The id of the long running operation. + :paramtype id: str + :keyword name: The name of the long running operation. + :paramtype name: str + :keyword status: The status of the long running operation. + :paramtype status: ~azure.mgmt.costmanagement.models.Status + :keyword type: The type of the long running operation. + :paramtype type: str + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.costmanagement.models.ErrorDetails + :keyword download_url: The URL to download the generated report. + :paramtype download_url: str + :keyword valid_till: The time at which report URL becomes invalid/expires in UTC e.g. + 2020-12-08T05:55:59.4394737Z. + :paramtype valid_till: ~datetime.datetime + """ + super(GenerateDetailedCostReportOperationStatuses, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs.get('name', None) + self.status = kwargs.get('status', None) + self.type = kwargs.get('type', None) + self.error = kwargs.get('error', None) + self.download_url = kwargs.get('download_url', None) + self.valid_till = kwargs.get('valid_till', None) + + +class GenerateDetailedCostReportTimePeriod(msrest.serialization.Model): + """The start and end date for pulling data for the cost detailed report. + + All required parameters must be populated in order to send to Azure. + + :ivar start: Required. The start date to pull data from. example format 2020-03-15. + :vartype start: str + :ivar end: Required. The end date to pull data to. example format 2020-03-15. + :vartype end: str + """ + + _validation = { + 'start': {'required': True}, + 'end': {'required': True}, + } + + _attribute_map = { + 'start': {'key': 'start', 'type': 'str'}, + 'end': {'key': 'end', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword start: Required. The start date to pull data from. example format 2020-03-15. + :paramtype start: str + :keyword end: Required. The end date to pull data to. example format 2020-03-15. + :paramtype end: str + """ + super(GenerateDetailedCostReportTimePeriod, self).__init__(**kwargs) + self.start = kwargs['start'] + self.end = kwargs['end'] + + class KpiProperties(msrest.serialization.Model): """Each KPI must contain a 'type' and 'enabled' key. - :param type: KPI type (Forecast, Budget). Possible values include: "Forecast", "Budget". - :type type: str or ~azure.mgmt.costmanagement.models.KpiType - :param id: ID of resource related to metric (budget). - :type id: str - :param enabled: show the KPI in the UI?. - :type enabled: bool + :ivar type: KPI type (Forecast, Budget). Possible values include: "Forecast", "Budget". + :vartype type: str or ~azure.mgmt.costmanagement.models.KpiType + :ivar id: ID of resource related to metric (budget). + :vartype id: str + :ivar enabled: show the KPI in the UI?. + :vartype enabled: bool """ _attribute_map = { @@ -1069,6 +1812,14 @@ def __init__( self, **kwargs ): + """ + :keyword type: KPI type (Forecast, Budget). Possible values include: "Forecast", "Budget". + :paramtype type: str or ~azure.mgmt.costmanagement.models.KpiType + :keyword id: ID of resource related to metric (budget). + :paramtype id: str + :keyword enabled: show the KPI in the UI?. + :paramtype enabled: bool + """ super(KpiProperties, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.id = kwargs.get('id', None) @@ -1082,8 +1833,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.costmanagement.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.costmanagement.models.OperationDisplay """ _validation = { @@ -1099,6 +1850,10 @@ def __init__( self, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.costmanagement.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = kwargs.get('display', None) @@ -1133,6 +1888,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1165,45 +1922,20 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None -class OperationStatus(msrest.serialization.Model): - """The status of the long running operation. - - :param status: The status of the long running operation. - :type status: ~azure.mgmt.costmanagement.models.Status - :param report_url: The URL to download the generated report. - :type report_url: str - :param valid_until: The time at which report URL becomes invalid. - :type valid_until: ~datetime.datetime - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'Status'}, - 'report_url': {'key': 'properties.reportUrl', 'type': 'str'}, - 'valid_until': {'key': 'properties.validUntil', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationStatus, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.report_url = kwargs.get('report_url', None) - self.valid_until = kwargs.get('valid_until', None) - - class PivotProperties(msrest.serialization.Model): """Each pivot must contain a 'type' and 'name'. - :param type: Data type to show in view. Possible values include: "Dimension", "TagKey". - :type type: str or ~azure.mgmt.costmanagement.models.PivotType - :param name: Data field to show in view. - :type name: str + :ivar type: Data type to show in view. Possible values include: "Dimension", "TagKey". + :vartype type: str or ~azure.mgmt.costmanagement.models.PivotType + :ivar name: Data field to show in view. + :vartype name: str """ _attribute_map = { @@ -1215,61 +1947,27 @@ def __init__( self, **kwargs ): + """ + :keyword type: Data type to show in view. Possible values include: "Dimension", "TagKey". + :paramtype type: str or ~azure.mgmt.costmanagement.models.PivotType + :keyword name: Data field to show in view. + :paramtype name: str + """ super(PivotProperties, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.name = kwargs.get('name', None) -class ProxySettingResource(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. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar kind: Resource kind. - :vartype kind: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True, 'max_length': 10, 'min_length': 0}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxySettingResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.kind = None - self.type = None - - class QueryAggregation(msrest.serialization.Model): """The aggregation expression to be used in the query. All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the column to aggregate. - :type name: str - :param function: Required. The name of the aggregation function to use. Possible values - include: "Avg", "Max", "Min", "Sum". - :type function: str or ~azure.mgmt.costmanagement.models.FunctionType + :ivar name: Required. The name of the column to aggregate. + :vartype name: str + :ivar function: Required. The name of the aggregation function to use. Possible values include: + "Sum". + :vartype function: str or ~azure.mgmt.costmanagement.models.FunctionType """ _validation = { @@ -1286,18 +1984,25 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the column to aggregate. + :paramtype name: str + :keyword function: Required. The name of the aggregation function to use. Possible values + include: "Sum". + :paramtype function: str or ~azure.mgmt.costmanagement.models.FunctionType + """ super(QueryAggregation, self).__init__(**kwargs) self.name = kwargs['name'] self.function = kwargs['function'] class QueryColumn(msrest.serialization.Model): - """QueryColumn. + """QueryColumn properties. - :param name: The name of column. - :type name: str - :param type: The type of column. - :type type: str + :ivar name: The name of column. + :vartype name: str + :ivar type: The type of column. + :vartype type: str """ _attribute_map = { @@ -1309,6 +2014,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of column. + :paramtype name: str + :keyword type: The type of column. + :paramtype type: str + """ super(QueryColumn, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.type = kwargs.get('type', None) @@ -1319,13 +2030,12 @@ class QueryComparisonExpression(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", - "Contains". - :type operator: str or ~azure.mgmt.costmanagement.models.OperatorType - :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.costmanagement.models.QueryOperatorType + :ivar values: Required. Array of values to use for comparison. + :vartype values: list[str] """ _validation = { @@ -1344,6 +2054,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.costmanagement.models.QueryOperatorType + :keyword values: Required. Array of values to use for comparison. + :paramtype values: list[str] + """ super(QueryComparisonExpression, self).__init__(**kwargs) self.name = kwargs['name'] self.operator = kwargs['operator'] @@ -1353,21 +2071,21 @@ def __init__( class QueryDataset(msrest.serialization.Model): """The definition of data present in the query. - :param granularity: The granularity of rows in the query. Possible values include: "Daily". - :type granularity: str or ~azure.mgmt.costmanagement.models.GranularityType - :param configuration: Has configuration information for the data in the export. The + :ivar granularity: The granularity of rows in the query. Possible values include: "Daily". + :vartype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :ivar configuration: Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided. - :type configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration - :param aggregation: Dictionary of aggregation expression to use in the query. The key of each + :vartype configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :ivar aggregation: Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the aggregated column. Query can have up to 2 aggregation clauses. - :type aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] - :param grouping: Array of group by expression to use in the query. Query can have up to 2 group + :vartype aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] + :ivar grouping: Array of group by expression to use in the query. Query can have up to 2 group by clauses. - :type grouping: list[~azure.mgmt.costmanagement.models.QueryGrouping] - :param filter: The filter expression to use in the query. Please reference our Query API REST + :vartype grouping: list[~azure.mgmt.costmanagement.models.QueryGrouping] + :ivar filter: The filter expression to use in the query. Please reference our Query API REST documentation for how to properly format the filter. - :type filter: ~azure.mgmt.costmanagement.models.QueryFilter + :vartype filter: ~azure.mgmt.costmanagement.models.QueryFilter """ _validation = { @@ -1386,6 +2104,23 @@ def __init__( self, **kwargs ): + """ + :keyword granularity: The granularity of rows in the query. Possible values include: "Daily". + :paramtype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :keyword configuration: Has configuration information for the data in the export. The + configuration will be ignored if aggregation and grouping are provided. + :paramtype configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :keyword aggregation: Dictionary of aggregation expression to use in the query. The key of each + item in the dictionary is the alias for the aggregated column. Query can have up to 2 + aggregation clauses. + :paramtype aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] + :keyword grouping: Array of group by expression to use in the query. Query can have up to 2 + group by clauses. + :paramtype grouping: list[~azure.mgmt.costmanagement.models.QueryGrouping] + :keyword filter: The filter expression to use in the query. Please reference our Query API REST + documentation for how to properly format the filter. + :paramtype filter: ~azure.mgmt.costmanagement.models.QueryFilter + """ super(QueryDataset, self).__init__(**kwargs) self.granularity = kwargs.get('granularity', None) self.configuration = kwargs.get('configuration', None) @@ -1394,56 +2129,12 @@ def __init__( self.filter = kwargs.get('filter', None) -class QueryDatasetAutoGenerated(msrest.serialization.Model): - """The definition of data present in the query. - - :param granularity: The granularity of rows in the query. Possible values include: "Daily". - :type granularity: str or ~azure.mgmt.costmanagement.models.GranularityType - :param configuration: Has configuration information for the data in the export. The - configuration will be ignored if aggregation and grouping are provided. - :type configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration - :param aggregation: Dictionary of aggregation expression to use in the query. The key of each - item in the dictionary is the alias for the aggregated column. Query can have up to 2 - aggregation clauses. - :type aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] - :param grouping: Array of group by expression to use in the query. Query can have up to 2 group - by clauses. - :type grouping: list[~azure.mgmt.costmanagement.models.QueryGrouping] - :param filter: The filter expression to use in the query. Please reference our Query API REST - documentation for how to properly format the filter. - :type filter: ~azure.mgmt.costmanagement.models.QueryFilterAutoGenerated - """ - - _validation = { - 'grouping': {'max_items': 2, 'min_items': 0}, - } - - _attribute_map = { - 'granularity': {'key': 'granularity', 'type': 'str'}, - 'configuration': {'key': 'configuration', 'type': 'QueryDatasetConfiguration'}, - 'aggregation': {'key': 'aggregation', 'type': '{QueryAggregation}'}, - 'grouping': {'key': 'grouping', 'type': '[QueryGrouping]'}, - 'filter': {'key': 'filter', 'type': 'QueryFilterAutoGenerated'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryDatasetAutoGenerated, self).__init__(**kwargs) - self.granularity = kwargs.get('granularity', None) - self.configuration = kwargs.get('configuration', None) - self.aggregation = kwargs.get('aggregation', None) - self.grouping = kwargs.get('grouping', None) - self.filter = kwargs.get('filter', None) - - class QueryDatasetConfiguration(msrest.serialization.Model): """The configuration of dataset in the query. - :param columns: Array of column names to be included in the query. Any valid query column name + :ivar columns: Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns. - :type columns: list[str] + :vartype columns: list[str] """ _attribute_map = { @@ -1454,6 +2145,11 @@ def __init__( self, **kwargs ): + """ + :keyword columns: Array of column names to be included in the query. Any valid query column + name is allowed. If not provided, then query includes all columns. + :paramtype columns: list[str] + """ super(QueryDatasetConfiguration, self).__init__(**kwargs) self.columns = kwargs.get('columns', None) @@ -1463,17 +2159,17 @@ class QueryDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of the query. Possible values include: "Usage", "ActualCost", + :ivar type: Required. The type of the query. Possible values include: "Usage", "ActualCost", "AmortizedCost". - :type type: str or ~azure.mgmt.costmanagement.models.ExportType - :param timeframe: Required. The time frame for pulling data for the query. If custom, then a + :vartype type: str or ~azure.mgmt.costmanagement.models.ExportType + :ivar timeframe: Required. The time frame for pulling data for the query. If custom, then a specific time period must be provided. Possible values include: "MonthToDate", "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". - :type timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType - :param time_period: Has time period for pulling data for the query. - :type time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod - :param dataset: Required. Has definition for data in this query. - :type dataset: ~azure.mgmt.costmanagement.models.QueryDataset + :vartype timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :ivar time_period: Has time period for pulling data for the query. + :vartype time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :ivar dataset: Required. Has definition for data in this query. + :vartype dataset: ~azure.mgmt.costmanagement.models.QueryDataset """ _validation = { @@ -1493,6 +2189,19 @@ def __init__( self, **kwargs ): + """ + :keyword type: Required. The type of the query. Possible values include: "Usage", "ActualCost", + "AmortizedCost". + :paramtype type: str or ~azure.mgmt.costmanagement.models.ExportType + :keyword timeframe: Required. The time frame for pulling data for the query. If custom, then a + specific time period must be provided. Possible values include: "MonthToDate", + "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". + :paramtype timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :keyword time_period: Has time period for pulling data for the query. + :paramtype time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :keyword dataset: Required. Has definition for data in this query. + :paramtype dataset: ~azure.mgmt.costmanagement.models.QueryDataset + """ super(QueryDefinition, self).__init__(**kwargs) self.type = kwargs['type'] self.timeframe = kwargs['timeframe'] @@ -1503,14 +2212,16 @@ def __init__( class QueryFilter(msrest.serialization.Model): """The filter expression to be used in the export. - :param and_property: The logical "AND" expression. Must have at least 2 items. - :type and_property: list[~azure.mgmt.costmanagement.models.QueryFilter] - :param or_property: The logical "OR" expression. Must have at least 2 items. - :type or_property: list[~azure.mgmt.costmanagement.models.QueryFilter] - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.costmanagement.models.QueryComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.costmanagement.models.QueryComparisonExpression + :ivar and_property: The logical "AND" expression. Must have at least 2 items. + :vartype and_property: list[~azure.mgmt.costmanagement.models.QueryFilter] + :ivar or_property: The logical "OR" expression. Must have at least 2 items. + :vartype or_property: list[~azure.mgmt.costmanagement.models.QueryFilter] + :ivar not_property: The logical "NOT" expression. + :vartype not_property: ~azure.mgmt.costmanagement.models.QueryFilter + :ivar dimension: Has comparison expression for a dimension. + :vartype dimension: ~azure.mgmt.costmanagement.models.QueryComparisonExpression + :ivar tag: Has comparison expression for a tag. + :vartype tag: ~azure.mgmt.costmanagement.models.QueryComparisonExpression """ _validation = { @@ -1521,55 +2232,33 @@ class QueryFilter(msrest.serialization.Model): _attribute_map = { 'and_property': {'key': 'and', 'type': '[QueryFilter]'}, 'or_property': {'key': 'or', 'type': '[QueryFilter]'}, - 'dimensions': {'key': 'dimensions', 'type': 'QueryComparisonExpression'}, - 'tags': {'key': 'tags', 'type': 'QueryComparisonExpression'}, + 'not_property': {'key': 'not', 'type': 'QueryFilter'}, + 'dimension': {'key': 'dimension', 'type': 'QueryComparisonExpression'}, + 'tag': {'key': 'tag', 'type': 'QueryComparisonExpression'}, } def __init__( self, **kwargs ): + """ + :keyword and_property: The logical "AND" expression. Must have at least 2 items. + :paramtype and_property: list[~azure.mgmt.costmanagement.models.QueryFilter] + :keyword or_property: The logical "OR" expression. Must have at least 2 items. + :paramtype or_property: list[~azure.mgmt.costmanagement.models.QueryFilter] + :keyword not_property: The logical "NOT" expression. + :paramtype not_property: ~azure.mgmt.costmanagement.models.QueryFilter + :keyword dimension: Has comparison expression for a dimension. + :paramtype dimension: ~azure.mgmt.costmanagement.models.QueryComparisonExpression + :keyword tag: Has comparison expression for a tag. + :paramtype tag: ~azure.mgmt.costmanagement.models.QueryComparisonExpression + """ super(QueryFilter, self).__init__(**kwargs) self.and_property = kwargs.get('and_property', None) self.or_property = kwargs.get('or_property', None) - self.dimensions = kwargs.get('dimensions', None) - self.tags = kwargs.get('tags', None) - - -class QueryFilterAutoGenerated(msrest.serialization.Model): - """The filter expression to be used in the export. - - :param and_property: The logical "AND" expression. Must have at least 2 items. - :type and_property: list[~azure.mgmt.costmanagement.models.QueryFilterAutoGenerated] - :param or_property: The logical "OR" expression. Must have at least 2 items. - :type or_property: list[~azure.mgmt.costmanagement.models.QueryFilterAutoGenerated] - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.costmanagement.models.QueryComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.costmanagement.models.QueryComparisonExpression - """ - - _validation = { - 'and_property': {'min_items': 2}, - 'or_property': {'min_items': 2}, - } - - _attribute_map = { - 'and_property': {'key': 'and', 'type': '[QueryFilterAutoGenerated]'}, - 'or_property': {'key': 'or', 'type': '[QueryFilterAutoGenerated]'}, - 'dimensions': {'key': 'dimensions', 'type': 'QueryComparisonExpression'}, - 'tags': {'key': 'tags', 'type': 'QueryComparisonExpression'}, - } - - def __init__( - self, - **kwargs - ): - super(QueryFilterAutoGenerated, self).__init__(**kwargs) - self.and_property = kwargs.get('and_property', None) - self.or_property = kwargs.get('or_property', None) - self.dimensions = kwargs.get('dimensions', None) - self.tags = kwargs.get('tags', None) + self.not_property = kwargs.get('not_property', None) + self.dimension = kwargs.get('dimension', None) + self.tag = kwargs.get('tag', None) class QueryGrouping(msrest.serialization.Model): @@ -1577,11 +2266,11 @@ class QueryGrouping(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. Has type of the column to group. Possible values include: "Tag", + :ivar type: Required. Has type of the column to group. Possible values include: "Tag", "Dimension". - :type type: str or ~azure.mgmt.costmanagement.models.QueryColumnType - :param name: Required. The name of the column to group. - :type name: str + :vartype type: str or ~azure.mgmt.costmanagement.models.QueryColumnType + :ivar name: Required. The name of the column to group. + :vartype name: str """ _validation = { @@ -1598,6 +2287,13 @@ def __init__( self, **kwargs ): + """ + :keyword type: Required. Has type of the column to group. Possible values include: "Tag", + "Dimension". + :paramtype type: str or ~azure.mgmt.costmanagement.models.QueryColumnType + :keyword name: Required. The name of the column to group. + :paramtype name: str + """ super(QueryGrouping, self).__init__(**kwargs) self.type = kwargs['type'] self.name = kwargs['name'] @@ -1614,40 +2310,40 @@ class QueryResult(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 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 - :ivar location: Resource location. + :ivar location: Location of the resource. :vartype location: str - :ivar sku: Resource SKU. + :ivar sku: SKU of the resource. :vartype sku: str - :param next_link: The link (url) to the next page of results. - :type next_link: str - :param columns: Array of columns. - :type columns: list[~azure.mgmt.costmanagement.models.QueryColumn] - :param rows: Array of rows. - :type rows: list[list[any]] + :ivar e_tag: ETag of the resource. + :vartype e_tag: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + :ivar columns: Array of columns. + :vartype columns: list[~azure.mgmt.costmanagement.models.QueryColumn] + :ivar rows: Array of rows. + :vartype rows: list[list[any]] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'location': {'readonly': True}, 'sku': {'readonly': True}, + 'e_tag': {'readonly': True}, + 'tags': {'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'}, 'location': {'key': 'location', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, 'columns': {'key': 'properties.columns', 'type': '[QueryColumn]'}, 'rows': {'key': 'properties.rows', 'type': '[[object]]'}, @@ -1657,10 +2353,15 @@ def __init__( self, **kwargs ): + """ + :keyword next_link: The link (url) to the next page of results. + :paramtype next_link: str + :keyword columns: Array of columns. + :paramtype columns: list[~azure.mgmt.costmanagement.models.QueryColumn] + :keyword rows: Array of rows. + :paramtype rows: list[list[any]] + """ super(QueryResult, self).__init__(**kwargs) - self.e_tag = kwargs.get('e_tag', None) - self.location = None - self.sku = None self.next_link = kwargs.get('next_link', None) self.columns = kwargs.get('columns', None) self.rows = kwargs.get('rows', None) @@ -1671,10 +2372,10 @@ class QueryTimePeriod(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param from_property: Required. The start date to pull data from. - :type from_property: ~datetime.datetime - :param to: Required. The end date to pull data to. - :type to: ~datetime.datetime + :ivar from_property: Required. The start date to pull data from. + :vartype from_property: ~datetime.datetime + :ivar to: Required. The end date to pull data to. + :vartype to: ~datetime.datetime """ _validation = { @@ -1691,6 +2392,12 @@ def __init__( self, **kwargs ): + """ + :keyword from_property: Required. The start date to pull data from. + :paramtype from_property: ~datetime.datetime + :keyword to: Required. The end date to pull data to. + :paramtype to: ~datetime.datetime + """ super(QueryTimePeriod, self).__init__(**kwargs) self.from_property = kwargs['from_property'] self.to = kwargs['to'] @@ -1701,11 +2408,11 @@ class ReportConfigAggregation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the column to aggregate. - :type name: str - :param function: Required. The name of the aggregation function to use. Possible values - include: "Avg", "Max", "Min", "Sum". - :type function: str or ~azure.mgmt.costmanagement.models.FunctionType + :ivar name: Required. The name of the column to aggregate. + :vartype name: str + :ivar function: Required. The name of the aggregation function to use. Possible values include: + "Sum". + :vartype function: str or ~azure.mgmt.costmanagement.models.FunctionType """ _validation = { @@ -1722,6 +2429,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the column to aggregate. + :paramtype name: str + :keyword function: Required. The name of the aggregation function to use. Possible values + include: "Sum". + :paramtype function: str or ~azure.mgmt.costmanagement.models.FunctionType + """ super(ReportConfigAggregation, self).__init__(**kwargs) self.name = kwargs['name'] self.function = kwargs['function'] @@ -1732,13 +2446,13 @@ class ReportConfigComparisonExpression(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", + :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", "Contains". - :type operator: str or ~azure.mgmt.costmanagement.models.OperatorType - :param values: Required. Array of values to use for comparison. - :type values: list[str] + :vartype operator: str or ~azure.mgmt.costmanagement.models.OperatorType + :ivar values: Required. Array of values to use for comparison. + :vartype values: list[str] """ _validation = { @@ -1757,6 +2471,15 @@ 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", + "Contains". + :paramtype operator: str or ~azure.mgmt.costmanagement.models.OperatorType + :keyword values: Required. Array of values to use for comparison. + :paramtype values: list[str] + """ super(ReportConfigComparisonExpression, self).__init__(**kwargs) self.name = kwargs['name'] self.operator = kwargs['operator'] @@ -1766,23 +2489,23 @@ def __init__( class ReportConfigDataset(msrest.serialization.Model): """The definition of data present in the report. - :param granularity: The granularity of rows in the report. Possible values include: "Daily", + :ivar granularity: The granularity of rows in the report. Possible values include: "Daily", "Monthly". - :type granularity: str or ~azure.mgmt.costmanagement.models.ReportGranularityType - :param configuration: Has configuration information for the data in the report. The + :vartype granularity: str or ~azure.mgmt.costmanagement.models.ReportGranularityType + :ivar configuration: Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping are provided. - :type configuration: ~azure.mgmt.costmanagement.models.ReportConfigDatasetConfiguration - :param aggregation: Dictionary of aggregation expression to use in the report. The key of each + :vartype configuration: ~azure.mgmt.costmanagement.models.ReportConfigDatasetConfiguration + :ivar aggregation: Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses. - :type aggregation: dict[str, ~azure.mgmt.costmanagement.models.ReportConfigAggregation] - :param grouping: Array of group by expression to use in the report. Report can have up to 2 + :vartype aggregation: dict[str, ~azure.mgmt.costmanagement.models.ReportConfigAggregation] + :ivar grouping: Array of group by expression to use in the report. Report can have up to 2 group by clauses. - :type grouping: list[~azure.mgmt.costmanagement.models.ReportConfigGrouping] - :param sorting: Array of order by expression to use in the report. - :type sorting: list[~azure.mgmt.costmanagement.models.ReportConfigSorting] - :param filter: Has filter expression to use in the report. - :type filter: ~azure.mgmt.costmanagement.models.ReportConfigFilter + :vartype grouping: list[~azure.mgmt.costmanagement.models.ReportConfigGrouping] + :ivar sorting: Array of order by expression to use in the report. + :vartype sorting: list[~azure.mgmt.costmanagement.models.ReportConfigSorting] + :ivar filter: Has filter expression to use in the report. + :vartype filter: ~azure.mgmt.costmanagement.models.ReportConfigFilter """ _validation = { @@ -1802,6 +2525,25 @@ def __init__( self, **kwargs ): + """ + :keyword granularity: The granularity of rows in the report. Possible values include: "Daily", + "Monthly". + :paramtype granularity: str or ~azure.mgmt.costmanagement.models.ReportGranularityType + :keyword configuration: Has configuration information for the data in the report. The + configuration will be ignored if aggregation and grouping are provided. + :paramtype configuration: ~azure.mgmt.costmanagement.models.ReportConfigDatasetConfiguration + :keyword aggregation: Dictionary of aggregation expression to use in the report. The key of + each item in the dictionary is the alias for the aggregated column. Report can have up to 2 + aggregation clauses. + :paramtype aggregation: dict[str, ~azure.mgmt.costmanagement.models.ReportConfigAggregation] + :keyword grouping: Array of group by expression to use in the report. Report can have up to 2 + group by clauses. + :paramtype grouping: list[~azure.mgmt.costmanagement.models.ReportConfigGrouping] + :keyword sorting: Array of order by expression to use in the report. + :paramtype sorting: list[~azure.mgmt.costmanagement.models.ReportConfigSorting] + :keyword filter: Has filter expression to use in the report. + :paramtype filter: ~azure.mgmt.costmanagement.models.ReportConfigFilter + """ super(ReportConfigDataset, self).__init__(**kwargs) self.granularity = kwargs.get('granularity', None) self.configuration = kwargs.get('configuration', None) @@ -1814,9 +2556,9 @@ def __init__( class ReportConfigDatasetConfiguration(msrest.serialization.Model): """The configuration of dataset in the report. - :param columns: Array of column names to be included in the report. Any valid report column - name is allowed. If not provided, then report includes all columns. - :type columns: list[str] + :ivar columns: Array of column names to be included in the report. Any valid report column name + is allowed. If not provided, then report includes all columns. + :vartype columns: list[str] """ _attribute_map = { @@ -1827,6 +2569,11 @@ def __init__( self, **kwargs ): + """ + :keyword columns: Array of column names to be included in the report. Any valid report column + name is allowed. If not provided, then report includes all columns. + :paramtype columns: list[str] + """ super(ReportConfigDatasetConfiguration, self).__init__(**kwargs) self.columns = kwargs.get('columns', None) @@ -1834,18 +2581,16 @@ def __init__( class ReportConfigFilter(msrest.serialization.Model): """The filter expression to be used in the report. - :param and_property: The logical "AND" expression. Must have at least 2 items. - :type and_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] - :param or_property: The logical "OR" expression. Must have at least 2 items. - :type or_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression - :param tag_key: Has comparison expression for a tag key. - :type tag_key: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression - :param tag_value: Has comparison expression for a tag value. - :type tag_value: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + :ivar and_property: The logical "AND" expression. Must have at least 2 items. + :vartype and_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :ivar or_property: The logical "OR" expression. Must have at least 2 items. + :vartype or_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :ivar not_property: The logical "NOT" expression. + :vartype not_property: ~azure.mgmt.costmanagement.models.ReportConfigFilter + :ivar dimension: Has comparison expression for a dimension. + :vartype dimension: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + :ivar tag: Has comparison expression for a tag. + :vartype tag: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression """ _validation = { @@ -1856,23 +2601,33 @@ class ReportConfigFilter(msrest.serialization.Model): _attribute_map = { 'and_property': {'key': 'and', 'type': '[ReportConfigFilter]'}, 'or_property': {'key': 'or', 'type': '[ReportConfigFilter]'}, - 'dimensions': {'key': 'dimensions', 'type': 'ReportConfigComparisonExpression'}, - 'tags': {'key': 'tags', 'type': 'ReportConfigComparisonExpression'}, - 'tag_key': {'key': 'tagKey', 'type': 'ReportConfigComparisonExpression'}, - 'tag_value': {'key': 'tagValue', 'type': 'ReportConfigComparisonExpression'}, + 'not_property': {'key': 'not', 'type': 'ReportConfigFilter'}, + 'dimension': {'key': 'dimension', 'type': 'ReportConfigComparisonExpression'}, + 'tag': {'key': 'tag', 'type': 'ReportConfigComparisonExpression'}, } def __init__( self, **kwargs ): + """ + :keyword and_property: The logical "AND" expression. Must have at least 2 items. + :paramtype and_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :keyword or_property: The logical "OR" expression. Must have at least 2 items. + :paramtype or_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :keyword not_property: The logical "NOT" expression. + :paramtype not_property: ~azure.mgmt.costmanagement.models.ReportConfigFilter + :keyword dimension: Has comparison expression for a dimension. + :paramtype dimension: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + :keyword tag: Has comparison expression for a tag. + :paramtype tag: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + """ super(ReportConfigFilter, self).__init__(**kwargs) self.and_property = kwargs.get('and_property', None) self.or_property = kwargs.get('or_property', None) - self.dimensions = kwargs.get('dimensions', None) - self.tags = kwargs.get('tags', None) - self.tag_key = kwargs.get('tag_key', None) - self.tag_value = kwargs.get('tag_value', None) + self.not_property = kwargs.get('not_property', None) + self.dimension = kwargs.get('dimension', None) + self.tag = kwargs.get('tag', None) class ReportConfigGrouping(msrest.serialization.Model): @@ -1880,12 +2635,12 @@ class ReportConfigGrouping(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. Has type of the column to group. Possible values include: "Tag", + :ivar type: Required. Has type of the column to group. Possible values include: "Tag", "Dimension". - :type type: str or ~azure.mgmt.costmanagement.models.ReportConfigColumnType - :param name: Required. The name of the column to group. This version supports subscription + :vartype type: str or ~azure.mgmt.costmanagement.models.ReportConfigColumnType + :ivar name: Required. The name of the column to group. This version supports subscription lowest possible grain. - :type name: str + :vartype name: str """ _validation = { @@ -1902,6 +2657,14 @@ def __init__( self, **kwargs ): + """ + :keyword type: Required. Has type of the column to group. Possible values include: "Tag", + "Dimension". + :paramtype type: str or ~azure.mgmt.costmanagement.models.ReportConfigColumnType + :keyword name: Required. The name of the column to group. This version supports subscription + lowest possible grain. + :paramtype name: str + """ super(ReportConfigGrouping, self).__init__(**kwargs) self.type = kwargs['type'] self.name = kwargs['name'] @@ -1912,10 +2675,10 @@ class ReportConfigSorting(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param direction: Direction of sort. Possible values include: "Ascending", "Descending". - :type direction: str or ~azure.mgmt.costmanagement.models.ReportConfigSortingDirection - :param name: Required. The name of the column to sort. - :type name: str + :ivar direction: Direction of sort. Possible values include: "Ascending", "Descending". + :vartype direction: str or ~azure.mgmt.costmanagement.models.ReportConfigSortingDirection + :ivar name: Required. The name of the column to sort. + :vartype name: str """ _validation = { @@ -1931,6 +2694,12 @@ def __init__( self, **kwargs ): + """ + :keyword direction: Direction of sort. Possible values include: "Ascending", "Descending". + :paramtype direction: str or ~azure.mgmt.costmanagement.models.ReportConfigSortingDirection + :keyword name: Required. The name of the column to sort. + :paramtype name: str + """ super(ReportConfigSorting, self).__init__(**kwargs) self.direction = kwargs.get('direction', None) self.name = kwargs['name'] @@ -1941,10 +2710,10 @@ class ReportConfigTimePeriod(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param from_property: Required. The start date to pull data from. - :type from_property: ~datetime.datetime - :param to: Required. The end date to pull data to. - :type to: ~datetime.datetime + :ivar from_property: Required. The start date to pull data from. + :vartype from_property: ~datetime.datetime + :ivar to: Required. The end date to pull data to. + :vartype to: ~datetime.datetime """ _validation = { @@ -1961,13 +2730,19 @@ def __init__( self, **kwargs ): + """ + :keyword from_property: Required. The start date to pull data from. + :paramtype from_property: ~datetime.datetime + :keyword to: Required. The end date to pull data to. + :paramtype to: ~datetime.datetime + """ super(ReportConfigTimePeriod, self).__init__(**kwargs) self.from_property = kwargs['from_property'] self.to = kwargs['to'] -class Setting(ProxySettingResource): - """State of the myscope setting. +class ResourceAutoGenerated(msrest.serialization.Model): + """The Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -1975,84 +2750,45 @@ class Setting(ProxySettingResource): :vartype id: str :ivar name: Resource name. :vartype name: str - :ivar kind: Resource kind. - :vartype kind: str :ivar type: Resource type. :vartype type: str - :param scope: Sets the default scope the current user will see when they sign into Azure Cost - Management in the Azure portal. - :type scope: str - :param start_on: Indicates what scope Cost Management in the Azure portal should default to. - Allowed values: LastUsed. Possible values include: "LastUsed", "ScopePicker", "SpecificScope". - :type start_on: str or ~azure.mgmt.costmanagement.models.SettingsPropertiesStartOn - :param cache: Array of scopes with additional details used by Cost Management in the Azure - portal. - :type cache: list[~azure.mgmt.costmanagement.models.CacheItem] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, - 'kind': {'readonly': True, 'max_length': 10, 'min_length': 0}, 'type': {'readonly': True}, + 'tags': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'start_on': {'key': 'properties.startOn', 'type': 'str'}, - 'cache': {'key': 'properties.cache', 'type': '[CacheItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(Setting, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.start_on = kwargs.get('start_on', None) - self.cache = kwargs.get('cache', None) - - -class SettingsListResult(msrest.serialization.Model): - """Result of listing settings. It contains a list of available settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of settings. - :vartype value: list[~azure.mgmt.costmanagement.models.Setting] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True, 'max_items': 10, 'min_items': 0}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Setting]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, **kwargs ): - super(SettingsListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None + """ + """ + super(ResourceAutoGenerated, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = None class Status(msrest.serialization.Model): """The status of the long running operation. - :param status: The status of the long running operation. Possible values include: "Running", - "Completed", "Failed". - :type status: str or ~azure.mgmt.costmanagement.models.OperationStatusType + :ivar status: The status of the long running operation. Possible values include: "InProgress", + "Completed", "Failed", "Queued", "NoDataFound", "ReadyToDownload", "TimedOut". + :vartype status: str or ~azure.mgmt.costmanagement.models.OperationStatusType """ _attribute_map = { @@ -2063,6 +2799,11 @@ def __init__( self, **kwargs ): + """ + :keyword status: The status of the long running operation. Possible values include: + "InProgress", "Completed", "Failed", "Queued", "NoDataFound", "ReadyToDownload", "TimedOut". + :paramtype status: str or ~azure.mgmt.costmanagement.models.OperationStatusType + """ super(Status, self).__init__(**kwargs) self.status = kwargs.get('status', None) @@ -2078,12 +2819,12 @@ class View(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 display_name: User input name of the view. Required. - :type display_name: str - :param scope: Cost Management scope to save the view on. This includes + :vartype e_tag: str + :ivar display_name: User input name of the view. Required. + :vartype display_name: str + :ivar scope: Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -2100,41 +2841,41 @@ class View(ProxyResource): ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope. - :type scope: str + :vartype scope: str :ivar created_on: Date the user created this view. :vartype created_on: ~datetime.datetime :ivar modified_on: Date when the user last modified this view. :vartype modified_on: ~datetime.datetime - :ivar date_range: Selected date range for viewing cost in. + :ivar date_range: Date range of the current view. :vartype date_range: str - :ivar currency: Selected currency. + :ivar currency: Currency of the current view. :vartype currency: str - :param chart: Chart type of the main view in Cost Analysis. Required. Possible values include: + :ivar chart: Chart type of the main view in Cost Analysis. Required. Possible values include: "Area", "Line", "StackedColumn", "GroupedColumn", "Table". - :type chart: str or ~azure.mgmt.costmanagement.models.ChartType - :param accumulated: Show costs accumulated over time. Possible values include: "true", "false". - :type accumulated: str or ~azure.mgmt.costmanagement.models.AccumulatedType - :param metric: Metric to use when displaying costs. Possible values include: "ActualCost", + :vartype chart: str or ~azure.mgmt.costmanagement.models.ChartType + :ivar accumulated: Show costs accumulated over time. Possible values include: "true", "false". + :vartype accumulated: str or ~azure.mgmt.costmanagement.models.AccumulatedType + :ivar metric: Metric to use when displaying costs. Possible values include: "ActualCost", "AmortizedCost", "AHUB". - :type metric: str or ~azure.mgmt.costmanagement.models.MetricType - :param kpis: List of KPIs to show in Cost Analysis UI. - :type kpis: list[~azure.mgmt.costmanagement.models.KpiProperties] - :param pivots: Configuration of 3 sub-views in the Cost Analysis UI. - :type pivots: list[~azure.mgmt.costmanagement.models.PivotProperties] - :param type_properties_query_type: The type of the report. Usage represents actual usage, + :vartype metric: str or ~azure.mgmt.costmanagement.models.MetricType + :ivar kpis: List of KPIs to show in Cost Analysis UI. + :vartype kpis: list[~azure.mgmt.costmanagement.models.KpiProperties] + :ivar pivots: Configuration of 3 sub-views in the Cost Analysis UI. + :vartype pivots: list[~azure.mgmt.costmanagement.models.PivotProperties] + :ivar type_properties_query_type: The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. Possible values include: "Usage". - :type type_properties_query_type: str or ~azure.mgmt.costmanagement.models.ReportType - :param timeframe: The time frame for pulling data for the report. If custom, then a specific + :vartype type_properties_query_type: str or ~azure.mgmt.costmanagement.models.ReportType + :ivar timeframe: The time frame for pulling data for the report. If custom, then a specific time period must be provided. Possible values include: "WeekToDate", "MonthToDate", "YearToDate", "Custom". - :type timeframe: str or ~azure.mgmt.costmanagement.models.ReportTimeframeType - :param time_period: Has time period for pulling data for the report. - :type time_period: ~azure.mgmt.costmanagement.models.ReportConfigTimePeriod - :param data_set: Has definition for data in this report config. - :type data_set: ~azure.mgmt.costmanagement.models.ReportConfigDataset - :ivar include_monetary_commitment: Include monetary commitment. + :vartype timeframe: str or ~azure.mgmt.costmanagement.models.ReportTimeframeType + :ivar time_period: Has time period for pulling data for the report. + :vartype time_period: ~azure.mgmt.costmanagement.models.ReportConfigTimePeriod + :ivar data_set: Has definition for data in this report config. + :vartype data_set: ~azure.mgmt.costmanagement.models.ReportConfigDataset + :ivar include_monetary_commitment: If true, report includes monetary commitment. :vartype include_monetary_commitment: bool """ @@ -2146,7 +2887,6 @@ class View(ProxyResource): 'modified_on': {'readonly': True}, 'date_range': {'readonly': True}, 'currency': {'readonly': True}, - 'include_monetary_commitment': {'readonly': True}, } _attribute_map = { @@ -2176,6 +2916,59 @@ 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 display_name: User input name of the view. Required. + :paramtype display_name: str + :keyword scope: Cost Management scope to save the view on. This includes + 'subscriptions/{subscriptionId}' for subscription scope, + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for + Department scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for BillingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + for Management Group scope, + '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for + ExternalBillingAccount scope, and + '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for + ExternalSubscription scope. + :paramtype scope: str + :keyword chart: Chart type of the main view in Cost Analysis. Required. Possible values + include: "Area", "Line", "StackedColumn", "GroupedColumn", "Table". + :paramtype chart: str or ~azure.mgmt.costmanagement.models.ChartType + :keyword accumulated: Show costs accumulated over time. Possible values include: "true", + "false". + :paramtype accumulated: str or ~azure.mgmt.costmanagement.models.AccumulatedType + :keyword metric: Metric to use when displaying costs. Possible values include: "ActualCost", + "AmortizedCost", "AHUB". + :paramtype metric: str or ~azure.mgmt.costmanagement.models.MetricType + :keyword kpis: List of KPIs to show in Cost Analysis UI. + :paramtype kpis: list[~azure.mgmt.costmanagement.models.KpiProperties] + :keyword pivots: Configuration of 3 sub-views in the Cost Analysis UI. + :paramtype pivots: list[~azure.mgmt.costmanagement.models.PivotProperties] + :keyword type_properties_query_type: The type of the report. Usage represents actual usage, + forecast represents forecasted data and UsageAndForecast represents both usage and forecasted + data. Actual usage and forecasted data can be differentiated based on dates. Possible values + include: "Usage". + :paramtype type_properties_query_type: str or ~azure.mgmt.costmanagement.models.ReportType + :keyword timeframe: The time frame for pulling data for the report. If custom, then a specific + time period must be provided. Possible values include: "WeekToDate", "MonthToDate", + "YearToDate", "Custom". + :paramtype timeframe: str or ~azure.mgmt.costmanagement.models.ReportTimeframeType + :keyword time_period: Has time period for pulling data for the report. + :paramtype time_period: ~azure.mgmt.costmanagement.models.ReportConfigTimePeriod + :keyword data_set: Has definition for data in this report config. + :paramtype data_set: ~azure.mgmt.costmanagement.models.ReportConfigDataset + :keyword include_monetary_commitment: If true, report includes monetary commitment. + :paramtype include_monetary_commitment: bool + """ super(View, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) self.scope = kwargs.get('scope', None) @@ -2192,7 +2985,7 @@ def __init__( self.timeframe = kwargs.get('timeframe', None) self.time_period = kwargs.get('time_period', None) self.data_set = kwargs.get('data_set', None) - self.include_monetary_commitment = None + self.include_monetary_commitment = kwargs.get('include_monetary_commitment', None) class ViewListResult(msrest.serialization.Model): @@ -2220,6 +3013,8 @@ def __init__( self, **kwargs ): + """ + """ super(ViewListResult, self).__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py index e3f7e70197dd..efb5b6ea1605 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/models/_models_py3.py @@ -15,7 +15,7 @@ from ._cost_management_client_enums import * -class Resource(msrest.serialization.Model): +class ProxyResource(msrest.serialization.Model): """The Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,36 +26,43 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] + :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 """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'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'}, } def __init__( self, + *, + e_tag: Optional[str] = None, **kwargs ): - super(Resource, 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(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None self.type = None - self.tags = None + self.e_tag = e_tag -class Alert(Resource): +class Alert(ProxyResource): """An individual alert. Variables are only populated by the server, and will be ignored when sending a request. @@ -66,45 +73,45 @@ class Alert(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 definition: defines the type of alert. - :type definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition - :param description: Alert description. - :type description: str - :param source: Source of alert. Possible values include: "Preset", "User". - :type source: str or ~azure.mgmt.costmanagement.models.AlertSource - :param details: Alert details. - :type details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails - :param cost_entity_id: related budget. - :type cost_entity_id: str - :param status: alert status. Possible values include: "None", "Active", "Overridden", + :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 definition: defines the type of alert. + :vartype definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :ivar description: Alert description. + :vartype description: str + :ivar source: Source of alert. Possible values include: "Preset", "User". + :vartype source: str or ~azure.mgmt.costmanagement.models.AlertSource + :ivar details: Alert details. + :vartype details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :ivar cost_entity_id: related budget. + :vartype cost_entity_id: str + :ivar status: alert status. Possible values include: "None", "Active", "Overridden", "Resolved", "Dismissed". - :type status: str or ~azure.mgmt.costmanagement.models.AlertStatus - :param creation_time: dateTime in which alert was created. - :type creation_time: str - :param close_time: dateTime in which alert was closed. - :type close_time: str - :param modification_time: dateTime in which alert was last modified. - :type modification_time: str - :param status_modification_user_name: - :type status_modification_user_name: str - :param status_modification_time: dateTime in which the alert status was last modified. - :type status_modification_time: str + :vartype status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :ivar creation_time: dateTime in which alert was created. + :vartype creation_time: str + :ivar close_time: dateTime in which alert was closed. + :vartype close_time: str + :ivar modification_time: dateTime in which alert was last modified. + :vartype modification_time: str + :ivar status_modification_user_name: User who last modified the alert. + :vartype status_modification_user_name: str + :ivar status_modification_time: dateTime in which the alert status was last modified. + :vartype status_modification_time: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'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'}, 'definition': {'key': 'properties.definition', 'type': 'AlertPropertiesDefinition'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'source': {'key': 'properties.source', 'type': 'str'}, @@ -121,6 +128,7 @@ class Alert(Resource): def __init__( self, *, + e_tag: Optional[str] = None, definition: Optional["AlertPropertiesDefinition"] = None, description: Optional[str] = None, source: Optional[Union[str, "AlertSource"]] = None, @@ -134,7 +142,35 @@ def __init__( status_modification_time: Optional[str] = None, **kwargs ): - super(Alert, 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 definition: defines the type of alert. + :paramtype definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :keyword description: Alert description. + :paramtype description: str + :keyword source: Source of alert. Possible values include: "Preset", "User". + :paramtype source: str or ~azure.mgmt.costmanagement.models.AlertSource + :keyword details: Alert details. + :paramtype details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :keyword cost_entity_id: related budget. + :paramtype cost_entity_id: str + :keyword status: alert status. Possible values include: "None", "Active", "Overridden", + "Resolved", "Dismissed". + :paramtype status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :keyword creation_time: dateTime in which alert was created. + :paramtype creation_time: str + :keyword close_time: dateTime in which alert was closed. + :paramtype close_time: str + :keyword modification_time: dateTime in which alert was last modified. + :paramtype modification_time: str + :keyword status_modification_user_name: User who last modified the alert. + :paramtype status_modification_user_name: str + :keyword status_modification_time: dateTime in which the alert status was last modified. + :paramtype status_modification_time: str + """ + super(Alert, self).__init__(e_tag=e_tag, **kwargs) self.definition = definition self.description = description self.source = source @@ -151,18 +187,18 @@ def __init__( class AlertPropertiesDefinition(msrest.serialization.Model): """defines the type of alert. - :param type: type of alert. Possible values include: "Budget", "Invoice", "Credit", "Quota", + :ivar type: type of alert. Possible values include: "Budget", "Invoice", "Credit", "Quota", "General", "xCloud", "BudgetForecast". - :type type: str or ~azure.mgmt.costmanagement.models.AlertType - :param category: Alert category. Possible values include: "Cost", "Usage", "Billing", "System". - :type category: str or ~azure.mgmt.costmanagement.models.AlertCategory - :param criteria: Criteria that triggered alert. Possible values include: + :vartype type: str or ~azure.mgmt.costmanagement.models.AlertType + :ivar category: Alert category. Possible values include: "Cost", "Usage", "Billing", "System". + :vartype category: str or ~azure.mgmt.costmanagement.models.AlertCategory + :ivar criteria: Criteria that triggered alert. Possible values include: "CostThresholdExceeded", "UsageThresholdExceeded", "CreditThresholdApproaching", "CreditThresholdReached", "QuotaThresholdApproaching", "QuotaThresholdReached", "MultiCurrency", "ForecastCostThresholdExceeded", "ForecastUsageThresholdExceeded", "InvoiceDueDateApproaching", "InvoiceDueDateReached", "CrossCloudNewDataAvailable", "CrossCloudCollectionError", "GeneralThresholdError". - :type criteria: str or ~azure.mgmt.costmanagement.models.AlertCriteria + :vartype criteria: str or ~azure.mgmt.costmanagement.models.AlertCriteria """ _attribute_map = { @@ -179,6 +215,21 @@ def __init__( criteria: Optional[Union[str, "AlertCriteria"]] = None, **kwargs ): + """ + :keyword type: type of alert. Possible values include: "Budget", "Invoice", "Credit", "Quota", + "General", "xCloud", "BudgetForecast". + :paramtype type: str or ~azure.mgmt.costmanagement.models.AlertType + :keyword category: Alert category. Possible values include: "Cost", "Usage", "Billing", + "System". + :paramtype category: str or ~azure.mgmt.costmanagement.models.AlertCategory + :keyword criteria: Criteria that triggered alert. Possible values include: + "CostThresholdExceeded", "UsageThresholdExceeded", "CreditThresholdApproaching", + "CreditThresholdReached", "QuotaThresholdApproaching", "QuotaThresholdReached", + "MultiCurrency", "ForecastCostThresholdExceeded", "ForecastUsageThresholdExceeded", + "InvoiceDueDateApproaching", "InvoiceDueDateReached", "CrossCloudNewDataAvailable", + "CrossCloudCollectionError", "GeneralThresholdError". + :paramtype criteria: str or ~azure.mgmt.costmanagement.models.AlertCriteria + """ super(AlertPropertiesDefinition, self).__init__(**kwargs) self.type = type self.category = category @@ -188,40 +239,52 @@ def __init__( class AlertPropertiesDetails(msrest.serialization.Model): """Alert details. - :param time_grain_type: Type of timegrain cadence. Possible values include: "None", "Monthly", + :ivar time_grain_type: Type of timegrain cadence. Possible values include: "None", "Monthly", "Quarterly", "Annually", "BillingMonth", "BillingQuarter", "BillingAnnual". - :type time_grain_type: str or ~azure.mgmt.costmanagement.models.AlertTimeGrainType - :param period_start_date: datetime of periodStartDate. - :type period_start_date: str - :param triggered_by: notificationId that triggered this alert. - :type triggered_by: str - :param resource_group_filter: array of resourceGroups to filter by. - :type resource_group_filter: list[any] - :param resource_filter: array of resources to filter by. - :type resource_filter: list[any] - :param meter_filter: array of meters to filter by. - :type meter_filter: list[any] - :param tag_filter: tags to filter by. - :type tag_filter: any - :param threshold: notification threshold percentage as a decimal which activated this alert. - :type threshold: float - :param operator: operator used to compare currentSpend with amount. Possible values include: + :vartype time_grain_type: str or ~azure.mgmt.costmanagement.models.AlertTimeGrainType + :ivar period_start_date: datetime of periodStartDate. + :vartype period_start_date: str + :ivar triggered_by: notificationId that triggered this alert. + :vartype triggered_by: str + :ivar resource_group_filter: array of resourceGroups to filter by. + :vartype resource_group_filter: list[any] + :ivar resource_filter: array of resources to filter by. + :vartype resource_filter: list[any] + :ivar meter_filter: array of meters to filter by. + :vartype meter_filter: list[any] + :ivar tag_filter: tags to filter by. + :vartype tag_filter: any + :ivar threshold: notification threshold percentage as a decimal which activated this alert. + :vartype threshold: float + :ivar operator: operator used to compare currentSpend with amount. Possible values include: "None", "EqualTo", "GreaterThan", "GreaterThanOrEqualTo", "LessThan", "LessThanOrEqualTo". - :type operator: str or ~azure.mgmt.costmanagement.models.AlertOperator - :param amount: budget threshold amount. - :type amount: float - :param unit: unit of currency being used. - :type unit: str - :param current_spend: current spend. - :type current_spend: float - :param contact_emails: list of emails to contact. - :type contact_emails: list[str] - :param contact_groups: list of action groups to broadcast to. - :type contact_groups: list[str] - :param contact_roles: list of contact roles. - :type contact_roles: list[str] - :param overriding_alert: overriding alert. - :type overriding_alert: str + :vartype operator: str or ~azure.mgmt.costmanagement.models.AlertOperator + :ivar amount: budget threshold amount. + :vartype amount: float + :ivar unit: unit of currency being used. + :vartype unit: str + :ivar current_spend: current spend. + :vartype current_spend: float + :ivar contact_emails: list of emails to contact. + :vartype contact_emails: list[str] + :ivar contact_groups: list of action groups to broadcast to. + :vartype contact_groups: list[str] + :ivar contact_roles: list of contact roles. + :vartype contact_roles: list[str] + :ivar overriding_alert: overriding alert. + :vartype overriding_alert: str + :ivar department_name: department name. + :vartype department_name: str + :ivar company_name: company name. + :vartype company_name: str + :ivar enrollment_number: enrollment number. + :vartype enrollment_number: str + :ivar enrollment_start_date: datetime of enrollmentStartDate. + :vartype enrollment_start_date: str + :ivar enrollment_end_date: datetime of enrollmentEndDate. + :vartype enrollment_end_date: str + :ivar invoicing_threshold: invoicing threshold. + :vartype invoicing_threshold: float """ _attribute_map = { @@ -241,6 +304,12 @@ class AlertPropertiesDetails(msrest.serialization.Model): 'contact_groups': {'key': 'contactGroups', 'type': '[str]'}, 'contact_roles': {'key': 'contactRoles', 'type': '[str]'}, 'overriding_alert': {'key': 'overridingAlert', 'type': 'str'}, + 'department_name': {'key': 'departmentName', 'type': 'str'}, + 'company_name': {'key': 'companyName', 'type': 'str'}, + 'enrollment_number': {'key': 'enrollmentNumber', 'type': 'str'}, + 'enrollment_start_date': {'key': 'enrollmentStartDate', 'type': 'str'}, + 'enrollment_end_date': {'key': 'enrollmentEndDate', 'type': 'str'}, + 'invoicing_threshold': {'key': 'invoicingThreshold', 'type': 'float'}, } def __init__( @@ -262,8 +331,62 @@ def __init__( contact_groups: Optional[List[str]] = None, contact_roles: Optional[List[str]] = None, overriding_alert: Optional[str] = None, + department_name: Optional[str] = None, + company_name: Optional[str] = None, + enrollment_number: Optional[str] = None, + enrollment_start_date: Optional[str] = None, + enrollment_end_date: Optional[str] = None, + invoicing_threshold: Optional[float] = None, **kwargs ): + """ + :keyword time_grain_type: Type of timegrain cadence. Possible values include: "None", + "Monthly", "Quarterly", "Annually", "BillingMonth", "BillingQuarter", "BillingAnnual". + :paramtype time_grain_type: str or ~azure.mgmt.costmanagement.models.AlertTimeGrainType + :keyword period_start_date: datetime of periodStartDate. + :paramtype period_start_date: str + :keyword triggered_by: notificationId that triggered this alert. + :paramtype triggered_by: str + :keyword resource_group_filter: array of resourceGroups to filter by. + :paramtype resource_group_filter: list[any] + :keyword resource_filter: array of resources to filter by. + :paramtype resource_filter: list[any] + :keyword meter_filter: array of meters to filter by. + :paramtype meter_filter: list[any] + :keyword tag_filter: tags to filter by. + :paramtype tag_filter: any + :keyword threshold: notification threshold percentage as a decimal which activated this alert. + :paramtype threshold: float + :keyword operator: operator used to compare currentSpend with amount. Possible values include: + "None", "EqualTo", "GreaterThan", "GreaterThanOrEqualTo", "LessThan", "LessThanOrEqualTo". + :paramtype operator: str or ~azure.mgmt.costmanagement.models.AlertOperator + :keyword amount: budget threshold amount. + :paramtype amount: float + :keyword unit: unit of currency being used. + :paramtype unit: str + :keyword current_spend: current spend. + :paramtype current_spend: float + :keyword contact_emails: list of emails to contact. + :paramtype contact_emails: list[str] + :keyword contact_groups: list of action groups to broadcast to. + :paramtype contact_groups: list[str] + :keyword contact_roles: list of contact roles. + :paramtype contact_roles: list[str] + :keyword overriding_alert: overriding alert. + :paramtype overriding_alert: str + :keyword department_name: department name. + :paramtype department_name: str + :keyword company_name: company name. + :paramtype company_name: str + :keyword enrollment_number: enrollment number. + :paramtype enrollment_number: str + :keyword enrollment_start_date: datetime of enrollmentStartDate. + :paramtype enrollment_start_date: str + :keyword enrollment_end_date: datetime of enrollmentEndDate. + :paramtype enrollment_end_date: str + :keyword invoicing_threshold: invoicing threshold. + :paramtype invoicing_threshold: float + """ super(AlertPropertiesDetails, self).__init__(**kwargs) self.time_grain_type = time_grain_type self.period_start_date = period_start_date @@ -281,6 +404,12 @@ def __init__( self.contact_groups = contact_groups self.contact_roles = contact_roles self.overriding_alert = overriding_alert + self.department_name = department_name + self.company_name = company_name + self.enrollment_number = enrollment_number + self.enrollment_start_date = enrollment_start_date + self.enrollment_end_date = enrollment_end_date + self.invoicing_threshold = invoicing_threshold class AlertsResult(msrest.serialization.Model): @@ -308,110 +437,146 @@ def __init__( self, **kwargs ): + """ + """ super(AlertsResult, self).__init__(**kwargs) self.value = None self.next_link = None -class CacheItem(msrest.serialization.Model): - """CacheItem. +class CommonExportProperties(msrest.serialization.Model): + """The common properties of the export. + + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param id: Required. Resource ID used by Resource Manager to uniquely identify the scope. - :type id: str - :param name: Required. Display name for the scope. - :type name: str - :param channel: Required. Indicates the account type. Allowed values include: EA, PAYG, Modern, - Internal, Unknown. - :type channel: str - :param subchannel: Required. Indicates the type of modern account. Allowed values include: - Individual, Enterprise, Partner, Indirect, NotApplicable. - :type subchannel: str - :param parent: Resource ID of the parent scope. For instance, subscription's resource ID for a - resource group or a management group resource ID for a subscription. - :type parent: str - :param status: Indicates the status of the scope. Status only applies to subscriptions and - billing accounts. - :type status: str + :ivar format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :vartype format: str or ~azure.mgmt.costmanagement.models.FormatType + :ivar delivery_info: Required. Has delivery information for the export. + :vartype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :ivar definition: Required. Has the definition for the export. + :vartype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :ivar run_history: If requested, has the most recent execution history for the export. + :vartype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar partition_data: If set to true, exported data will be partitioned by size and placed in a + blob directory together with a manifest file. Note: this option is currently available only for + modern commerce scopes. + :vartype partition_data: bool + :ivar next_run_time_estimate: If the export has an active schedule, provides an estimate of the + next execution time. + :vartype next_run_time_estimate: ~datetime.datetime """ _validation = { - 'id': {'required': True}, - 'name': {'required': True}, - 'channel': {'required': True}, - 'subchannel': {'required': True}, + 'delivery_info': {'required': True}, + 'definition': {'required': True}, + 'next_run_time_estimate': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'channel': {'key': 'channel', 'type': 'str'}, - 'subchannel': {'key': 'subchannel', 'type': 'str'}, - 'parent': {'key': 'parent', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, + 'format': {'key': 'format', 'type': 'str'}, + 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, + 'definition': {'key': 'definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'runHistory', 'type': 'ExportExecutionListResult'}, + 'partition_data': {'key': 'partitionData', 'type': 'bool'}, + 'next_run_time_estimate': {'key': 'nextRunTimeEstimate', 'type': 'iso-8601'}, } def __init__( self, *, - id: str, - name: str, - channel: str, - subchannel: str, - parent: Optional[str] = None, - status: Optional[str] = None, + delivery_info: "ExportDeliveryInfo", + definition: "ExportDefinition", + format: Optional[Union[str, "FormatType"]] = None, + run_history: Optional["ExportExecutionListResult"] = None, + partition_data: Optional[bool] = None, **kwargs ): - super(CacheItem, self).__init__(**kwargs) - self.id = id - self.name = name - self.channel = channel - self.subchannel = subchannel - self.parent = parent - self.status = status + """ + :keyword format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :paramtype format: str or ~azure.mgmt.costmanagement.models.FormatType + :keyword delivery_info: Required. Has delivery information for the export. + :paramtype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :keyword definition: Required. Has the definition for the export. + :paramtype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :keyword run_history: If requested, has the most recent execution history for the export. + :paramtype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :keyword partition_data: If set to true, exported data will be partitioned by size and placed + in a blob directory together with a manifest file. Note: this option is currently available + only for modern commerce scopes. + :paramtype partition_data: bool + """ + super(CommonExportProperties, self).__init__(**kwargs) + self.format = format + self.delivery_info = delivery_info + self.definition = definition + self.run_history = run_history + self.partition_data = partition_data + self.next_run_time_estimate = None -class CommonExportProperties(msrest.serialization.Model): - """The common properties of the export. +class Resource(msrest.serialization.Model): + """The Resource model definition. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param format: The format of the export being delivered. Possible values include: "Csv". - :type format: str or ~azure.mgmt.costmanagement.models.FormatType - :param delivery_info: Required. Has delivery information for the export. - :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Required. Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Location of the resource. + :vartype location: str + :ivar sku: SKU of the resource. + :vartype sku: str + :ivar e_tag: ETag of the resource. + :vartype e_tag: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { - 'delivery_info': {'required': True}, - 'definition': {'required': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + 'sku': {'readonly': True}, + 'e_tag': {'readonly': True}, + 'tags': {'readonly': True}, } _attribute_map = { - 'format': {'key': 'format', 'type': 'str'}, - 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, - 'definition': {'key': 'definition', 'type': 'ExportDefinition'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, - *, - delivery_info: "ExportDeliveryInfo", - definition: "ExportDefinition", - format: Optional[Union[str, "FormatType"]] = None, **kwargs ): - super(CommonExportProperties, self).__init__(**kwargs) - self.format = format - self.delivery_info = delivery_info - self.definition = definition + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = None + self.sku = None + self.e_tag = None + self.tags = None class Dimension(Resource): - """Dimension. + """List of Dimension. Variables are only populated by the server, and will be ignored when sending a request. @@ -421,6 +586,12 @@ class Dimension(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str + :ivar location: Location of the resource. + :vartype location: str + :ivar sku: SKU of the resource. + :vartype sku: str + :ivar e_tag: ETag of the resource. + :vartype e_tag: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar description: Dimension description. @@ -429,8 +600,8 @@ class Dimension(Resource): :vartype filter_enabled: bool :ivar grouping_enabled: Grouping enabled. :vartype grouping_enabled: bool - :param data: - :type data: list[str] + :ivar data: Dimension data. + :vartype data: list[str] :ivar total: Total number of data for the dimension. :vartype total: int :ivar category: Dimension category. @@ -447,6 +618,9 @@ class Dimension(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'location': {'readonly': True}, + 'sku': {'readonly': True}, + 'e_tag': {'readonly': True}, 'tags': {'readonly': True}, 'description': {'readonly': True}, 'filter_enabled': {'readonly': True}, @@ -462,6 +636,9 @@ class Dimension(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'filter_enabled': {'key': 'properties.filterEnabled', 'type': 'bool'}, @@ -480,6 +657,10 @@ def __init__( data: Optional[List[str]] = None, **kwargs ): + """ + :keyword data: Dimension data. + :paramtype data: list[str] + """ super(Dimension, self).__init__(**kwargs) self.description = None self.filter_enabled = None @@ -513,6 +694,8 @@ def __init__( self, **kwargs ): + """ + """ super(DimensionsListResult, self).__init__(**kwargs) self.value = None @@ -520,29 +703,29 @@ def __init__( class DismissAlertPayload(msrest.serialization.Model): """The request payload to update an alert. - :param definition: defines the type of alert. - :type definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition - :param description: Alert description. - :type description: str - :param source: Source of alert. Possible values include: "Preset", "User". - :type source: str or ~azure.mgmt.costmanagement.models.AlertSource - :param details: Alert details. - :type details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails - :param cost_entity_id: related budget. - :type cost_entity_id: str - :param status: alert status. Possible values include: "None", "Active", "Overridden", + :ivar definition: defines the type of alert. + :vartype definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :ivar description: Alert description. + :vartype description: str + :ivar source: Source of alert. Possible values include: "Preset", "User". + :vartype source: str or ~azure.mgmt.costmanagement.models.AlertSource + :ivar details: Alert details. + :vartype details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :ivar cost_entity_id: related budget. + :vartype cost_entity_id: str + :ivar status: alert status. Possible values include: "None", "Active", "Overridden", "Resolved", "Dismissed". - :type status: str or ~azure.mgmt.costmanagement.models.AlertStatus - :param creation_time: dateTime in which alert was created. - :type creation_time: str - :param close_time: dateTime in which alert was closed. - :type close_time: str - :param modification_time: dateTime in which alert was last modified. - :type modification_time: str - :param status_modification_user_name: - :type status_modification_user_name: str - :param status_modification_time: dateTime in which the alert status was last modified. - :type status_modification_time: str + :vartype status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :ivar creation_time: dateTime in which alert was created. + :vartype creation_time: str + :ivar close_time: dateTime in which alert was closed. + :vartype close_time: str + :ivar modification_time: dateTime in which alert was last modified. + :vartype modification_time: str + :ivar status_modification_user_name: User who last modified the alert. + :vartype status_modification_user_name: str + :ivar status_modification_time: dateTime in which the alert status was last modified. + :vartype status_modification_time: str """ _attribute_map = { @@ -575,6 +758,31 @@ def __init__( status_modification_time: Optional[str] = None, **kwargs ): + """ + :keyword definition: defines the type of alert. + :paramtype definition: ~azure.mgmt.costmanagement.models.AlertPropertiesDefinition + :keyword description: Alert description. + :paramtype description: str + :keyword source: Source of alert. Possible values include: "Preset", "User". + :paramtype source: str or ~azure.mgmt.costmanagement.models.AlertSource + :keyword details: Alert details. + :paramtype details: ~azure.mgmt.costmanagement.models.AlertPropertiesDetails + :keyword cost_entity_id: related budget. + :paramtype cost_entity_id: str + :keyword status: alert status. Possible values include: "None", "Active", "Overridden", + "Resolved", "Dismissed". + :paramtype status: str or ~azure.mgmt.costmanagement.models.AlertStatus + :keyword creation_time: dateTime in which alert was created. + :paramtype creation_time: str + :keyword close_time: dateTime in which alert was closed. + :paramtype close_time: str + :keyword modification_time: dateTime in which alert was last modified. + :paramtype modification_time: str + :keyword status_modification_user_name: User who last modified the alert. + :paramtype status_modification_user_name: str + :keyword status_modification_time: dateTime in which the alert status was last modified. + :paramtype status_modification_time: str + """ super(DismissAlertPayload, self).__init__(**kwargs) self.definition = definition self.description = description @@ -614,6 +822,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -631,8 +841,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.costmanagement.models.ErrorDetails + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.costmanagement.models.ErrorDetails """ _attribute_map = { @@ -645,12 +855,16 @@ def __init__( error: Optional["ErrorDetails"] = None, **kwargs ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.costmanagement.models.ErrorDetails + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error -class ProxyResource(msrest.serialization.Model): - """The Resource model definition. +class Export(ProxyResource): + """An export resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -660,15 +874,34 @@ 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 + :ivar format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :vartype format: str or ~azure.mgmt.costmanagement.models.FormatType + :ivar delivery_info: Has delivery information for the export. + :vartype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :ivar definition: Has the definition for the export. + :vartype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :ivar run_history: If requested, has the most recent execution history for the export. + :vartype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar partition_data: If set to true, exported data will be partitioned by size and placed in a + blob directory together with a manifest file. Note: this option is currently available only for + modern commerce scopes. + :vartype partition_data: bool + :ivar next_run_time_estimate: If the export has an active schedule, provides an estimate of the + next execution time. + :vartype next_run_time_estimate: ~datetime.datetime + :ivar schedule: Has schedule information for the export. + :vartype schedule: ~azure.mgmt.costmanagement.models.ExportSchedule """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'next_run_time_estimate': {'readonly': True}, } _attribute_map = { @@ -676,95 +909,137 @@ class ProxyResource(msrest.serialization.Model): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'format': {'key': 'properties.format', 'type': 'str'}, + 'delivery_info': {'key': 'properties.deliveryInfo', 'type': 'ExportDeliveryInfo'}, + 'definition': {'key': 'properties.definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'properties.runHistory', 'type': 'ExportExecutionListResult'}, + 'partition_data': {'key': 'properties.partitionData', 'type': 'bool'}, + 'next_run_time_estimate': {'key': 'properties.nextRunTimeEstimate', 'type': 'iso-8601'}, + 'schedule': {'key': 'properties.schedule', 'type': 'ExportSchedule'}, } def __init__( self, *, e_tag: Optional[str] = None, + format: Optional[Union[str, "FormatType"]] = None, + delivery_info: Optional["ExportDeliveryInfo"] = None, + definition: Optional["ExportDefinition"] = None, + run_history: Optional["ExportExecutionListResult"] = None, + partition_data: Optional[bool] = None, + schedule: Optional["ExportSchedule"] = None, **kwargs ): - super(ProxyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.e_tag = e_tag - + """ + :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 format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :paramtype format: str or ~azure.mgmt.costmanagement.models.FormatType + :keyword delivery_info: Has delivery information for the export. + :paramtype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :keyword definition: Has the definition for the export. + :paramtype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :keyword run_history: If requested, has the most recent execution history for the export. + :paramtype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :keyword partition_data: If set to true, exported data will be partitioned by size and placed + in a blob directory together with a manifest file. Note: this option is currently available + only for modern commerce scopes. + :paramtype partition_data: bool + :keyword schedule: Has schedule information for the export. + :paramtype schedule: ~azure.mgmt.costmanagement.models.ExportSchedule + """ + super(Export, self).__init__(e_tag=e_tag, **kwargs) + self.format = format + self.delivery_info = delivery_info + self.definition = definition + self.run_history = run_history + self.partition_data = partition_data + self.next_run_time_estimate = None + self.schedule = schedule -class Export(ProxyResource): - """A export resource. - Variables are only populated by the server, and will be ignored when sending a request. +class ExportDataset(msrest.serialization.Model): + """The definition for data in the export. - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :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 - used to determine whether the user is updating the latest version or not. - :type e_tag: str - :param format: The format of the export being delivered. Possible values include: "Csv". - :type format: str or ~azure.mgmt.costmanagement.models.FormatType - :param delivery_info: Has delivery information for the export. - :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition - :param schedule: Has schedule information for the export. - :type schedule: ~azure.mgmt.costmanagement.models.ExportSchedule + :ivar granularity: The granularity of rows in the export. Currently only 'Daily' is supported. + Possible values include: "Daily". + :vartype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :ivar configuration: The export dataset configuration. + :vartype configuration: ~azure.mgmt.costmanagement.models.ExportDatasetConfiguration """ - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'ExportDatasetConfiguration'}, } + def __init__( + self, + *, + granularity: Optional[Union[str, "GranularityType"]] = None, + configuration: Optional["ExportDatasetConfiguration"] = None, + **kwargs + ): + """ + :keyword granularity: The granularity of rows in the export. Currently only 'Daily' is + supported. Possible values include: "Daily". + :paramtype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :keyword configuration: The export dataset configuration. + :paramtype configuration: ~azure.mgmt.costmanagement.models.ExportDatasetConfiguration + """ + super(ExportDataset, self).__init__(**kwargs) + self.granularity = granularity + self.configuration = configuration + + +class ExportDatasetConfiguration(msrest.serialization.Model): + """The export dataset configuration. Allows columns to be selected for the export. If not provided then the export will include all available columns. + + :ivar columns: Array of column names to be included in the export. If not provided then the + export will include all available columns. The available columns can vary by customer channel + (see examples). + :vartype columns: list[str] + """ + _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'format': {'key': 'properties.format', 'type': 'str'}, - 'delivery_info': {'key': 'properties.deliveryInfo', 'type': 'ExportDeliveryInfo'}, - 'definition': {'key': 'properties.definition', 'type': 'ExportDefinition'}, - 'schedule': {'key': 'properties.schedule', 'type': 'ExportSchedule'}, + 'columns': {'key': 'columns', 'type': '[str]'}, } def __init__( self, *, - e_tag: Optional[str] = None, - format: Optional[Union[str, "FormatType"]] = None, - delivery_info: Optional["ExportDeliveryInfo"] = None, - definition: Optional["ExportDefinition"] = None, - schedule: Optional["ExportSchedule"] = None, + columns: Optional[List[str]] = None, **kwargs ): - super(Export, self).__init__(e_tag=e_tag, **kwargs) - self.format = format - self.delivery_info = delivery_info - self.definition = definition - self.schedule = schedule + """ + :keyword columns: Array of column names to be included in the export. If not provided then the + export will include all available columns. The available columns can vary by customer channel + (see examples). + :paramtype columns: list[str] + """ + super(ExportDatasetConfiguration, self).__init__(**kwargs) + self.columns = columns class ExportDefinition(msrest.serialization.Model): - """The definition of a query. + """The definition of an export. All required parameters must be populated in order to send to Azure. - :param type: Required. The type of the query. Possible values include: "Usage", "ActualCost", - "AmortizedCost". - :type type: str or ~azure.mgmt.costmanagement.models.ExportType - :param timeframe: Required. The time frame for pulling data for the query. If custom, then a + :ivar type: Required. The type of the export. Note that 'Usage' is equivalent to 'ActualCost' + and is applicable to exports that do not yet provide data for charges or amortization for + service reservations. Possible values include: "Usage", "ActualCost", "AmortizedCost". + :vartype type: str or ~azure.mgmt.costmanagement.models.ExportType + :ivar timeframe: Required. The time frame for pulling data for the export. If custom, then a specific time period must be provided. Possible values include: "MonthToDate", "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". - :type timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType - :param time_period: Has time period for pulling data for the query. - :type time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod - :param data_set: Has definition for data in this query. - :type data_set: ~azure.mgmt.costmanagement.models.QueryDatasetAutoGenerated + :vartype timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :ivar time_period: Has time period for pulling data for the export. + :vartype time_period: ~azure.mgmt.costmanagement.models.ExportTimePeriod + :ivar data_set: The definition for data in the export. + :vartype data_set: ~azure.mgmt.costmanagement.models.ExportDataset """ _validation = { @@ -775,8 +1050,8 @@ class ExportDefinition(msrest.serialization.Model): _attribute_map = { 'type': {'key': 'type', 'type': 'str'}, 'timeframe': {'key': 'timeframe', 'type': 'str'}, - 'time_period': {'key': 'timePeriod', 'type': 'QueryTimePeriod'}, - 'data_set': {'key': 'dataSet', 'type': 'QueryDatasetAutoGenerated'}, + 'time_period': {'key': 'timePeriod', 'type': 'ExportTimePeriod'}, + 'data_set': {'key': 'dataSet', 'type': 'ExportDataset'}, } def __init__( @@ -784,10 +1059,25 @@ def __init__( *, type: Union[str, "ExportType"], timeframe: Union[str, "TimeframeType"], - time_period: Optional["QueryTimePeriod"] = None, - data_set: Optional["QueryDatasetAutoGenerated"] = None, + time_period: Optional["ExportTimePeriod"] = None, + data_set: Optional["ExportDataset"] = None, **kwargs ): + """ + :keyword type: Required. The type of the export. Note that 'Usage' is equivalent to + 'ActualCost' and is applicable to exports that do not yet provide data for charges or + amortization for service reservations. Possible values include: "Usage", "ActualCost", + "AmortizedCost". + :paramtype type: str or ~azure.mgmt.costmanagement.models.ExportType + :keyword timeframe: Required. The time frame for pulling data for the export. If custom, then a + specific time period must be provided. Possible values include: "MonthToDate", + "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". + :paramtype timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :keyword time_period: Has time period for pulling data for the export. + :paramtype time_period: ~azure.mgmt.costmanagement.models.ExportTimePeriod + :keyword data_set: The definition for data in the export. + :paramtype data_set: ~azure.mgmt.costmanagement.models.ExportDataset + """ super(ExportDefinition, self).__init__(**kwargs) self.type = type self.timeframe = timeframe @@ -796,21 +1086,30 @@ def __init__( class ExportDeliveryDestination(msrest.serialization.Model): - """The destination information for the delivery of the export. To allow access to a storage account, you must register the account's subscription with the Microsoft.CostManagementExports resource provider. This is required once per subscription. When creating an export in the Azure portal, it is done automatically, however API users need to register the subscription. For more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services . + """This represents the blob storage account location where exports of costs will be delivered. There are two ways to configure the destination. The approach recommended for most customers is to specify the resourceId of the storage account. This requires a one-time registration of the account's subscription with the Microsoft.CostManagementExports resource provider in order to give Azure Cost Management services access to the storage. When creating an export in the Azure portal this registration is performed automatically but API users may need to register the subscription explicitly (for more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Another way to configure the destination is available ONLY to Partners with a Microsoft Partner Agreement plan who are global admins of their billing account. These Partners, instead of specifying the resourceId of a storage account, can specify the storage account name along with a SAS token for the account. This allows exports of costs to a storage account in any tenant. The SAS token should be created for the blob service with Service/Container/Object resource types and with Read/Write/Delete/List/Add/Create permissions (for more information see https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key ). All required parameters must be populated in order to send to Azure. - :param resource_id: Required. The resource id of the storage account where exports will be - delivered. - :type resource_id: str - :param container: Required. The name of the container where exports will be uploaded. - :type container: str - :param root_folder_path: The name of the directory where exports will be uploaded. - :type root_folder_path: str + :ivar resource_id: The resource id of the storage account where exports will be delivered. This + is not required if a sasToken and storageAccount are specified. + :vartype resource_id: str + :ivar container: Required. The name of the container where exports will be uploaded. If the + container does not exist it will be created. + :vartype container: str + :ivar root_folder_path: The name of the directory where exports will be uploaded. + :vartype root_folder_path: str + :ivar sas_token: A SAS token for the storage account. For a restricted set of Azure customers + this together with storageAccount can be specified instead of resourceId. Note: the value + returned by the API for this property will always be obfuscated. Returning this same obfuscated + value will not result in the SAS token being updated. To update this value a new SAS token must + be specified. + :vartype sas_token: str + :ivar storage_account: The storage account where exports will be uploaded. For a restricted set + of Azure customers this together with sasToken can be specified instead of resourceId. + :vartype storage_account: str """ _validation = { - 'resource_id': {'required': True}, 'container': {'required': True}, } @@ -818,20 +1117,45 @@ class ExportDeliveryDestination(msrest.serialization.Model): 'resource_id': {'key': 'resourceId', 'type': 'str'}, 'container': {'key': 'container', 'type': 'str'}, 'root_folder_path': {'key': 'rootFolderPath', 'type': 'str'}, + 'sas_token': {'key': 'sasToken', 'type': 'str'}, + 'storage_account': {'key': 'storageAccount', 'type': 'str'}, } def __init__( self, *, - resource_id: str, container: str, + resource_id: Optional[str] = None, root_folder_path: Optional[str] = None, + sas_token: Optional[str] = None, + storage_account: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: The resource id of the storage account where exports will be delivered. + This is not required if a sasToken and storageAccount are specified. + :paramtype resource_id: str + :keyword container: Required. The name of the container where exports will be uploaded. If the + container does not exist it will be created. + :paramtype container: str + :keyword root_folder_path: The name of the directory where exports will be uploaded. + :paramtype root_folder_path: str + :keyword sas_token: A SAS token for the storage account. For a restricted set of Azure + customers this together with storageAccount can be specified instead of resourceId. Note: the + value returned by the API for this property will always be obfuscated. Returning this same + obfuscated value will not result in the SAS token being updated. To update this value a new SAS + token must be specified. + :paramtype sas_token: str + :keyword storage_account: The storage account where exports will be uploaded. For a restricted + set of Azure customers this together with sasToken can be specified instead of resourceId. + :paramtype storage_account: str + """ super(ExportDeliveryDestination, self).__init__(**kwargs) self.resource_id = resource_id self.container = container self.root_folder_path = root_folder_path + self.sas_token = sas_token + self.storage_account = storage_account class ExportDeliveryInfo(msrest.serialization.Model): @@ -839,8 +1163,8 @@ class ExportDeliveryInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param destination: Required. Has destination for the export being delivered. - :type destination: ~azure.mgmt.costmanagement.models.ExportDeliveryDestination + :ivar destination: Required. Has destination for the export being delivered. + :vartype destination: ~azure.mgmt.costmanagement.models.ExportDeliveryDestination """ _validation = { @@ -857,12 +1181,16 @@ def __init__( destination: "ExportDeliveryDestination", **kwargs ): + """ + :keyword destination: Required. Has destination for the export being delivered. + :paramtype destination: ~azure.mgmt.costmanagement.models.ExportDeliveryDestination + """ super(ExportDeliveryInfo, self).__init__(**kwargs) self.destination = destination -class ExportExecution(Resource): - """A export execution. +class ExportExecution(ProxyResource): + """An export execution. Variables are only populated by the server, and will be ignored when sending a request. @@ -872,41 +1200,43 @@ class ExportExecution(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 execution_type: The type of the export execution. Possible values include: "OnDemand", + :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 execution_type: The type of the export execution. Possible values include: "OnDemand", "Scheduled". - :type execution_type: str or ~azure.mgmt.costmanagement.models.ExecutionType - :param status: The status of the export execution. Possible values include: "Queued", + :vartype execution_type: str or ~azure.mgmt.costmanagement.models.ExecutionType + :ivar status: The last known status of the export execution. Possible values include: "Queued", "InProgress", "Completed", "Failed", "Timeout", "NewDataNotAvailable", "DataNotAvailable". - :type status: str or ~azure.mgmt.costmanagement.models.ExecutionStatus - :param submitted_by: The identifier for the entity that executed the export. For OnDemand - executions, it is the email id. For Scheduled executions, it is the constant value - System. - :type submitted_by: str - :param submitted_time: The time when export was queued to be executed. - :type submitted_time: ~datetime.datetime - :param processing_start_time: The time when export was picked up to be executed. - :type processing_start_time: ~datetime.datetime - :param processing_end_time: The time when export execution finished. - :type processing_end_time: ~datetime.datetime - :param file_name: The name of the file export got written to. - :type file_name: str - :param run_settings: The common properties of the export. - :type run_settings: ~azure.mgmt.costmanagement.models.CommonExportProperties + :vartype status: str or ~azure.mgmt.costmanagement.models.ExecutionStatus + :ivar submitted_by: The identifier for the entity that executed the export. For OnDemand + executions it is the user email. For scheduled executions it is 'System'. + :vartype submitted_by: str + :ivar submitted_time: The time when export was queued to be executed. + :vartype submitted_time: ~datetime.datetime + :ivar processing_start_time: The time when export was picked up to be executed. + :vartype processing_start_time: ~datetime.datetime + :ivar processing_end_time: The time when the export execution finished. + :vartype processing_end_time: ~datetime.datetime + :ivar file_name: The name of the exported file. + :vartype file_name: str + :ivar run_settings: The export settings that were in effect for this execution. + :vartype run_settings: ~azure.mgmt.costmanagement.models.CommonExportProperties + :ivar error: The details of any error. + :vartype error: ~azure.mgmt.costmanagement.models.ErrorDetails """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'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'}, 'execution_type': {'key': 'properties.executionType', 'type': 'str'}, 'status': {'key': 'properties.status', 'type': 'str'}, 'submitted_by': {'key': 'properties.submittedBy', 'type': 'str'}, @@ -915,11 +1245,13 @@ class ExportExecution(Resource): 'processing_end_time': {'key': 'properties.processingEndTime', 'type': 'iso-8601'}, 'file_name': {'key': 'properties.fileName', 'type': 'str'}, 'run_settings': {'key': 'properties.runSettings', 'type': 'CommonExportProperties'}, + 'error': {'key': 'properties.error', 'type': 'ErrorDetails'}, } def __init__( self, *, + e_tag: Optional[str] = None, execution_type: Optional[Union[str, "ExecutionType"]] = None, status: Optional[Union[str, "ExecutionStatus"]] = None, submitted_by: Optional[str] = None, @@ -928,9 +1260,37 @@ def __init__( processing_end_time: Optional[datetime.datetime] = None, file_name: Optional[str] = None, run_settings: Optional["CommonExportProperties"] = None, + error: Optional["ErrorDetails"] = None, **kwargs ): - super(ExportExecution, 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 execution_type: The type of the export execution. Possible values include: "OnDemand", + "Scheduled". + :paramtype execution_type: str or ~azure.mgmt.costmanagement.models.ExecutionType + :keyword status: The last known status of the export execution. Possible values include: + "Queued", "InProgress", "Completed", "Failed", "Timeout", "NewDataNotAvailable", + "DataNotAvailable". + :paramtype status: str or ~azure.mgmt.costmanagement.models.ExecutionStatus + :keyword submitted_by: The identifier for the entity that executed the export. For OnDemand + executions it is the user email. For scheduled executions it is 'System'. + :paramtype submitted_by: str + :keyword submitted_time: The time when export was queued to be executed. + :paramtype submitted_time: ~datetime.datetime + :keyword processing_start_time: The time when export was picked up to be executed. + :paramtype processing_start_time: ~datetime.datetime + :keyword processing_end_time: The time when the export execution finished. + :paramtype processing_end_time: ~datetime.datetime + :keyword file_name: The name of the exported file. + :paramtype file_name: str + :keyword run_settings: The export settings that were in effect for this execution. + :paramtype run_settings: ~azure.mgmt.costmanagement.models.CommonExportProperties + :keyword error: The details of any error. + :paramtype error: ~azure.mgmt.costmanagement.models.ErrorDetails + """ + super(ExportExecution, self).__init__(e_tag=e_tag, **kwargs) self.execution_type = execution_type self.status = status self.submitted_by = submitted_by @@ -939,14 +1299,15 @@ def __init__( self.processing_end_time = processing_end_time self.file_name = file_name self.run_settings = run_settings + self.error = error class ExportExecutionListResult(msrest.serialization.Model): - """Result of listing exports execution history of a export by name. + """Result of listing the execution history of an export. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: The list of export executions. + :ivar value: A list of export executions. :vartype value: list[~azure.mgmt.costmanagement.models.ExportExecution] """ @@ -962,6 +1323,8 @@ def __init__( self, **kwargs ): + """ + """ super(ExportExecutionListResult, self).__init__(**kwargs) self.value = None @@ -987,6 +1350,8 @@ def __init__( self, **kwargs ): + """ + """ super(ExportListResult, self).__init__(**kwargs) self.value = None @@ -994,27 +1359,43 @@ def __init__( class ExportProperties(CommonExportProperties): """The properties of the export. + Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. - :param format: The format of the export being delivered. Possible values include: "Csv". - :type format: str or ~azure.mgmt.costmanagement.models.FormatType - :param delivery_info: Required. Has delivery information for the export. - :type delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo - :param definition: Required. Has definition for the export. - :type definition: ~azure.mgmt.costmanagement.models.ExportDefinition - :param schedule: Has schedule information for the export. - :type schedule: ~azure.mgmt.costmanagement.models.ExportSchedule + :ivar format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :vartype format: str or ~azure.mgmt.costmanagement.models.FormatType + :ivar delivery_info: Required. Has delivery information for the export. + :vartype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :ivar definition: Required. Has the definition for the export. + :vartype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :ivar run_history: If requested, has the most recent execution history for the export. + :vartype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :ivar partition_data: If set to true, exported data will be partitioned by size and placed in a + blob directory together with a manifest file. Note: this option is currently available only for + modern commerce scopes. + :vartype partition_data: bool + :ivar next_run_time_estimate: If the export has an active schedule, provides an estimate of the + next execution time. + :vartype next_run_time_estimate: ~datetime.datetime + :ivar schedule: Has schedule information for the export. + :vartype schedule: ~azure.mgmt.costmanagement.models.ExportSchedule """ _validation = { 'delivery_info': {'required': True}, 'definition': {'required': True}, + 'next_run_time_estimate': {'readonly': True}, } _attribute_map = { 'format': {'key': 'format', 'type': 'str'}, 'delivery_info': {'key': 'deliveryInfo', 'type': 'ExportDeliveryInfo'}, 'definition': {'key': 'definition', 'type': 'ExportDefinition'}, + 'run_history': {'key': 'runHistory', 'type': 'ExportExecutionListResult'}, + 'partition_data': {'key': 'partitionData', 'type': 'bool'}, + 'next_run_time_estimate': {'key': 'nextRunTimeEstimate', 'type': 'iso-8601'}, 'schedule': {'key': 'schedule', 'type': 'ExportSchedule'}, } @@ -1024,10 +1405,29 @@ def __init__( delivery_info: "ExportDeliveryInfo", definition: "ExportDefinition", format: Optional[Union[str, "FormatType"]] = None, + run_history: Optional["ExportExecutionListResult"] = None, + partition_data: Optional[bool] = None, schedule: Optional["ExportSchedule"] = None, **kwargs ): - super(ExportProperties, self).__init__(format=format, delivery_info=delivery_info, definition=definition, **kwargs) + """ + :keyword format: The format of the export being delivered. Currently only 'Csv' is supported. + Possible values include: "Csv". + :paramtype format: str or ~azure.mgmt.costmanagement.models.FormatType + :keyword delivery_info: Required. Has delivery information for the export. + :paramtype delivery_info: ~azure.mgmt.costmanagement.models.ExportDeliveryInfo + :keyword definition: Required. Has the definition for the export. + :paramtype definition: ~azure.mgmt.costmanagement.models.ExportDefinition + :keyword run_history: If requested, has the most recent execution history for the export. + :paramtype run_history: ~azure.mgmt.costmanagement.models.ExportExecutionListResult + :keyword partition_data: If set to true, exported data will be partitioned by size and placed + in a blob directory together with a manifest file. Note: this option is currently available + only for modern commerce scopes. + :paramtype partition_data: bool + :keyword schedule: Has schedule information for the export. + :paramtype schedule: ~azure.mgmt.costmanagement.models.ExportSchedule + """ + super(ExportProperties, self).__init__(format=format, delivery_info=delivery_info, definition=definition, run_history=run_history, partition_data=partition_data, **kwargs) self.schedule = schedule @@ -1036,10 +1436,10 @@ class ExportRecurrencePeriod(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param from_property: Required. The start date of recurrence. - :type from_property: ~datetime.datetime - :param to: The end date of recurrence. - :type to: ~datetime.datetime + :ivar from_property: Required. The start date of recurrence. + :vartype from_property: ~datetime.datetime + :ivar to: The end date of recurrence. + :vartype to: ~datetime.datetime """ _validation = { @@ -1058,31 +1458,31 @@ def __init__( to: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword from_property: Required. The start date of recurrence. + :paramtype from_property: ~datetime.datetime + :keyword to: The end date of recurrence. + :paramtype to: ~datetime.datetime + """ super(ExportRecurrencePeriod, self).__init__(**kwargs) self.from_property = from_property self.to = to class ExportSchedule(msrest.serialization.Model): - """The schedule associated with a export. - - All required parameters must be populated in order to send to Azure. - - :param status: The status of the schedule. Whether active or not. If inactive, the export's - scheduled execution is paused. Possible values include: "Active", "Inactive". - :type status: str or ~azure.mgmt.costmanagement.models.StatusType - :param recurrence: Required. The schedule recurrence. Possible values include: "Daily", - "Weekly", "Monthly", "Annually". - :type recurrence: str or ~azure.mgmt.costmanagement.models.RecurrenceType - :param recurrence_period: Has start and end date of the recurrence. The start date must be in + """The schedule associated with the export. + + :ivar status: The status of the export's schedule. If 'Inactive', the export's schedule is + paused. Possible values include: "Active", "Inactive". + :vartype status: str or ~azure.mgmt.costmanagement.models.StatusType + :ivar recurrence: The schedule recurrence. Possible values include: "Daily", "Weekly", + "Monthly", "Annually". + :vartype recurrence: str or ~azure.mgmt.costmanagement.models.RecurrenceType + :ivar recurrence_period: Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than start date. - :type recurrence_period: ~azure.mgmt.costmanagement.models.ExportRecurrencePeriod + :vartype recurrence_period: ~azure.mgmt.costmanagement.models.ExportRecurrencePeriod """ - _validation = { - 'recurrence': {'required': True}, - } - _attribute_map = { 'status': {'key': 'status', 'type': 'str'}, 'recurrence': {'key': 'recurrence', 'type': 'str'}, @@ -1092,37 +1492,140 @@ class ExportSchedule(msrest.serialization.Model): def __init__( self, *, - recurrence: Union[str, "RecurrenceType"], status: Optional[Union[str, "StatusType"]] = None, + recurrence: Optional[Union[str, "RecurrenceType"]] = None, recurrence_period: Optional["ExportRecurrencePeriod"] = None, **kwargs ): + """ + :keyword status: The status of the export's schedule. If 'Inactive', the export's schedule is + paused. Possible values include: "Active", "Inactive". + :paramtype status: str or ~azure.mgmt.costmanagement.models.StatusType + :keyword recurrence: The schedule recurrence. Possible values include: "Daily", "Weekly", + "Monthly", "Annually". + :paramtype recurrence: str or ~azure.mgmt.costmanagement.models.RecurrenceType + :keyword recurrence_period: Has start and end date of the recurrence. The start date must be in + future. If present, the end date must be greater than start date. + :paramtype recurrence_period: ~azure.mgmt.costmanagement.models.ExportRecurrencePeriod + """ super(ExportSchedule, self).__init__(**kwargs) self.status = status self.recurrence = recurrence self.recurrence_period = recurrence_period +class ExportTimePeriod(msrest.serialization.Model): + """The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date range is 3 months. + + All required parameters must be populated in order to send to Azure. + + :ivar from_property: Required. The start date for export data. + :vartype from_property: ~datetime.datetime + :ivar to: Required. The end date for export data. + :vartype to: ~datetime.datetime + """ + + _validation = { + 'from_property': {'required': True}, + 'to': {'required': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + from_property: datetime.datetime, + to: datetime.datetime, + **kwargs + ): + """ + :keyword from_property: Required. The start date for export data. + :paramtype from_property: ~datetime.datetime + :keyword to: Required. The end date for export data. + :paramtype to: ~datetime.datetime + """ + super(ExportTimePeriod, self).__init__(**kwargs) + self.from_property = from_property + self.to = to + + +class ForecastDataset(msrest.serialization.Model): + """The definition of data present in the forecast. + + :ivar granularity: The granularity of rows in the forecast. Possible values include: "Daily". + :vartype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :ivar configuration: Has configuration information for the data in the export. The + configuration will be ignored if aggregation and grouping are provided. + :vartype configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :ivar aggregation: Dictionary of aggregation expression to use in the forecast. The key of each + item in the dictionary is the alias for the aggregated column. forecast can have up to 2 + aggregation clauses. + :vartype aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] + :ivar filter: Has filter expression to use in the forecast. + :vartype filter: ~azure.mgmt.costmanagement.models.QueryFilter + """ + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'QueryDatasetConfiguration'}, + 'aggregation': {'key': 'aggregation', 'type': '{QueryAggregation}'}, + 'filter': {'key': 'filter', 'type': 'QueryFilter'}, + } + + def __init__( + self, + *, + granularity: Optional[Union[str, "GranularityType"]] = None, + configuration: Optional["QueryDatasetConfiguration"] = None, + aggregation: Optional[Dict[str, "QueryAggregation"]] = None, + filter: Optional["QueryFilter"] = None, + **kwargs + ): + """ + :keyword granularity: The granularity of rows in the forecast. Possible values include: + "Daily". + :paramtype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :keyword configuration: Has configuration information for the data in the export. The + configuration will be ignored if aggregation and grouping are provided. + :paramtype configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :keyword aggregation: Dictionary of aggregation expression to use in the forecast. The key of + each item in the dictionary is the alias for the aggregated column. forecast can have up to 2 + aggregation clauses. + :paramtype aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] + :keyword filter: Has filter expression to use in the forecast. + :paramtype filter: ~azure.mgmt.costmanagement.models.QueryFilter + """ + super(ForecastDataset, self).__init__(**kwargs) + self.granularity = granularity + self.configuration = configuration + self.aggregation = aggregation + self.filter = filter + + class ForecastDefinition(msrest.serialization.Model): """The definition of a forecast. All required parameters must be populated in order to send to Azure. - :param type: Required. The type of the forecast. Possible values include: "Usage", - "ActualCost", "AmortizedCost". - :type type: str or ~azure.mgmt.costmanagement.models.ForecastType - :param timeframe: Required. The time frame for pulling data for the forecast. If custom, then a + :ivar type: Required. The type of the forecast. Possible values include: "Usage", "ActualCost", + "AmortizedCost". + :vartype type: str or ~azure.mgmt.costmanagement.models.ForecastType + :ivar timeframe: Required. The time frame for pulling data for the forecast. If custom, then a specific time period must be provided. Possible values include: "MonthToDate", "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". - :type timeframe: str or ~azure.mgmt.costmanagement.models.ForecastTimeframeType - :param time_period: Has time period for pulling data for the forecast. - :type time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod - :param dataset: Required. Has definition for data in this forecast. - :type dataset: ~azure.mgmt.costmanagement.models.QueryDataset - :param include_actual_cost: a boolean determining if actualCost will be included. - :type include_actual_cost: bool - :param include_fresh_partial_cost: a boolean determining if FreshPartialCost will be included. - :type include_fresh_partial_cost: bool + :vartype timeframe: str or ~azure.mgmt.costmanagement.models.ForecastTimeframeType + :ivar time_period: Has time period for pulling data for the forecast. + :vartype time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :ivar dataset: Required. Has definition for data in this forecast. + :vartype dataset: ~azure.mgmt.costmanagement.models.ForecastDataset + :ivar include_actual_cost: a boolean determining if actualCost will be included. + :vartype include_actual_cost: bool + :ivar include_fresh_partial_cost: a boolean determining if FreshPartialCost will be included. + :vartype include_fresh_partial_cost: bool """ _validation = { @@ -1135,7 +1638,7 @@ class ForecastDefinition(msrest.serialization.Model): 'type': {'key': 'type', 'type': 'str'}, 'timeframe': {'key': 'timeframe', 'type': 'str'}, 'time_period': {'key': 'timePeriod', 'type': 'QueryTimePeriod'}, - 'dataset': {'key': 'dataset', 'type': 'QueryDataset'}, + 'dataset': {'key': 'dataset', 'type': 'ForecastDataset'}, 'include_actual_cost': {'key': 'includeActualCost', 'type': 'bool'}, 'include_fresh_partial_cost': {'key': 'includeFreshPartialCost', 'type': 'bool'}, } @@ -1145,12 +1648,30 @@ def __init__( *, type: Union[str, "ForecastType"], timeframe: Union[str, "ForecastTimeframeType"], - dataset: "QueryDataset", + dataset: "ForecastDataset", time_period: Optional["QueryTimePeriod"] = None, include_actual_cost: Optional[bool] = None, include_fresh_partial_cost: Optional[bool] = None, **kwargs ): + """ + :keyword type: Required. The type of the forecast. Possible values include: "Usage", + "ActualCost", "AmortizedCost". + :paramtype type: str or ~azure.mgmt.costmanagement.models.ForecastType + :keyword timeframe: Required. The time frame for pulling data for the forecast. If custom, then + a specific time period must be provided. Possible values include: "MonthToDate", + "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". + :paramtype timeframe: str or ~azure.mgmt.costmanagement.models.ForecastTimeframeType + :keyword time_period: Has time period for pulling data for the forecast. + :paramtype time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :keyword dataset: Required. Has definition for data in this forecast. + :paramtype dataset: ~azure.mgmt.costmanagement.models.ForecastDataset + :keyword include_actual_cost: a boolean determining if actualCost will be included. + :paramtype include_actual_cost: bool + :keyword include_fresh_partial_cost: a boolean determining if FreshPartialCost will be + included. + :paramtype include_fresh_partial_cost: bool + """ super(ForecastDefinition, self).__init__(**kwargs) self.type = type self.timeframe = timeframe @@ -1160,20 +1681,290 @@ def __init__( self.include_fresh_partial_cost = include_fresh_partial_cost -class KpiProperties(msrest.serialization.Model): - """Each KPI must contain a 'type' and 'enabled' key. - - :param type: KPI type (Forecast, Budget). Possible values include: "Forecast", "Budget". - :type type: str or ~azure.mgmt.costmanagement.models.KpiType - :param id: ID of resource related to metric (budget). - :type id: str - :param enabled: show the KPI in the UI?. - :type enabled: bool +class GenerateDetailedCostReportDefinition(msrest.serialization.Model): + """The definition of a cost detailed report. + + :ivar metric: The type of the detailed report. By default ActualCost is provided. Possible + values include: "ActualCost", "AmortizedCost". + :vartype metric: str or ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportMetricType + :ivar time_period: Has time period for pulling data for the cost detailed report. Can only have + one of either timePeriod or invoiceId or billingPeriod parameters. If none provided current + month cost is provided. + :vartype time_period: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportTimePeriod + :ivar billing_period: Billing Period in YearMonth(e.g. 202008) format. Only for legacy + enterprise customers can use this. Can only have one of either timePeriod or invoiceId or + billingPeriod parameters. If none provided current month cost is provided. + :vartype billing_period: str + :ivar invoice_id: Invoice Id for PayAsYouGo customers and Modern billing profile scope. Can + only have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided + current month cost is provided. + :vartype invoice_id: str + :ivar customer_id: Customer Id for Modern (Invoice Id and billing profile is also required for + this). + :vartype customer_id: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, + 'metric': {'key': 'metric', 'type': 'str'}, + 'time_period': {'key': 'timePeriod', 'type': 'GenerateDetailedCostReportTimePeriod'}, + 'billing_period': {'key': 'billingPeriod', 'type': 'str'}, + 'invoice_id': {'key': 'invoiceId', 'type': 'str'}, + 'customer_id': {'key': 'customerId', 'type': 'str'}, + } + + def __init__( + self, + *, + metric: Optional[Union[str, "GenerateDetailedCostReportMetricType"]] = None, + time_period: Optional["GenerateDetailedCostReportTimePeriod"] = None, + billing_period: Optional[str] = None, + invoice_id: Optional[str] = None, + customer_id: Optional[str] = None, + **kwargs + ): + """ + :keyword metric: The type of the detailed report. By default ActualCost is provided. Possible + values include: "ActualCost", "AmortizedCost". + :paramtype metric: str or + ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportMetricType + :keyword time_period: Has time period for pulling data for the cost detailed report. Can only + have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided + current month cost is provided. + :paramtype time_period: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportTimePeriod + :keyword billing_period: Billing Period in YearMonth(e.g. 202008) format. Only for legacy + enterprise customers can use this. Can only have one of either timePeriod or invoiceId or + billingPeriod parameters. If none provided current month cost is provided. + :paramtype billing_period: str + :keyword invoice_id: Invoice Id for PayAsYouGo customers and Modern billing profile scope. Can + only have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided + current month cost is provided. + :paramtype invoice_id: str + :keyword customer_id: Customer Id for Modern (Invoice Id and billing profile is also required + for this). + :paramtype customer_id: str + """ + super(GenerateDetailedCostReportDefinition, self).__init__(**kwargs) + self.metric = metric + self.time_period = time_period + self.billing_period = billing_period + self.invoice_id = invoice_id + self.customer_id = customer_id + + +class GenerateDetailedCostReportErrorResponse(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. + +Some Error responses: + + +* + 413 Request Entity Too Large - Request is throttled. The amount of data required to fulfill the request exceeds the maximum size permitted of 2Gb. Please utilize our Exports feature instead. + +* + 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.costmanagement.models.ErrorDetails + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetails'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetails"] = None, + **kwargs + ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.costmanagement.models.ErrorDetails + """ + super(GenerateDetailedCostReportErrorResponse, self).__init__(**kwargs) + self.error = error + + +class GenerateDetailedCostReportOperationResult(msrest.serialization.Model): + """The result of the long running operation for cost detailed report. + + :ivar id: The id of the long running operation. + :vartype id: str + :ivar name: The name of the long running operation. + :vartype name: str + :ivar type: The type of the long running operation. + :vartype type: str + :ivar download_url: The URL to download the generated report. + :vartype download_url: str + :ivar valid_till: The time at which report URL becomes invalid/expires in UTC e.g. + 2020-12-08T05:55:59.4394737Z. + :vartype valid_till: ~datetime.datetime + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'download_url': {'key': 'properties.downloadUrl', 'type': 'str'}, + 'valid_till': {'key': 'properties.validTill', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + type: Optional[str] = None, + download_url: Optional[str] = None, + valid_till: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword id: The id of the long running operation. + :paramtype id: str + :keyword name: The name of the long running operation. + :paramtype name: str + :keyword type: The type of the long running operation. + :paramtype type: str + :keyword download_url: The URL to download the generated report. + :paramtype download_url: str + :keyword valid_till: The time at which report URL becomes invalid/expires in UTC e.g. + 2020-12-08T05:55:59.4394737Z. + :paramtype valid_till: ~datetime.datetime + """ + super(GenerateDetailedCostReportOperationResult, self).__init__(**kwargs) + self.id = id + self.name = name + self.type = type + self.download_url = download_url + self.valid_till = valid_till + + +class GenerateDetailedCostReportOperationStatuses(msrest.serialization.Model): + """The status of the long running operation for cost detailed report. + + :ivar id: The id of the long running operation. + :vartype id: str + :ivar name: The name of the long running operation. + :vartype name: str + :ivar status: The status of the long running operation. + :vartype status: ~azure.mgmt.costmanagement.models.Status + :ivar type: The type of the long running operation. + :vartype type: str + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.costmanagement.models.ErrorDetails + :ivar download_url: The URL to download the generated report. + :vartype download_url: str + :ivar valid_till: The time at which report URL becomes invalid/expires in UTC e.g. + 2020-12-08T05:55:59.4394737Z. + :vartype valid_till: ~datetime.datetime + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'Status'}, + 'type': {'key': 'type', 'type': 'str'}, + 'error': {'key': 'error', 'type': 'ErrorDetails'}, + 'download_url': {'key': 'properties.downloadUrl', 'type': 'str'}, + 'valid_till': {'key': 'properties.validTill', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + status: Optional["Status"] = None, + type: Optional[str] = None, + error: Optional["ErrorDetails"] = None, + download_url: Optional[str] = None, + valid_till: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword id: The id of the long running operation. + :paramtype id: str + :keyword name: The name of the long running operation. + :paramtype name: str + :keyword status: The status of the long running operation. + :paramtype status: ~azure.mgmt.costmanagement.models.Status + :keyword type: The type of the long running operation. + :paramtype type: str + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.costmanagement.models.ErrorDetails + :keyword download_url: The URL to download the generated report. + :paramtype download_url: str + :keyword valid_till: The time at which report URL becomes invalid/expires in UTC e.g. + 2020-12-08T05:55:59.4394737Z. + :paramtype valid_till: ~datetime.datetime + """ + super(GenerateDetailedCostReportOperationStatuses, self).__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.type = type + self.error = error + self.download_url = download_url + self.valid_till = valid_till + + +class GenerateDetailedCostReportTimePeriod(msrest.serialization.Model): + """The start and end date for pulling data for the cost detailed report. + + All required parameters must be populated in order to send to Azure. + + :ivar start: Required. The start date to pull data from. example format 2020-03-15. + :vartype start: str + :ivar end: Required. The end date to pull data to. example format 2020-03-15. + :vartype end: str + """ + + _validation = { + 'start': {'required': True}, + 'end': {'required': True}, + } + + _attribute_map = { + 'start': {'key': 'start', 'type': 'str'}, + 'end': {'key': 'end', 'type': 'str'}, + } + + def __init__( + self, + *, + start: str, + end: str, + **kwargs + ): + """ + :keyword start: Required. The start date to pull data from. example format 2020-03-15. + :paramtype start: str + :keyword end: Required. The end date to pull data to. example format 2020-03-15. + :paramtype end: str + """ + super(GenerateDetailedCostReportTimePeriod, self).__init__(**kwargs) + self.start = start + self.end = end + + +class KpiProperties(msrest.serialization.Model): + """Each KPI must contain a 'type' and 'enabled' key. + + :ivar type: KPI type (Forecast, Budget). Possible values include: "Forecast", "Budget". + :vartype type: str or ~azure.mgmt.costmanagement.models.KpiType + :ivar id: ID of resource related to metric (budget). + :vartype id: str + :ivar enabled: show the KPI in the UI?. + :vartype enabled: bool + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, 'enabled': {'key': 'enabled', 'type': 'bool'}, } @@ -1185,6 +1976,14 @@ def __init__( enabled: Optional[bool] = None, **kwargs ): + """ + :keyword type: KPI type (Forecast, Budget). Possible values include: "Forecast", "Budget". + :paramtype type: str or ~azure.mgmt.costmanagement.models.KpiType + :keyword id: ID of resource related to metric (budget). + :paramtype id: str + :keyword enabled: show the KPI in the UI?. + :paramtype enabled: bool + """ super(KpiProperties, self).__init__(**kwargs) self.type = type self.id = id @@ -1198,8 +1997,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{operation}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.costmanagement.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.costmanagement.models.OperationDisplay """ _validation = { @@ -1217,6 +2016,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.costmanagement.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1251,6 +2054,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1283,49 +2088,20 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None -class OperationStatus(msrest.serialization.Model): - """The status of the long running operation. - - :param status: The status of the long running operation. - :type status: ~azure.mgmt.costmanagement.models.Status - :param report_url: The URL to download the generated report. - :type report_url: str - :param valid_until: The time at which report URL becomes invalid. - :type valid_until: ~datetime.datetime - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'Status'}, - 'report_url': {'key': 'properties.reportUrl', 'type': 'str'}, - 'valid_until': {'key': 'properties.validUntil', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - status: Optional["Status"] = None, - report_url: Optional[str] = None, - valid_until: Optional[datetime.datetime] = None, - **kwargs - ): - super(OperationStatus, self).__init__(**kwargs) - self.status = status - self.report_url = report_url - self.valid_until = valid_until - - class PivotProperties(msrest.serialization.Model): """Each pivot must contain a 'type' and 'name'. - :param type: Data type to show in view. Possible values include: "Dimension", "TagKey". - :type type: str or ~azure.mgmt.costmanagement.models.PivotType - :param name: Data field to show in view. - :type name: str + :ivar type: Data type to show in view. Possible values include: "Dimension", "TagKey". + :vartype type: str or ~azure.mgmt.costmanagement.models.PivotType + :ivar name: Data field to show in view. + :vartype name: str """ _attribute_map = { @@ -1340,61 +2116,27 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword type: Data type to show in view. Possible values include: "Dimension", "TagKey". + :paramtype type: str or ~azure.mgmt.costmanagement.models.PivotType + :keyword name: Data field to show in view. + :paramtype name: str + """ super(PivotProperties, self).__init__(**kwargs) self.type = type self.name = name -class ProxySettingResource(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. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar kind: Resource kind. - :vartype kind: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'kind': {'readonly': True, 'max_length': 10, 'min_length': 0}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxySettingResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.kind = None - self.type = None - - class QueryAggregation(msrest.serialization.Model): """The aggregation expression to be used in the query. All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the column to aggregate. - :type name: str - :param function: Required. The name of the aggregation function to use. Possible values - include: "Avg", "Max", "Min", "Sum". - :type function: str or ~azure.mgmt.costmanagement.models.FunctionType + :ivar name: Required. The name of the column to aggregate. + :vartype name: str + :ivar function: Required. The name of the aggregation function to use. Possible values include: + "Sum". + :vartype function: str or ~azure.mgmt.costmanagement.models.FunctionType """ _validation = { @@ -1414,18 +2156,25 @@ def __init__( function: Union[str, "FunctionType"], **kwargs ): + """ + :keyword name: Required. The name of the column to aggregate. + :paramtype name: str + :keyword function: Required. The name of the aggregation function to use. Possible values + include: "Sum". + :paramtype function: str or ~azure.mgmt.costmanagement.models.FunctionType + """ super(QueryAggregation, self).__init__(**kwargs) self.name = name self.function = function class QueryColumn(msrest.serialization.Model): - """QueryColumn. + """QueryColumn properties. - :param name: The name of column. - :type name: str - :param type: The type of column. - :type type: str + :ivar name: The name of column. + :vartype name: str + :ivar type: The type of column. + :vartype type: str """ _attribute_map = { @@ -1440,6 +2189,12 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of column. + :paramtype name: str + :keyword type: The type of column. + :paramtype type: str + """ super(QueryColumn, self).__init__(**kwargs) self.name = name self.type = type @@ -1450,13 +2205,12 @@ class QueryComparisonExpression(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", - "Contains". - :type operator: str or ~azure.mgmt.costmanagement.models.OperatorType - :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.costmanagement.models.QueryOperatorType + :ivar values: Required. Array of values to use for comparison. + :vartype values: list[str] """ _validation = { @@ -1475,10 +2229,18 @@ def __init__( self, *, name: str, - operator: Union[str, "OperatorType"], + operator: Union[str, "QueryOperatorType"], 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.costmanagement.models.QueryOperatorType + :keyword values: Required. Array of values to use for comparison. + :paramtype values: list[str] + """ super(QueryComparisonExpression, self).__init__(**kwargs) self.name = name self.operator = operator @@ -1488,21 +2250,21 @@ def __init__( class QueryDataset(msrest.serialization.Model): """The definition of data present in the query. - :param granularity: The granularity of rows in the query. Possible values include: "Daily". - :type granularity: str or ~azure.mgmt.costmanagement.models.GranularityType - :param configuration: Has configuration information for the data in the export. The + :ivar granularity: The granularity of rows in the query. Possible values include: "Daily". + :vartype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :ivar configuration: Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided. - :type configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration - :param aggregation: Dictionary of aggregation expression to use in the query. The key of each + :vartype configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :ivar aggregation: Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the aggregated column. Query can have up to 2 aggregation clauses. - :type aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] - :param grouping: Array of group by expression to use in the query. Query can have up to 2 group + :vartype aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] + :ivar grouping: Array of group by expression to use in the query. Query can have up to 2 group by clauses. - :type grouping: list[~azure.mgmt.costmanagement.models.QueryGrouping] - :param filter: The filter expression to use in the query. Please reference our Query API REST + :vartype grouping: list[~azure.mgmt.costmanagement.models.QueryGrouping] + :ivar filter: The filter expression to use in the query. Please reference our Query API REST documentation for how to properly format the filter. - :type filter: ~azure.mgmt.costmanagement.models.QueryFilter + :vartype filter: ~azure.mgmt.costmanagement.models.QueryFilter """ _validation = { @@ -1527,6 +2289,23 @@ def __init__( filter: Optional["QueryFilter"] = None, **kwargs ): + """ + :keyword granularity: The granularity of rows in the query. Possible values include: "Daily". + :paramtype granularity: str or ~azure.mgmt.costmanagement.models.GranularityType + :keyword configuration: Has configuration information for the data in the export. The + configuration will be ignored if aggregation and grouping are provided. + :paramtype configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration + :keyword aggregation: Dictionary of aggregation expression to use in the query. The key of each + item in the dictionary is the alias for the aggregated column. Query can have up to 2 + aggregation clauses. + :paramtype aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] + :keyword grouping: Array of group by expression to use in the query. Query can have up to 2 + group by clauses. + :paramtype grouping: list[~azure.mgmt.costmanagement.models.QueryGrouping] + :keyword filter: The filter expression to use in the query. Please reference our Query API REST + documentation for how to properly format the filter. + :paramtype filter: ~azure.mgmt.costmanagement.models.QueryFilter + """ super(QueryDataset, self).__init__(**kwargs) self.granularity = granularity self.configuration = configuration @@ -1535,62 +2314,12 @@ def __init__( self.filter = filter -class QueryDatasetAutoGenerated(msrest.serialization.Model): - """The definition of data present in the query. - - :param granularity: The granularity of rows in the query. Possible values include: "Daily". - :type granularity: str or ~azure.mgmt.costmanagement.models.GranularityType - :param configuration: Has configuration information for the data in the export. The - configuration will be ignored if aggregation and grouping are provided. - :type configuration: ~azure.mgmt.costmanagement.models.QueryDatasetConfiguration - :param aggregation: Dictionary of aggregation expression to use in the query. The key of each - item in the dictionary is the alias for the aggregated column. Query can have up to 2 - aggregation clauses. - :type aggregation: dict[str, ~azure.mgmt.costmanagement.models.QueryAggregation] - :param grouping: Array of group by expression to use in the query. Query can have up to 2 group - by clauses. - :type grouping: list[~azure.mgmt.costmanagement.models.QueryGrouping] - :param filter: The filter expression to use in the query. Please reference our Query API REST - documentation for how to properly format the filter. - :type filter: ~azure.mgmt.costmanagement.models.QueryFilterAutoGenerated - """ - - _validation = { - 'grouping': {'max_items': 2, 'min_items': 0}, - } - - _attribute_map = { - 'granularity': {'key': 'granularity', 'type': 'str'}, - 'configuration': {'key': 'configuration', 'type': 'QueryDatasetConfiguration'}, - 'aggregation': {'key': 'aggregation', 'type': '{QueryAggregation}'}, - 'grouping': {'key': 'grouping', 'type': '[QueryGrouping]'}, - 'filter': {'key': 'filter', 'type': 'QueryFilterAutoGenerated'}, - } - - def __init__( - self, - *, - granularity: Optional[Union[str, "GranularityType"]] = None, - configuration: Optional["QueryDatasetConfiguration"] = None, - aggregation: Optional[Dict[str, "QueryAggregation"]] = None, - grouping: Optional[List["QueryGrouping"]] = None, - filter: Optional["QueryFilterAutoGenerated"] = None, - **kwargs - ): - super(QueryDatasetAutoGenerated, self).__init__(**kwargs) - self.granularity = granularity - self.configuration = configuration - self.aggregation = aggregation - self.grouping = grouping - self.filter = filter - - class QueryDatasetConfiguration(msrest.serialization.Model): """The configuration of dataset in the query. - :param columns: Array of column names to be included in the query. Any valid query column name + :ivar columns: Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns. - :type columns: list[str] + :vartype columns: list[str] """ _attribute_map = { @@ -1603,6 +2332,11 @@ def __init__( columns: Optional[List[str]] = None, **kwargs ): + """ + :keyword columns: Array of column names to be included in the query. Any valid query column + name is allowed. If not provided, then query includes all columns. + :paramtype columns: list[str] + """ super(QueryDatasetConfiguration, self).__init__(**kwargs) self.columns = columns @@ -1612,17 +2346,17 @@ class QueryDefinition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of the query. Possible values include: "Usage", "ActualCost", + :ivar type: Required. The type of the query. Possible values include: "Usage", "ActualCost", "AmortizedCost". - :type type: str or ~azure.mgmt.costmanagement.models.ExportType - :param timeframe: Required. The time frame for pulling data for the query. If custom, then a + :vartype type: str or ~azure.mgmt.costmanagement.models.ExportType + :ivar timeframe: Required. The time frame for pulling data for the query. If custom, then a specific time period must be provided. Possible values include: "MonthToDate", "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". - :type timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType - :param time_period: Has time period for pulling data for the query. - :type time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod - :param dataset: Required. Has definition for data in this query. - :type dataset: ~azure.mgmt.costmanagement.models.QueryDataset + :vartype timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :ivar time_period: Has time period for pulling data for the query. + :vartype time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :ivar dataset: Required. Has definition for data in this query. + :vartype dataset: ~azure.mgmt.costmanagement.models.QueryDataset """ _validation = { @@ -1647,6 +2381,19 @@ def __init__( time_period: Optional["QueryTimePeriod"] = None, **kwargs ): + """ + :keyword type: Required. The type of the query. Possible values include: "Usage", "ActualCost", + "AmortizedCost". + :paramtype type: str or ~azure.mgmt.costmanagement.models.ExportType + :keyword timeframe: Required. The time frame for pulling data for the query. If custom, then a + specific time period must be provided. Possible values include: "MonthToDate", + "BillingMonthToDate", "TheLastMonth", "TheLastBillingMonth", "WeekToDate", "Custom". + :paramtype timeframe: str or ~azure.mgmt.costmanagement.models.TimeframeType + :keyword time_period: Has time period for pulling data for the query. + :paramtype time_period: ~azure.mgmt.costmanagement.models.QueryTimePeriod + :keyword dataset: Required. Has definition for data in this query. + :paramtype dataset: ~azure.mgmt.costmanagement.models.QueryDataset + """ super(QueryDefinition, self).__init__(**kwargs) self.type = type self.timeframe = timeframe @@ -1657,14 +2404,16 @@ def __init__( class QueryFilter(msrest.serialization.Model): """The filter expression to be used in the export. - :param and_property: The logical "AND" expression. Must have at least 2 items. - :type and_property: list[~azure.mgmt.costmanagement.models.QueryFilter] - :param or_property: The logical "OR" expression. Must have at least 2 items. - :type or_property: list[~azure.mgmt.costmanagement.models.QueryFilter] - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.costmanagement.models.QueryComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.costmanagement.models.QueryComparisonExpression + :ivar and_property: The logical "AND" expression. Must have at least 2 items. + :vartype and_property: list[~azure.mgmt.costmanagement.models.QueryFilter] + :ivar or_property: The logical "OR" expression. Must have at least 2 items. + :vartype or_property: list[~azure.mgmt.costmanagement.models.QueryFilter] + :ivar not_property: The logical "NOT" expression. + :vartype not_property: ~azure.mgmt.costmanagement.models.QueryFilter + :ivar dimension: Has comparison expression for a dimension. + :vartype dimension: ~azure.mgmt.costmanagement.models.QueryComparisonExpression + :ivar tag: Has comparison expression for a tag. + :vartype tag: ~azure.mgmt.costmanagement.models.QueryComparisonExpression """ _validation = { @@ -1675,8 +2424,9 @@ class QueryFilter(msrest.serialization.Model): _attribute_map = { 'and_property': {'key': 'and', 'type': '[QueryFilter]'}, 'or_property': {'key': 'or', 'type': '[QueryFilter]'}, - 'dimensions': {'key': 'dimensions', 'type': 'QueryComparisonExpression'}, - 'tags': {'key': 'tags', 'type': 'QueryComparisonExpression'}, + 'not_property': {'key': 'not', 'type': 'QueryFilter'}, + 'dimension': {'key': 'dimension', 'type': 'QueryComparisonExpression'}, + 'tag': {'key': 'tag', 'type': 'QueryComparisonExpression'}, } def __init__( @@ -1684,56 +2434,29 @@ def __init__( *, and_property: Optional[List["QueryFilter"]] = None, or_property: Optional[List["QueryFilter"]] = None, - dimensions: Optional["QueryComparisonExpression"] = None, - tags: Optional["QueryComparisonExpression"] = None, + not_property: Optional["QueryFilter"] = None, + dimension: Optional["QueryComparisonExpression"] = None, + tag: Optional["QueryComparisonExpression"] = None, **kwargs ): + """ + :keyword and_property: The logical "AND" expression. Must have at least 2 items. + :paramtype and_property: list[~azure.mgmt.costmanagement.models.QueryFilter] + :keyword or_property: The logical "OR" expression. Must have at least 2 items. + :paramtype or_property: list[~azure.mgmt.costmanagement.models.QueryFilter] + :keyword not_property: The logical "NOT" expression. + :paramtype not_property: ~azure.mgmt.costmanagement.models.QueryFilter + :keyword dimension: Has comparison expression for a dimension. + :paramtype dimension: ~azure.mgmt.costmanagement.models.QueryComparisonExpression + :keyword tag: Has comparison expression for a tag. + :paramtype tag: ~azure.mgmt.costmanagement.models.QueryComparisonExpression + """ super(QueryFilter, self).__init__(**kwargs) self.and_property = and_property self.or_property = or_property - self.dimensions = dimensions - self.tags = tags - - -class QueryFilterAutoGenerated(msrest.serialization.Model): - """The filter expression to be used in the export. - - :param and_property: The logical "AND" expression. Must have at least 2 items. - :type and_property: list[~azure.mgmt.costmanagement.models.QueryFilterAutoGenerated] - :param or_property: The logical "OR" expression. Must have at least 2 items. - :type or_property: list[~azure.mgmt.costmanagement.models.QueryFilterAutoGenerated] - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.costmanagement.models.QueryComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.costmanagement.models.QueryComparisonExpression - """ - - _validation = { - 'and_property': {'min_items': 2}, - 'or_property': {'min_items': 2}, - } - - _attribute_map = { - 'and_property': {'key': 'and', 'type': '[QueryFilterAutoGenerated]'}, - 'or_property': {'key': 'or', 'type': '[QueryFilterAutoGenerated]'}, - 'dimensions': {'key': 'dimensions', 'type': 'QueryComparisonExpression'}, - 'tags': {'key': 'tags', 'type': 'QueryComparisonExpression'}, - } - - def __init__( - self, - *, - and_property: Optional[List["QueryFilterAutoGenerated"]] = None, - or_property: Optional[List["QueryFilterAutoGenerated"]] = None, - dimensions: Optional["QueryComparisonExpression"] = None, - tags: Optional["QueryComparisonExpression"] = None, - **kwargs - ): - super(QueryFilterAutoGenerated, self).__init__(**kwargs) - self.and_property = and_property - self.or_property = or_property - self.dimensions = dimensions - self.tags = tags + self.not_property = not_property + self.dimension = dimension + self.tag = tag class QueryGrouping(msrest.serialization.Model): @@ -1741,11 +2464,11 @@ class QueryGrouping(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. Has type of the column to group. Possible values include: "Tag", + :ivar type: Required. Has type of the column to group. Possible values include: "Tag", "Dimension". - :type type: str or ~azure.mgmt.costmanagement.models.QueryColumnType - :param name: Required. The name of the column to group. - :type name: str + :vartype type: str or ~azure.mgmt.costmanagement.models.QueryColumnType + :ivar name: Required. The name of the column to group. + :vartype name: str """ _validation = { @@ -1765,6 +2488,13 @@ def __init__( name: str, **kwargs ): + """ + :keyword type: Required. Has type of the column to group. Possible values include: "Tag", + "Dimension". + :paramtype type: str or ~azure.mgmt.costmanagement.models.QueryColumnType + :keyword name: Required. The name of the column to group. + :paramtype name: str + """ super(QueryGrouping, self).__init__(**kwargs) self.type = type self.name = name @@ -1781,40 +2511,40 @@ class QueryResult(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 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 - :ivar location: Resource location. + :ivar location: Location of the resource. :vartype location: str - :ivar sku: Resource SKU. + :ivar sku: SKU of the resource. :vartype sku: str - :param next_link: The link (url) to the next page of results. - :type next_link: str - :param columns: Array of columns. - :type columns: list[~azure.mgmt.costmanagement.models.QueryColumn] - :param rows: Array of rows. - :type rows: list[list[any]] + :ivar e_tag: ETag of the resource. + :vartype e_tag: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + :ivar columns: Array of columns. + :vartype columns: list[~azure.mgmt.costmanagement.models.QueryColumn] + :ivar rows: Array of rows. + :vartype rows: list[list[any]] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'readonly': True}, 'location': {'readonly': True}, 'sku': {'readonly': True}, + 'e_tag': {'readonly': True}, + 'tags': {'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'}, 'location': {'key': 'location', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, 'columns': {'key': 'properties.columns', 'type': '[QueryColumn]'}, 'rows': {'key': 'properties.rows', 'type': '[[object]]'}, @@ -1823,16 +2553,20 @@ class QueryResult(Resource): def __init__( self, *, - e_tag: Optional[str] = None, next_link: Optional[str] = None, columns: Optional[List["QueryColumn"]] = None, rows: Optional[List[List[Any]]] = None, **kwargs ): + """ + :keyword next_link: The link (url) to the next page of results. + :paramtype next_link: str + :keyword columns: Array of columns. + :paramtype columns: list[~azure.mgmt.costmanagement.models.QueryColumn] + :keyword rows: Array of rows. + :paramtype rows: list[list[any]] + """ super(QueryResult, self).__init__(**kwargs) - self.e_tag = e_tag - self.location = None - self.sku = None self.next_link = next_link self.columns = columns self.rows = rows @@ -1843,10 +2577,10 @@ class QueryTimePeriod(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param from_property: Required. The start date to pull data from. - :type from_property: ~datetime.datetime - :param to: Required. The end date to pull data to. - :type to: ~datetime.datetime + :ivar from_property: Required. The start date to pull data from. + :vartype from_property: ~datetime.datetime + :ivar to: Required. The end date to pull data to. + :vartype to: ~datetime.datetime """ _validation = { @@ -1866,6 +2600,12 @@ def __init__( to: datetime.datetime, **kwargs ): + """ + :keyword from_property: Required. The start date to pull data from. + :paramtype from_property: ~datetime.datetime + :keyword to: Required. The end date to pull data to. + :paramtype to: ~datetime.datetime + """ super(QueryTimePeriod, self).__init__(**kwargs) self.from_property = from_property self.to = to @@ -1876,11 +2616,11 @@ class ReportConfigAggregation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the column to aggregate. - :type name: str - :param function: Required. The name of the aggregation function to use. Possible values - include: "Avg", "Max", "Min", "Sum". - :type function: str or ~azure.mgmt.costmanagement.models.FunctionType + :ivar name: Required. The name of the column to aggregate. + :vartype name: str + :ivar function: Required. The name of the aggregation function to use. Possible values include: + "Sum". + :vartype function: str or ~azure.mgmt.costmanagement.models.FunctionType """ _validation = { @@ -1900,6 +2640,13 @@ def __init__( function: Union[str, "FunctionType"], **kwargs ): + """ + :keyword name: Required. The name of the column to aggregate. + :paramtype name: str + :keyword function: Required. The name of the aggregation function to use. Possible values + include: "Sum". + :paramtype function: str or ~azure.mgmt.costmanagement.models.FunctionType + """ super(ReportConfigAggregation, self).__init__(**kwargs) self.name = name self.function = function @@ -1910,13 +2657,13 @@ class ReportConfigComparisonExpression(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", + :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", "Contains". - :type operator: str or ~azure.mgmt.costmanagement.models.OperatorType - :param values: Required. Array of values to use for comparison. - :type values: list[str] + :vartype operator: str or ~azure.mgmt.costmanagement.models.OperatorType + :ivar values: Required. Array of values to use for comparison. + :vartype values: list[str] """ _validation = { @@ -1939,6 +2686,15 @@ 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", + "Contains". + :paramtype operator: str or ~azure.mgmt.costmanagement.models.OperatorType + :keyword values: Required. Array of values to use for comparison. + :paramtype values: list[str] + """ super(ReportConfigComparisonExpression, self).__init__(**kwargs) self.name = name self.operator = operator @@ -1948,23 +2704,23 @@ def __init__( class ReportConfigDataset(msrest.serialization.Model): """The definition of data present in the report. - :param granularity: The granularity of rows in the report. Possible values include: "Daily", + :ivar granularity: The granularity of rows in the report. Possible values include: "Daily", "Monthly". - :type granularity: str or ~azure.mgmt.costmanagement.models.ReportGranularityType - :param configuration: Has configuration information for the data in the report. The + :vartype granularity: str or ~azure.mgmt.costmanagement.models.ReportGranularityType + :ivar configuration: Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping are provided. - :type configuration: ~azure.mgmt.costmanagement.models.ReportConfigDatasetConfiguration - :param aggregation: Dictionary of aggregation expression to use in the report. The key of each + :vartype configuration: ~azure.mgmt.costmanagement.models.ReportConfigDatasetConfiguration + :ivar aggregation: Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses. - :type aggregation: dict[str, ~azure.mgmt.costmanagement.models.ReportConfigAggregation] - :param grouping: Array of group by expression to use in the report. Report can have up to 2 + :vartype aggregation: dict[str, ~azure.mgmt.costmanagement.models.ReportConfigAggregation] + :ivar grouping: Array of group by expression to use in the report. Report can have up to 2 group by clauses. - :type grouping: list[~azure.mgmt.costmanagement.models.ReportConfigGrouping] - :param sorting: Array of order by expression to use in the report. - :type sorting: list[~azure.mgmt.costmanagement.models.ReportConfigSorting] - :param filter: Has filter expression to use in the report. - :type filter: ~azure.mgmt.costmanagement.models.ReportConfigFilter + :vartype grouping: list[~azure.mgmt.costmanagement.models.ReportConfigGrouping] + :ivar sorting: Array of order by expression to use in the report. + :vartype sorting: list[~azure.mgmt.costmanagement.models.ReportConfigSorting] + :ivar filter: Has filter expression to use in the report. + :vartype filter: ~azure.mgmt.costmanagement.models.ReportConfigFilter """ _validation = { @@ -1991,6 +2747,25 @@ def __init__( filter: Optional["ReportConfigFilter"] = None, **kwargs ): + """ + :keyword granularity: The granularity of rows in the report. Possible values include: "Daily", + "Monthly". + :paramtype granularity: str or ~azure.mgmt.costmanagement.models.ReportGranularityType + :keyword configuration: Has configuration information for the data in the report. The + configuration will be ignored if aggregation and grouping are provided. + :paramtype configuration: ~azure.mgmt.costmanagement.models.ReportConfigDatasetConfiguration + :keyword aggregation: Dictionary of aggregation expression to use in the report. The key of + each item in the dictionary is the alias for the aggregated column. Report can have up to 2 + aggregation clauses. + :paramtype aggregation: dict[str, ~azure.mgmt.costmanagement.models.ReportConfigAggregation] + :keyword grouping: Array of group by expression to use in the report. Report can have up to 2 + group by clauses. + :paramtype grouping: list[~azure.mgmt.costmanagement.models.ReportConfigGrouping] + :keyword sorting: Array of order by expression to use in the report. + :paramtype sorting: list[~azure.mgmt.costmanagement.models.ReportConfigSorting] + :keyword filter: Has filter expression to use in the report. + :paramtype filter: ~azure.mgmt.costmanagement.models.ReportConfigFilter + """ super(ReportConfigDataset, self).__init__(**kwargs) self.granularity = granularity self.configuration = configuration @@ -2003,9 +2778,9 @@ def __init__( class ReportConfigDatasetConfiguration(msrest.serialization.Model): """The configuration of dataset in the report. - :param columns: Array of column names to be included in the report. Any valid report column - name is allowed. If not provided, then report includes all columns. - :type columns: list[str] + :ivar columns: Array of column names to be included in the report. Any valid report column name + is allowed. If not provided, then report includes all columns. + :vartype columns: list[str] """ _attribute_map = { @@ -2018,6 +2793,11 @@ def __init__( columns: Optional[List[str]] = None, **kwargs ): + """ + :keyword columns: Array of column names to be included in the report. Any valid report column + name is allowed. If not provided, then report includes all columns. + :paramtype columns: list[str] + """ super(ReportConfigDatasetConfiguration, self).__init__(**kwargs) self.columns = columns @@ -2025,18 +2805,16 @@ def __init__( class ReportConfigFilter(msrest.serialization.Model): """The filter expression to be used in the report. - :param and_property: The logical "AND" expression. Must have at least 2 items. - :type and_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] - :param or_property: The logical "OR" expression. Must have at least 2 items. - :type or_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] - :param dimensions: Has comparison expression for a dimension. - :type dimensions: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression - :param tags: A set of tags. Has comparison expression for a tag. - :type tags: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression - :param tag_key: Has comparison expression for a tag key. - :type tag_key: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression - :param tag_value: Has comparison expression for a tag value. - :type tag_value: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + :ivar and_property: The logical "AND" expression. Must have at least 2 items. + :vartype and_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :ivar or_property: The logical "OR" expression. Must have at least 2 items. + :vartype or_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :ivar not_property: The logical "NOT" expression. + :vartype not_property: ~azure.mgmt.costmanagement.models.ReportConfigFilter + :ivar dimension: Has comparison expression for a dimension. + :vartype dimension: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + :ivar tag: Has comparison expression for a tag. + :vartype tag: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression """ _validation = { @@ -2047,10 +2825,9 @@ class ReportConfigFilter(msrest.serialization.Model): _attribute_map = { 'and_property': {'key': 'and', 'type': '[ReportConfigFilter]'}, 'or_property': {'key': 'or', 'type': '[ReportConfigFilter]'}, - 'dimensions': {'key': 'dimensions', 'type': 'ReportConfigComparisonExpression'}, - 'tags': {'key': 'tags', 'type': 'ReportConfigComparisonExpression'}, - 'tag_key': {'key': 'tagKey', 'type': 'ReportConfigComparisonExpression'}, - 'tag_value': {'key': 'tagValue', 'type': 'ReportConfigComparisonExpression'}, + 'not_property': {'key': 'not', 'type': 'ReportConfigFilter'}, + 'dimension': {'key': 'dimension', 'type': 'ReportConfigComparisonExpression'}, + 'tag': {'key': 'tag', 'type': 'ReportConfigComparisonExpression'}, } def __init__( @@ -2058,19 +2835,29 @@ def __init__( *, and_property: Optional[List["ReportConfigFilter"]] = None, or_property: Optional[List["ReportConfigFilter"]] = None, - dimensions: Optional["ReportConfigComparisonExpression"] = None, - tags: Optional["ReportConfigComparisonExpression"] = None, - tag_key: Optional["ReportConfigComparisonExpression"] = None, - tag_value: Optional["ReportConfigComparisonExpression"] = None, + not_property: Optional["ReportConfigFilter"] = None, + dimension: Optional["ReportConfigComparisonExpression"] = None, + tag: Optional["ReportConfigComparisonExpression"] = None, **kwargs ): + """ + :keyword and_property: The logical "AND" expression. Must have at least 2 items. + :paramtype and_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :keyword or_property: The logical "OR" expression. Must have at least 2 items. + :paramtype or_property: list[~azure.mgmt.costmanagement.models.ReportConfigFilter] + :keyword not_property: The logical "NOT" expression. + :paramtype not_property: ~azure.mgmt.costmanagement.models.ReportConfigFilter + :keyword dimension: Has comparison expression for a dimension. + :paramtype dimension: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + :keyword tag: Has comparison expression for a tag. + :paramtype tag: ~azure.mgmt.costmanagement.models.ReportConfigComparisonExpression + """ super(ReportConfigFilter, self).__init__(**kwargs) self.and_property = and_property self.or_property = or_property - self.dimensions = dimensions - self.tags = tags - self.tag_key = tag_key - self.tag_value = tag_value + self.not_property = not_property + self.dimension = dimension + self.tag = tag class ReportConfigGrouping(msrest.serialization.Model): @@ -2078,12 +2865,12 @@ class ReportConfigGrouping(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. Has type of the column to group. Possible values include: "Tag", + :ivar type: Required. Has type of the column to group. Possible values include: "Tag", "Dimension". - :type type: str or ~azure.mgmt.costmanagement.models.ReportConfigColumnType - :param name: Required. The name of the column to group. This version supports subscription + :vartype type: str or ~azure.mgmt.costmanagement.models.ReportConfigColumnType + :ivar name: Required. The name of the column to group. This version supports subscription lowest possible grain. - :type name: str + :vartype name: str """ _validation = { @@ -2103,6 +2890,14 @@ def __init__( name: str, **kwargs ): + """ + :keyword type: Required. Has type of the column to group. Possible values include: "Tag", + "Dimension". + :paramtype type: str or ~azure.mgmt.costmanagement.models.ReportConfigColumnType + :keyword name: Required. The name of the column to group. This version supports subscription + lowest possible grain. + :paramtype name: str + """ super(ReportConfigGrouping, self).__init__(**kwargs) self.type = type self.name = name @@ -2113,10 +2908,10 @@ class ReportConfigSorting(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param direction: Direction of sort. Possible values include: "Ascending", "Descending". - :type direction: str or ~azure.mgmt.costmanagement.models.ReportConfigSortingDirection - :param name: Required. The name of the column to sort. - :type name: str + :ivar direction: Direction of sort. Possible values include: "Ascending", "Descending". + :vartype direction: str or ~azure.mgmt.costmanagement.models.ReportConfigSortingDirection + :ivar name: Required. The name of the column to sort. + :vartype name: str """ _validation = { @@ -2135,6 +2930,12 @@ def __init__( direction: Optional[Union[str, "ReportConfigSortingDirection"]] = None, **kwargs ): + """ + :keyword direction: Direction of sort. Possible values include: "Ascending", "Descending". + :paramtype direction: str or ~azure.mgmt.costmanagement.models.ReportConfigSortingDirection + :keyword name: Required. The name of the column to sort. + :paramtype name: str + """ super(ReportConfigSorting, self).__init__(**kwargs) self.direction = direction self.name = name @@ -2145,10 +2946,10 @@ class ReportConfigTimePeriod(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param from_property: Required. The start date to pull data from. - :type from_property: ~datetime.datetime - :param to: Required. The end date to pull data to. - :type to: ~datetime.datetime + :ivar from_property: Required. The start date to pull data from. + :vartype from_property: ~datetime.datetime + :ivar to: Required. The end date to pull data to. + :vartype to: ~datetime.datetime """ _validation = { @@ -2168,13 +2969,19 @@ def __init__( to: datetime.datetime, **kwargs ): + """ + :keyword from_property: Required. The start date to pull data from. + :paramtype from_property: ~datetime.datetime + :keyword to: Required. The end date to pull data to. + :paramtype to: ~datetime.datetime + """ super(ReportConfigTimePeriod, self).__init__(**kwargs) self.from_property = from_property self.to = to -class Setting(ProxySettingResource): - """State of the myscope setting. +class ResourceAutoGenerated(msrest.serialization.Model): + """The Resource model definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -2182,88 +2989,45 @@ class Setting(ProxySettingResource): :vartype id: str :ivar name: Resource name. :vartype name: str - :ivar kind: Resource kind. - :vartype kind: str :ivar type: Resource type. :vartype type: str - :param scope: Sets the default scope the current user will see when they sign into Azure Cost - Management in the Azure portal. - :type scope: str - :param start_on: Indicates what scope Cost Management in the Azure portal should default to. - Allowed values: LastUsed. Possible values include: "LastUsed", "ScopePicker", "SpecificScope". - :type start_on: str or ~azure.mgmt.costmanagement.models.SettingsPropertiesStartOn - :param cache: Array of scopes with additional details used by Cost Management in the Azure - portal. - :type cache: list[~azure.mgmt.costmanagement.models.CacheItem] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, - 'kind': {'readonly': True, 'max_length': 10, 'min_length': 0}, 'type': {'readonly': True}, + 'tags': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'start_on': {'key': 'properties.startOn', 'type': 'str'}, - 'cache': {'key': 'properties.cache', 'type': '[CacheItem]'}, - } - - def __init__( - self, - *, - scope: Optional[str] = None, - start_on: Optional[Union[str, "SettingsPropertiesStartOn"]] = None, - cache: Optional[List["CacheItem"]] = None, - **kwargs - ): - super(Setting, self).__init__(**kwargs) - self.scope = scope - self.start_on = start_on - self.cache = cache - - -class SettingsListResult(msrest.serialization.Model): - """Result of listing settings. It contains a list of available settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of settings. - :vartype value: list[~azure.mgmt.costmanagement.models.Setting] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True, 'max_items': 10, 'min_items': 0}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Setting]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } def __init__( self, **kwargs ): - super(SettingsListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None + """ + """ + super(ResourceAutoGenerated, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.tags = None class Status(msrest.serialization.Model): """The status of the long running operation. - :param status: The status of the long running operation. Possible values include: "Running", - "Completed", "Failed". - :type status: str or ~azure.mgmt.costmanagement.models.OperationStatusType + :ivar status: The status of the long running operation. Possible values include: "InProgress", + "Completed", "Failed", "Queued", "NoDataFound", "ReadyToDownload", "TimedOut". + :vartype status: str or ~azure.mgmt.costmanagement.models.OperationStatusType """ _attribute_map = { @@ -2276,6 +3040,11 @@ def __init__( status: Optional[Union[str, "OperationStatusType"]] = None, **kwargs ): + """ + :keyword status: The status of the long running operation. Possible values include: + "InProgress", "Completed", "Failed", "Queued", "NoDataFound", "ReadyToDownload", "TimedOut". + :paramtype status: str or ~azure.mgmt.costmanagement.models.OperationStatusType + """ super(Status, self).__init__(**kwargs) self.status = status @@ -2291,12 +3060,12 @@ class View(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 display_name: User input name of the view. Required. - :type display_name: str - :param scope: Cost Management scope to save the view on. This includes + :vartype e_tag: str + :ivar display_name: User input name of the view. Required. + :vartype display_name: str + :ivar scope: Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -2313,41 +3082,41 @@ class View(ProxyResource): ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope. - :type scope: str + :vartype scope: str :ivar created_on: Date the user created this view. :vartype created_on: ~datetime.datetime :ivar modified_on: Date when the user last modified this view. :vartype modified_on: ~datetime.datetime - :ivar date_range: Selected date range for viewing cost in. + :ivar date_range: Date range of the current view. :vartype date_range: str - :ivar currency: Selected currency. + :ivar currency: Currency of the current view. :vartype currency: str - :param chart: Chart type of the main view in Cost Analysis. Required. Possible values include: + :ivar chart: Chart type of the main view in Cost Analysis. Required. Possible values include: "Area", "Line", "StackedColumn", "GroupedColumn", "Table". - :type chart: str or ~azure.mgmt.costmanagement.models.ChartType - :param accumulated: Show costs accumulated over time. Possible values include: "true", "false". - :type accumulated: str or ~azure.mgmt.costmanagement.models.AccumulatedType - :param metric: Metric to use when displaying costs. Possible values include: "ActualCost", + :vartype chart: str or ~azure.mgmt.costmanagement.models.ChartType + :ivar accumulated: Show costs accumulated over time. Possible values include: "true", "false". + :vartype accumulated: str or ~azure.mgmt.costmanagement.models.AccumulatedType + :ivar metric: Metric to use when displaying costs. Possible values include: "ActualCost", "AmortizedCost", "AHUB". - :type metric: str or ~azure.mgmt.costmanagement.models.MetricType - :param kpis: List of KPIs to show in Cost Analysis UI. - :type kpis: list[~azure.mgmt.costmanagement.models.KpiProperties] - :param pivots: Configuration of 3 sub-views in the Cost Analysis UI. - :type pivots: list[~azure.mgmt.costmanagement.models.PivotProperties] - :param type_properties_query_type: The type of the report. Usage represents actual usage, + :vartype metric: str or ~azure.mgmt.costmanagement.models.MetricType + :ivar kpis: List of KPIs to show in Cost Analysis UI. + :vartype kpis: list[~azure.mgmt.costmanagement.models.KpiProperties] + :ivar pivots: Configuration of 3 sub-views in the Cost Analysis UI. + :vartype pivots: list[~azure.mgmt.costmanagement.models.PivotProperties] + :ivar type_properties_query_type: The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. Possible values include: "Usage". - :type type_properties_query_type: str or ~azure.mgmt.costmanagement.models.ReportType - :param timeframe: The time frame for pulling data for the report. If custom, then a specific + :vartype type_properties_query_type: str or ~azure.mgmt.costmanagement.models.ReportType + :ivar timeframe: The time frame for pulling data for the report. If custom, then a specific time period must be provided. Possible values include: "WeekToDate", "MonthToDate", "YearToDate", "Custom". - :type timeframe: str or ~azure.mgmt.costmanagement.models.ReportTimeframeType - :param time_period: Has time period for pulling data for the report. - :type time_period: ~azure.mgmt.costmanagement.models.ReportConfigTimePeriod - :param data_set: Has definition for data in this report config. - :type data_set: ~azure.mgmt.costmanagement.models.ReportConfigDataset - :ivar include_monetary_commitment: Include monetary commitment. + :vartype timeframe: str or ~azure.mgmt.costmanagement.models.ReportTimeframeType + :ivar time_period: Has time period for pulling data for the report. + :vartype time_period: ~azure.mgmt.costmanagement.models.ReportConfigTimePeriod + :ivar data_set: Has definition for data in this report config. + :vartype data_set: ~azure.mgmt.costmanagement.models.ReportConfigDataset + :ivar include_monetary_commitment: If true, report includes monetary commitment. :vartype include_monetary_commitment: bool """ @@ -2359,7 +3128,6 @@ class View(ProxyResource): 'modified_on': {'readonly': True}, 'date_range': {'readonly': True}, 'currency': {'readonly': True}, - 'include_monetary_commitment': {'readonly': True}, } _attribute_map = { @@ -2400,8 +3168,62 @@ def __init__( timeframe: Optional[Union[str, "ReportTimeframeType"]] = None, time_period: Optional["ReportConfigTimePeriod"] = None, data_set: Optional["ReportConfigDataset"] = None, + include_monetary_commitment: Optional[bool] = 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 display_name: User input name of the view. Required. + :paramtype display_name: str + :keyword scope: Cost Management scope to save the view on. This includes + 'subscriptions/{subscriptionId}' for subscription scope, + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for + Department scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' + for EnrollmentAccount scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for BillingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' + for Management Group scope, + '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for + ExternalBillingAccount scope, and + '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for + ExternalSubscription scope. + :paramtype scope: str + :keyword chart: Chart type of the main view in Cost Analysis. Required. Possible values + include: "Area", "Line", "StackedColumn", "GroupedColumn", "Table". + :paramtype chart: str or ~azure.mgmt.costmanagement.models.ChartType + :keyword accumulated: Show costs accumulated over time. Possible values include: "true", + "false". + :paramtype accumulated: str or ~azure.mgmt.costmanagement.models.AccumulatedType + :keyword metric: Metric to use when displaying costs. Possible values include: "ActualCost", + "AmortizedCost", "AHUB". + :paramtype metric: str or ~azure.mgmt.costmanagement.models.MetricType + :keyword kpis: List of KPIs to show in Cost Analysis UI. + :paramtype kpis: list[~azure.mgmt.costmanagement.models.KpiProperties] + :keyword pivots: Configuration of 3 sub-views in the Cost Analysis UI. + :paramtype pivots: list[~azure.mgmt.costmanagement.models.PivotProperties] + :keyword type_properties_query_type: The type of the report. Usage represents actual usage, + forecast represents forecasted data and UsageAndForecast represents both usage and forecasted + data. Actual usage and forecasted data can be differentiated based on dates. Possible values + include: "Usage". + :paramtype type_properties_query_type: str or ~azure.mgmt.costmanagement.models.ReportType + :keyword timeframe: The time frame for pulling data for the report. If custom, then a specific + time period must be provided. Possible values include: "WeekToDate", "MonthToDate", + "YearToDate", "Custom". + :paramtype timeframe: str or ~azure.mgmt.costmanagement.models.ReportTimeframeType + :keyword time_period: Has time period for pulling data for the report. + :paramtype time_period: ~azure.mgmt.costmanagement.models.ReportConfigTimePeriod + :keyword data_set: Has definition for data in this report config. + :paramtype data_set: ~azure.mgmt.costmanagement.models.ReportConfigDataset + :keyword include_monetary_commitment: If true, report includes monetary commitment. + :paramtype include_monetary_commitment: bool + """ super(View, self).__init__(e_tag=e_tag, **kwargs) self.display_name = display_name self.scope = scope @@ -2418,7 +3240,7 @@ def __init__( self.timeframe = timeframe self.time_period = time_period self.data_set = data_set - self.include_monetary_commitment = None + self.include_monetary_commitment = include_monetary_commitment class ViewListResult(msrest.serialization.Model): @@ -2446,6 +3268,8 @@ def __init__( self, **kwargs ): + """ + """ super(ViewListResult, self).__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/__init__.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/__init__.py index c70a4cb564cb..4ee0774295e4 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/__init__.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/__init__.py @@ -6,24 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._settings_operations import SettingsOperations +from ._exports_operations import ExportsOperations +from ._generate_detailed_cost_report_operations import GenerateDetailedCostReportOperations +from ._generate_detailed_cost_report_operation_results_operations import GenerateDetailedCostReportOperationResultsOperations +from ._generate_detailed_cost_report_operation_status_operations import GenerateDetailedCostReportOperationStatusOperations from ._views_operations import ViewsOperations from ._alerts_operations import AlertsOperations from ._forecast_operations import ForecastOperations from ._dimensions_operations import DimensionsOperations from ._query_operations import QueryOperations -from ._generate_reservation_details_report_operations import GenerateReservationDetailsReportOperations from ._operations import Operations -from ._exports_operations import ExportsOperations __all__ = [ - 'SettingsOperations', + 'ExportsOperations', + 'GenerateDetailedCostReportOperations', + 'GenerateDetailedCostReportOperationResultsOperations', + 'GenerateDetailedCostReportOperationStatusOperations', 'ViewsOperations', 'AlertsOperations', 'ForecastOperations', 'DimensionsOperations', 'QueryOperations', - 'GenerateReservationDetailsReportOperations', 'Operations', - 'ExportsOperations', ] diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_alerts_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_alerts_operations.py index 13969e75db88..721be767d89b 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_alerts_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_alerts_operations.py @@ -5,23 +5,169 @@ # 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_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.CostManagement/alerts') + 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 + alert_id, # 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.CostManagement/alerts/{alertId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "alertId": _SERIALIZER.url("alert_id", alert_id, '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_dismiss_request( + scope, # type: str + alert_id, # 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.CostManagement/alerts/{alertId}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "alertId": _SERIALIZER.url("alert_id", alert_id, '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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_external_request( + external_cloud_provider_type, # type: Union[str, "_models.ExternalCloudProviderType"] + external_cloud_provider_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.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/alerts') + path_format_arguments = { + "externalCloudProviderType": _SERIALIZER.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + "externalCloudProviderId": _SERIALIZER.url("external_cloud_provider_id", external_cloud_provider_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 AlertsOperations(object): """AlertsOperations operations. @@ -44,6 +190,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope, # type: str @@ -79,31 +226,21 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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') + + request = build_list_request( + scope=scope, + template_url=self.list.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsResult', pipeline_response) @@ -112,8 +249,11 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts'} # type: ignore + + @distributed_trace def get( self, scope, # type: str @@ -152,32 +292,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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), - 'alertId': self._serialize.url("alert_id", alert_id, '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, + alert_id=alert_id, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -186,8 +316,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}'} # type: ignore + + @distributed_trace def dismiss( self, scope, # type: str @@ -229,37 +362,27 @@ def dismiss( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.dismiss.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'alertId': self._serialize.url("alert_id", alert_id, '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DismissAlertPayload') - # 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_dismiss_request( + scope=scope, + alert_id=alert_id, + content_type=content_type, + json=_json, + template_url=self.dismiss.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, 'DismissAlertPayload') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -268,8 +391,11 @@ def dismiss( return cls(pipeline_response, deserialized, {}) return deserialized + dismiss.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}'} # type: ignore + + @distributed_trace def list_external( self, external_cloud_provider_type, # type: Union[str, "_models.ExternalCloudProviderType"] @@ -282,7 +408,8 @@ def list_external( :param external_cloud_provider_type: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. - :type external_cloud_provider_type: str or ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType :param external_cloud_provider_id: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. :type external_cloud_provider_id: str @@ -296,32 +423,22 @@ def list_external( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.list_external.metadata['url'] # type: ignore - path_format_arguments = { - 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), - 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_external_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + template_url=self.list_external.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsResult', pipeline_response) @@ -330,4 +447,6 @@ def list_external( return cls(pipeline_response, deserialized, {}) return deserialized + list_external.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/alerts'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py index ff843ebbf69e..221c56a8e174 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_dimensions_operations.py @@ -5,24 +5,124 @@ # 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 + filter = kwargs.pop('filter', None) # type: Optional[str] + 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", '/{scope}/providers/Microsoft.CostManagement/dimensions') + 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 filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + 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) + + # 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_by_external_cloud_provider_type_request( + external_cloud_provider_type, # type: Union[str, "_models.ExternalCloudProviderType"] + external_cloud_provider_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + 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", '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/dimensions') + path_format_arguments = { + "externalCloudProviderType": _SERIALIZER.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + "externalCloudProviderId": _SERIALIZER.url("external_cloud_provider_id", external_cloud_provider_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') + 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) + + # 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 DimensionsOperations(object): """DimensionsOperations operations. @@ -45,6 +145,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope, # type: str @@ -87,8 +188,9 @@ def list( :param top: May be used to limit the number of results to the most recent N dimension data. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DimensionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.costmanagement.models.DimensionsListResultor None] + :return: An iterator like instance of either DimensionsListResult or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.costmanagement.models.DimensionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DimensionsListResult"] @@ -96,42 +198,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - 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) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + filter=filter, + expand=expand, + skiptoken=skiptoken, + top=top, + 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, + expand=expand, + skiptoken=skiptoken, + top=top, + 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('DimensionsListResult', pipeline_response) + deserialized = self._deserialize("DimensionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -144,17 +241,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200, 204]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/dimensions'} # type: ignore + @distributed_trace def by_external_cloud_provider_type( self, external_cloud_provider_type, # type: Union[str, "_models.ExternalCloudProviderType"] @@ -171,7 +270,8 @@ def by_external_cloud_provider_type( :param external_cloud_provider_type: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. - :type external_cloud_provider_type: str or ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType :param external_cloud_provider_id: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. :type external_cloud_provider_id: str @@ -188,7 +288,8 @@ def by_external_cloud_provider_type( :param top: May be used to limit the number of results to the most recent N dimension data. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DimensionsListResult or the result of cls(response) + :return: An iterator like instance of either DimensionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.costmanagement.models.DimensionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -197,43 +298,39 @@ def by_external_cloud_provider_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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.by_external_cloud_provider_type.metadata['url'] # type: ignore - path_format_arguments = { - 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), - 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_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') - 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) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_by_external_cloud_provider_type_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + filter=filter, + expand=expand, + skiptoken=skiptoken, + top=top, + template_url=self.by_external_cloud_provider_type.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_by_external_cloud_provider_type_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + filter=filter, + expand=expand, + skiptoken=skiptoken, + top=top, + 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('DimensionsListResult', pipeline_response) + deserialized = self._deserialize("DimensionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -246,12 +343,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_exports_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_exports_operations.py index 89eefe5166d4..69087278c6cc 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_exports_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_exports_operations.py @@ -5,23 +5,245 @@ # 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_list_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.CostManagement/exports') + 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 expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + export_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + expand = kwargs.pop('expand', None) # type: Optional[str] + + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "exportName": _SERIALIZER.url("export_name", export_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') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, '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 + export_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.CostManagement/exports/{exportName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "exportName": _SERIALIZER.url("export_name", export_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 + export_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.CostManagement/exports/{exportName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "exportName": _SERIALIZER.url("export_name", export_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_execute_request( + scope, # type: str + export_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.CostManagement/exports/{exportName}/run') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "exportName": _SERIALIZER.url("export_name", export_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_execution_history_request( + scope, # type: str + export_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.CostManagement/exports/{exportName}/runHistory') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "exportName": _SERIALIZER.url("export_name", export_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 ExportsOperations(object): """ExportsOperations operations. @@ -44,15 +266,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope, # type: str + expand=None, # type: Optional[str] **kwargs # type: Any ): # type: (...) -> "_models.ExportListResult" """The operation to list all exports at the given scope. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -69,6 +293,9 @@ def list( '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. :type scope: str + :param expand: May be used to expand the properties within an export. Currently only + 'runHistory' is supported and will return information for the last execution of each export. + :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ExportListResult, or the result of cls(response) :rtype: ~azure.mgmt.costmanagement.models.ExportListResult @@ -79,31 +306,22 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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') + + request = build_list_request( + scope=scope, + expand=expand, + template_url=self.list.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ExportListResult', pipeline_response) @@ -112,18 +330,22 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports'} # type: ignore + + @distributed_trace def get( self, scope, # type: str export_name, # type: str + expand=None, # type: Optional[str] **kwargs # type: Any ): # type: (...) -> "_models.Export" """The operation to get the export for the defined scope by export name. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -142,6 +364,9 @@ def get( :type scope: str :param export_name: Export Name. :type export_name: str + :param expand: May be used to expand the properties within an export. Currently only + 'runHistory' is supported and will return information for the last 10 executions of the export. + :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: Export, or the result of cls(response) :rtype: ~azure.mgmt.costmanagement.models.Export @@ -152,32 +377,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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), - 'exportName': self._serialize.url("export_name", export_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, + export_name=export_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Export', pipeline_response) @@ -186,8 +402,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'} # type: ignore + + @distributed_trace def create_or_update( self, scope, # type: str @@ -200,7 +419,7 @@ def create_or_update( the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -231,37 +450,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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), - 'exportName': self._serialize.url("export_name", export_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, 'Export') - # 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, + export_name=export_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, 'Export') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -274,8 +483,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'} # type: ignore + + @distributed_trace def delete( self, scope, # type: str @@ -285,7 +497,7 @@ def delete( # type: (...) -> None """The operation to delete a export. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -314,32 +526,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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), - 'exportName': self._serialize.url("export_name", export_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + scope=scope, + export_name=export_name, + template_url=self.delete.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.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -347,6 +549,8 @@ def delete( delete.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}'} # type: ignore + + @distributed_trace def execute( self, scope, # type: str @@ -354,9 +558,9 @@ def execute( **kwargs # type: Any ): # type: (...) -> None - """The operation to execute a export. + """The operation to execute an export. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -385,32 +589,22 @@ def execute( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.execute.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'exportName': self._serialize.url("export_name", export_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_execute_request( + scope=scope, + export_name=export_name, + template_url=self.execute.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.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -418,6 +612,8 @@ def execute( execute.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run'} # type: ignore + + @distributed_trace def get_execution_history( self, scope, # type: str @@ -425,9 +621,9 @@ def get_execution_history( **kwargs # type: Any ): # type: (...) -> "_models.ExportExecutionListResult" - """The operation to get the execution history of an export for the defined scope by export name. + """The operation to get the execution history of an export for the defined scope and export name. - :param scope: The scope associated with query and export operations. This includes + :param scope: The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -456,32 +652,22 @@ def get_execution_history( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get_execution_history.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'exportName': self._serialize.url("export_name", export_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_execution_history_request( + scope=scope, + export_name=export_name, + template_url=self.get_execution_history.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ExportExecutionListResult', pipeline_response) @@ -490,4 +676,6 @@ def get_execution_history( return cls(pipeline_response, deserialized, {}) return deserialized + get_execution_history.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_forecast_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_forecast_operations.py index 71c2e338e1e5..b923daa2a696 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_forecast_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_forecast_operations.py @@ -5,23 +5,111 @@ # 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_usage_request( + scope, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + 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.CostManagement/forecast') + 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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_external_cloud_provider_usage_request( + external_cloud_provider_type, # type: Union[str, "_models.ExternalCloudProviderType"] + external_cloud_provider_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + 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.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/forecast') + path_format_arguments = { + "externalCloudProviderType": _SERIALIZER.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + "externalCloudProviderId": _SERIALIZER.url("external_cloud_provider_id", external_cloud_provider_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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ForecastOperations(object): """ForecastOperations operations. @@ -44,6 +132,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def usage( self, scope, # type: str @@ -87,38 +176,27 @@ def usage( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.usage.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') - - # 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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ForecastDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ForecastDefinition') + + request = build_usage_request( + scope=scope, + content_type=content_type, + json=_json, + filter=filter, + template_url=self.usage.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -129,8 +207,11 @@ def usage( return cls(pipeline_response, deserialized, {}) return deserialized + usage.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/forecast'} # type: ignore + + @distributed_trace def external_cloud_provider_usage( self, external_cloud_provider_type, # type: Union[str, "_models.ExternalCloudProviderType"] @@ -145,7 +226,8 @@ def external_cloud_provider_usage( :param external_cloud_provider_type: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. - :type external_cloud_provider_type: str or ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType :param external_cloud_provider_id: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. :type external_cloud_provider_id: str @@ -165,39 +247,28 @@ def external_cloud_provider_usage( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.external_cloud_provider_usage.metadata['url'] # type: ignore - path_format_arguments = { - 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), - 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_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') - - # 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') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ForecastDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ForecastDefinition') + + request = build_external_cloud_provider_usage_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + content_type=content_type, + json=_json, + filter=filter, + template_url=self.external_cloud_provider_usage.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QueryResult', pipeline_response) @@ -206,4 +277,6 @@ def external_cloud_provider_usage( return cls(pipeline_response, deserialized, {}) return deserialized + external_cloud_provider_usage.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/forecast'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operation_results_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operation_results_operations.py new file mode 100644 index 000000000000..42112b413a03 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operation_results_operations.py @@ -0,0 +1,154 @@ +# 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. +# -------------------------------------------------------------------------- +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 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( + operation_id, # type: str + 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.CostManagement/operationResults/{operationId}') + path_format_arguments = { + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "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 GenerateDetailedCostReportOperationResultsOperations(object): + """GenerateDetailedCostReportOperationResultsOperations 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.costmanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + operation_id, # type: str + scope, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.GenerateDetailedCostReportOperationResult"] + """Get the result of the specified operation. This link is provided in the + GenerateDetailedCostReport creation request response header. + + :param operation_id: The target operation Id. + :type operation_id: str + :param scope: The scope associated with usage details operations. This includes + '/subscriptions/{subscriptionId}/' for subscription scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, + '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, + '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount + scope. Also, Modern Commerce Account scopes are + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenerateDetailedCostReportOperationResult, or the result of cls(response) + :rtype: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportOperationResult or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateDetailedCostReportOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + operation_id=operation_id, + scope=scope, + 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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('GenerateDetailedCostReportOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/operationResults/{operationId}'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operation_status_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operation_status_operations.py new file mode 100644 index 000000000000..76f5d21f135f --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operation_status_operations.py @@ -0,0 +1,152 @@ +# 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. +# -------------------------------------------------------------------------- +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 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( + operation_id, # type: str + 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.CostManagement/operationStatus/{operationId}') + path_format_arguments = { + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "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 GenerateDetailedCostReportOperationStatusOperations(object): + """GenerateDetailedCostReportOperationStatusOperations 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.costmanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + operation_id, # type: str + scope, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.GenerateDetailedCostReportOperationStatuses" + """Get the status of the specified operation. This link is provided in the + GenerateDetailedCostReport creation request response header. + + :param operation_id: The target operation Id. + :type operation_id: str + :param scope: The scope associated with usage details operations. This includes + '/subscriptions/{subscriptionId}/' for subscription scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, + '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, + '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount + scope. Also, Modern Commerce Account scopes are + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenerateDetailedCostReportOperationStatuses, or the result of cls(response) + :rtype: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportOperationStatuses + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateDetailedCostReportOperationStatuses"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + operation_id=operation_id, + scope=scope, + 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.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenerateDetailedCostReportOperationStatuses', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/operationStatus/{operationId}'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operations.py new file mode 100644 index 000000000000..e0b07aeb3237 --- /dev/null +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_detailed_cost_report_operations.py @@ -0,0 +1,229 @@ +# 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. +# -------------------------------------------------------------------------- +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +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_create_operation_request_initial( + scope, # 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.CostManagement/generateDetailedCostReport') + 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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on +class GenerateDetailedCostReportOperations(object): + """GenerateDetailedCostReportOperations 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.costmanagement.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 _create_operation_initial( + self, + scope, # type: str + parameters, # type: "_models.GenerateDetailedCostReportDefinition" + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.GenerateDetailedCostReportOperationResult"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenerateDetailedCostReportOperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GenerateDetailedCostReportDefinition') + + request = build_create_operation_request_initial( + scope=scope, + content_type=content_type, + json=_json, + template_url=self._create_operation_initial.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, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize('GenerateDetailedCostReportOperationResult', pipeline_response) + + if response.status_code == 202: + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Azure-Consumption-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-Consumption-AsyncOperation')) + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + _create_operation_initial.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/generateDetailedCostReport'} # type: ignore + + + @distributed_trace + def begin_create_operation( + self, + scope, # type: str + parameters, # type: "_models.GenerateDetailedCostReportDefinition" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.GenerateDetailedCostReportOperationResult"] + """Generates the detailed cost report for provided date range, billing period(Only enterprise + customers) or Invoice Id asynchronously at a certain scope. Call returns a 202 with header + Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the + operation will provide the status and if the operation is completed the blob file where + generated detailed cost report is being stored. + + :param scope: The scope associated with usage details operations. This includes + '/subscriptions/{subscriptionId}/' for subscription scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, + '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, + '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount + scope. Also, Modern Commerce Account scopes are + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount scope, + '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' + for billingProfile scope, + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' + for invoiceSection scope, and + 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' + specific for partners. + :type scope: str + :param parameters: Parameters supplied to the Create detailed cost report operation. + :type parameters: ~azure.mgmt.costmanagement.models.GenerateDetailedCostReportDefinition + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either GenerateDetailedCostReportOperationResult + or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.costmanagement.models.GenerateDetailedCostReportOperationResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.GenerateDetailedCostReportOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_operation_initial( + scope=scope, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('GenerateDetailedCostReportOperationResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_operation.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/generateDetailedCostReport'} # type: ignore diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_reservation_details_report_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_reservation_details_report_operations.py deleted file mode 100644 index 4c93c64e8755..000000000000 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_generate_reservation_details_report_operations.py +++ /dev/null @@ -1,310 +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.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -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]] - -class GenerateReservationDetailsReportOperations(object): - """GenerateReservationDetailsReportOperations 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.costmanagement.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 _by_billing_account_id_initial( - self, - billing_account_id, # type: str - start_date, # type: str - end_date, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationStatus"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatus"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self._by_billing_account_id_initial.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['startDate'] = self._serialize.query("start_date", start_date, 'str') - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - 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.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationStatus', pipeline_response) - - if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - _by_billing_account_id_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/generateReservationDetailsReport'} # type: ignore - - def begin_by_billing_account_id( - self, - billing_account_id, # type: str - start_date, # type: str - end_date, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationStatus"] - """Generates the reservations details report for provided date range asynchronously based on - enrollment id. - - :param billing_account_id: Enrollment ID (Legacy BillingAccount ID). - :type billing_account_id: str - :param start_date: Start Date. - :type start_date: str - :param end_date: End Date. - :type end_date: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either OperationStatus or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.costmanagement.models.OperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._by_billing_account_id_initial( - billing_account_id=billing_account_id, - start_date=start_date, - end_date=end_date, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationStatus', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - path_format_arguments = { - 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_by_billing_account_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/generateReservationDetailsReport'} # type: ignore - - def _by_billing_profile_id_initial( - self, - billing_account_id, # type: str - billing_profile_id, # type: str - start_date, # type: str - end_date, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.OperationStatus"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatus"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self._by_billing_profile_id_initial.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['startDate'] = self._serialize.query("start_date", start_date, 'str') - query_parameters['endDate'] = self._serialize.query("end_date", end_date, 'str') - 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.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationStatus', pipeline_response) - - if response.status_code == 202: - response_headers['Location']=self._deserialize('str', response.headers.get('Location')) - response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - _by_billing_profile_id_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/generateReservationDetailsReport'} # type: ignore - - def begin_by_billing_profile_id( - self, - billing_account_id, # type: str - billing_profile_id, # type: str - start_date, # type: str - end_date, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.OperationStatus"] - """Generates the reservations details report for provided date range asynchronously by billing - profile. - - :param billing_account_id: BillingAccount ID. - :type billing_account_id: str - :param billing_profile_id: BillingProfile ID. - :type billing_profile_id: str - :param start_date: Start Date. - :type start_date: str - :param end_date: End Date. - :type end_date: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either OperationStatus or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.costmanagement.models.OperationStatus] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatus"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._by_billing_profile_id_initial( - billing_account_id=billing_account_id, - billing_profile_id=billing_profile_id, - start_date=start_date, - end_date=end_date, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('OperationStatus', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - 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'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_by_billing_profile_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/generateReservationDetailsReport'} # type: ignore diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_operations.py index 4a538a66f2c5..90a48b13018d 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/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.CostManagement/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-11-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.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py index b5dd2dc857ec..07b21f7e8075 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_query_operations.py @@ -5,23 +5,105 @@ # 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_usage_request( + scope, # 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.CostManagement/query') + 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] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_usage_by_external_cloud_provider_type_request( + external_cloud_provider_type, # type: Union[str, "_models.ExternalCloudProviderType"] + external_cloud_provider_id, # 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", '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query') + path_format_arguments = { + "externalCloudProviderType": _SERIALIZER.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), + "externalCloudProviderId": _SERIALIZER.url("external_cloud_provider_id", external_cloud_provider_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class QueryOperations(object): """QueryOperations operations. @@ -44,6 +126,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def usage( self, scope, # type: str @@ -82,36 +165,26 @@ def usage( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.usage.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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QueryDefinition') - # 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_usage_request( + scope=scope, + content_type=content_type, + json=_json, + template_url=self.usage.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, 'QueryDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -122,8 +195,11 @@ def usage( return cls(pipeline_response, deserialized, {}) return deserialized + usage.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/query'} # type: ignore + + @distributed_trace def usage_by_external_cloud_provider_type( self, external_cloud_provider_type, # type: Union[str, "_models.ExternalCloudProviderType"] @@ -137,7 +213,8 @@ def usage_by_external_cloud_provider_type( :param external_cloud_provider_type: The external cloud provider type associated with dimension/query operations. This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. - :type external_cloud_provider_type: str or ~azure.mgmt.costmanagement.models.ExternalCloudProviderType + :type external_cloud_provider_type: str or + ~azure.mgmt.costmanagement.models.ExternalCloudProviderType :param external_cloud_provider_id: This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for consolidated account used with dimension/query operations. :type external_cloud_provider_id: str @@ -153,37 +230,27 @@ def usage_by_external_cloud_provider_type( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.usage_by_external_cloud_provider_type.metadata['url'] # type: ignore - path_format_arguments = { - 'externalCloudProviderType': self._serialize.url("external_cloud_provider_type", external_cloud_provider_type, 'str'), - 'externalCloudProviderId': self._serialize.url("external_cloud_provider_id", external_cloud_provider_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'QueryDefinition') - # 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_usage_by_external_cloud_provider_type_request( + external_cloud_provider_type=external_cloud_provider_type, + external_cloud_provider_id=external_cloud_provider_id, + content_type=content_type, + json=_json, + template_url=self.usage_by_external_cloud_provider_type.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, 'QueryDefinition') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('QueryResult', pipeline_response) @@ -192,4 +259,6 @@ def usage_by_external_cloud_provider_type( return cls(pipeline_response, deserialized, {}) return deserialized + usage_by_external_cloud_provider_type.metadata = {'url': '/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query'} # type: ignore + diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_settings_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_settings_operations.py deleted file mode 100644 index 3140937a8c4c..000000000000 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_settings_operations.py +++ /dev/null @@ -1,281 +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 SettingsOperations(object): - """SettingsOperations 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.costmanagement.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, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SettingsListResult"] - """Lists all of the settings that have been customized. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SettingsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.costmanagement.models.SettingsListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SettingsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = 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('SettingsListResult', 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]: - error = self._deserialize.failsafe_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': '/providers/Microsoft.CostManagement/settings'} # type: ignore - - def get( - self, - setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Setting" - """Retrieves the current value for a specific setting. - - :param setting_name: Name of the setting. Allowed values: myscope. - :type setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Setting, or the result of cls(response) - :rtype: ~azure.mgmt.costmanagement.models.Setting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Setting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'settingName': self._serialize.url("setting_name", setting_name, 'str', max_length=32, min_length=0), - } - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Setting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/providers/Microsoft.CostManagement/settings/{settingName}'} # type: ignore - - def create_or_update( - self, - setting_name, # type: str - parameters, # type: "_models.Setting" - **kwargs # type: Any - ): - # type: (...) -> "_models.Setting" - """Sets a new value for a specific setting. - - :param setting_name: Name of the setting. Allowed values: myscope. - :type setting_name: str - :param parameters: Body supplied to the CreateOrUpdate setting operation. - :type parameters: ~azure.mgmt.costmanagement.models.Setting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Setting, or the result of cls(response) - :rtype: ~azure.mgmt.costmanagement.models.Setting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Setting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = { - 'settingName': self._serialize.url("setting_name", setting_name, 'str', max_length=32, min_length=0), - } - 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['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Setting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Setting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/providers/Microsoft.CostManagement/settings/{settingName}'} # type: ignore - - def delete( - self, - setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Remove the current value for a specific setting and reverts back to the default value, if - applicable. - - :param setting_name: Name of the setting. Allowed values: myscope. - :type setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'settingName': self._serialize.url("setting_name", setting_name, 'str', max_length=32, min_length=0), - } - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/providers/Microsoft.CostManagement/settings/{settingName}'} # type: ignore diff --git a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_views_operations.py b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_views_operations.py index d7512a2a7003..c64dae362407 100644 --- a/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_views_operations.py +++ b/sdk/costmanagement/azure-mgmt-costmanagement/azure/mgmt/costmanagement/operations/_views_operations.py @@ -5,24 +5,296 @@ # 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( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.CostManagement/views') + + # 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_scope_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.CostManagement/views') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, '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_request( + view_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.CostManagement/views/{viewName}') + path_format_arguments = { + "viewName": _SERIALIZER.url("view_name", view_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( + view_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", '/providers/Microsoft.CostManagement/views/{viewName}') + path_format_arguments = { + "viewName": _SERIALIZER.url("view_name", view_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( + view_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.CostManagement/views/{viewName}') + path_format_arguments = { + "viewName": _SERIALIZER.url("view_name", view_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_scope_request( + scope, # type: str + view_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.CostManagement/views/{viewName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "viewName": _SERIALIZER.url("view_name", view_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_by_scope_request( + scope, # type: str + view_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.CostManagement/views/{viewName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "viewName": _SERIALIZER.url("view_name", view_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_by_scope_request( + scope, # type: str + view_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.CostManagement/views/{viewName}') + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str'), + "viewName": _SERIALIZER.url("view_name", view_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 ViewsOperations(object): """ViewsOperations operations. @@ -45,6 +317,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +327,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ViewListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.costmanagement.models.ViewListResultor None] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.costmanagement.models.ViewListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ViewListResult"] @@ -62,30 +335,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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('ViewListResult', pipeline_response) + deserialized = self._deserialize("ViewListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,18 +367,20 @@ 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, 204]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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.metadata = {'url': '/providers/Microsoft.CostManagement/views'} # type: ignore + @distributed_trace def list_by_scope( self, scope, # type: str @@ -137,7 +409,7 @@ def list_by_scope( :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 ViewListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.costmanagement.models.ViewListResultor None] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.costmanagement.models.ViewListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ViewListResult"] @@ -145,34 +417,29 @@ def list_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, '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_scope_request( + scope=scope, + template_url=self.list_by_scope.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_scope_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('ViewListResult', pipeline_response) + deserialized = self._deserialize("ViewListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,18 +451,20 @@ 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, 204]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, 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_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views'} # type: ignore + @distributed_trace def get( self, view_name, # type: str @@ -216,31 +485,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'viewName': self._serialize.url("view_name", view_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( + view_name=view_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('View', pipeline_response) @@ -249,8 +508,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace def create_or_update( self, view_name, # type: str @@ -276,36 +538,26 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-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 = { - 'viewName': self._serialize.url("view_name", view_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'View') + + request = build_create_or_update_request( + view_name=view_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, 'View') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -318,8 +570,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace def delete( self, view_name, # type: str @@ -340,31 +595,21 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'viewName': self._serialize.url("view_name", view_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( + view_name=view_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -372,6 +617,8 @@ def delete( delete.metadata = {'url': '/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace def get_by_scope( self, scope, # type: str @@ -411,32 +658,22 @@ def get_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.get_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'viewName': self._serialize.url("view_name", view_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_by_scope_request( + scope=scope, + view_name=view_name, + template_url=self.get_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('View', pipeline_response) @@ -445,8 +682,11 @@ def get_by_scope( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace def create_or_update_by_scope( self, scope, # type: str @@ -491,37 +731,27 @@ def create_or_update_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'viewName': self._serialize.url("view_name", view_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, 'View') - # 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_by_scope_request( + scope=scope, + view_name=view_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_scope.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, 'View') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -534,8 +764,11 @@ def create_or_update_by_scope( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore + + @distributed_trace def delete_by_scope( self, scope, # type: str @@ -575,35 +808,26 @@ def delete_by_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str'), - 'viewName': self._serialize.url("view_name", view_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_by_scope_request( + scope=scope, + view_name=view_name, + template_url=self.delete_by_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete_by_scope.metadata = {'url': '/{scope}/providers/Microsoft.CostManagement/views/{viewName}'} # type: ignore +