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 4b582714b6b0..c849298acf05 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/consumption_management_client.py @@ -13,15 +13,25 @@ from msrest import Serializer, Deserializer from msrestazure import AzureConfiguration from .version import VERSION +from msrest.pipeline import ClientRawResponse +import uuid from .operations.usage_details_operations import UsageDetailsOperations +from .operations.usage_details_by_billing_account_operations import UsageDetailsByBillingAccountOperations +from .operations.usage_details_by_department_operations import UsageDetailsByDepartmentOperations +from .operations.usage_details_by_enrollment_account_operations import UsageDetailsByEnrollmentAccountOperations from .operations.marketplaces_operations import MarketplacesOperations +from .operations.marketplaces_by_billing_account_operations import MarketplacesByBillingAccountOperations +from .operations.marketplaces_by_department_operations import MarketplacesByDepartmentOperations +from .operations.marketplaces_by_enrollment_accounts_operations import MarketplacesByEnrollmentAccountsOperations +from .operations.get_balances_by_billing_account_operations import GetBalancesByBillingAccountOperations from .operations.reservations_summaries_operations import ReservationsSummariesOperations from .operations.reservations_details_operations import ReservationsDetailsOperations from .operations.reservation_recommendations_operations import ReservationRecommendationsOperations from .operations.budgets_operations import BudgetsOperations from .operations.operations import Operations from .operations.price_sheet_operations import PriceSheetOperations -from .operations.cost_allocation_tags_operations import CostAllocationTagsOperations +from .operations.cost_tags_operations import CostTagsOperations +from .operations.tags_operations import TagsOperations from . import models @@ -65,8 +75,22 @@ class ConsumptionManagementClient(object): :ivar usage_details: UsageDetails operations :vartype usage_details: azure.mgmt.consumption.operations.UsageDetailsOperations + :ivar usage_details_by_billing_account: UsageDetailsByBillingAccount operations + :vartype usage_details_by_billing_account: azure.mgmt.consumption.operations.UsageDetailsByBillingAccountOperations + :ivar usage_details_by_department: UsageDetailsByDepartment operations + :vartype usage_details_by_department: azure.mgmt.consumption.operations.UsageDetailsByDepartmentOperations + :ivar usage_details_by_enrollment_account: UsageDetailsByEnrollmentAccount operations + :vartype usage_details_by_enrollment_account: azure.mgmt.consumption.operations.UsageDetailsByEnrollmentAccountOperations :ivar marketplaces: Marketplaces operations :vartype marketplaces: azure.mgmt.consumption.operations.MarketplacesOperations + :ivar marketplaces_by_billing_account: MarketplacesByBillingAccount operations + :vartype marketplaces_by_billing_account: azure.mgmt.consumption.operations.MarketplacesByBillingAccountOperations + :ivar marketplaces_by_department: MarketplacesByDepartment operations + :vartype marketplaces_by_department: azure.mgmt.consumption.operations.MarketplacesByDepartmentOperations + :ivar marketplaces_by_enrollment_accounts: MarketplacesByEnrollmentAccounts operations + :vartype marketplaces_by_enrollment_accounts: azure.mgmt.consumption.operations.MarketplacesByEnrollmentAccountsOperations + :ivar get_balances_by_billing_account: GetBalancesByBillingAccount operations + :vartype get_balances_by_billing_account: azure.mgmt.consumption.operations.GetBalancesByBillingAccountOperations :ivar reservations_summaries: ReservationsSummaries operations :vartype reservations_summaries: azure.mgmt.consumption.operations.ReservationsSummariesOperations :ivar reservations_details: ReservationsDetails operations @@ -79,8 +103,10 @@ class ConsumptionManagementClient(object): :vartype operations: azure.mgmt.consumption.operations.Operations :ivar price_sheet: PriceSheet operations :vartype price_sheet: azure.mgmt.consumption.operations.PriceSheetOperations - :ivar cost_allocation_tags: CostAllocationTags operations - :vartype cost_allocation_tags: azure.mgmt.consumption.operations.CostAllocationTagsOperations + :ivar cost_tags: CostTags operations + :vartype cost_tags: azure.mgmt.consumption.operations.CostTagsOperations + :ivar tags: Tags operations + :vartype tags: azure.mgmt.consumption.operations.TagsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -103,8 +129,22 @@ def __init__( self.usage_details = UsageDetailsOperations( self._client, self.config, self._serialize, self._deserialize) + self.usage_details_by_billing_account = UsageDetailsByBillingAccountOperations( + self._client, self.config, self._serialize, self._deserialize) + self.usage_details_by_department = UsageDetailsByDepartmentOperations( + self._client, self.config, self._serialize, self._deserialize) + self.usage_details_by_enrollment_account = UsageDetailsByEnrollmentAccountOperations( + self._client, self.config, self._serialize, self._deserialize) self.marketplaces = MarketplacesOperations( self._client, self.config, self._serialize, self._deserialize) + self.marketplaces_by_billing_account = MarketplacesByBillingAccountOperations( + self._client, self.config, self._serialize, self._deserialize) + self.marketplaces_by_department = MarketplacesByDepartmentOperations( + self._client, self.config, self._serialize, self._deserialize) + self.marketplaces_by_enrollment_accounts = MarketplacesByEnrollmentAccountsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.get_balances_by_billing_account = GetBalancesByBillingAccountOperations( + self._client, self.config, self._serialize, self._deserialize) self.reservations_summaries = ReservationsSummariesOperations( self._client, self.config, self._serialize, self._deserialize) self.reservations_details = ReservationsDetailsOperations( @@ -117,5 +157,65 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.price_sheet = PriceSheetOperations( self._client, self.config, self._serialize, self._deserialize) - self.cost_allocation_tags = CostAllocationTagsOperations( + self.cost_tags = CostTagsOperations( self._client, self.config, self._serialize, self._deserialize) + self.tags = TagsOperations( + self._client, self.config, self._serialize, self._deserialize) + + def get_balances_by_billing_account( + self, billing_account_id, custom_headers=None, raw=False, **operation_config): + """Gets the balances for a scope by billingAccountId. Balances are + available via this API only for May 1, 2014 or later. + + :param billing_account_id: BillingAccount ID + :type billing_account_id: 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: Balance or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.Balance or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get_balances_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 = {} + 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('Balance', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_balances_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py index 699ba3830208..5cca9140d4e5 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py @@ -12,16 +12,21 @@ from .meter_details import MeterDetails from .usage_detail import UsageDetail from .marketplace import Marketplace +from .balance_properties_new_purchases_details_item import BalancePropertiesNewPurchasesDetailsItem +from .balance_properties_adjustment_details_item import BalancePropertiesAdjustmentDetailsItem +from .balance import Balance from .reservation_summaries import ReservationSummaries from .reservation_details import ReservationDetails from .reservation_recommendations import ReservationRecommendations +from .tag import Tag +from .tags import Tags from .budget_time_period import BudgetTimePeriod from .filters import Filters from .current_spend import CurrentSpend from .notification import Notification from .budget import Budget -from .cost_allocation_tag import CostAllocationTag -from .cost_allocation_tags import CostAllocationTags +from .cost_tag import CostTag +from .cost_tags import CostTags from .error_details import ErrorDetails from .error_response import ErrorResponse, ErrorResponseException from .operation_display import OperationDisplay @@ -40,6 +45,7 @@ from .budget_paged import BudgetPaged from .operation_paged import OperationPaged from .consumption_management_client_enums import ( + BillingFrequency, CategoryType, TimeGrainType, OperatorType, @@ -50,16 +56,21 @@ 'MeterDetails', 'UsageDetail', 'Marketplace', + 'BalancePropertiesNewPurchasesDetailsItem', + 'BalancePropertiesAdjustmentDetailsItem', + 'Balance', 'ReservationSummaries', 'ReservationDetails', 'ReservationRecommendations', + 'Tag', + 'Tags', 'BudgetTimePeriod', 'Filters', 'CurrentSpend', 'Notification', 'Budget', - 'CostAllocationTag', - 'CostAllocationTags', + 'CostTag', + 'CostTags', 'ErrorDetails', 'ErrorResponse', 'ErrorResponseException', 'OperationDisplay', @@ -77,6 +88,7 @@ 'ReservationRecommendationsPaged', 'BudgetPaged', 'OperationPaged', + 'BillingFrequency', 'CategoryType', 'TimeGrainType', 'OperatorType', diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/balance.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/balance.py new file mode 100644 index 000000000000..25629579ae55 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/balance.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. +# -------------------------------------------------------------------------- + +from .resource import Resource + + +class Balance(Resource): + """A balance 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 currency: The ISO currency in which the meter is charged, for + example, USD. + :vartype currency: str + :ivar beginning_balance: The beginning balance for the billing period. + :vartype beginning_balance: decimal.Decimal + :ivar ending_balance: The ending balance for the billing period (for open + periods this will be updated daily). + :vartype ending_balance: decimal.Decimal + :ivar new_purchases: Total new purchase amount. + :vartype new_purchases: decimal.Decimal + :ivar adjustments: Total adjustment amount. + :vartype adjustments: decimal.Decimal + :ivar utilized: Total Commitment usage. + :vartype utilized: decimal.Decimal + :ivar service_overage: Overage for Azure services. + :vartype service_overage: decimal.Decimal + :ivar charges_billed_separately: Charges Billed separately. + :vartype charges_billed_separately: decimal.Decimal + :ivar total_overage: serviceOverage + chargesBilledSeparately. + :vartype total_overage: decimal.Decimal + :ivar total_usage: Azure service commitment + total Overage. + :vartype total_usage: decimal.Decimal + :ivar azure_marketplace_service_charges: Total charges for Azure + Marketplace. + :vartype azure_marketplace_service_charges: decimal.Decimal + :param billing_frequency: The billing frequency. Possible values include: + 'Month', 'Quarter', 'Year' + :type billing_frequency: str or + ~azure.mgmt.consumption.models.BillingFrequency + :ivar price_hidden: Price is hidden or not. + :vartype price_hidden: bool + :ivar new_purchases_details: List of new purchases. + :vartype new_purchases_details: + list[~azure.mgmt.consumption.models.BalancePropertiesNewPurchasesDetailsItem] + :ivar adjustment_details: List of Adjustments (Promo credit, SIE credit + etc.). + :vartype adjustment_details: + list[~azure.mgmt.consumption.models.BalancePropertiesAdjustmentDetailsItem] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'readonly': True}, + 'currency': {'readonly': True}, + 'beginning_balance': {'readonly': True}, + 'ending_balance': {'readonly': True}, + 'new_purchases': {'readonly': True}, + 'adjustments': {'readonly': True}, + 'utilized': {'readonly': True}, + 'service_overage': {'readonly': True}, + 'charges_billed_separately': {'readonly': True}, + 'total_overage': {'readonly': True}, + 'total_usage': {'readonly': True}, + 'azure_marketplace_service_charges': {'readonly': True}, + 'price_hidden': {'readonly': True}, + 'new_purchases_details': {'readonly': True}, + 'adjustment_details': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'currency': {'key': 'properties.currency', 'type': 'str'}, + 'beginning_balance': {'key': 'properties.beginningBalance', 'type': 'decimal'}, + 'ending_balance': {'key': 'properties.endingBalance', 'type': 'decimal'}, + 'new_purchases': {'key': 'properties.newPurchases', 'type': 'decimal'}, + 'adjustments': {'key': 'properties.adjustments', 'type': 'decimal'}, + 'utilized': {'key': 'properties.utilized', 'type': 'decimal'}, + 'service_overage': {'key': 'properties.serviceOverage', 'type': 'decimal'}, + 'charges_billed_separately': {'key': 'properties.chargesBilledSeparately', 'type': 'decimal'}, + 'total_overage': {'key': 'properties.totalOverage', 'type': 'decimal'}, + 'total_usage': {'key': 'properties.totalUsage', 'type': 'decimal'}, + 'azure_marketplace_service_charges': {'key': 'properties.azureMarketplaceServiceCharges', 'type': 'decimal'}, + 'billing_frequency': {'key': 'properties.billingFrequency', 'type': 'str'}, + 'price_hidden': {'key': 'properties.priceHidden', 'type': 'bool'}, + 'new_purchases_details': {'key': 'properties.newPurchasesDetails', 'type': '[BalancePropertiesNewPurchasesDetailsItem]'}, + 'adjustment_details': {'key': 'properties.adjustmentDetails', 'type': '[BalancePropertiesAdjustmentDetailsItem]'}, + } + + def __init__(self, billing_frequency=None): + super(Balance, self).__init__() + self.currency = None + self.beginning_balance = None + self.ending_balance = None + self.new_purchases = None + self.adjustments = None + self.utilized = None + self.service_overage = None + self.charges_billed_separately = None + self.total_overage = None + self.total_usage = None + self.azure_marketplace_service_charges = None + self.billing_frequency = billing_frequency + self.price_hidden = None + self.new_purchases_details = None + self.adjustment_details = None diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/balance_properties_adjustment_details_item.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/balance_properties_adjustment_details_item.py new file mode 100644 index 000000000000..8826f2fc4cea --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/balance_properties_adjustment_details_item.py @@ -0,0 +1,40 @@ +# 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 BalancePropertiesAdjustmentDetailsItem(Model): + """BalancePropertiesAdjustmentDetailsItem. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: the name of new adjustment. + :vartype name: str + :ivar value: the value of new adjustment. + :vartype value: decimal.Decimal + """ + + _validation = { + 'name': {'readonly': True}, + 'value': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'decimal'}, + } + + def __init__(self): + super(BalancePropertiesAdjustmentDetailsItem, self).__init__() + self.name = None + self.value = None diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/balance_properties_new_purchases_details_item.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/balance_properties_new_purchases_details_item.py new file mode 100644 index 000000000000..6fff54e26448 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/balance_properties_new_purchases_details_item.py @@ -0,0 +1,40 @@ +# 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 BalancePropertiesNewPurchasesDetailsItem(Model): + """BalancePropertiesNewPurchasesDetailsItem. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar name: the name of new purchase. + :vartype name: str + :ivar value: the value of new purchase. + :vartype value: decimal.Decimal + """ + + _validation = { + 'name': {'readonly': True}, + 'value': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'decimal'}, + } + + def __init__(self): + super(BalancePropertiesNewPurchasesDetailsItem, self).__init__() + self.name = None + self.value = None 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 bb0db82f76b3..6ccc81576ae3 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 @@ -12,6 +12,13 @@ from enum import Enum +class BillingFrequency(Enum): + + month = "Month" + quarter = "Quarter" + year = "Year" + + class CategoryType(Enum): cost = "Cost" diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tag.py similarity index 81% rename from azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.py rename to azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tag.py index 6176ebb7cd72..af15f79e0c68 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tag.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tag.py @@ -12,10 +12,10 @@ from msrest.serialization import Model -class CostAllocationTag(Model): - """The cost allocation tag. +class CostTag(Model): + """The cost tag. - :param key: Cost allocation tag key. + :param key: Cost tag key. :type key: str """ @@ -24,5 +24,5 @@ class CostAllocationTag(Model): } def __init__(self, key=None): - super(CostAllocationTag, self).__init__() + super(CostTag, self).__init__() self.key = key diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tags.py similarity index 72% rename from azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.py rename to azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tags.py index 3688c720f6b9..4773e92bde71 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_allocation_tags.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/cost_tags.py @@ -12,8 +12,8 @@ from .proxy_resource import ProxyResource -class CostAllocationTags(ProxyResource): - """A cost allocation tag resource. +class CostTags(ProxyResource): + """A cost tag resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -28,9 +28,8 @@ class CostAllocationTags(ProxyResource): this field will be used to determine whether the user is updating the latest version or not. :type e_tag: str - :param cost_allocation_tags: Cost allocation tags. - :type cost_allocation_tags: - list[~azure.mgmt.consumption.models.CostAllocationTag] + :param cost_tags: Cost tags. + :type cost_tags: list[~azure.mgmt.consumption.models.CostTag] """ _validation = { @@ -44,9 +43,9 @@ class CostAllocationTags(ProxyResource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'e_tag': {'key': 'eTag', 'type': 'str'}, - 'cost_allocation_tags': {'key': 'properties.costAllocationTags', 'type': '[CostAllocationTag]'}, + 'cost_tags': {'key': 'properties.costTags', 'type': '[CostTag]'}, } - def __init__(self, e_tag=None, cost_allocation_tags=None): - super(CostAllocationTags, self).__init__(e_tag=e_tag) - self.cost_allocation_tags = cost_allocation_tags + def __init__(self, e_tag=None, cost_tags=None): + super(CostTags, self).__init__(e_tag=e_tag) + self.cost_tags = cost_tags diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/query_options.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/query_options.py index 2cd0e67b848e..a61093e680bb 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/models/query_options.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/query_options.py @@ -13,10 +13,9 @@ class QueryOptions(Model): - """Additional parameters for a set of operations, such as: UsageDetails_list, - UsageDetails_list_by_billing_period. + """Additional parameters for a set of operations. - :param apply: OData apply expression to aggregatie usageDetails by tags or + :param apply: OData apply expression to aggregate usageDetails by tags or (tags and properties/usageStart) :type apply: str """ diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/tag.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/tag.py new file mode 100644 index 000000000000..d1403dabeb28 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/tag.py @@ -0,0 +1,28 @@ +# 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 Tag(Model): + """The tag resource. + + :param key: Tag key. + :type key: str + """ + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + } + + def __init__(self, key=None): + super(Tag, self).__init__() + self.key = key diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/models/tags.py b/azure-mgmt-consumption/azure/mgmt/consumption/models/tags.py new file mode 100644 index 000000000000..e3bcdd517698 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/models/tags.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 .proxy_resource import ProxyResource + + +class Tags(ProxyResource): + """A resource listing all tags. + + 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 + :param e_tag: eTag of the resource. To handle concurrent update scenarion, + this field will be used to determine whether the user is updating the + latest version or not. + :type e_tag: str + :param tags: A list of Tag. + :type tags: list[~azure.mgmt.consumption.models.Tag] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'e_tag': {'key': 'eTag', 'type': 'str'}, + 'tags': {'key': 'properties.tags', 'type': '[Tag]'}, + } + + def __init__(self, e_tag=None, tags=None): + super(Tags, self).__init__(e_tag=e_tag) + self.tags = tags diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py index 1ee112dda428..51e3c9cf1644 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/__init__.py @@ -10,23 +10,39 @@ # -------------------------------------------------------------------------- from .usage_details_operations import UsageDetailsOperations +from .usage_details_by_billing_account_operations import UsageDetailsByBillingAccountOperations +from .usage_details_by_department_operations import UsageDetailsByDepartmentOperations +from .usage_details_by_enrollment_account_operations import UsageDetailsByEnrollmentAccountOperations from .marketplaces_operations import MarketplacesOperations +from .marketplaces_by_billing_account_operations import MarketplacesByBillingAccountOperations +from .marketplaces_by_department_operations import MarketplacesByDepartmentOperations +from .marketplaces_by_enrollment_accounts_operations import MarketplacesByEnrollmentAccountsOperations +from .get_balances_by_billing_account_operations import GetBalancesByBillingAccountOperations from .reservations_summaries_operations import ReservationsSummariesOperations from .reservations_details_operations import ReservationsDetailsOperations from .reservation_recommendations_operations import ReservationRecommendationsOperations from .budgets_operations import BudgetsOperations from .operations import Operations from .price_sheet_operations import PriceSheetOperations -from .cost_allocation_tags_operations import CostAllocationTagsOperations +from .cost_tags_operations import CostTagsOperations +from .tags_operations import TagsOperations __all__ = [ 'UsageDetailsOperations', + 'UsageDetailsByBillingAccountOperations', + 'UsageDetailsByDepartmentOperations', + 'UsageDetailsByEnrollmentAccountOperations', 'MarketplacesOperations', + 'MarketplacesByBillingAccountOperations', + 'MarketplacesByDepartmentOperations', + 'MarketplacesByEnrollmentAccountsOperations', + 'GetBalancesByBillingAccountOperations', 'ReservationsSummariesOperations', 'ReservationsDetailsOperations', 'ReservationRecommendationsOperations', 'BudgetsOperations', 'Operations', 'PriceSheetOperations', - 'CostAllocationTagsOperations', + 'CostTagsOperations', + 'TagsOperations', ] diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_tags_operations.py similarity index 75% rename from azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py rename to azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_tags_operations.py index 689c045f2d8f..b6911db1dea4 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_allocation_tags_operations.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/cost_tags_operations.py @@ -15,8 +15,8 @@ from .. import models -class CostAllocationTagsOperations(object): - """CostAllocationTagsOperations operations. +class CostTagsOperations(object): + """CostTagsOperations operations. :param client: Client for service requests. :param config: Configuration of service client. @@ -38,17 +38,17 @@ def __init__(self, client, config, serializer, deserializer): def get( self, billing_account_id, custom_headers=None, raw=False, **operation_config): - """Get cost allocation tags for a billing account. + """Get cost tags for a billing account. - :param billing_account_id: Azure Billing Account ID. + :param billing_account_id: BillingAccount ID :type billing_account_id: 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: CostAllocationTags or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.consumption.models.CostAllocationTags or + :return: CostTags or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.CostTags or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException` @@ -84,43 +84,42 @@ def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CostAllocationTags', response) + deserialized = self._deserialize('CostTags', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - get.metadata = {'url': '/providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costAllocationTags'} + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'} def create_or_update( - self, billing_account_id, e_tag=None, cost_allocation_tags=None, custom_headers=None, raw=False, **operation_config): - """The operation to create or update cost allocation tags assiciated with - a billing account. 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. + self, billing_account_id, e_tag=None, cost_tags=None, custom_headers=None, raw=False, **operation_config): + """The operation to create or update cost tags assiciated with a billing + account. 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 billing_account_id: Azure Billing Account ID. + :param billing_account_id: BillingAccount ID :type billing_account_id: str :param e_tag: eTag of the resource. To handle concurrent update scenarion, this field will be used to determine whether the user is updating the latest version or not. :type e_tag: str - :param cost_allocation_tags: Cost allocation tags. - :type cost_allocation_tags: - list[~azure.mgmt.consumption.models.CostAllocationTag] + :param cost_tags: Cost tags. + :type cost_tags: list[~azure.mgmt.consumption.models.CostTag] :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: CostAllocationTags or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.consumption.models.CostAllocationTags or + :return: CostTags or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.CostTags or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException` """ - parameters = models.CostAllocationTags(e_tag=e_tag, cost_allocation_tags=cost_allocation_tags) + parameters = models.CostTags(e_tag=e_tag, cost_tags=cost_tags) # Construct URL url = self.create_or_update.metadata['url'] @@ -144,7 +143,7 @@ def create_or_update( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(parameters, 'CostAllocationTags') + body_content = self._serialize.body(parameters, 'CostTags') # Construct and send request request = self._client.put(url, query_parameters) @@ -157,13 +156,13 @@ def create_or_update( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('CostAllocationTags', response) + deserialized = self._deserialize('CostTags', response) if response.status_code == 201: - deserialized = self._deserialize('CostAllocationTags', response) + deserialized = self._deserialize('CostTags', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - create_or_update.metadata = {'url': '/providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costAllocationTags'} + create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/costTags'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/get_balances_by_billing_account_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/get_balances_by_billing_account_operations.py new file mode 100644 index 000000000000..361c0e9341a8 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/get_balances_by_billing_account_operations.py @@ -0,0 +1,98 @@ +# 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 GetBalancesByBillingAccountOperations(object): + """GetBalancesByBillingAccountOperations 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-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def by_billing_period( + self, billing_account_id, billing_period_name, custom_headers=None, raw=False, **operation_config): + """Gets the balances for a scope by billing period and billingAccountId. + Balances 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 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: Balance or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.Balance or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.by_billing_period.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 = {} + 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('Balance', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + by_billing_period.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_billing_account_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_billing_account_operations.py new file mode 100644 index 000000000000..0ce103039dcf --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_billing_account_operations.py @@ -0,0 +1,216 @@ +# 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 MarketplacesByBillingAccountOperations(object): + """MarketplacesByBillingAccountOperations 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-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def list( + self, billing_account_id, filter=None, top=None, skiptoken=None, custom_headers=None, raw=False, **operation_config): + """Lists the marketplaces for a scope by billingAccountId and current + billing period. Marketplaces are available via this API only for May 1, + 2014 or later. + + :param billing_account_id: BillingAccount ID + :type billing_account_id: str + :param filter: May be used to filter marketplaces by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName or + properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', + 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + :type filter: str + :param top: May be used to limit the number of results to the most + recent N marketplaces. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation + returned a partial result. If a previous response contains a nextLink + element, the value of the nextLink element will include a skiptoken + parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: 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: An iterator like instance of Marketplace + :rtype: + ~azure.mgmt.consumption.models.MarketplacePaged[~azure.mgmt.consumption.models.Marketplace] + :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 = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = self._serialize.query("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 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.MarketplacePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MarketplacePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/marketplaces'} + + def list_by_billing_period( + self, billing_account_id, billing_period_name, filter=None, top=None, skiptoken=None, custom_headers=None, raw=False, **operation_config): + """Lists the marketplaces for a scope by billing period and + billingAccountId. Marketplaces 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 filter: May be used to filter marketplaces by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName or + properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', + 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + :type filter: str + :param top: May be used to limit the number of results to the most + recent N marketplaces. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation + returned a partial result. If a previous response contains a nextLink + element, the value of the nextLink element will include a skiptoken + parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: 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: An iterator like instance of Marketplace + :rtype: + ~azure.mgmt.consumption.models.MarketplacePaged[~azure.mgmt.consumption.models.Marketplace] + :raises: + :class:`ErrorResponseException` + """ + 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 = { + '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 filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = self._serialize.query("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 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.MarketplacePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MarketplacePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_billing_period.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_department_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_department_operations.py new file mode 100644 index 000000000000..bee20da7f7ed --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_department_operations.py @@ -0,0 +1,215 @@ +# 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 MarketplacesByDepartmentOperations(object): + """MarketplacesByDepartmentOperations 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-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def list( + self, department_id, filter=None, top=None, skiptoken=None, custom_headers=None, raw=False, **operation_config): + """Lists the marketplaces for a scope by departmentId and current billing + period. Marketplaces are available via this API only for May 1, 2014 or + later. + + :param department_id: Department ID + :type department_id: str + :param filter: May be used to filter marketplaces by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName or + properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', + 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + :type filter: str + :param top: May be used to limit the number of results to the most + recent N marketplaces. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation + returned a partial result. If a previous response contains a nextLink + element, the value of the nextLink element will include a skiptoken + parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: 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: An iterator like instance of Marketplace + :rtype: + ~azure.mgmt.consumption.models.MarketplacePaged[~azure.mgmt.consumption.models.Marketplace] + :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 = { + 'departmentId': self._serialize.url("department_id", department_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = self._serialize.query("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 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.MarketplacePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MarketplacePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/marketplaces'} + + def list_by_billing_period( + self, department_id, billing_period_name, filter=None, top=None, skiptoken=None, custom_headers=None, raw=False, **operation_config): + """Lists the marketplaces for a scope by billing period and departmentId. + Marketplaces 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 filter: May be used to filter marketplaces by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName or + properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', + 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + :type filter: str + :param top: May be used to limit the number of results to the most + recent N marketplaces. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation + returned a partial result. If a previous response contains a nextLink + element, the value of the nextLink element will include a skiptoken + parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: 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: An iterator like instance of Marketplace + :rtype: + ~azure.mgmt.consumption.models.MarketplacePaged[~azure.mgmt.consumption.models.Marketplace] + :raises: + :class:`ErrorResponseException` + """ + 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 = { + '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 filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = self._serialize.query("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 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.MarketplacePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MarketplacePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_billing_period.metadata = {'url': '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_enrollment_accounts_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_enrollment_accounts_operations.py new file mode 100644 index 000000000000..e0499257c636 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_by_enrollment_accounts_operations.py @@ -0,0 +1,216 @@ +# 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 MarketplacesByEnrollmentAccountsOperations(object): + """MarketplacesByEnrollmentAccountsOperations 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-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def list( + self, enrollment_account_id, filter=None, top=None, skiptoken=None, custom_headers=None, raw=False, **operation_config): + """Lists the marketplaces for a scope by enrollmentAccountId and current + billing period. Marketplaces are available via this API only for May 1, + 2014 or later. + + :param enrollment_account_id: EnrollmentAccount ID + :type enrollment_account_id: str + :param filter: May be used to filter marketplaces by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName or + properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', + 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + :type filter: str + :param top: May be used to limit the number of results to the most + recent N marketplaces. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation + returned a partial result. If a previous response contains a nextLink + element, the value of the nextLink element will include a skiptoken + parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: 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: An iterator like instance of Marketplace + :rtype: + ~azure.mgmt.consumption.models.MarketplacePaged[~azure.mgmt.consumption.models.Marketplace] + :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 = { + '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 filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = self._serialize.query("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 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.MarketplacePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MarketplacePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/marketplaces'} + + def list_by_billing_period( + self, enrollment_account_id, billing_period_name, filter=None, top=None, skiptoken=None, custom_headers=None, raw=False, **operation_config): + """Lists the marketplaces for a scope by billing period and + enrollmentAccountId. Marketplaces 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 filter: May be used to filter marketplaces by + properties/usageEnd (Utc time), properties/usageStart (Utc time), + properties/resourceGroup, properties/instanceName or + properties/instanceId. The filter supports 'eq', 'lt', 'gt', 'le', + 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. + :type filter: str + :param top: May be used to limit the number of results to the most + recent N marketplaces. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation + returned a partial result. If a previous response contains a nextLink + element, the value of the nextLink element will include a skiptoken + parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: 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: An iterator like instance of Marketplace + :rtype: + ~azure.mgmt.consumption.models.MarketplacePaged[~azure.mgmt.consumption.models.Marketplace] + :raises: + :class:`ErrorResponseException` + """ + 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 = { + '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 filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=1000, minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + query_parameters['api-version'] = self._serialize.query("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 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.MarketplacePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.MarketplacePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_billing_period.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/marketplaces'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_operations.py index a1b597f10be8..54802a27ac04 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_operations.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/marketplaces_operations.py @@ -38,8 +38,9 @@ def __init__(self, client, config, serializer, deserializer): def list( self, filter=None, top=None, skiptoken=None, custom_headers=None, raw=False, **operation_config): - """Lists the marketplaces for a scope by subscriptionId. Marketplaces are - available via this API only for May 1, 2014 or later. + """Lists the marketplaces for a scope by subscriptionId and current + billing period. Marketplaces are available via this API only for May 1, + 2014 or later. :param filter: May be used to filter marketplaces by properties/usageEnd (Utc time), properties/usageStart (Utc time), diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/tags_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/tags_operations.py new file mode 100644 index 000000000000..f306b1c810cc --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/tags_operations.py @@ -0,0 +1,94 @@ +# 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 TagsOperations(object): + """TagsOperations 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-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def get( + self, billing_account_id, custom_headers=None, raw=False, **operation_config): + """Get all available tag keys for a billing account. + + :param billing_account_id: BillingAccount ID + :type billing_account_id: 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: Tags or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.consumption.models.Tags or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.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') + + # 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('Tags', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/providers/Microsoft.CostManagement/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/tags'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_billing_account_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_billing_account_operations.py new file mode 100644 index 000000000000..7aab23099c08 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_billing_account_operations.py @@ -0,0 +1,250 @@ +# 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 UsageDetailsByBillingAccountOperations(object): + """UsageDetailsByBillingAccountOperations 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-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def list( + 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.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.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/usageDetails'} + + def list_by_billing_period( + 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_by_billing_period.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_by_billing_period.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_department_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_department_operations.py new file mode 100644 index 000000000000..b034c6b04200 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_department_operations.py @@ -0,0 +1,250 @@ +# 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 UsageDetailsByDepartmentOperations(object): + """UsageDetailsByDepartmentOperations 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-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def list( + 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.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.metadata = {'url': '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Consumption/usageDetails'} + + def list_by_billing_period( + 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_by_billing_period.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_by_billing_period.metadata = {'url': '/providers/Microsoft.Billing/departments/{departmentId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'} diff --git a/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_enrollment_account_operations.py b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_enrollment_account_operations.py new file mode 100644 index 000000000000..7e0205fd1d13 --- /dev/null +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_by_enrollment_account_operations.py @@ -0,0 +1,250 @@ +# 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 UsageDetailsByEnrollmentAccountOperations(object): + """UsageDetailsByEnrollmentAccountOperations 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-03-31. Constant value: "2018-03-31". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-03-31" + + self.config = config + + def list( + 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.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.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Consumption/usageDetails'} + + def list_by_billing_period( + 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_by_billing_period.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_by_billing_period.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/usageDetails'} 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 index fef1b3fc2402..2c540194330e 100644 --- a/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_operations.py +++ b/azure-mgmt-consumption/azure/mgmt/consumption/operations/usage_details_operations.py @@ -38,8 +38,8 @@ def __init__(self, client, config, serializer, deserializer): 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 billing period. Usage details - are available via this API only for May 1, 2014 or later. + """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