Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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<msrest:optionsforoperations>`.
:return: Balance or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.consumption.models.Balance or
~msrest.pipeline.ClientRawResponse
:raises:
:class:`ErrorResponseException<azure.mgmt.consumption.models.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'}
20 changes: 16 additions & 4 deletions azure-mgmt-consumption/azure/mgmt/consumption/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,6 +45,7 @@
from .budget_paged import BudgetPaged
from .operation_paged import OperationPaged
from .consumption_management_client_enums import (
BillingFrequency,
CategoryType,
TimeGrainType,
OperatorType,
Expand All @@ -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',
Expand All @@ -77,6 +88,7 @@
'ReservationRecommendationsPaged',
'BudgetPaged',
'OperationPaged',
'BillingFrequency',
'CategoryType',
'TimeGrainType',
'OperatorType',
Expand Down
128 changes: 128 additions & 0 deletions azure-mgmt-consumption/azure/mgmt/consumption/models/balance.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading