diff --git a/sdk/commerce/azure-mgmt-commerce/_meta.json b/sdk/commerce/azure-mgmt-commerce/_meta.json index c3c91e172763..9500a5bfa30a 100644 --- a/sdk/commerce/azure-mgmt-commerce/_meta.json +++ b/sdk/commerce/azure-mgmt-commerce/_meta.json @@ -1,11 +1,11 @@ { - "commit": "18e0a756cd948b08cec7d4264f2dbbbfa53246ac", + "commit": "7169b6e1f8a67633adfb1451441861fba16dcc4d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ "@autorest/python@6.4.0", "@autorest/modelerfour@4.24.3" ], - "autorest_command": "autorest specification/commerce/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/commerce/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/commerce/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_usage_management_client.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_usage_management_client.py index 0dced992e11d..d8b3eef27087 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_usage_management_client.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_usage_management_client.py @@ -39,6 +39,8 @@ class UsageManagementClient: # pylint: disable=client-accepts-api-version-keywo :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_version.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_version.py index c096871cfd88..e5754a47ce68 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_version.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "6.1.0b1" +VERSION = "1.0.0b1" diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_usage_management_client.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_usage_management_client.py index dd0b695d42f7..3e03bf20d6df 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_usage_management_client.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/_usage_management_client.py @@ -39,6 +39,8 @@ class UsageManagementClient: # pylint: disable=client-accepts-api-version-keywo :keyword api_version: Api Version. Default value is "2015-06-01-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_usage_aggregates_operations.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_usage_aggregates_operations.py index b0882237ebe0..4220fcf1c798 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_usage_aggregates_operations.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/aio/operations/_usage_aggregates_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -22,10 +22,13 @@ ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request @@ -58,8 +61,7 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( + async def _list_initial( self, reported_start_time: datetime.datetime, reported_end_time: datetime.datetime, @@ -67,7 +69,75 @@ def list( aggregation_granularity: Union[str, _models.AggregationGranularity] = "Daily", continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.UsageAggregation"]: + ) -> Union[_models.UsageAggregationListResult, _models.ErrorResponse]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2015-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Union[_models.UsageAggregationListResult, _models.ErrorResponse]] = kwargs.pop("cls", None) + + request = build_list_request( + subscription_id=self._config.subscription_id, + reported_start_time=reported_start_time, + reported_end_time=reported_end_time, + show_details=show_details, + aggregation_granularity=aggregation_granularity, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + template_url=self._list_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = 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]: + 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) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("UsageAggregationListResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("ErrorResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _list_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates"} + + @distributed_trace_async + async def begin_list( + self, + reported_start_time: datetime.datetime, + reported_end_time: datetime.datetime, + show_details: Optional[bool] = None, + aggregation_granularity: Union[str, _models.AggregationGranularity] = "Daily", + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[AsyncIterable["_models.UsageAggregation"]]: """Query aggregated Azure subscription consumption data for a date range. .. seealso:: @@ -94,10 +164,21 @@ def list( Default value is None. :type continuation_token_parameter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageAggregation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.commerce.models.UsageAggregation] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either + UsageAggregationListResult or An instance of LROPoller that returns an iterator like instance + of either ErrorResponse or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.commerce.models.UsageAggregation]] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -125,7 +206,7 @@ def prepare_request(next_link=None): aggregation_granularity=aggregation_granularity, continuation_token_parameter=continuation_token_parameter, api_version=api_version, - template_url=self.list.metadata["url"], + template_url=self.begin_list.metadata["url"], headers=_headers, params=_params, ) @@ -172,6 +253,47 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged(get_next, extract_data) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._list_initial( + reported_start_time=reported_start_time, + reported_end_time=reported_end_time, + show_details=show_details, + aggregation_granularity=aggregation_granularity, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + async def internal_get_next(next_link=None): + if next_link is None: + return pipeline_response + return await get_next(next_link) + + return AsyncItemPaged(internal_get_next, extract_data) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates"} + begin_list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates"} diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/__init__.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/__init__.py index 3d60a59c7fcd..98843673504c 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/__init__.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/__init__.py @@ -7,7 +7,6 @@ # -------------------------------------------------------------------------- from ._models_py3 import ErrorResponse -from ._models_py3 import InfoField from ._models_py3 import MeterInfo from ._models_py3 import MonetaryCommitment from ._models_py3 import MonetaryCredit @@ -26,7 +25,6 @@ __all__ = [ "ErrorResponse", - "InfoField", "MeterInfo", "MonetaryCommitment", "MonetaryCredit", diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py index 54c7af15002e..c8364224d65f 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/models/_models_py3.py @@ -43,26 +43,6 @@ def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, self.message = message -class InfoField(_serialization.Model): - """Key-value pairs of instance details in the legacy format. - - :ivar project: Identifies the name of the instance provisioned by the user. - :vartype project: str - """ - - _attribute_map = { - "project": {"key": "project", "type": "str"}, - } - - def __init__(self, *, project: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword project: Identifies the name of the instance provisioned by the user. - :paramtype project: str - """ - super().__init__(**kwargs) - self.project = project - - class MeterInfo(_serialization.Model): """Detailed information about the meter. @@ -485,7 +465,7 @@ class UsageAggregation(_serialization.Model): # pylint: disable=too-many-instan :ivar meter_region: Region of the meterId used for billing purposes. :vartype meter_region: str :ivar info_fields: Key-value pairs of instance details (legacy format). - :vartype info_fields: ~azure.mgmt.commerce.models.InfoField + :vartype info_fields: any :ivar instance_data: Key-value pairs of instance details represented as a string. :vartype instance_data: str """ @@ -504,7 +484,7 @@ class UsageAggregation(_serialization.Model): # pylint: disable=too-many-instan "meter_category": {"key": "properties.meterCategory", "type": "str"}, "meter_sub_category": {"key": "properties.meterSubCategory", "type": "str"}, "meter_region": {"key": "properties.meterRegion", "type": "str"}, - "info_fields": {"key": "properties.infoFields", "type": "InfoField"}, + "info_fields": {"key": "properties.infoFields", "type": "object"}, "instance_data": {"key": "properties.instanceData", "type": "str"}, } @@ -524,7 +504,7 @@ def __init__( meter_category: Optional[str] = None, meter_sub_category: Optional[str] = None, meter_region: Optional[str] = None, - info_fields: Optional["_models.InfoField"] = None, + info_fields: Optional[Any] = None, instance_data: Optional[str] = None, **kwargs: Any ) -> None: @@ -558,7 +538,7 @@ def __init__( :keyword meter_region: Region of the meterId used for billing purposes. :paramtype meter_region: str :keyword info_fields: Key-value pairs of instance details (legacy format). - :paramtype info_fields: ~azure.mgmt.commerce.models.InfoField + :paramtype info_fields: any :keyword instance_data: Key-value pairs of instance details represented as a string. :paramtype instance_data: str """ diff --git a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py index dc04b7fa9830..83d8098a8843 100644 --- a/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py +++ b/sdk/commerce/azure-mgmt-commerce/azure/mgmt/commerce/operations/_usage_aggregates_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast import urllib.parse from azure.core.exceptions import ( @@ -22,10 +22,12 @@ from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._serialization import Serializer @@ -106,8 +108,75 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _list_initial( + self, + reported_start_time: datetime.datetime, + reported_end_time: datetime.datetime, + show_details: Optional[bool] = None, + aggregation_granularity: Union[str, _models.AggregationGranularity] = "Daily", + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> Union[_models.UsageAggregationListResult, _models.ErrorResponse]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2015-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) + cls: ClsType[Union[_models.UsageAggregationListResult, _models.ErrorResponse]] = kwargs.pop("cls", None) + + request = build_list_request( + subscription_id=self._config.subscription_id, + reported_start_time=reported_start_time, + reported_end_time=reported_end_time, + show_details=show_details, + aggregation_granularity=aggregation_granularity, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + template_url=self._list_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = 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]: + 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) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("UsageAggregationListResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("ErrorResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _list_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates"} + @distributed_trace - def list( + def begin_list( self, reported_start_time: datetime.datetime, reported_end_time: datetime.datetime, @@ -115,7 +184,7 @@ def list( aggregation_granularity: Union[str, _models.AggregationGranularity] = "Daily", continuation_token_parameter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.UsageAggregation"]: + ) -> LROPoller[Iterable["_models.UsageAggregation"]]: """Query aggregated Azure subscription consumption data for a date range. .. seealso:: @@ -142,10 +211,21 @@ def list( Default value is None. :type continuation_token_parameter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageAggregation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.commerce.models.UsageAggregation] + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns an iterator like instance of either + UsageAggregationListResult or An instance of LROPoller that returns an iterator like instance + of either ErrorResponse or the result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.mgmt.commerce.models.UsageAggregation]] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -173,7 +253,7 @@ def prepare_request(next_link=None): aggregation_granularity=aggregation_granularity, continuation_token_parameter=continuation_token_parameter, api_version=api_version, - template_url=self.list.metadata["url"], + template_url=self.begin_list.metadata["url"], headers=_headers, params=_params, ) @@ -220,6 +300,47 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged(get_next, extract_data) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._list_initial( + reported_start_time=reported_start_time, + reported_end_time=reported_end_time, + show_details=show_details, + aggregation_granularity=aggregation_granularity, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + def internal_get_next(next_link=None): + if next_link is None: + return pipeline_response + return get_next(next_link) + + return ItemPaged(internal_get_next, extract_data) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates"} + begin_list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Commerce/UsageAggregates"} diff --git a/sdk/commerce/azure-mgmt-commerce/generated_samples/get_usage_aggregates_list.py b/sdk/commerce/azure-mgmt-commerce/generated_samples/get_usage_aggregates_list.py new file mode 100644 index 000000000000..eb0013fa93eb --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/generated_samples/get_usage_aggregates_list.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import isodate + +from azure.identity import DefaultAzureCredential +from azure.mgmt.commerce import UsageManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-commerce +# USAGE + python get_usage_aggregates_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = UsageManagementClient( + credential=DefaultAzureCredential(), + subscription_id="f68815e6-3c41-45ef-bbd8-5f83303c396b", + ) + + response = client.usage_aggregates.begin_list( + reported_start_time=isodate.parse_datetime("2014-05-01T00:00:00+00:00"), + reported_end_time=isodate.parse_datetime("2015-06-01T00:00:00+00:00"), + ).result() + for item in response: + print(item) + + +# x-ms-original-file: specification/commerce/resource-manager/Microsoft.Commerce/preview/2015-06-01-preview/examples/GetUsageAggregatesList.json +if __name__ == "__main__": + main()