diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py b/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py index 964559ade279..8a04c902f2ef 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py @@ -13,8 +13,16 @@ from msrest import Serializer, Deserializer from msrestazure import AzureConfiguration from .version import VERSION +from msrest.pipeline import ClientRawResponse +import uuid +from .operations.price_sheet_operations import PriceSheetOperations +from .operations.usage_details_operations import UsageDetailsOperations from .operations.forecasts_operations import ForecastsOperations from .operations.operations import Operations +from .operations.report_config_operations import ReportConfigOperations +from .operations.billing_account_dimensions_operations import BillingAccountDimensionsOperations +from .operations.subscription_dimensions_operations import SubscriptionDimensionsOperations +from .operations.resource_group_dimensions_operations import ResourceGroupDimensionsOperations from . import models @@ -56,10 +64,22 @@ class ConsumptionManagementClient(object): :ivar config: Configuration for client. :vartype config: ConsumptionManagementClientConfiguration + :ivar price_sheet: PriceSheet operations + :vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations + :ivar usage_details: UsageDetails operations + :vartype usage_details: azure.mgmt.consumption.operations.UsageDetailsOperations :ivar forecasts: Forecasts operations :vartype forecasts: azure.mgmt.consumption.operations.ForecastsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.consumption.operations.Operations + :ivar report_config: ReportConfig operations + :vartype report_config: azure.mgmt.consumption.operations.ReportConfigOperations + :ivar billing_account_dimensions: BillingAccountDimensions operations + :vartype billing_account_dimensions: azure.mgmt.consumption.operations.BillingAccountDimensionsOperations + :ivar subscription_dimensions: SubscriptionDimensions operations + :vartype subscription_dimensions: azure.mgmt.consumption.operations.SubscriptionDimensionsOperations + :ivar resource_group_dimensions: ResourceGroupDimensions operations + :vartype resource_group_dimensions: azure.mgmt.consumption.operations.ResourceGroupDimensionsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -80,7 +100,237 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) + self.price_sheet = PriceSheetOperations( + self._client, self.config, self._serialize, self._deserialize) + self.usage_details = UsageDetailsOperations( + self._client, self.config, self._serialize, self._deserialize) self.forecasts = ForecastsOperations( self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( self._client, self.config, self._serialize, self._deserialize) + self.report_config = ReportConfigOperations( + self._client, self.config, self._serialize, self._deserialize) + self.billing_account_dimensions = BillingAccountDimensionsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.subscription_dimensions = SubscriptionDimensionsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.resource_group_dimensions = ResourceGroupDimensionsOperations( + self._client, self.config, self._serialize, self._deserialize) + + def analyze_subscription_usage( + self, parameters, custom_headers=None, raw=False, **operation_config): + """Lists the usage data for subscriptionId. + + :param parameters: Parameters supplied to the CreateOrUpdate Report + Config operation. + :type parameters: + ~azure.mgmt.consumption.models.ReportConfigDefinition + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageAnalysis + :rtype: + ~azure.mgmt.consumption.models.UsageAnalysisPaged[~azure.mgmt.consumption.models.UsageAnalysis] + :raises: + :class:`ErrorResponseException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.analyze_subscription_usage.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'ReportConfigDefinition') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + analyze_subscription_usage.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/AnalyzeUsage'} + + def analyze_resource_group_usage( + self, resource_group_name, parameters, custom_headers=None, raw=False, **operation_config): + """Lists the usage data for subscriptionId and resource group. + + :param resource_group_name: Azure Resource Group Name. + :type resource_group_name: str + :param parameters: Parameters supplied to the CreateOrUpdate Report + Config operation. + :type parameters: + ~azure.mgmt.consumption.models.ReportConfigDefinition + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageAnalysis + :rtype: + ~azure.mgmt.consumption.models.UsageAnalysisPaged[~azure.mgmt.consumption.models.UsageAnalysis] + :raises: + :class:`ErrorResponseException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.analyze_resource_group_usage.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'ReportConfigDefinition') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + analyze_resource_group_usage.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Consumption/AnalyzeUsage'} + + def analyze_billing_account_usage( + self, billing_account_id, parameters, custom_headers=None, raw=False, **operation_config): + """Lists the usage data for billing account. + + :param billing_account_id: BillingAccount ID + :type billing_account_id: str + :param parameters: Parameters supplied to the CreateOrUpdate Report + Config operation. + :type parameters: + ~azure.mgmt.consumption.models.ReportConfigDefinition + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageAnalysis + :rtype: + ~azure.mgmt.consumption.models.UsageAnalysisPaged[~azure.mgmt.consumption.models.UsageAnalysis] + :raises: + :class:`ErrorResponseException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.analyze_billing_account_usage.metadata['url'] + path_format_arguments = { + 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'ReportConfigDefinition') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageAnalysisPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + analyze_billing_account_usage.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/AnalyzeUsage'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py index 0517b5a47712..13db64df7612 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py @@ -14,14 +14,45 @@ from .operation_display import OperationDisplay from .operation import Operation from .resource import Resource +from .meter_details import MeterDetails +from .price_sheet_properties import PriceSheetProperties +from .price_sheet_result import PriceSheetResult from .forecast_properties_confidence_levels_item import ForecastPropertiesConfidenceLevelsItem from .forecast import Forecast +from .usage_detail import UsageDetail +from .report_config_recurrence_period import ReportConfigRecurrencePeriod +from .report_config_schedule import ReportConfigSchedule +from .report_config_delivery_destination import ReportConfigDeliveryDestination +from .report_config_delivery_info import ReportConfigDeliveryInfo +from .report_config_time_period import ReportConfigTimePeriod +from .report_config_dataset_configuration import ReportConfigDatasetConfiguration +from .report_config_aggregation import ReportConfigAggregation +from .report_config_grouping import ReportConfigGrouping +from .report_config_comparison_expression import ReportConfigComparisonExpression +from .report_config_filter import ReportConfigFilter +from .report_config_dataset import ReportConfigDataset +from .report_config_definition import ReportConfigDefinition +from .report_config import ReportConfig +from .report_config_list_result import ReportConfigListResult +from .dimension import Dimension +from .usage_analysis_column import UsageAnalysisColumn +from .usage_analysis import UsageAnalysis +from .query_options import QueryOptions +from .usage_detail_paged import UsageDetailPaged from .forecast_paged import ForecastPaged from .operation_paged import OperationPaged +from .dimension_paged import DimensionPaged +from .usage_analysis_paged import UsageAnalysisPaged from .consumption_management_client_enums import ( Grain, ChargeType, Bound, + StatusType, + RecurrenceType, + FormatType, + TimeframeType, + GranularityType, + ReportConfigColumnType, ) __all__ = [ @@ -30,11 +61,42 @@ 'OperationDisplay', 'Operation', 'Resource', + 'MeterDetails', + 'PriceSheetProperties', + 'PriceSheetResult', 'ForecastPropertiesConfidenceLevelsItem', 'Forecast', + 'UsageDetail', + 'ReportConfigRecurrencePeriod', + 'ReportConfigSchedule', + 'ReportConfigDeliveryDestination', + 'ReportConfigDeliveryInfo', + 'ReportConfigTimePeriod', + 'ReportConfigDatasetConfiguration', + 'ReportConfigAggregation', + 'ReportConfigGrouping', + 'ReportConfigComparisonExpression', + 'ReportConfigFilter', + 'ReportConfigDataset', + 'ReportConfigDefinition', + 'ReportConfig', + 'ReportConfigListResult', + 'Dimension', + 'UsageAnalysisColumn', + 'UsageAnalysis', + 'QueryOptions', + 'UsageDetailPaged', 'ForecastPaged', 'OperationPaged', + 'DimensionPaged', + 'UsageAnalysisPaged', 'Grain', 'ChargeType', 'Bound', + 'StatusType', + 'RecurrenceType', + 'FormatType', + 'TimeframeType', + 'GranularityType', + 'ReportConfigColumnType', ] diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/consumption_management_client_enums.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/consumption_management_client_enums.py index 6e062c9adf02..a4942d7b0117 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/consumption_management_client_enums.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/consumption_management_client_enums.py @@ -29,3 +29,41 @@ class Bound(Enum): upper = "Upper" lower = "Lower" + + +class StatusType(Enum): + + active = "Active" + inactive = "Inactive" + + +class RecurrenceType(Enum): + + daily = "Daily" + weekly = "Weekly" + monthly = "Monthly" + annually = "Annually" + + +class FormatType(Enum): + + csv = "Csv" + + +class TimeframeType(Enum): + + week_to_date = "WeekToDate" + month_to_date = "MonthToDate" + year_to_date = "YearToDate" + custom = "Custom" + + +class GranularityType(Enum): + + daily = "Daily" + + +class ReportConfigColumnType(Enum): + + tag = "Tag" + dimension = "Dimension" diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/dimension.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/dimension.py new file mode 100644 index 000000000000..5eecf20913ef --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/dimension.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class Dimension(Resource): + """Dimension. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :param data: + :type data: list[str] + :param total: + :type total: int + :param category: + :type category: str + :param usage_start: + :type usage_start: datetime + :param usage_end: + :type usage_end: datetime + :param next_link: + :type next_link: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'data': {'key': 'properties.data', 'type': '[str]'}, + 'total': {'key': 'properties.total', 'type': 'int'}, + 'category': {'key': 'properties.category', 'type': 'str'}, + 'usage_start': {'key': 'properties.usageStart', 'type': 'iso-8601'}, + 'usage_end': {'key': 'properties.usageEnd', 'type': 'iso-8601'}, + 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + } + + def __init__(self, data=None, total=None, category=None, usage_start=None, usage_end=None, next_link=None): + super(Dimension, self).__init__() + self.data = data + self.total = total + self.category = category + self.usage_start = usage_start + self.usage_end = usage_end + self.next_link = next_link diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/dimension_paged.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/dimension_paged.py new file mode 100644 index 000000000000..ec7fba922493 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/dimension_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class DimensionPaged(Paged): + """ + A paging container for iterating over a list of :class:`Dimension ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Dimension]'} + } + + def __init__(self, *args, **kwargs): + + super(DimensionPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/meter_details.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/meter_details.py new file mode 100644 index 000000000000..c6806291332d --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/meter_details.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class MeterDetails(Model): + """The properties of the meter detail. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar meter_name: The name of the meter, within the given meter category + :vartype meter_name: str + :ivar meter_category: The category of the meter, for example, 'Cloud + services', 'Networking', etc.. + :vartype meter_category: str + :ivar meter_sub_category: The subcategory of the meter, for example, 'A6 + Cloud services', 'ExpressRoute (IXP)', etc.. + :vartype meter_sub_category: str + :ivar unit: The unit in which the meter consumption is charged, for + example, 'Hours', 'GB', etc. + :vartype unit: str + :ivar meter_location: The location in which the Azure service is + available. + :vartype meter_location: str + :ivar total_included_quantity: The total included quantity associated with + the offer. + :vartype total_included_quantity: decimal.Decimal + :ivar pretax_standard_rate: The pretax listing price. + :vartype pretax_standard_rate: decimal.Decimal + """ + + _validation = { + 'meter_name': {'readonly': True}, + 'meter_category': {'readonly': True}, + 'meter_sub_category': {'readonly': True}, + 'unit': {'readonly': True}, + 'meter_location': {'readonly': True}, + 'total_included_quantity': {'readonly': True}, + 'pretax_standard_rate': {'readonly': True}, + } + + _attribute_map = { + 'meter_name': {'key': 'meterName', 'type': 'str'}, + 'meter_category': {'key': 'meterCategory', 'type': 'str'}, + 'meter_sub_category': {'key': 'meterSubCategory', 'type': 'str'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'meter_location': {'key': 'meterLocation', 'type': 'str'}, + 'total_included_quantity': {'key': 'totalIncludedQuantity', 'type': 'decimal'}, + 'pretax_standard_rate': {'key': 'pretaxStandardRate', 'type': 'decimal'}, + } + + def __init__(self): + super(MeterDetails, self).__init__() + self.meter_name = None + self.meter_category = None + self.meter_sub_category = None + self.unit = None + self.meter_location = None + self.total_included_quantity = None + self.pretax_standard_rate = None diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/price_sheet_properties.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/price_sheet_properties.py new file mode 100644 index 000000000000..2f7013ad404d --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/price_sheet_properties.py @@ -0,0 +1,77 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PriceSheetProperties(Model): + """The properties of the price sheet. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar billing_period_id: The id of the billing period resource that the + usage belongs to. + :vartype billing_period_id: str + :ivar meter_id: The meter id (GUID) + :vartype meter_id: str + :ivar meter_details: The details about the meter. By default this is not + populated, unless it's specified in $expand. + :vartype meter_details: ~azure.mgmt.consumption.models.MeterDetails + :ivar unit_of_measure: Unit of measure + :vartype unit_of_measure: str + :ivar included_quantity: Included quality for an offer + :vartype included_quantity: decimal.Decimal + :ivar part_number: Part Number + :vartype part_number: str + :ivar unit_price: Unit Price + :vartype unit_price: decimal.Decimal + :ivar currency_code: Currency Code + :vartype currency_code: str + :ivar offer_id: Offer Id + :vartype offer_id: str + """ + + _validation = { + 'billing_period_id': {'readonly': True}, + 'meter_id': {'readonly': True}, + 'meter_details': {'readonly': True}, + 'unit_of_measure': {'readonly': True}, + 'included_quantity': {'readonly': True}, + 'part_number': {'readonly': True}, + 'unit_price': {'readonly': True}, + 'currency_code': {'readonly': True}, + 'offer_id': {'readonly': True}, + } + + _attribute_map = { + 'billing_period_id': {'key': 'billingPeriodId', 'type': 'str'}, + 'meter_id': {'key': 'meterId', 'type': 'str'}, + 'meter_details': {'key': 'meterDetails', 'type': 'MeterDetails'}, + 'unit_of_measure': {'key': 'unitOfMeasure', 'type': 'str'}, + 'included_quantity': {'key': 'includedQuantity', 'type': 'decimal'}, + 'part_number': {'key': 'partNumber', 'type': 'str'}, + 'unit_price': {'key': 'unitPrice', 'type': 'decimal'}, + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'offer_id': {'key': 'offerId', 'type': 'str'}, + } + + def __init__(self): + super(PriceSheetProperties, self).__init__() + self.billing_period_id = None + self.meter_id = None + self.meter_details = None + self.unit_of_measure = None + self.included_quantity = None + self.part_number = None + self.unit_price = None + self.currency_code = None + self.offer_id = None diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/price_sheet_result.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/price_sheet_result.py new file mode 100644 index 000000000000..2cdc8b8f8ed7 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/price_sheet_result.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class PriceSheetResult(Resource): + """An pricesheet resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar pricesheets: Price sheet + :vartype pricesheets: + list[~azure.mgmt.consumption.models.PriceSheetProperties] + :ivar next_link: The link (url) to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'readonly': True}, + 'pricesheets': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'pricesheets': {'key': 'properties.pricesheets', 'type': '[PriceSheetProperties]'}, + 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + } + + def __init__(self): + super(PriceSheetResult, self).__init__() + self.pricesheets = None + self.next_link = None diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/query_options.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/query_options.py new file mode 100644 index 000000000000..a61093e680bb --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/query_options.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class QueryOptions(Model): + """Additional parameters for a set of operations. + + :param apply: OData apply expression to aggregate usageDetails by tags or + (tags and properties/usageStart) + :type apply: str + """ + + def __init__(self, apply=None): + super(QueryOptions, self).__init__() + self.apply = apply diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config.py new file mode 100644 index 000000000000..d6de1c48d9ec --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class ReportConfig(Resource): + """A report config resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :param schedule: Has schedule information for the report config. + :type schedule: ~azure.mgmt.consumption.models.ReportConfigSchedule + :param format: The format of the report being delivered. Possible values + include: 'Csv' + :type format: str or ~azure.mgmt.consumption.models.FormatType + :param delivery_info: Has delivery information for the report config. + :type delivery_info: + ~azure.mgmt.consumption.models.ReportConfigDeliveryInfo + :param definition: Has definition for the report config. + :type definition: ~azure.mgmt.consumption.models.ReportConfigDefinition + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'readonly': True}, + 'delivery_info': {'required': True}, + 'definition': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'schedule': {'key': 'properties.schedule', 'type': 'ReportConfigSchedule'}, + 'format': {'key': 'properties.format', 'type': 'str'}, + 'delivery_info': {'key': 'properties.deliveryInfo', 'type': 'ReportConfigDeliveryInfo'}, + 'definition': {'key': 'properties.definition', 'type': 'ReportConfigDefinition'}, + } + + def __init__(self, delivery_info, definition, schedule=None, format=None): + super(ReportConfig, self).__init__() + self.schedule = schedule + self.format = format + self.delivery_info = delivery_info + self.definition = definition diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_aggregation.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_aggregation.py new file mode 100644 index 000000000000..7debf4cae669 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_aggregation.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigAggregation(Model): + """The aggregation expression to be used in the report. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param name: The name of the column to aggregate. + :type name: str + :ivar function: The name of the aggregation function to use. Default + value: "Sum" . + :vartype function: str + """ + + _validation = { + 'name': {'required': True}, + 'function': {'required': True, 'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'function': {'key': 'function', 'type': 'str'}, + } + + function = "Sum" + + def __init__(self, name): + super(ReportConfigAggregation, self).__init__() + self.name = name diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_comparison_expression.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_comparison_expression.py new file mode 100644 index 000000000000..48c56a8b2ef9 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_comparison_expression.py @@ -0,0 +1,46 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigComparisonExpression(Model): + """The comparison expression to be used in the report. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :param name: The name of the column to use in comaprison. + :type name: str + :ivar operator: The operator to use for comparison. Default value: "In" . + :vartype operator: str + :param values: Array of values to use for comparison + :type values: list[str] + """ + + _validation = { + 'name': {'required': True}, + 'operator': {'required': True, 'constant': True}, + 'values': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'operator': {'key': 'operator', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + } + + operator = "In" + + def __init__(self, name, values): + super(ReportConfigComparisonExpression, self).__init__() + self.name = name + self.values = values diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_dataset.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_dataset.py new file mode 100644 index 000000000000..ee34f641f753 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_dataset.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigDataset(Model): + """The definition of data present in the report. + + :param granularity: The granularity of rows in the report. Possible values + include: 'Daily' + :type granularity: str or ~azure.mgmt.consumption.models.GranularityType + :param configuration: Has configuration information for the data in the + report. The configuration will be ignored if aggregation and grouping are + provided. + :type configuration: + ~azure.mgmt.consumption.models.ReportConfigDatasetConfiguration + :param aggregation: Dictionary of aggregation expression to use in the + report. The key of each item in the dictionary is the alias for the + aggregated column. Report can have upto 2 aggregation clauses. + :type aggregation: dict[str, + ~azure.mgmt.consumption.models.ReportConfigAggregation] + :param grouping: Array of group by expression to use in the report. Report + can have upto 2 group by clauses. + :type grouping: list[~azure.mgmt.consumption.models.ReportConfigGrouping] + :param filter: Has filter expression to use in the report. + :type filter: ~azure.mgmt.consumption.models.ReportConfigFilter + """ + + _validation = { + 'grouping': {'max_items': 2}, + } + + _attribute_map = { + 'granularity': {'key': 'granularity', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'ReportConfigDatasetConfiguration'}, + 'aggregation': {'key': 'aggregation', 'type': '{ReportConfigAggregation}'}, + 'grouping': {'key': 'grouping', 'type': '[ReportConfigGrouping]'}, + 'filter': {'key': 'filter', 'type': 'ReportConfigFilter'}, + } + + def __init__(self, granularity=None, configuration=None, aggregation=None, grouping=None, filter=None): + super(ReportConfigDataset, self).__init__() + self.granularity = granularity + self.configuration = configuration + self.aggregation = aggregation + self.grouping = grouping + self.filter = filter diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_dataset_configuration.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_dataset_configuration.py new file mode 100644 index 000000000000..6c17fe70fbc5 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_dataset_configuration.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigDatasetConfiguration(Model): + """The configuration of dataset in the report. + + :param columns: Array of column names to be included in the report. Any + valid report column name is allowed. If not provided, then report includes + all columns. + :type columns: list[str] + """ + + _attribute_map = { + 'columns': {'key': 'columns', 'type': '[str]'}, + } + + def __init__(self, columns=None): + super(ReportConfigDatasetConfiguration, self).__init__() + self.columns = columns diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_definition.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_definition.py new file mode 100644 index 000000000000..e31d628af408 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_definition.py @@ -0,0 +1,51 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigDefinition(Model): + """The definition of a report config. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar type: The type of the report. Default value: "Usage" . + :vartype type: str + :param timeframe: The time frame for pulling data for the report. If + custom, then a specific time period must be provided. Possible values + include: 'WeekToDate', 'MonthToDate', 'YearToDate', 'Custom' + :type timeframe: str or ~azure.mgmt.consumption.models.TimeframeType + :param time_period: Has time period for pulling data for the report. + :type time_period: ~azure.mgmt.consumption.models.ReportConfigTimePeriod + :param dataset: Has definition for data in this report config. + :type dataset: ~azure.mgmt.consumption.models.ReportConfigDataset + """ + + _validation = { + 'type': {'required': True, 'constant': True}, + 'timeframe': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'timeframe': {'key': 'timeframe', 'type': 'str'}, + 'time_period': {'key': 'timePeriod', 'type': 'ReportConfigTimePeriod'}, + 'dataset': {'key': 'dataset', 'type': 'ReportConfigDataset'}, + } + + type = "Usage" + + def __init__(self, timeframe, time_period=None, dataset=None): + super(ReportConfigDefinition, self).__init__() + self.timeframe = timeframe + self.time_period = time_period + self.dataset = dataset diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_delivery_destination.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_delivery_destination.py new file mode 100644 index 000000000000..ed86b4a6a1ee --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_delivery_destination.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. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigDeliveryDestination(Model): + """The destination information for the delivery of the report. + + :param resource_id: The resource id of the storage account where reports + will be delivered. + :type resource_id: str + :param container: The name of the container where reports will be + uploaded. + :type container: str + :param root_folder_path: The name of the directory where reports will be + uploaded. + :type root_folder_path: str + """ + + _validation = { + 'resource_id': {'required': True}, + 'container': {'required': True}, + } + + _attribute_map = { + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'container': {'key': 'container', 'type': 'str'}, + 'root_folder_path': {'key': 'rootFolderPath', 'type': 'str'}, + } + + def __init__(self, resource_id, container, root_folder_path=None): + super(ReportConfigDeliveryDestination, self).__init__() + self.resource_id = resource_id + self.container = container + self.root_folder_path = root_folder_path diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_delivery_info.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_delivery_info.py new file mode 100644 index 000000000000..4c2fb15809b8 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_delivery_info.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigDeliveryInfo(Model): + """The delivery information associated with a report config. + + :param destination: Has destination for the report being delivered. + :type destination: + ~azure.mgmt.consumption.models.ReportConfigDeliveryDestination + """ + + _validation = { + 'destination': {'required': True}, + } + + _attribute_map = { + 'destination': {'key': 'destination', 'type': 'ReportConfigDeliveryDestination'}, + } + + def __init__(self, destination): + super(ReportConfigDeliveryInfo, self).__init__() + self.destination = destination diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_filter.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_filter.py new file mode 100644 index 000000000000..0c6f19dbec89 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_filter.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigFilter(Model): + """The filter expression to be used in the report. + + :param and_property: The logical "AND" expression. Must have atleast 2 + items. + :type and_property: + list[~azure.mgmt.consumption.models.ReportConfigFilter] + :param or_property: The logical "OR" expression. Must have atleast 2 + items. + :type or_property: list[~azure.mgmt.consumption.models.ReportConfigFilter] + :param not_property: The logical "NOT" expression. + :type not_property: ~azure.mgmt.consumption.models.ReportConfigFilter + :param dimension: Has comparison expression for a dimension + :type dimension: + ~azure.mgmt.consumption.models.ReportConfigComparisonExpression + :param tag: Has comparison expression for a tag + :type tag: ~azure.mgmt.consumption.models.ReportConfigComparisonExpression + """ + + _validation = { + 'and_property': {'min_items': 2}, + 'or_property': {'min_items': 2}, + } + + _attribute_map = { + 'and_property': {'key': 'and', 'type': '[ReportConfigFilter]'}, + 'or_property': {'key': 'or', 'type': '[ReportConfigFilter]'}, + 'not_property': {'key': 'not', 'type': 'ReportConfigFilter'}, + 'dimension': {'key': 'dimension', 'type': 'ReportConfigComparisonExpression'}, + 'tag': {'key': 'tag', 'type': 'ReportConfigComparisonExpression'}, + } + + def __init__(self, and_property=None, or_property=None, not_property=None, dimension=None, tag=None): + super(ReportConfigFilter, self).__init__() + self.and_property = and_property + self.or_property = or_property + self.not_property = not_property + self.dimension = dimension + self.tag = tag diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_grouping.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_grouping.py new file mode 100644 index 000000000000..dd1304ba969f --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_grouping.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigGrouping(Model): + """The group by expression to be used in the report. + + :param column_type: Has type of the column to group. Possible values + include: 'Tag', 'Dimension' + :type column_type: str or + ~azure.mgmt.consumption.models.ReportConfigColumnType + :param name: The name of the column to group. + :type name: str + """ + + _validation = { + 'column_type': {'required': True}, + 'name': {'required': True}, + } + + _attribute_map = { + 'column_type': {'key': 'columnType', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, column_type, name): + super(ReportConfigGrouping, self).__init__() + self.column_type = column_type + self.name = name diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_list_result.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_list_result.py new file mode 100644 index 000000000000..0429bca41135 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_list_result.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigListResult(Model): + """Result of listing report configs. It contains a list of available report + configurations in the scope provided. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar value: The list of report configs. + :vartype value: list[~azure.mgmt.consumption.models.ReportConfig] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ReportConfig]'}, + } + + def __init__(self): + super(ReportConfigListResult, self).__init__() + self.value = None diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_recurrence_period.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_recurrence_period.py new file mode 100644 index 000000000000..8d84293cbbb7 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_recurrence_period.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigRecurrencePeriod(Model): + """The start and end date for recurrence schedule. + + :param from_property: The start date of recurrence. + :type from_property: datetime + :param to: The end date of recurrence. If not provided, we default this to + 10 years from the start date. + :type to: datetime + """ + + _validation = { + 'from_property': {'required': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, from_property, to=None): + super(ReportConfigRecurrencePeriod, self).__init__() + self.from_property = from_property + self.to = to diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_schedule.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_schedule.py new file mode 100644 index 000000000000..98a9196c1512 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_schedule.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigSchedule(Model): + """The schedule associated with a report config. + + :param status: The status of the schedule. Whether active or not. If + inactive, the report's scheduled execution is paused. Possible values + include: 'Active', 'Inactive' + :type status: str or ~azure.mgmt.consumption.models.StatusType + :param recurrence: The schedule recurrence. Possible values include: + 'Daily', 'Weekly', 'Monthly', 'Annually' + :type recurrence: str or ~azure.mgmt.consumption.models.RecurrenceType + :param recurrence_period: Has start and end date of the recurrence. The + start date must be in future. If present, the end date must be greater + than start date. + :type recurrence_period: + ~azure.mgmt.consumption.models.ReportConfigRecurrencePeriod + """ + + _validation = { + 'recurrence': {'required': True}, + 'recurrence_period': {'required': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'recurrence': {'key': 'recurrence', 'type': 'str'}, + 'recurrence_period': {'key': 'recurrencePeriod', 'type': 'ReportConfigRecurrencePeriod'}, + } + + def __init__(self, recurrence, recurrence_period, status=None): + super(ReportConfigSchedule, self).__init__() + self.status = status + self.recurrence = recurrence + self.recurrence_period = recurrence_period diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_time_period.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_time_period.py new file mode 100644 index 000000000000..d2291e922323 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/report_config_time_period.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ReportConfigTimePeriod(Model): + """The start and end date for pulling data for the report. + + :param from_property: The start date to pull data from. + :type from_property: datetime + :param to: The end date to pull data to. + :type to: datetime + """ + + _validation = { + 'from_property': {'required': True}, + 'to': {'required': True}, + } + + _attribute_map = { + 'from_property': {'key': 'from', 'type': 'iso-8601'}, + 'to': {'key': 'to', 'type': 'iso-8601'}, + } + + def __init__(self, from_property, to): + super(ReportConfigTimePeriod, self).__init__() + self.from_property = from_property + self.to = to diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis.py new file mode 100644 index 000000000000..9400a55b9d01 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class UsageAnalysis(Resource): + """UsageAnalysis. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :param next_link: + :type next_link: str + :param columns: Array of columns + :type columns: list[~azure.mgmt.consumption.models.UsageAnalysisColumn] + :param rows: + :type rows: list[list[object]] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, + 'columns': {'key': 'properties.columns', 'type': '[UsageAnalysisColumn]'}, + 'rows': {'key': 'properties.rows', 'type': '[[object]]'}, + } + + def __init__(self, next_link=None, columns=None, rows=None): + super(UsageAnalysis, self).__init__() + self.next_link = next_link + self.columns = columns + self.rows = rows diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis_column.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis_column.py new file mode 100644 index 000000000000..f56886d66c73 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis_column.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class UsageAnalysisColumn(Model): + """UsageAnalysisColumn. + + :param name: + :type name: str + :param type: + :type type: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, name=None, type=None): + super(UsageAnalysisColumn, self).__init__() + self.name = name + self.type = type diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis_paged.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis_paged.py new file mode 100644 index 000000000000..194f3027fcd7 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_analysis_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class UsageAnalysisPaged(Paged): + """ + A paging container for iterating over a list of :class:`UsageAnalysis ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[UsageAnalysis]'} + } + + def __init__(self, *args, **kwargs): + + super(UsageAnalysisPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_detail.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_detail.py new file mode 100644 index 000000000000..70b9ada119b1 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_detail.py @@ -0,0 +1,187 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class UsageDetail(Resource): + """An usage detail resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar billing_period_id: The id of the billing period resource that the + usage belongs to. + :vartype billing_period_id: str + :ivar invoice_id: The id of the invoice resource that the usage belongs + to. + :vartype invoice_id: str + :ivar usage_start: The start of the date time range covered by the usage + detail. + :vartype usage_start: datetime + :ivar usage_end: The end of the date time range covered by the usage + detail. + :vartype usage_end: datetime + :ivar instance_name: The name of the resource instance that the usage is + about. + :vartype instance_name: str + :ivar instance_id: The uri of the resource instance that the usage is + about. + :vartype instance_id: str + :ivar instance_location: The location of the resource instance that the + usage is about. + :vartype instance_location: str + :ivar currency: The ISO currency in which the meter is charged, for + example, USD. + :vartype currency: str + :ivar usage_quantity: The quantity of usage. + :vartype usage_quantity: decimal.Decimal + :ivar billable_quantity: The billable usage quantity. + :vartype billable_quantity: decimal.Decimal + :ivar pretax_cost: The amount of cost before tax. + :vartype pretax_cost: decimal.Decimal + :ivar is_estimated: The estimated usage is subject to change. + :vartype is_estimated: bool + :ivar meter_id: The meter id (GUID). + :vartype meter_id: str + :ivar meter_details: The details about the meter. By default this is not + populated, unless it's specified in $expand. + :vartype meter_details: ~azure.mgmt.consumption.models.MeterDetails + :ivar subscription_guid: Subscription guid. + :vartype subscription_guid: str + :ivar subscription_name: Subscription name. + :vartype subscription_name: str + :ivar account_name: Account name. + :vartype account_name: str + :ivar department_name: Department name. + :vartype department_name: str + :ivar product: Product name. + :vartype product: str + :ivar consumed_service: Consumed service name. + :vartype consumed_service: str + :ivar cost_center: The cost center of this department if it is a + department and a costcenter exists + :vartype cost_center: str + :ivar part_number: Part Number + :vartype part_number: str + :ivar resource_guid: Resource Guid + :vartype resource_guid: str + :ivar offer_id: Offer Id + :vartype offer_id: str + :ivar charges_billed_separately: Charges billed separately + :vartype charges_billed_separately: bool + :ivar additional_properties: Additional details of this usage item. By + default this is not populated, unless it's specified in $expand. + :vartype additional_properties: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'readonly': True}, + 'billing_period_id': {'readonly': True}, + 'invoice_id': {'readonly': True}, + 'usage_start': {'readonly': True}, + 'usage_end': {'readonly': True}, + 'instance_name': {'readonly': True}, + 'instance_id': {'readonly': True}, + 'instance_location': {'readonly': True}, + 'currency': {'readonly': True}, + 'usage_quantity': {'readonly': True}, + 'billable_quantity': {'readonly': True}, + 'pretax_cost': {'readonly': True}, + 'is_estimated': {'readonly': True}, + 'meter_id': {'readonly': True}, + 'meter_details': {'readonly': True}, + 'subscription_guid': {'readonly': True}, + 'subscription_name': {'readonly': True}, + 'account_name': {'readonly': True}, + 'department_name': {'readonly': True}, + 'product': {'readonly': True}, + 'consumed_service': {'readonly': True}, + 'cost_center': {'readonly': True}, + 'part_number': {'readonly': True}, + 'resource_guid': {'readonly': True}, + 'offer_id': {'readonly': True}, + 'charges_billed_separately': {'readonly': True}, + 'additional_properties': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'billing_period_id': {'key': 'properties.billingPeriodId', 'type': 'str'}, + 'invoice_id': {'key': 'properties.invoiceId', 'type': 'str'}, + 'usage_start': {'key': 'properties.usageStart', 'type': 'iso-8601'}, + 'usage_end': {'key': 'properties.usageEnd', 'type': 'iso-8601'}, + 'instance_name': {'key': 'properties.instanceName', 'type': 'str'}, + 'instance_id': {'key': 'properties.instanceId', 'type': 'str'}, + 'instance_location': {'key': 'properties.instanceLocation', 'type': 'str'}, + 'currency': {'key': 'properties.currency', 'type': 'str'}, + 'usage_quantity': {'key': 'properties.usageQuantity', 'type': 'decimal'}, + 'billable_quantity': {'key': 'properties.billableQuantity', 'type': 'decimal'}, + 'pretax_cost': {'key': 'properties.pretaxCost', 'type': 'decimal'}, + 'is_estimated': {'key': 'properties.isEstimated', 'type': 'bool'}, + 'meter_id': {'key': 'properties.meterId', 'type': 'str'}, + 'meter_details': {'key': 'properties.meterDetails', 'type': 'MeterDetails'}, + 'subscription_guid': {'key': 'properties.subscriptionGuid', 'type': 'str'}, + 'subscription_name': {'key': 'properties.subscriptionName', 'type': 'str'}, + 'account_name': {'key': 'properties.accountName', 'type': 'str'}, + 'department_name': {'key': 'properties.departmentName', 'type': 'str'}, + 'product': {'key': 'properties.product', 'type': 'str'}, + 'consumed_service': {'key': 'properties.consumedService', 'type': 'str'}, + 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, + 'part_number': {'key': 'properties.partNumber', 'type': 'str'}, + 'resource_guid': {'key': 'properties.resourceGuid', 'type': 'str'}, + 'offer_id': {'key': 'properties.offerId', 'type': 'str'}, + 'charges_billed_separately': {'key': 'properties.chargesBilledSeparately', 'type': 'bool'}, + 'additional_properties': {'key': 'properties.additionalProperties', 'type': 'str'}, + } + + def __init__(self): + super(UsageDetail, self).__init__() + self.billing_period_id = None + self.invoice_id = None + self.usage_start = None + self.usage_end = None + self.instance_name = None + self.instance_id = None + self.instance_location = None + self.currency = None + self.usage_quantity = None + self.billable_quantity = None + self.pretax_cost = None + self.is_estimated = None + self.meter_id = None + self.meter_details = None + self.subscription_guid = None + self.subscription_name = None + self.account_name = None + self.department_name = None + self.product = None + self.consumed_service = None + self.cost_center = None + self.part_number = None + self.resource_guid = None + self.offer_id = None + self.charges_billed_separately = None + self.additional_properties = None diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_detail_paged.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_detail_paged.py new file mode 100644 index 000000000000..ae15d28a276e --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/usage_detail_paged.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class UsageDetailPaged(Paged): + """ + A paging container for iterating over a list of :class:`UsageDetail ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[UsageDetail]'} + } + + def __init__(self, *args, **kwargs): + + super(UsageDetailPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py index 9afe5b7e60d3..45a433eb2980 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py @@ -9,10 +9,22 @@ # regenerated. # -------------------------------------------------------------------------- +from .price_sheet_operations import PriceSheetOperations +from .usage_details_operations import UsageDetailsOperations from .forecasts_operations import ForecastsOperations from .operations import Operations +from .report_config_operations import ReportConfigOperations +from .billing_account_dimensions_operations import BillingAccountDimensionsOperations +from .subscription_dimensions_operations import SubscriptionDimensionsOperations +from .resource_group_dimensions_operations import ResourceGroupDimensionsOperations __all__ = [ + 'PriceSheetOperations', + 'UsageDetailsOperations', 'ForecastsOperations', 'Operations', + 'ReportConfigOperations', + 'BillingAccountDimensionsOperations', + 'SubscriptionDimensionsOperations', + 'ResourceGroupDimensionsOperations', ] diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/billing_account_dimensions_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/billing_account_dimensions_operations.py new file mode 100644 index 000000000000..5f6ac6a32107 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/billing_account_dimensions_operations.py @@ -0,0 +1,127 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class BillingAccountDimensionsOperations(object): + """BillingAccountDimensionsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Version of the API to be used with the client request. The current version is 2018-05-31. Constant value: "2018-05-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-05-31" + + self.config = config + + def list( + self, billing_account_id, filter=None, expand=None, skiptoken=None, top=None, custom_headers=None, raw=False, **operation_config): + """Lists the dimensions by billingAccount Id. + + :param billing_account_id: BillingAccount ID + :type billing_account_id: str + :param filter: May be used to filter dimensions by + properties/category, properties/usageStart, properties/usageEnd. + Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + :type filter: str + :param expand: May be used to expand the properties/data within a + dimension dategory. By default, data is not included when listing + dimensions. + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N dimension data. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Dimension + :rtype: + ~azure.mgmt.consumption.models.DimensionPaged[~azure.mgmt.consumption.models.Dimension] + :raises: + :class:`ErrorResponseException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.DimensionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.DimensionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/dimensions'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/price_sheet_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/price_sheet_operations.py new file mode 100644 index 000000000000..2416932bb74a --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/price_sheet_operations.py @@ -0,0 +1,188 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class PriceSheetOperations(object): + """PriceSheetOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Version of the API to be used with the client request. The current version is 2018-05-31. Constant value: "2018-05-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-05-31" + + self.config = config + + def get( + self, expand=None, skiptoken=None, top=None, custom_headers=None, raw=False, **operation_config): + """Gets the price sheet for a scope by subscriptionId. Price sheet is + available via this API only for May 1, 2014 or later. + + :param expand: May be used to expand the properties/meterDetails + within a price sheet. By default, these fields are not included when + returning price sheet. + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the top N + results. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PriceSheetResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.PriceSheetResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PriceSheetResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/pricesheets/default'} + + def get_by_billing_period( + self, billing_period_name, expand=None, skiptoken=None, top=None, custom_headers=None, raw=False, **operation_config): + """Get the price sheet for a scope by subscriptionId and billing period. + Price sheet is available via this API only for May 1, 2014 or later. + + :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. + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the top N + results. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PriceSheetResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.PriceSheetResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_by_billing_period.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PriceSheetResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_by_billing_period.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/default'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/report_config_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/report_config_operations.py new file mode 100644 index 000000000000..48bf02278fee --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/report_config_operations.py @@ -0,0 +1,516 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class ReportConfigOperations(object): + """ReportConfigOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Version of the API to be used with the client request. The current version is 2018-05-31. Constant value: "2018-05-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-05-31" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Lists all report configs for a subscription. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ReportConfigListResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.ReportConfigListResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ReportConfigListResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs'} + + def list_by_resource_group_name( + self, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Lists all report configs for a resource group under a subscription. + + :param resource_group_name: Azure Resource Group Name. + :type resource_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ReportConfigListResult or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.ReportConfigListResult or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.list_by_resource_group_name.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ReportConfigListResult', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_by_resource_group_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs'} + + def get( + self, report_config_name, custom_headers=None, raw=False, **operation_config): + """Gets the report config for a subscription by report config name. + + :param report_config_name: Report Config Name. + :type report_config_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ReportConfig or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.ReportConfig or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'reportConfigName': self._serialize.url("report_config_name", report_config_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ReportConfig', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}'} + + def create_or_update( + self, report_config_name, parameters, custom_headers=None, raw=False, **operation_config): + """The operation to create or update a report config. Update operation + requires latest eTag to be set in the request mandatorily. You may + obtain the latest eTag by performing a get operation. Create operation + does not require eTag. + + :param report_config_name: Report Config Name. + :type report_config_name: str + :param parameters: Parameters supplied to the CreateOrUpdate Report + Config operation. + :type parameters: ~azure.mgmt.consumption.models.ReportConfig + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ReportConfig or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.ReportConfig or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'reportConfigName': self._serialize.url("report_config_name", report_config_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'ReportConfig') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ReportConfig', response) + if response.status_code == 201: + deserialized = self._deserialize('ReportConfig', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}'} + + def delete( + self, report_config_name, custom_headers=None, raw=False, **operation_config): + """The operation to delete a report. + + :param report_config_name: Report Config Name. + :type report_config_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'reportConfigName': self._serialize.url("report_config_name", report_config_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}'} + + def get_by_resource_group_name( + self, resource_group_name, report_config_name, custom_headers=None, raw=False, **operation_config): + """Gets the report config for a resource group under a subscription by + report config name. + + :param resource_group_name: Azure Resource Group Name. + :type resource_group_name: str + :param report_config_name: Report Config Name. + :type report_config_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ReportConfig or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.ReportConfig or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_by_resource_group_name.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'reportConfigName': self._serialize.url("report_config_name", report_config_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ReportConfig', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_by_resource_group_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}'} + + def create_or_update_by_resource_group_name( + self, resource_group_name, report_config_name, parameters, custom_headers=None, raw=False, **operation_config): + """The operation to create or update a report config. Update operation + requires latest eTag to be set in the request mandatorily. You may + obtain the latest eTag by performing a get operation. Create operation + does not require eTag. + + :param resource_group_name: Azure Resource Group Name. + :type resource_group_name: str + :param report_config_name: Report Config Name. + :type report_config_name: str + :param parameters: Parameters supplied to the CreateOrUpdate Report + Config operation. + :type parameters: ~azure.mgmt.consumption.models.ReportConfig + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ReportConfig or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.ReportConfig or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.create_or_update_by_resource_group_name.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'reportConfigName': self._serialize.url("report_config_name", report_config_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(parameters, 'ReportConfig') + + # Construct and send request + request = self._client.put(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ReportConfig', response) + if response.status_code == 201: + deserialized = self._deserialize('ReportConfig', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_by_resource_group_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}'} + + def delete_by_resource_group_name( + self, resource_group_name, report_config_name, custom_headers=None, raw=False, **operation_config): + """The operation to delete a report config. + + :param resource_group_name: Azure Resource Group Name. + :type resource_group_name: str + :param report_config_name: Report Config Name. + :type report_config_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.delete_by_resource_group_name.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'reportConfigName': self._serialize.url("report_config_name", report_config_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete_by_resource_group_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/resource_group_dimensions_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/resource_group_dimensions_operations.py new file mode 100644 index 000000000000..8dcc597bcb77 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/resource_group_dimensions_operations.py @@ -0,0 +1,128 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class ResourceGroupDimensionsOperations(object): + """ResourceGroupDimensionsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Version of the API to be used with the client request. The current version is 2018-05-31. Constant value: "2018-05-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-05-31" + + self.config = config + + def list( + self, resource_group_name, filter=None, expand=None, skiptoken=None, top=None, custom_headers=None, raw=False, **operation_config): + """Lists the dimensions by resource group Id. + + :param resource_group_name: Azure Resource Group Name. + :type resource_group_name: str + :param filter: May be used to filter dimensions by + properties/category, properties/usageStart, properties/usageEnd. + Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + :type filter: str + :param expand: May be used to expand the properties/data within a + dimension dategory. By default, data is not included when listing + dimensions. + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N dimension data. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Dimension + :rtype: + ~azure.mgmt.consumption.models.DimensionPaged[~azure.mgmt.consumption.models.Dimension] + :raises: + :class:`ErrorResponseException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.DimensionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.DimensionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/dimensions'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/subscription_dimensions_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/subscription_dimensions_operations.py new file mode 100644 index 000000000000..49a53e34f677 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/subscription_dimensions_operations.py @@ -0,0 +1,125 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class SubscriptionDimensionsOperations(object): + """SubscriptionDimensionsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Version of the API to be used with the client request. The current version is 2018-05-31. Constant value: "2018-05-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-05-31" + + self.config = config + + def list( + self, filter=None, expand=None, skiptoken=None, top=None, custom_headers=None, raw=False, **operation_config): + """Lists the dimensions by subscription Id. + + :param filter: May be used to filter dimensions by + properties/category, properties/usageStart, properties/usageEnd. + Supported operators are 'eq','lt', 'gt', 'le', 'ge'. + :type filter: str + :param expand: May be used to expand the properties/data within a + dimension dategory. By default, data is not included when listing + dimensions. + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N dimension data. + :type top: int + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of Dimension + :rtype: + ~azure.mgmt.consumption.models.DimensionPaged[~azure.mgmt.consumption.models.Dimension] + :raises: + :class:`ErrorResponseException` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.DimensionPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.DimensionPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/dimensions'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_operations.py new file mode 100644 index 000000000000..7e9e93d6f9fd --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_operations.py @@ -0,0 +1,883 @@ +# 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 uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class UsageDetailsOperations(object): + """UsageDetailsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Version of the API to be used with the client request. The current version is 2018-05-31. Constant value: "2018-05-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-05-31" + + self.config = config + + def list( + self, expand=None, filter=None, skiptoken=None, top=None, query_options=None, custom_headers=None, raw=False, **operation_config): + """Lists the usage details for a scope by current billing period. Usage + details are available via this API only for May 1, 2014 or later. + + :param expand: May be used to expand the + properties/additionalProperties or properties/meterDetails within a + list of usage details. By default, these fields are not included when + listing usage details. + :type expand: str + :param filter: May be used to filter usageDetails by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName, + properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + 'not'. Tag filter is a key value pair string where key and value is + separated by a colon (:). + :type filter: str + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N usageDetails. + :type top: int + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.consumption.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageDetail + :rtype: + ~azure.mgmt.consumption.models.UsageDetailPaged[~azure.mgmt.consumption.models.UsageDetail] + :raises: + :class:`ErrorResponseException` + """ + apply = None + if query_options is not None: + apply = query_options.apply + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/usageDetails'} + + def list_by_billing_period( + self, billing_period_name, expand=None, filter=None, skiptoken=None, top=None, query_options=None, custom_headers=None, raw=False, **operation_config): + """Lists the usage details for a scope by billing period. Usage details + are available via this API only for May 1, 2014 or later. + + :param billing_period_name: Billing Period Name. + :type billing_period_name: str + :param expand: May be used to expand the + properties/additionalProperties or properties/meterDetails within a + list of usage details. By default, these fields are not included when + listing usage details. + :type expand: str + :param filter: May be used to filter usageDetails 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'. + Tag filter is a key value pair string where key and value is separated + by a colon (:). + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N usageDetails. + :type top: int + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.consumption.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageDetail + :rtype: + ~azure.mgmt.consumption.models.UsageDetailPaged[~azure.mgmt.consumption.models.UsageDetail] + :raises: + :class:`ErrorResponseException` + """ + apply = None + if query_options is not None: + apply = query_options.apply + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_by_billing_period.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_billing_period.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'} + + def list_by_billing_account( + self, billing_account_id, expand=None, filter=None, skiptoken=None, top=None, query_options=None, custom_headers=None, raw=False, **operation_config): + """Lists the usage details by billingAccountId for a scope by current + billing period. Usage details are available via this API only for May + 1, 2014 or later. + + :param billing_account_id: BillingAccount ID + :type billing_account_id: str + :param expand: May be used to expand the + properties/additionalProperties or properties/meterDetails within a + list of usage details. By default, these fields are not included when + listing usage details. + :type expand: str + :param filter: May be used to filter usageDetails by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName, + properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + 'not'. Tag filter is a key value pair string where key and value is + separated by a colon (:). + :type filter: str + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N usageDetails. + :type top: int + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.consumption.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageDetail + :rtype: + ~azure.mgmt.consumption.models.UsageDetailPaged[~azure.mgmt.consumption.models.UsageDetail] + :raises: + :class:`ErrorResponseException` + """ + apply = None + if query_options is not None: + apply = query_options.apply + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_by_billing_account.metadata['url'] + path_format_arguments = { + 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/usageDetails'} + + def list_for_billing_period_by_billing_account( + self, billing_account_id, billing_period_name, expand=None, filter=None, skiptoken=None, top=None, query_options=None, custom_headers=None, raw=False, **operation_config): + """Lists the usage details based on billingAccountId for a scope by + billing period. Usage details are available via this API only for May + 1, 2014 or later. + + :param billing_account_id: BillingAccount ID + :type billing_account_id: str + :param billing_period_name: Billing Period Name. + :type billing_period_name: str + :param expand: May be used to expand the + properties/additionalProperties or properties/meterDetails within a + list of usage details. By default, these fields are not included when + listing usage details. + :type expand: str + :param filter: May be used to filter usageDetails 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'. + Tag filter is a key value pair string where key and value is separated + by a colon (:). + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N usageDetails. + :type top: int + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.consumption.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageDetail + :rtype: + ~azure.mgmt.consumption.models.UsageDetailPaged[~azure.mgmt.consumption.models.UsageDetail] + :raises: + :class:`ErrorResponseException` + """ + apply = None + if query_options is not None: + apply = query_options.apply + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_for_billing_period_by_billing_account.metadata['url'] + path_format_arguments = { + 'billingAccountId': self._serialize.url("billing_account_id", billing_account_id, 'str'), + 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_for_billing_period_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'} + + def list_by_department( + self, department_id, expand=None, filter=None, skiptoken=None, top=None, query_options=None, custom_headers=None, raw=False, **operation_config): + """Lists the usage details by departmentId for a scope by current billing + period. Usage details are available via this API only for May 1, 2014 + or later. + + :param department_id: Department ID + :type department_id: str + :param expand: May be used to expand the + properties/additionalProperties or properties/meterDetails within a + list of usage details. By default, these fields are not included when + listing usage details. + :type expand: str + :param filter: May be used to filter usageDetails by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName, + properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + 'not'. Tag filter is a key value pair string where key and value is + separated by a colon (:). + :type filter: str + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N usageDetails. + :type top: int + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.consumption.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageDetail + :rtype: + ~azure.mgmt.consumption.models.UsageDetailPaged[~azure.mgmt.consumption.models.UsageDetail] + :raises: + :class:`ErrorResponseException` + """ + apply = None + if query_options is not None: + apply = query_options.apply + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_by_department.metadata['url'] + path_format_arguments = { + 'departmentId': self._serialize.url("department_id", department_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_department.metadata = {'url': '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/usageDetails'} + + def list_for_billing_period_by_department( + self, department_id, billing_period_name, expand=None, filter=None, skiptoken=None, top=None, query_options=None, custom_headers=None, raw=False, **operation_config): + """Lists the usage details based on departmentId for a scope by billing + period. Usage details are available via this API only for May 1, 2014 + or later. + + :param department_id: Department ID + :type department_id: str + :param billing_period_name: Billing Period Name. + :type billing_period_name: str + :param expand: May be used to expand the + properties/additionalProperties or properties/meterDetails within a + list of usage details. By default, these fields are not included when + listing usage details. + :type expand: str + :param filter: May be used to filter usageDetails 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'. + Tag filter is a key value pair string where key and value is separated + by a colon (:). + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N usageDetails. + :type top: int + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.consumption.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageDetail + :rtype: + ~azure.mgmt.consumption.models.UsageDetailPaged[~azure.mgmt.consumption.models.UsageDetail] + :raises: + :class:`ErrorResponseException` + """ + apply = None + if query_options is not None: + apply = query_options.apply + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_for_billing_period_by_department.metadata['url'] + path_format_arguments = { + 'departmentId': self._serialize.url("department_id", department_id, 'str'), + 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_for_billing_period_by_department.metadata = {'url': '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'} + + def list_by_enrollment_account( + self, enrollment_account_id, expand=None, filter=None, skiptoken=None, top=None, query_options=None, custom_headers=None, raw=False, **operation_config): + """Lists the usage details by enrollmentAccountId for a scope by current + billing period. Usage details are available via this API only for May + 1, 2014 or later. + + :param enrollment_account_id: EnrollmentAccount ID + :type enrollment_account_id: str + :param expand: May be used to expand the + properties/additionalProperties or properties/meterDetails within a + list of usage details. By default, these fields are not included when + listing usage details. + :type expand: str + :param filter: May be used to filter usageDetails by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName, + properties/instanceId or tags. The filter supports 'eq', 'lt', 'gt', + 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or + 'not'. Tag filter is a key value pair string where key and value is + separated by a colon (:). + :type filter: str + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N usageDetails. + :type top: int + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.consumption.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageDetail + :rtype: + ~azure.mgmt.consumption.models.UsageDetailPaged[~azure.mgmt.consumption.models.UsageDetail] + :raises: + :class:`ErrorResponseException` + """ + apply = None + if query_options is not None: + apply = query_options.apply + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_by_enrollment_account.metadata['url'] + path_format_arguments = { + 'enrollmentAccountId': self._serialize.url("enrollment_account_id", enrollment_account_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_enrollment_account.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/usageDetails'} + + def list_for_billing_period_by_enrollment_account( + self, enrollment_account_id, billing_period_name, expand=None, filter=None, skiptoken=None, top=None, query_options=None, custom_headers=None, raw=False, **operation_config): + """Lists the usage details based on enrollmentAccountId for a scope by + billing period. Usage details are available via this API only for May + 1, 2014 or later. + + :param enrollment_account_id: EnrollmentAccount ID + :type enrollment_account_id: str + :param billing_period_name: Billing Period Name. + :type billing_period_name: str + :param expand: May be used to expand the + properties/additionalProperties or properties/meterDetails within a + list of usage details. By default, these fields are not included when + listing usage details. + :type expand: str + :param filter: May be used to filter usageDetails 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'. + Tag filter is a key value pair string where key and value is separated + by a colon (:). + :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. + :type skiptoken: str + :param top: May be used to limit the number of results to the most + recent N usageDetails. + :type top: int + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.consumption.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of UsageDetail + :rtype: + ~azure.mgmt.consumption.models.UsageDetailPaged[~azure.mgmt.consumption.models.UsageDetail] + :raises: + :class:`ErrorResponseException` + """ + apply = None + if query_options is not None: + apply = query_options.apply + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_for_billing_period_by_enrollment_account.metadata['url'] + path_format_arguments = { + 'enrollmentAccountId': self._serialize.url("enrollment_account_id", enrollment_account_id, 'str'), + 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send( + request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_for_billing_period_by_enrollment_account.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'}