From 3bc7bfdf9218fa3a2072b896d97c88cb63f385ad Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 27 Apr 2022 01:01:16 +0000 Subject: [PATCH] CodeGen from PR 18174 in Azure/azure-rest-api-specs [Hub Generated] Review request for Microsoft.Consumption to add version stable/2021-10-01 (#18174) * Adding details about access and Report Schema for reservation report * MISC * Missing errors * fixing model error * MISC * MISC * MISC * MSIC * MISC * Removing Etag to fix the S360 item * Fixing Routing issue * MISC * MISC * MISC * MISC --- .../azure-mgmt-consumption/_meta.json | 6 +- .../azure/mgmt/consumption/_configuration.py | 9 +- .../_consumption_management_client.py | 17 +- .../azure/mgmt/consumption/_metadata.json | 4 +- .../azure/mgmt/consumption/_version.py | 2 +- .../mgmt/consumption/aio/_configuration.py | 9 +- .../aio/_consumption_management_client.py | 15 +- .../operations/_aggregated_cost_operations.py | 29 ++- .../aio/operations/_balances_operations.py | 27 ++- .../aio/operations/_budgets_operations.py | 51 ++++- .../aio/operations/_charges_operations.py | 25 +- .../aio/operations/_credits_operations.py | 16 +- .../aio/operations/_events_operations.py | 33 ++- .../aio/operations/_lots_operations.py | 134 +++++++++-- .../operations/_marketplaces_operations.py | 24 +- .../consumption/aio/operations/_operations.py | 18 +- .../aio/operations/_price_sheet_operations.py | 43 ++-- ...ation_recommendation_details_operations.py | 28 ++- ..._reservation_recommendations_operations.py | 32 +-- .../_reservation_transactions_operations.py | 34 ++- .../_reservations_details_operations.py | 64 ++++-- .../_reservations_summaries_operations.py | 71 ++++-- .../aio/operations/_tags_operations.py | 16 +- .../operations/_usage_details_operations.py | 28 ++- .../mgmt/consumption/models/_models_py3.py | 8 - .../operations/_aggregated_cost_operations.py | 76 +++--- .../operations/_balances_operations.py | 72 +++--- .../operations/_budgets_operations.py | 139 ++++++----- .../operations/_charges_operations.py | 57 +++-- .../operations/_credits_operations.py | 40 ++-- .../operations/_events_operations.py | 83 ++++--- .../operations/_lots_operations.py | 216 +++++++++++++++--- .../operations/_marketplaces_operations.py | 53 +++-- .../consumption/operations/_operations.py | 39 ++-- .../operations/_price_sheet_operations.py | 100 ++++---- ...ation_recommendation_details_operations.py | 66 +++--- ..._reservation_recommendations_operations.py | 61 ++--- .../_reservation_transactions_operations.py | 82 ++++--- .../_reservations_details_operations.py | 147 +++++++----- .../_reservations_summaries_operations.py | 160 +++++++------ .../operations/_tags_operations.py | 40 ++-- .../operations/_usage_details_operations.py | 61 +++-- 42 files changed, 1478 insertions(+), 757 deletions(-) diff --git a/sdk/consumption/azure-mgmt-consumption/_meta.json b/sdk/consumption/azure-mgmt-consumption/_meta.json index 4d72f9b7503e..0ba682bae92b 100644 --- a/sdk/consumption/azure-mgmt-consumption/_meta.json +++ b/sdk/consumption/azure-mgmt-consumption/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.12.0", + "@autorest/python@5.13.0", "@autorest/modelerfour@4.19.3" ], - "commit": "87c075973362d149fd8e23b31b061692d8c6dd45", + "commit": "731678aa0923415ebcb5fcead877a10244c2c629", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/consumption/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/consumption/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/consumption/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_configuration.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_configuration.py index 9a166da9681a..f7117a221edc 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_configuration.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class ConsumptionManagementClientConfiguration(Configuration): +class ConsumptionManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ConsumptionManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class ConsumptionManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure Subscription ID. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(ConsumptionManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-10-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-consumption/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py index f5854037b375..f0f3e668b8df 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_consumption_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import ConsumptionManagementClientConfiguration @@ -21,8 +22,9 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ConsumptionManagementClient: - """Consumption management client provides access to consumption resources for Azure Enterprise Subscriptions. +class ConsumptionManagementClient: # pylint: disable=too-many-instance-attributes + """Consumption management client provides access to consumption resources for Azure Enterprise + Subscriptions. :ivar usage_details: UsageDetailsOperations operations :vartype usage_details: azure.mgmt.consumption.operations.UsageDetailsOperations @@ -66,8 +68,11 @@ class ConsumptionManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure Subscription ID. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -105,7 +110,7 @@ def __init__( def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_metadata.json b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_metadata.json index 6cba7ea11366..7e8fa9e53afc 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_metadata.json +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConsumptionManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConsumptionManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConsumptionManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConsumptionManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py index b77ac9246082..e5754a47ce68 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "9.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_configuration.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_configuration.py index 3a6a9f371adc..ff0354538d38 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_configuration.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ConsumptionManagementClientConfiguration(Configuration): +class ConsumptionManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ConsumptionManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class ConsumptionManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure Subscription ID. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(ConsumptionManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-10-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-consumption/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_consumption_management_client.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_consumption_management_client.py index db2099a12566..0c9042d1122f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_consumption_management_client.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/_consumption_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models from ._configuration import ConsumptionManagementClientConfiguration @@ -21,8 +22,9 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ConsumptionManagementClient: - """Consumption management client provides access to consumption resources for Azure Enterprise Subscriptions. +class ConsumptionManagementClient: # pylint: disable=too-many-instance-attributes + """Consumption management client provides access to consumption resources for Azure Enterprise + Subscriptions. :ivar usage_details: UsageDetailsOperations operations :vartype usage_details: azure.mgmt.consumption.aio.operations.UsageDetailsOperations @@ -67,8 +69,11 @@ class ConsumptionManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure Subscription ID. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_aggregated_cost_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_aggregated_cost_operations.py index e37b43fe879f..a8e9ac19f486 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_aggregated_cost_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_aggregated_cost_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -59,7 +58,7 @@ async def get_by_management_group( :param filter: May be used to filter aggregated cost by properties/usageStart (Utc time), properties/usageEnd (Utc time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where - key and value is separated by a colon (:). + key and value is separated by a colon (:). Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupAggregatedCostResult, or the result of cls(response) @@ -72,16 +71,23 @@ async def get_by_management_group( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_by_management_group_request( management_group_id=management_group_id, + api_version=api_version, filter=filter, template_url=self.get_by_management_group.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +102,7 @@ async def get_by_management_group( return deserialized - get_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost'} # type: ignore + get_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost"} # type: ignore @distributed_trace_async @@ -124,16 +130,23 @@ async def get_for_billing_period_by_management_group( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_for_billing_period_by_management_group_request( management_group_id=management_group_id, billing_period_name=billing_period_name, + api_version=api_version, template_url=self.get_for_billing_period_by_management_group.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,5 +161,5 @@ async def get_for_billing_period_by_management_group( return deserialized - get_for_billing_period_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost'} # type: ignore + get_for_billing_period_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_balances_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_balances_operations.py index c82e7d22142a..851e0c66af74 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_balances_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_balances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -66,15 +65,22 @@ async def get_by_billing_account( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, template_url=self.get_by_billing_account.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -89,7 +95,7 @@ async def get_by_billing_account( return deserialized - get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances'} # type: ignore + get_by_billing_account.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances"} # type: ignore @distributed_trace_async @@ -117,16 +123,23 @@ async def get_for_billing_period_by_billing_account( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_for_billing_period_by_billing_account_request( billing_account_id=billing_account_id, billing_period_name=billing_period_name, + api_version=api_version, template_url=self.get_for_billing_period_by_billing_account.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,5 +154,5 @@ async def get_for_billing_period_by_billing_account( return deserialized - get_for_billing_period_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'} # type: ignore + get_for_billing_period_by_billing_account.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_budgets_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_budgets_operations.py index a48eae0e327e..a0e89fe8ac95 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_budgets_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_budgets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -75,6 +74,8 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.BudgetsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.BudgetsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -85,6 +86,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, template_url=self.list.metadata['url'], ) request = _convert_request(request) @@ -94,6 +96,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -111,7 +114,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -125,7 +132,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/budgets"} # type: ignore @distributed_trace_async async def get( @@ -164,16 +171,23 @@ async def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( scope=scope, budget_name=budget_name, + api_version=api_version, template_url=self.get.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,7 +202,7 @@ async def get( return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}"} # type: ignore @distributed_trace_async @@ -233,6 +247,7 @@ async def create_or_update( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] _json = self._serialize.body(parameters, 'Budget') @@ -240,6 +255,7 @@ async def create_or_update( request = build_create_or_update_request( scope=scope, budget_name=budget_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], @@ -247,7 +263,11 @@ async def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -266,11 +286,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, budget_name: str, @@ -306,16 +326,23 @@ async def delete( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_delete_request( scope=scope, budget_name=budget_name, + api_version=api_version, template_url=self.delete.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -326,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_charges_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_charges_operations.py index 9299c6302b02..2f239c113d0b 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_charges_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_charges_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -73,18 +72,19 @@ async def list( 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. :type scope: str - :param start_date: Start date. + :param start_date: Start date. Default value is None. :type start_date: str - :param end_date: End date. + :param end_date: End date. Default value is None. :type end_date: str :param filter: May be used to filter charges by properties/usageEnd (Utc time), properties/usageStart (Utc time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where - key and value is separated by a colon (:). + key and value is separated by a colon (:). Default value is None. :type filter: str :param apply: May be used to group charges for billingAccount scope by properties/billingProfileId, properties/invoiceSectionId, properties/customerId (specific for - Partner Led), or for billingProfile scope by properties/invoiceSectionId. + Partner Led), or for billingProfile scope by properties/invoiceSectionId. Default value is + None. :type apply: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ChargesListResult, or the result of cls(response) @@ -97,9 +97,12 @@ async def list( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_list_request( scope=scope, + api_version=api_version, start_date=start_date, end_date=end_date, filter=filter, @@ -109,7 +112,11 @@ async def list( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -124,5 +131,5 @@ async def list( return deserialized - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/charges'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/charges"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_credits_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_credits_operations.py index d55db2f7170d..6407531c686d 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_credits_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_credits_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -68,16 +67,23 @@ async def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, template_url=self.get.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -94,5 +100,5 @@ async def get( return deserialized - get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_events_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_events_operations.py index 53baf5f4d6a5..632f95e65a13 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_events_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_events_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -71,6 +69,8 @@ def list_by_billing_profile( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Events] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.Events"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -82,6 +82,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, start_date=start_date, end_date=end_date, template_url=self.list_by_billing_profile.metadata['url'], @@ -94,6 +95,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, start_date=start_date, end_date=end_date, template_url=next_link, @@ -113,7 +115,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -127,7 +133,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events'} # type: ignore + list_by_billing_profile.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events"} # type: ignore @distributed_trace def list_by_billing_account( @@ -143,13 +149,16 @@ def list_by_billing_account( :type billing_account_id: str :param filter: May be used to filter the events by lotId, lotSource etc. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. - Tag filter is a key value pair string where key and value is separated by a colon (:). + Tag filter is a key value pair string where key and value is separated by a colon (:). Default + value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Events or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Events] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.Events"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -160,6 +169,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=self.list_by_billing_account.metadata['url'], ) @@ -170,6 +180,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -188,7 +199,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,4 +217,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events'} # type: ignore + list_by_billing_account.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py index bf8185fc2cd3..d1d1649f3d22 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_lots_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,12 +14,11 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._lots_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request +from ...operations._lots_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_customer_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -53,9 +51,8 @@ def list_by_billing_profile( billing_profile_id: str, **kwargs: Any ) -> AsyncIterable["_models.Lots"]: - """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - billing profile. Microsoft Azure consumption commitments are only supported for the billing - account scope. + """Lists all Azure credits for a billing account or a billing profile. The API is only supported + for Microsoft Customer Agreements (MCA) billing accounts. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -66,6 +63,8 @@ def list_by_billing_profile( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Lots] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -77,6 +76,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, template_url=self.list_by_billing_profile.metadata['url'], ) request = _convert_request(request) @@ -87,6 +87,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -104,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,7 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots'} # type: ignore + list_by_billing_profile.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots"} # type: ignore @distributed_trace def list_by_billing_account( @@ -127,21 +132,24 @@ def list_by_billing_account( filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.Lots"]: - """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - billing profile. Microsoft Azure consumption commitments are only supported for the billing - account scope. + """Lists all Microsoft Azure consumption commitments for a billing account. The API is only + supported for Microsoft Customer Agreements (MCA) and Direct Enterprise Agreement (EA) billing + accounts. :param billing_account_id: BillingAccount ID. :type billing_account_id: str :param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag - filter is a key value pair string where key and value is separated by a colon (:). + filter is a key value pair string where key and value is separated by a colon (:). Default + value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Lots or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Lots] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -152,6 +160,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=self.list_by_billing_account.metadata['url'], ) @@ -162,6 +171,95 @@ def prepare_request(next_link=None): request = build_list_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("Lots", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots"} # type: ignore + + @distributed_trace + def list_by_customer( + self, + billing_account_id: str, + customer_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Lots"]: + """Lists all Azure credits for a customer. The API is only supported for Microsoft Partner + Agreements (MPA) billing accounts. + + :param billing_account_id: BillingAccount ID. + :type billing_account_id: str + :param customer_id: Customer ID. + :type customer_id: str + :param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq', + 'lt', 'gt', 'le', 'ge', and 'and'. Tag filter is a key value pair string where key and value is + separated by a colon (:). Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Lots or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.Lots] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_customer_request( + billing_account_id=billing_account_id, + customer_id=customer_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_customer_request( + billing_account_id=billing_account_id, + customer_id=customer_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -180,7 +278,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -194,4 +296,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots'} # type: ignore + list_by_customer.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_marketplaces_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_marketplaces_operations.py index 48e202474ecd..1317ddf8bd23 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_marketplaces_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_marketplaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -73,13 +71,15 @@ def list( :param filter: May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - currently support 'ne', 'or', or 'not'. + currently support 'ne', 'or', or 'not'. Default value is None. :type filter: str :param top: May be used to limit the number of results to the most recent N marketplaces. + Default value is None. :type top: int :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include - a skiptoken parameter that specifies a starting point to use for subsequent calls. + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MarketplacesListResult or the result of @@ -88,6 +88,8 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.MarketplacesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MarketplacesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -98,6 +100,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, filter=filter, top=top, skiptoken=skiptoken, @@ -110,6 +113,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, filter=filter, top=top, skiptoken=skiptoken, @@ -130,7 +134,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -144,4 +152,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/marketplaces'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/marketplaces"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_operations.py index 911dcd6cace9..dfa99591e1aa 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -59,6 +57,8 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -68,6 +68,7 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], ) request = _convert_request(request) @@ -76,6 +77,7 @@ def prepare_request(next_link=None): else: request = build_list_request( + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -93,7 +95,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,4 +113,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Consumption/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Consumption/operations"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_price_sheet_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_price_sheet_operations.py index a9c72e9a256f..7ea8a98ee2b2 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_price_sheet_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_price_sheet_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -56,13 +55,15 @@ async def get( 2014 or later. :param expand: May be used to expand the properties/meterDetails within a price sheet. By - default, these fields are not included when returning price sheet. + default, these fields are not included when returning price sheet. Default value is None. :type expand: str :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include - a skiptoken parameter that specifies a starting point to use for subsequent calls. + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str - :param top: May be used to limit the number of results to the top N results. + :param top: May be used to limit the number of results to the top N results. Default value is + None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: PriceSheetResult, or the result of cls(response) @@ -75,9 +76,12 @@ async def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, skiptoken=skiptoken, top=top, @@ -86,7 +90,11 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +109,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default"} # type: ignore @distributed_trace_async @@ -119,13 +127,15 @@ async def get_by_billing_period( :param billing_period_name: Billing Period Name. :type billing_period_name: str :param expand: May be used to expand the properties/meterDetails within a price sheet. By - default, these fields are not included when returning price sheet. + default, these fields are not included when returning price sheet. Default value is None. :type expand: str :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include - a skiptoken parameter that specifies a starting point to use for subsequent calls. + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str - :param top: May be used to limit the number of results to the top N results. + :param top: May be used to limit the number of results to the top N results. Default value is + None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: PriceSheetResult, or the result of cls(response) @@ -138,10 +148,13 @@ async def get_by_billing_period( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_by_billing_period_request( subscription_id=self._config.subscription_id, billing_period_name=billing_period_name, + api_version=api_version, expand=expand, skiptoken=skiptoken, top=top, @@ -150,7 +163,11 @@ async def get_by_billing_period( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -165,5 +182,5 @@ async def get_by_billing_period( return deserialized - get_by_billing_period.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default'} # type: ignore + get_by_billing_period.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendation_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendation_details_operations.py index 9cc6837324c5..eaad777932e0 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendation_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendation_details_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -47,7 +46,8 @@ def __init__(self, client, config, serializer, deserializer) -> None: @distributed_trace_async async def get( self, - scope: str, + resource_scope: str, + scope: Union[str, "_models.Scope"], region: str, term: Union[str, "_models.Term"], look_back_period: Union[str, "_models.LookBackPeriod"], @@ -56,13 +56,15 @@ async def get( ) -> Optional["_models.ReservationRecommendationDetailsModel"]: """Details of a reservation recommendation for what-if analysis of reserved instances. - :param scope: The scope associated with reservation recommendation details operations. This - includes '/subscriptions/{subscriptionId}/' for subscription scope, + :param resource_scope: The scope associated with reservation recommendation details operations. + This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope. - :type scope: str + :type resource_scope: str + :param scope: Scope of the reservation. + :type scope: str or ~azure.mgmt.consumption.models.Scope :param region: Used to select the region the recommendation should be generated for. :type region: str :param term: Specify length of reservation recommendation term. @@ -84,8 +86,12 @@ async def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( + resource_scope=resource_scope, + api_version=api_version, scope=scope, region=region, term=term, @@ -96,7 +102,11 @@ async def get( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -113,5 +123,5 @@ async def get( return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationRecommendationDetails'} # type: ignore + get.metadata = {'url': "/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendationDetails"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendations_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendations_operations.py index 1e1cefed53f4..42e1d70d58f7 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendations_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_recommendations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -49,26 +47,26 @@ def __init__(self, client, config, serializer, deserializer) -> None: @distributed_trace def list( self, - scope: str, + resource_scope: str, filter: Optional[str] = None, **kwargs: Any ) -> AsyncIterable["_models.ReservationRecommendationsListResult"]: """List of recommendations for purchasing reserved instances. - :param scope: The scope associated with reservation recommendations operations. This includes - '/subscriptions/{subscriptionId}/' for subscription scope, + :param resource_scope: The scope associated with reservation recommendations operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope. - :type scope: str + :type resource_scope: str :param filter: May be used to filter reservationRecommendations by: properties/scope with allowed values ['Single', 'Shared'] and default value 'Single'; properties/resourceType with allowed values ['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', 'AzureDataExplorer', 'VMwareCloudSimple'] and default value 'VirtualMachines'; and properties/lookBackPeriod with allowed values ['Last7Days', 'Last30Days', 'Last60Days'] and - default value 'Last7Days'. + default value 'Last7Days'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationRecommendationsListResult or the result @@ -77,6 +75,8 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationRecommendationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationRecommendationsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -86,7 +86,8 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], ) @@ -96,7 +97,8 @@ def prepare_request(next_link=None): else: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -115,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -129,4 +135,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationRecommendations'} # type: ignore + list.metadata = {'url': "/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendations"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_transactions_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_transactions_operations.py index cae35efb82f8..219f33ce9003 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_transactions_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservation_transactions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -58,7 +56,7 @@ def list( :param billing_account_id: BillingAccount ID. :type billing_account_id: str :param filter: Filter reservation transactions by date range. The properties/EventDate for - start date and end date. The filter supports 'le' and 'ge'. + start date and end date. The filter supports 'le' and 'ge'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationTransactionsListResult or the result of @@ -67,6 +65,8 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationTransactionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationTransactionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -77,6 +77,7 @@ def prepare_request(next_link=None): request = build_list_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], ) @@ -87,6 +88,7 @@ def prepare_request(next_link=None): request = build_list_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -105,7 +107,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,7 +125,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions"} # type: ignore @distributed_trace def list_by_billing_profile( @@ -136,7 +142,7 @@ def list_by_billing_profile( :param billing_profile_id: Azure Billing Profile ID. :type billing_profile_id: str :param filter: Filter reservation transactions by date range. The properties/EventDate for - start date and end date. The filter supports 'le' and 'ge'. + start date and end date. The filter supports 'le' and 'ge'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModernReservationTransactionsListResult or the @@ -145,6 +151,8 @@ def list_by_billing_profile( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ModernReservationTransactionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ModernReservationTransactionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -156,6 +164,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, filter=filter, template_url=self.list_by_billing_profile.metadata['url'], ) @@ -167,6 +176,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -185,7 +195,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,4 +213,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/reservationTransactions'} # type: ignore + list_by_billing_profile.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/reservationTransactions"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_details_operations.py index a5c894333b6f..371227cbc77a 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_details_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -67,6 +65,8 @@ def list_by_reservation_order( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -77,6 +77,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_request( reservation_order_id=reservation_order_id, + api_version=api_version, filter=filter, template_url=self.list_by_reservation_order.metadata['url'], ) @@ -87,6 +88,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_request( reservation_order_id=reservation_order_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -105,7 +107,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,7 +125,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + list_by_reservation_order.metadata = {'url': "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails"} # type: ignore @distributed_trace def list_by_reservation_order_and_reservation( @@ -145,6 +151,8 @@ def list_by_reservation_order_and_reservation( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -156,6 +164,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_and_reservation_request( reservation_order_id=reservation_order_id, reservation_id=reservation_id, + api_version=api_version, filter=filter, template_url=self.list_by_reservation_order_and_reservation.metadata['url'], ) @@ -167,6 +176,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_and_reservation_request( reservation_order_id=reservation_order_id, reservation_id=reservation_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -185,7 +195,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,12 +213,12 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_reservation_order_and_reservation.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + list_by_reservation_order_and_reservation.metadata = {'url': "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails"} # type: ignore @distributed_trace def list( self, - scope: str, + resource_scope: str, start_date: Optional[str] = None, end_date: Optional[str] = None, filter: Optional[str] = None, @@ -214,25 +228,27 @@ def list( ) -> AsyncIterable["_models.ReservationDetailsListResult"]: """Lists the reservations details for the defined scope and provided date range. - :param scope: The scope associated with reservations details operations. This includes + :param resource_scope: The scope associated with reservations details operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope (legacy), and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope (modern). - :type scope: str - :param start_date: Start date. Only applicable when querying with billing profile. + :type resource_scope: str + :param start_date: Start date. Only applicable when querying with billing profile. Default + value is None. :type start_date: str - :param end_date: End date. Only applicable when querying with billing profile. + :param end_date: End date. Only applicable when querying with billing profile. Default value is + None. :type end_date: str :param filter: Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. Not applicable when querying with - billing profile. + billing profile. Default value is None. :type filter: str :param reservation_id: Reservation Id GUID. Only valid if reservationOrderId is also provided. - Filter to a specific reservation. + Filter to a specific reservation. Default value is None. :type reservation_id: str :param reservation_order_id: Reservation Order Id GUID. Required if reservationId is provided. - Filter to a specific reservation order. + Filter to a specific reservation order. Default value is None. :type reservation_order_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationDetailsListResult or the result of @@ -241,6 +257,8 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -250,7 +268,8 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, start_date=start_date, end_date=end_date, filter=filter, @@ -264,7 +283,8 @@ def prepare_request(next_link=None): else: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, start_date=start_date, end_date=end_date, filter=filter, @@ -287,7 +307,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -301,4 +325,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + list.metadata = {'url': "/{resourceScope}/providers/Microsoft.Consumption/reservationDetails"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_summaries_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_summaries_operations.py index 7842a6354a4c..77b5f47c3c84 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_summaries_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_reservations_summaries_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -61,7 +59,7 @@ def list_by_reservation_order( :param grain: Can be daily or monthly. :type grain: str or ~azure.mgmt.consumption.models.Datagrain :param filter: Required only for daily grain. The properties/UsageDate for start date and end - date. The filter supports 'le' and 'ge'. + date. The filter supports 'le' and 'ge'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationSummariesListResult or the result of @@ -70,6 +68,8 @@ def list_by_reservation_order( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -80,6 +80,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_request( reservation_order_id=reservation_order_id, + api_version=api_version, grain=grain, filter=filter, template_url=self.list_by_reservation_order.metadata['url'], @@ -91,6 +92,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_request( reservation_order_id=reservation_order_id, + api_version=api_version, grain=grain, filter=filter, template_url=next_link, @@ -110,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -124,7 +130,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + list_by_reservation_order.metadata = {'url': "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries"} # type: ignore @distributed_trace def list_by_reservation_order_and_reservation( @@ -144,7 +150,7 @@ def list_by_reservation_order_and_reservation( :param grain: Can be daily or monthly. :type grain: str or ~azure.mgmt.consumption.models.Datagrain :param filter: Required only for daily grain. The properties/UsageDate for start date and end - date. The filter supports 'le' and 'ge'. + date. The filter supports 'le' and 'ge'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationSummariesListResult or the result of @@ -153,6 +159,8 @@ def list_by_reservation_order_and_reservation( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -164,6 +172,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_and_reservation_request( reservation_order_id=reservation_order_id, reservation_id=reservation_id, + api_version=api_version, grain=grain, filter=filter, template_url=self.list_by_reservation_order_and_reservation.metadata['url'], @@ -176,6 +185,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_and_reservation_request( reservation_order_id=reservation_order_id, reservation_id=reservation_id, + api_version=api_version, grain=grain, filter=filter, template_url=next_link, @@ -195,7 +205,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -209,12 +223,12 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_reservation_order_and_reservation.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + list_by_reservation_order_and_reservation.metadata = {'url': "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries"} # type: ignore @distributed_trace def list( self, - scope: str, + resource_scope: str, grain: Union[str, "_models.Datagrain"], start_date: Optional[str] = None, end_date: Optional[str] = None, @@ -225,26 +239,29 @@ def list( ) -> AsyncIterable["_models.ReservationSummariesListResult"]: """Lists the reservations summaries for the defined scope daily or monthly grain. - :param scope: The scope associated with reservations summaries operations. This includes - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope - (legacy), and + :param resource_scope: The scope associated with reservations summaries operations. This + includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount + scope (legacy), and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope (modern). - :type scope: str + :type resource_scope: str :param grain: Can be daily or monthly. :type grain: str or ~azure.mgmt.consumption.models.Datagrain - :param start_date: Start date. Only applicable when querying with billing profile. + :param start_date: Start date. Only applicable when querying with billing profile. Default + value is None. :type start_date: str - :param end_date: End date. Only applicable when querying with billing profile. + :param end_date: End date. Only applicable when querying with billing profile. Default value is + None. :type end_date: str :param filter: Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. Not applicable when querying with billing profile. + Default value is None. :type filter: str :param reservation_id: Reservation Id GUID. Only valid if reservationOrderId is also provided. - Filter to a specific reservation. + Filter to a specific reservation. Default value is None. :type reservation_id: str :param reservation_order_id: Reservation Order Id GUID. Required if reservationId is provided. - Filter to a specific reservation order. + Filter to a specific reservation order. Default value is None. :type reservation_order_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationSummariesListResult or the result of @@ -253,6 +270,8 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -262,7 +281,8 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, grain=grain, start_date=start_date, end_date=end_date, @@ -277,7 +297,8 @@ def prepare_request(next_link=None): else: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, grain=grain, start_date=start_date, end_date=end_date, @@ -301,7 +322,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -315,4 +340,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + list.metadata = {'url': "/{resourceScope}/providers/Microsoft.Consumption/reservationSummaries"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_tags_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_tags_operations.py index d40873679d09..941f21560a84 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_tags_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_tags_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -74,15 +73,22 @@ async def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( scope=scope, + api_version=api_version, template_url=self.get.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -99,5 +105,5 @@ async def get( return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/tags'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/tags"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_usage_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_usage_details_operations.py index 39855ebabfe8..be534508c417 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_usage_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/aio/operations/_usage_details_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -82,7 +80,7 @@ def list( :type scope: str :param expand: May be used to expand the properties/additionalInfo or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage - details. + details. Default value is None. :type expand: str :param filter: May be used to filter usageDetails by properties/resourceGroup, properties/resourceName, properties/resourceId, properties/chargeType, @@ -90,15 +88,17 @@ def list( 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). PublisherType Filter accepts two values azure and marketplace and it is currently supported for Web Direct Offer - Type. + Type. Default value is None. :type filter: str :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include - a skiptoken parameter that specifies a starting point to use for subsequent calls. + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int - :param metric: Allows to select different type of cost/usage records. + :param metric: Allows to select different type of cost/usage records. Default value is None. :type metric: str or ~azure.mgmt.consumption.models.Metrictype :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageDetailsListResult or the result of @@ -107,6 +107,8 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.consumption.models.UsageDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageDetailsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -117,6 +119,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, expand=expand, filter=filter, skiptoken=skiptoken, @@ -131,6 +134,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, expand=expand, filter=filter, skiptoken=skiptoken, @@ -153,7 +157,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -167,4 +175,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/usageDetails'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/usageDetails"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py index e5e45e6f8c92..a51c2237756e 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/models/_models_py3.py @@ -533,8 +533,6 @@ class BudgetFilter(msrest.serialization.Model): :ivar and_property: The logical "AND" expression. Must have at least 2 items. :vartype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] - :ivar not_property: The logical "NOT" expression. - :vartype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties :ivar dimensions: Has comparison expression for a dimension. :vartype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression :ivar tags: A set of tags. Has comparison expression for a tag. @@ -543,7 +541,6 @@ class BudgetFilter(msrest.serialization.Model): _attribute_map = { 'and_property': {'key': 'and', 'type': '[BudgetFilterProperties]'}, - 'not_property': {'key': 'not', 'type': 'BudgetFilterProperties'}, 'dimensions': {'key': 'dimensions', 'type': 'BudgetComparisonExpression'}, 'tags': {'key': 'tags', 'type': 'BudgetComparisonExpression'}, } @@ -552,7 +549,6 @@ def __init__( self, *, and_property: Optional[List["BudgetFilterProperties"]] = None, - not_property: Optional["BudgetFilterProperties"] = None, dimensions: Optional["BudgetComparisonExpression"] = None, tags: Optional["BudgetComparisonExpression"] = None, **kwargs @@ -560,8 +556,6 @@ def __init__( """ :keyword and_property: The logical "AND" expression. Must have at least 2 items. :paramtype and_property: list[~azure.mgmt.consumption.models.BudgetFilterProperties] - :keyword not_property: The logical "NOT" expression. - :paramtype not_property: ~azure.mgmt.consumption.models.BudgetFilterProperties :keyword dimensions: Has comparison expression for a dimension. :paramtype dimensions: ~azure.mgmt.consumption.models.BudgetComparisonExpression :keyword tags: A set of tags. Has comparison expression for a tag. @@ -569,7 +563,6 @@ def __init__( """ super(BudgetFilter, self).__init__(**kwargs) self.and_property = and_property - self.not_property = not_property self.dimensions = dimensions self.tags = tags @@ -1509,7 +1502,6 @@ def __init__( self.type = None self.etag = None self.tags = None - self.kind = 'ReservationRecommendation' # type: str class LegacyReservationRecommendation(ReservationRecommendation): diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_aggregated_cost_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_aggregated_cost_operations.py index c1b9ea8b9752..0c38a6ee2587 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_aggregated_cost_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_aggregated_cost_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,7 +16,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,31 +31,32 @@ def build_get_by_management_group_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost') + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -65,30 +66,31 @@ def build_get_for_billing_period_by_management_group_request( billing_period_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost') + _url = kwargs.pop("template_url", "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost") # pylint: disable=line-too-long path_format_arguments = { "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str'), "billingPeriodName": _SERIALIZER.url("billing_period_name", billing_period_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -129,7 +131,7 @@ def get_by_management_group( :param filter: May be used to filter aggregated cost by properties/usageStart (Utc time), properties/usageEnd (Utc time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where - key and value is separated by a colon (:). + key and value is separated by a colon (:). Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupAggregatedCostResult, or the result of cls(response) @@ -142,16 +144,23 @@ def get_by_management_group( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_by_management_group_request( management_group_id=management_group_id, + api_version=api_version, filter=filter, template_url=self.get_by_management_group.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -166,7 +175,7 @@ def get_by_management_group( return deserialized - get_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost'} # type: ignore + get_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Consumption/aggregatedcost"} # type: ignore @distributed_trace @@ -194,16 +203,23 @@ def get_for_billing_period_by_management_group( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_for_billing_period_by_management_group_request( management_group_id=management_group_id, billing_period_name=billing_period_name, + api_version=api_version, template_url=self.get_for_billing_period_by_management_group.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,5 +234,5 @@ def get_for_billing_period_by_management_group( return deserialized - get_for_billing_period_by_management_group.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost'} # type: ignore + get_for_billing_period_by_management_group.metadata = {'url': "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_balances_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_balances_operations.py index 766289431ea6..9f6a2ff076dd 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_balances_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_balances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,7 +16,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -29,29 +29,30 @@ def build_get_by_billing_account_request( billing_account_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -61,30 +62,31 @@ def build_get_for_billing_period_by_billing_account_request( billing_period_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), "billingPeriodName": _SERIALIZER.url("billing_period_name", billing_period_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -132,15 +134,22 @@ def get_by_billing_account( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, template_url=self.get_by_billing_account.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -155,7 +164,7 @@ def get_by_billing_account( return deserialized - get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances'} # type: ignore + get_by_billing_account.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances"} # type: ignore @distributed_trace @@ -183,16 +192,23 @@ def get_for_billing_period_by_billing_account( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_for_billing_period_by_billing_account_request( billing_account_id=billing_account_id, billing_period_name=billing_period_name, + api_version=api_version, template_url=self.get_for_billing_period_by_billing_account.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -207,5 +223,5 @@ def get_for_billing_period_by_billing_account( return deserialized - get_for_billing_period_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'} # type: ignore + get_for_billing_period_by_billing_account.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_budgets_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_budgets_operations.py index 3ec0e2da3ace..9946898f7d8a 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_budgets_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_budgets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,29 +31,30 @@ def build_list_request( scope: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/budgets') + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Consumption/budgets") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -63,30 +64,31 @@ def build_get_request( budget_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}') + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), "budgetName": _SERIALIZER.url("budget_name", budget_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -99,34 +101,34 @@ def build_create_or_update_request( content: Any = None, **kwargs: Any ) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-10-01") # type: str content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-10-01" accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}') + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), "budgetName": _SERIALIZER.url("budget_name", budget_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, json=json, content=content, **kwargs @@ -138,30 +140,31 @@ def build_delete_request( budget_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}') + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), "budgetName": _SERIALIZER.url("budget_name", budget_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -215,6 +218,8 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.BudgetsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.BudgetsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -225,6 +230,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, template_url=self.list.metadata['url'], ) request = _convert_request(request) @@ -234,6 +240,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -251,7 +258,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -265,7 +276,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/budgets"} # type: ignore @distributed_trace def get( @@ -304,16 +315,23 @@ def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( scope=scope, budget_name=budget_name, + api_version=api_version, template_url=self.get.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -328,7 +346,7 @@ def get( return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}"} # type: ignore @distributed_trace @@ -373,6 +391,7 @@ def create_or_update( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] _json = self._serialize.body(parameters, 'Budget') @@ -380,6 +399,7 @@ def create_or_update( request = build_create_or_update_request( scope=scope, budget_name=budget_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update.metadata['url'], @@ -387,7 +407,11 @@ def create_or_update( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -406,11 +430,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, scope: str, budget_name: str, @@ -446,16 +470,23 @@ def delete( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_delete_request( scope=scope, budget_name=budget_name, + api_version=api_version, template_url=self.delete.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -466,5 +497,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_charges_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_charges_operations.py index 4ba593ca7748..d345964926a0 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_charges_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_charges_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,7 +16,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -34,37 +34,38 @@ def build_list_request( apply: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/charges') + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Consumption/charges") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if start_date is not None: - query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') + _query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') if end_date is not None: - query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') + _query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') if apply is not None: - query_parameters['$apply'] = _SERIALIZER.query("apply", apply, 'str') + _query_parameters['$apply'] = _SERIALIZER.query("apply", apply, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -119,18 +120,19 @@ def list( 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. :type scope: str - :param start_date: Start date. + :param start_date: Start date. Default value is None. :type start_date: str - :param end_date: End date. + :param end_date: End date. Default value is None. :type end_date: str :param filter: May be used to filter charges by properties/usageEnd (Utc time), properties/usageStart (Utc time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where - key and value is separated by a colon (:). + key and value is separated by a colon (:). Default value is None. :type filter: str :param apply: May be used to group charges for billingAccount scope by properties/billingProfileId, properties/invoiceSectionId, properties/customerId (specific for - Partner Led), or for billingProfile scope by properties/invoiceSectionId. + Partner Led), or for billingProfile scope by properties/invoiceSectionId. Default value is + None. :type apply: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ChargesListResult, or the result of cls(response) @@ -143,9 +145,12 @@ def list( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_list_request( scope=scope, + api_version=api_version, start_date=start_date, end_date=end_date, filter=filter, @@ -155,7 +160,11 @@ def list( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -170,5 +179,5 @@ def list( return deserialized - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/charges'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/charges"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_credits_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_credits_operations.py index 03e4222981c9..9a6644fe5e32 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_credits_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_credits_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,7 +16,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,30 +30,31 @@ def build_get_request( billing_profile_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), "billingProfileId": _SERIALIZER.url("billing_profile_id", billing_profile_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -103,16 +104,23 @@ def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, template_url=self.get.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -129,5 +137,5 @@ def get( return deserialized - get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_events_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_events_operations.py index f0a317b6bbdc..1175feaa81a5 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_events_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_events_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -34,32 +34,33 @@ def build_list_by_billing_profile_request( end_date: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), "billingProfileId": _SERIALIZER.url("billing_profile_id", billing_profile_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') - query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') + _query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -70,31 +71,32 @@ def build_list_by_billing_account_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -145,6 +147,8 @@ def list_by_billing_profile( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Events] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.Events"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -156,6 +160,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, start_date=start_date, end_date=end_date, template_url=self.list_by_billing_profile.metadata['url'], @@ -168,6 +173,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, start_date=start_date, end_date=end_date, template_url=next_link, @@ -187,7 +193,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -201,7 +211,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events'} # type: ignore + list_by_billing_profile.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events"} # type: ignore @distributed_trace def list_by_billing_account( @@ -217,13 +227,16 @@ def list_by_billing_account( :type billing_account_id: str :param filter: May be used to filter the events by lotId, lotSource etc. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. - Tag filter is a key value pair string where key and value is separated by a colon (:). + Tag filter is a key value pair string where key and value is separated by a colon (:). Default + value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Events or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Events] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.Events"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -234,6 +247,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=self.list_by_billing_account.metadata['url'], ) @@ -244,6 +258,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -262,7 +277,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -276,4 +295,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events'} # type: ignore + list_by_billing_account.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/events"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py index 5d74e051f327..3231417ba010 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_lots_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,30 +31,31 @@ def build_list_by_billing_profile_request( billing_profile_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), "billingProfileId": _SERIALIZER.url("billing_profile_id", billing_profile_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -65,31 +66,70 @@ def build_list_by_billing_account_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_customer_request( + billing_account_id: str, + customer_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots") # pylint: disable=line-too-long + path_format_arguments = { + "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), + "customerId": _SERIALIZER.url("customer_id", customer_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -122,9 +162,8 @@ def list_by_billing_profile( billing_profile_id: str, **kwargs: Any ) -> Iterable["_models.Lots"]: - """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - billing profile. Microsoft Azure consumption commitments are only supported for the billing - account scope. + """Lists all Azure credits for a billing account or a billing profile. The API is only supported + for Microsoft Customer Agreements (MCA) billing accounts. :param billing_account_id: BillingAccount ID. :type billing_account_id: str @@ -135,6 +174,8 @@ def list_by_billing_profile( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Lots] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -146,6 +187,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, template_url=self.list_by_billing_profile.metadata['url'], ) request = _convert_request(request) @@ -156,6 +198,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -173,7 +216,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,7 +234,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots'} # type: ignore + list_by_billing_profile.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots"} # type: ignore @distributed_trace def list_by_billing_account( @@ -196,21 +243,24 @@ def list_by_billing_account( filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.Lots"]: - """Lists all Azure credits and Microsoft Azure consumption commitments for a billing account or a - billing profile. Microsoft Azure consumption commitments are only supported for the billing - account scope. + """Lists all Microsoft Azure consumption commitments for a billing account. The API is only + supported for Microsoft Customer Agreements (MCA) and Direct Enterprise Agreement (EA) billing + accounts. :param billing_account_id: BillingAccount ID. :type billing_account_id: str :param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag - filter is a key value pair string where key and value is separated by a colon (:). + filter is a key value pair string where key and value is separated by a colon (:). Default + value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Lots or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Lots] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -221,6 +271,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=self.list_by_billing_account.metadata['url'], ) @@ -231,6 +282,95 @@ def prepare_request(next_link=None): request = build_list_by_billing_account_request( billing_account_id=billing_account_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("Lots", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_billing_account.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots"} # type: ignore + + @distributed_trace + def list_by_customer( + self, + billing_account_id: str, + customer_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.Lots"]: + """Lists all Azure credits for a customer. The API is only supported for Microsoft Partner + Agreements (MPA) billing accounts. + + :param billing_account_id: BillingAccount ID. + :type billing_account_id: str + :param customer_id: Customer ID. + :type customer_id: str + :param filter: May be used to filter the lots by Status, Source etc. The filter supports 'eq', + 'lt', 'gt', 'le', 'ge', and 'and'. Tag filter is a key value pair string where key and value is + separated by a colon (:). Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Lots or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.Lots] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.Lots"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_customer_request( + billing_account_id=billing_account_id, + customer_id=customer_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_customer_request( + billing_account_id=billing_account_id, + customer_id=customer_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -249,7 +389,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -263,4 +407,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/lots'} # type: ignore + list_by_customer.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}/providers/Microsoft.Consumption/lots"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_marketplaces_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_marketplaces_operations.py index 89d24ec18df7..a1c9ab326e7c 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_marketplaces_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_marketplaces_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -34,35 +34,36 @@ def build_list_request( skiptoken: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/marketplaces') + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Consumption/marketplaces") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) if skiptoken is not None: - query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -115,13 +116,15 @@ def list( :param filter: May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), properties/resourceGroup, properties/instanceName or properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not - currently support 'ne', 'or', or 'not'. + currently support 'ne', 'or', or 'not'. Default value is None. :type filter: str :param top: May be used to limit the number of results to the most recent N marketplaces. + Default value is None. :type top: int :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include - a skiptoken parameter that specifies a starting point to use for subsequent calls. + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MarketplacesListResult or the result of @@ -129,6 +132,8 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.MarketplacesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.MarketplacesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -139,6 +144,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, filter=filter, top=top, skiptoken=skiptoken, @@ -151,6 +157,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, filter=filter, top=top, skiptoken=skiptoken, @@ -171,7 +178,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,4 +196,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/marketplaces'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/marketplaces"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_operations.py index 97bea4f4f2fe..398b427ae03c 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,24 +29,25 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Consumption/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Consumption/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -84,6 +85,8 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -93,6 +96,7 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], ) request = _convert_request(request) @@ -101,6 +105,7 @@ def prepare_request(next_link=None): else: request = build_list_request( + api_version=api_version, template_url=next_link, ) request = _convert_request(request) @@ -118,7 +123,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +141,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Consumption/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Consumption/operations"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_price_sheet_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_price_sheet_operations.py index d3abc8099c07..375b1efa779a 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_price_sheet_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_price_sheet_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,7 +16,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,35 +33,36 @@ def build_get_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') if skiptoken is not None: - query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -75,36 +76,37 @@ def build_get_by_billing_period_request( top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), "billingPeriodName": _SERIALIZER.url("billing_period_name", billing_period_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') if skiptoken is not None: - query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -142,13 +144,15 @@ def get( 2014 or later. :param expand: May be used to expand the properties/meterDetails within a price sheet. By - default, these fields are not included when returning price sheet. + default, these fields are not included when returning price sheet. Default value is None. :type expand: str :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include - a skiptoken parameter that specifies a starting point to use for subsequent calls. + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str - :param top: May be used to limit the number of results to the top N results. + :param top: May be used to limit the number of results to the top N results. Default value is + None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: PriceSheetResult, or the result of cls(response) @@ -161,9 +165,12 @@ def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, skiptoken=skiptoken, top=top, @@ -172,7 +179,11 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,7 +198,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default"} # type: ignore @distributed_trace @@ -205,13 +216,15 @@ def get_by_billing_period( :param billing_period_name: Billing Period Name. :type billing_period_name: str :param expand: May be used to expand the properties/meterDetails within a price sheet. By - default, these fields are not included when returning price sheet. + default, these fields are not included when returning price sheet. Default value is None. :type expand: str :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include - a skiptoken parameter that specifies a starting point to use for subsequent calls. + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str - :param top: May be used to limit the number of results to the top N results. + :param top: May be used to limit the number of results to the top N results. Default value is + None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response :return: PriceSheetResult, or the result of cls(response) @@ -224,10 +237,13 @@ def get_by_billing_period( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_by_billing_period_request( subscription_id=self._config.subscription_id, billing_period_name=billing_period_name, + api_version=api_version, expand=expand, skiptoken=skiptoken, top=top, @@ -236,7 +252,11 @@ def get_by_billing_period( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,5 +271,5 @@ def get_by_billing_period( return deserialized - get_by_billing_period.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default'} # type: ignore + get_by_billing_period.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendation_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendation_details_operations.py index 28ff15e7a380..f61fe0117b20 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendation_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendation_details_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,7 +16,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -26,41 +26,44 @@ _SERIALIZER.client_side_validation = False def build_get_request( - scope: str, + resource_scope: str, *, + scope: Union[str, "_models.Scope"], region: str, term: Union[str, "_models.Term"], look_back_period: Union[str, "_models.LookBackPeriod"], product: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/reservationRecommendationDetails') + _url = kwargs.pop("template_url", "/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendationDetails") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - query_parameters['region'] = _SERIALIZER.query("region", region, 'str') - query_parameters['term'] = _SERIALIZER.query("term", term, 'str') - query_parameters['lookBackPeriod'] = _SERIALIZER.query("look_back_period", look_back_period, 'str') - query_parameters['product'] = _SERIALIZER.query("product", product, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['scope'] = _SERIALIZER.query("scope", scope, 'str') + _query_parameters['region'] = _SERIALIZER.query("region", region, 'str') + _query_parameters['term'] = _SERIALIZER.query("term", term, 'str') + _query_parameters['lookBackPeriod'] = _SERIALIZER.query("look_back_period", look_back_period, 'str') + _query_parameters['product'] = _SERIALIZER.query("product", product, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -89,7 +92,8 @@ def __init__(self, client, config, serializer, deserializer): @distributed_trace def get( self, - scope: str, + resource_scope: str, + scope: Union[str, "_models.Scope"], region: str, term: Union[str, "_models.Term"], look_back_period: Union[str, "_models.LookBackPeriod"], @@ -98,13 +102,15 @@ def get( ) -> Optional["_models.ReservationRecommendationDetailsModel"]: """Details of a reservation recommendation for what-if analysis of reserved instances. - :param scope: The scope associated with reservation recommendation details operations. This - includes '/subscriptions/{subscriptionId}/' for subscription scope, + :param resource_scope: The scope associated with reservation recommendation details operations. + This includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope. - :type scope: str + :type resource_scope: str + :param scope: Scope of the reservation. + :type scope: str or ~azure.mgmt.consumption.models.Scope :param region: Used to select the region the recommendation should be generated for. :type region: str :param term: Specify length of reservation recommendation term. @@ -126,8 +132,12 @@ def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( + resource_scope=resource_scope, + api_version=api_version, scope=scope, region=region, term=term, @@ -138,7 +148,11 @@ def get( request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -155,5 +169,5 @@ def get( return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationRecommendationDetails'} # type: ignore + get.metadata = {'url': "/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendationDetails"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendations_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendations_operations.py index 5f0143efd8d2..f0748f0f508d 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendations_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_recommendations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -27,36 +27,37 @@ _SERIALIZER.client_side_validation = False def build_list_request( - scope: str, + resource_scope: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/reservationRecommendations') + _url = kwargs.pop("template_url", "/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendations") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters = 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') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -85,26 +86,26 @@ def __init__(self, client, config, serializer, deserializer): @distributed_trace def list( self, - scope: str, + resource_scope: str, filter: Optional[str] = None, **kwargs: Any ) -> Iterable["_models.ReservationRecommendationsListResult"]: """List of recommendations for purchasing reserved instances. - :param scope: The scope associated with reservation recommendations operations. This includes - '/subscriptions/{subscriptionId}/' for subscription scope, + :param resource_scope: The scope associated with reservation recommendations operations. This + includes '/subscriptions/{subscriptionId}/' for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile scope. - :type scope: str + :type resource_scope: str :param filter: May be used to filter reservationRecommendations by: properties/scope with allowed values ['Single', 'Shared'] and default value 'Single'; properties/resourceType with allowed values ['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', 'AzureDataExplorer', 'VMwareCloudSimple'] and default value 'VirtualMachines'; and properties/lookBackPeriod with allowed values ['Last7Days', 'Last30Days', 'Last60Days'] and - default value 'Last7Days'. + default value 'Last7Days'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationRecommendationsListResult or the result @@ -113,6 +114,8 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationRecommendationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationRecommendationsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -122,7 +125,8 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], ) @@ -132,7 +136,8 @@ def prepare_request(next_link=None): else: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -151,7 +156,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -165,4 +174,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationRecommendations'} # type: ignore + list.metadata = {'url': "/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendations"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_transactions_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_transactions_operations.py index 8c16e5f40959..795252246e3f 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_transactions_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservation_transactions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,31 +32,32 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters = 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') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -68,32 +69,33 @@ def build_list_by_billing_profile_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/reservationTransactions') + _url = kwargs.pop("template_url", "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/reservationTransactions") # pylint: disable=line-too-long path_format_arguments = { "billingAccountId": _SERIALIZER.url("billing_account_id", billing_account_id, 'str'), "billingProfileId": _SERIALIZER.url("billing_profile_id", billing_profile_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _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') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -131,7 +133,7 @@ def list( :param billing_account_id: BillingAccount ID. :type billing_account_id: str :param filter: Filter reservation transactions by date range. The properties/EventDate for - start date and end date. The filter supports 'le' and 'ge'. + start date and end date. The filter supports 'le' and 'ge'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationTransactionsListResult or the result of @@ -140,6 +142,8 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationTransactionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationTransactionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -150,6 +154,7 @@ def prepare_request(next_link=None): request = build_list_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=self.list.metadata['url'], ) @@ -160,6 +165,7 @@ def prepare_request(next_link=None): request = build_list_request( billing_account_id=billing_account_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -178,7 +184,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -192,7 +202,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/reservationTransactions"} # type: ignore @distributed_trace def list_by_billing_profile( @@ -209,7 +219,7 @@ def list_by_billing_profile( :param billing_profile_id: Azure Billing Profile ID. :type billing_profile_id: str :param filter: Filter reservation transactions by date range. The properties/EventDate for - start date and end date. The filter supports 'le' and 'ge'. + start date and end date. The filter supports 'le' and 'ge'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ModernReservationTransactionsListResult or the @@ -218,6 +228,8 @@ def list_by_billing_profile( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ModernReservationTransactionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ModernReservationTransactionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -229,6 +241,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, filter=filter, template_url=self.list_by_billing_profile.metadata['url'], ) @@ -240,6 +253,7 @@ def prepare_request(next_link=None): request = build_list_by_billing_profile_request( billing_account_id=billing_account_id, billing_profile_id=billing_profile_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -258,7 +272,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -272,4 +290,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/reservationTransactions'} # type: ignore + list_by_billing_profile.metadata = {'url': "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/reservationTransactions"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_details_operations.py index b71b51feec3b..3495535a1964 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_details_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -32,30 +32,31 @@ def build_list_by_reservation_order_request( filter: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails') + _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails") # pylint: disable=line-too-long path_format_arguments = { "reservationOrderId": _SERIALIZER.url("reservation_order_id", reservation_order_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -67,37 +68,38 @@ def build_list_by_reservation_order_and_reservation_request( filter: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails') + _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails") # pylint: disable=line-too-long path_format_arguments = { "reservationOrderId": _SERIALIZER.url("reservation_order_id", reservation_order_id, 'str'), "reservationId": _SERIALIZER.url("reservation_id", reservation_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) def build_list_request( - scope: str, + resource_scope: str, *, start_date: Optional[str] = None, end_date: Optional[str] = None, @@ -106,39 +108,40 @@ def build_list_request( reservation_order_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/reservationDetails') + _url = kwargs.pop("template_url", "/{resourceScope}/providers/Microsoft.Consumption/reservationDetails") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if start_date is not None: - query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') + _query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') if end_date is not None: - query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') + _query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') if reservation_id is not None: - query_parameters['reservationId'] = _SERIALIZER.query("reservation_id", reservation_id, 'str') + _query_parameters['reservationId'] = _SERIALIZER.query("reservation_id", reservation_id, 'str') if reservation_order_id is not None: - query_parameters['reservationOrderId'] = _SERIALIZER.query("reservation_order_id", reservation_order_id, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['reservationOrderId'] = _SERIALIZER.query("reservation_order_id", reservation_order_id, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -185,6 +188,8 @@ def list_by_reservation_order( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -195,6 +200,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_request( reservation_order_id=reservation_order_id, + api_version=api_version, filter=filter, template_url=self.list_by_reservation_order.metadata['url'], ) @@ -205,6 +211,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_request( reservation_order_id=reservation_order_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -223,7 +230,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,7 +248,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + list_by_reservation_order.metadata = {'url': "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails"} # type: ignore @distributed_trace def list_by_reservation_order_and_reservation( @@ -263,6 +274,8 @@ def list_by_reservation_order_and_reservation( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -274,6 +287,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_and_reservation_request( reservation_order_id=reservation_order_id, reservation_id=reservation_id, + api_version=api_version, filter=filter, template_url=self.list_by_reservation_order_and_reservation.metadata['url'], ) @@ -285,6 +299,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_and_reservation_request( reservation_order_id=reservation_order_id, reservation_id=reservation_id, + api_version=api_version, filter=filter, template_url=next_link, ) @@ -303,7 +318,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -317,12 +336,12 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_reservation_order_and_reservation.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + list_by_reservation_order_and_reservation.metadata = {'url': "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails"} # type: ignore @distributed_trace def list( self, - scope: str, + resource_scope: str, start_date: Optional[str] = None, end_date: Optional[str] = None, filter: Optional[str] = None, @@ -332,25 +351,27 @@ def list( ) -> Iterable["_models.ReservationDetailsListResult"]: """Lists the reservations details for the defined scope and provided date range. - :param scope: The scope associated with reservations details operations. This includes + :param resource_scope: The scope associated with reservations details operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope (legacy), and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope (modern). - :type scope: str - :param start_date: Start date. Only applicable when querying with billing profile. + :type resource_scope: str + :param start_date: Start date. Only applicable when querying with billing profile. Default + value is None. :type start_date: str - :param end_date: End date. Only applicable when querying with billing profile. + :param end_date: End date. Only applicable when querying with billing profile. Default value is + None. :type end_date: str :param filter: Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. Not applicable when querying with - billing profile. + billing profile. Default value is None. :type filter: str :param reservation_id: Reservation Id GUID. Only valid if reservationOrderId is also provided. - Filter to a specific reservation. + Filter to a specific reservation. Default value is None. :type reservation_id: str :param reservation_order_id: Reservation Order Id GUID. Required if reservationId is provided. - Filter to a specific reservation order. + Filter to a specific reservation order. Default value is None. :type reservation_order_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationDetailsListResult or the result of @@ -359,6 +380,8 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationDetailsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -368,7 +391,8 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, start_date=start_date, end_date=end_date, filter=filter, @@ -382,7 +406,8 @@ def prepare_request(next_link=None): else: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, start_date=start_date, end_date=end_date, filter=filter, @@ -405,7 +430,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -419,4 +448,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationDetails'} # type: ignore + list.metadata = {'url': "/{resourceScope}/providers/Microsoft.Consumption/reservationDetails"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_summaries_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_summaries_operations.py index 1e647a2df5a9..1d618119aa2d 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_summaries_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_reservations_summaries_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,32 +33,33 @@ def build_list_by_reservation_order_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries') + _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries") # pylint: disable=line-too-long path_format_arguments = { "reservationOrderId": _SERIALIZER.url("reservation_order_id", reservation_order_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -71,39 +72,40 @@ def build_list_by_reservation_order_and_reservation_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries') + _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries") # pylint: disable=line-too-long path_format_arguments = { "reservationOrderId": _SERIALIZER.url("reservation_order_id", reservation_order_id, 'str'), "reservationId": _SERIALIZER.url("reservation_id", reservation_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) def build_list_request( - scope: str, + resource_scope: str, *, grain: Union[str, "_models.Datagrain"], start_date: Optional[str] = None, @@ -113,40 +115,41 @@ def build_list_request( reservation_order_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/reservationSummaries') + _url = kwargs.pop("template_url", "/{resourceScope}/providers/Microsoft.Consumption/reservationSummaries") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['grain'] = _SERIALIZER.query("grain", grain, 'str') if start_date is not None: - query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') + _query_parameters['startDate'] = _SERIALIZER.query("start_date", start_date, 'str') if end_date is not None: - query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') + _query_parameters['endDate'] = _SERIALIZER.query("end_date", end_date, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') if reservation_id is not None: - query_parameters['reservationId'] = _SERIALIZER.query("reservation_id", reservation_id, 'str') + _query_parameters['reservationId'] = _SERIALIZER.query("reservation_id", reservation_id, 'str') if reservation_order_id is not None: - query_parameters['reservationOrderId'] = _SERIALIZER.query("reservation_order_id", reservation_order_id, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['reservationOrderId'] = _SERIALIZER.query("reservation_order_id", reservation_order_id, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -187,7 +190,7 @@ def list_by_reservation_order( :param grain: Can be daily or monthly. :type grain: str or ~azure.mgmt.consumption.models.Datagrain :param filter: Required only for daily grain. The properties/UsageDate for start date and end - date. The filter supports 'le' and 'ge'. + date. The filter supports 'le' and 'ge'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationSummariesListResult or the result of @@ -196,6 +199,8 @@ def list_by_reservation_order( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -206,6 +211,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_request( reservation_order_id=reservation_order_id, + api_version=api_version, grain=grain, filter=filter, template_url=self.list_by_reservation_order.metadata['url'], @@ -217,6 +223,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_request( reservation_order_id=reservation_order_id, + api_version=api_version, grain=grain, filter=filter, template_url=next_link, @@ -236,7 +243,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -250,7 +261,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_reservation_order.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + list_by_reservation_order.metadata = {'url': "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationSummaries"} # type: ignore @distributed_trace def list_by_reservation_order_and_reservation( @@ -270,7 +281,7 @@ def list_by_reservation_order_and_reservation( :param grain: Can be daily or monthly. :type grain: str or ~azure.mgmt.consumption.models.Datagrain :param filter: Required only for daily grain. The properties/UsageDate for start date and end - date. The filter supports 'le' and 'ge'. + date. The filter supports 'le' and 'ge'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationSummariesListResult or the result of @@ -279,6 +290,8 @@ def list_by_reservation_order_and_reservation( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -290,6 +303,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_and_reservation_request( reservation_order_id=reservation_order_id, reservation_id=reservation_id, + api_version=api_version, grain=grain, filter=filter, template_url=self.list_by_reservation_order_and_reservation.metadata['url'], @@ -302,6 +316,7 @@ def prepare_request(next_link=None): request = build_list_by_reservation_order_and_reservation_request( reservation_order_id=reservation_order_id, reservation_id=reservation_id, + api_version=api_version, grain=grain, filter=filter, template_url=next_link, @@ -321,7 +336,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,12 +354,12 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_reservation_order_and_reservation.metadata = {'url': '/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + list_by_reservation_order_and_reservation.metadata = {'url': "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationSummaries"} # type: ignore @distributed_trace def list( self, - scope: str, + resource_scope: str, grain: Union[str, "_models.Datagrain"], start_date: Optional[str] = None, end_date: Optional[str] = None, @@ -351,26 +370,29 @@ def list( ) -> Iterable["_models.ReservationSummariesListResult"]: """Lists the reservations summaries for the defined scope daily or monthly grain. - :param scope: The scope associated with reservations summaries operations. This includes - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount scope - (legacy), and + :param resource_scope: The scope associated with reservations summaries operations. This + includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for BillingAccount + scope (legacy), and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope (modern). - :type scope: str + :type resource_scope: str :param grain: Can be daily or monthly. :type grain: str or ~azure.mgmt.consumption.models.Datagrain - :param start_date: Start date. Only applicable when querying with billing profile. + :param start_date: Start date. Only applicable when querying with billing profile. Default + value is None. :type start_date: str - :param end_date: End date. Only applicable when querying with billing profile. + :param end_date: End date. Only applicable when querying with billing profile. Default value is + None. :type end_date: str :param filter: Required only for daily grain. The properties/UsageDate for start date and end date. The filter supports 'le' and 'ge'. Not applicable when querying with billing profile. + Default value is None. :type filter: str :param reservation_id: Reservation Id GUID. Only valid if reservationOrderId is also provided. - Filter to a specific reservation. + Filter to a specific reservation. Default value is None. :type reservation_id: str :param reservation_order_id: Reservation Order Id GUID. Required if reservationId is provided. - Filter to a specific reservation order. + Filter to a specific reservation order. Default value is None. :type reservation_order_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ReservationSummariesListResult or the result of @@ -379,6 +401,8 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.ReservationSummariesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationSummariesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -388,7 +412,8 @@ def prepare_request(next_link=None): if not next_link: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, grain=grain, start_date=start_date, end_date=end_date, @@ -403,7 +428,8 @@ def prepare_request(next_link=None): else: request = build_list_request( - scope=scope, + resource_scope=resource_scope, + api_version=api_version, grain=grain, start_date=start_date, end_date=end_date, @@ -427,7 +453,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -441,4 +471,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/reservationSummaries'} # type: ignore + list.metadata = {'url': "/{resourceScope}/providers/Microsoft.Consumption/reservationSummaries"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_tags_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_tags_operations.py index 7779aae4a563..1ef2cd6cb021 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_tags_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_tags_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -15,7 +16,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -29,29 +29,30 @@ def build_get_request( scope: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/tags') + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Consumption/tags") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -107,15 +108,22 @@ def get( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + request = build_get_request( scope=scope, + api_version=api_version, template_url=self.get.metadata['url'], ) request = _convert_request(request) request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -132,5 +140,5 @@ def get( return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/tags'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/tags"} # type: ignore diff --git a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_usage_details_operations.py b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_usage_details_operations.py index 90e128516fa6..1f78cdaac404 100644 --- a/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_usage_details_operations.py +++ b/sdk/consumption/azure-mgmt-consumption/azure/mgmt/consumption/operations/_usage_details_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -16,7 +17,6 @@ from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -36,39 +36,40 @@ def build_list_request( metric: Optional[Union[str, "_models.Metrictype"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-01" + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/{scope}/providers/Microsoft.Consumption/usageDetails') + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Consumption/usageDetails") path_format_arguments = { "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') if skiptoken is not None: - query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') if top is not None: - query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=1000, minimum=1) + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if metric is not None: - query_parameters['metric'] = _SERIALIZER.query("metric", metric, 'str') + _query_parameters['metric'] = _SERIALIZER.query("metric", metric, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_query_parameters, + headers=_header_parameters, **kwargs ) @@ -130,7 +131,7 @@ def list( :type scope: str :param expand: May be used to expand the properties/additionalInfo or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage - details. + details. Default value is None. :type expand: str :param filter: May be used to filter usageDetails by properties/resourceGroup, properties/resourceName, properties/resourceId, properties/chargeType, @@ -138,15 +139,17 @@ def list( 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). PublisherType Filter accepts two values azure and marketplace and it is currently supported for Web Direct Offer - Type. + Type. Default value is None. :type filter: str :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include - a skiptoken parameter that specifies a starting point to use for subsequent calls. + a skiptoken parameter that specifies a starting point to use for subsequent calls. Default + value is None. :type skiptoken: str :param top: May be used to limit the number of results to the most recent N usageDetails. + Default value is None. :type top: int - :param metric: Allows to select different type of cost/usage records. + :param metric: Allows to select different type of cost/usage records. Default value is None. :type metric: str or ~azure.mgmt.consumption.models.Metrictype :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageDetailsListResult or the result of @@ -154,6 +157,8 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.consumption.models.UsageDetailsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-10-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageDetailsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError @@ -164,6 +169,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, expand=expand, filter=filter, skiptoken=skiptoken, @@ -178,6 +184,7 @@ def prepare_request(next_link=None): request = build_list_request( scope=scope, + api_version=api_version, expand=expand, filter=filter, skiptoken=skiptoken, @@ -200,7 +207,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -214,4 +225,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Consumption/usageDetails'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Consumption/usageDetails"} # type: ignore