Azure Consumption Management Client for accessing consumption resources, budgets, and usage analytics for Azure Enterprise Subscriptions
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Manage Azure credits, lots, events, and price sheet information for Enterprise Agreement and Microsoft Customer Agreement billing accounts. This module provides comprehensive billing and credit management capabilities.
Access credit balance and summary information for billing profiles.
def get(billing_account_id: str, billing_profile_id: str, **kwargs) -> Optional[CreditSummary]:
"""
Get credit summary for a billing account and billing profile.
Parameters:
- billing_account_id: The billing account ID (str)
- billing_profile_id: The billing profile ID (str)
Returns:
CreditSummary: Credit balance and summary information
"""Access Azure credit lots and Microsoft Azure consumption commitments.
def list_by_billing_profile(
billing_account_id: str,
billing_profile_id: str,
**kwargs
) -> Iterable[Lots]:
"""
List Azure credits for a billing profile.
Parameters:
- billing_account_id: The billing account ID (str)
- billing_profile_id: The billing profile ID (str)
Returns:
Iterable[Lots]: Collection of credit lots
"""
def list_by_billing_account(
billing_account_id: str,
filter: str = None,
**kwargs
) -> Iterable[Lots]:
"""
List Azure consumption commitments for a billing account.
Parameters:
- billing_account_id: The billing account ID (str)
- filter: OData filter expression (str, optional)
Returns:
Iterable[Lots]: Collection of lots
"""
def list_by_customer(
billing_account_id: str,
customer_id: str,
filter: str = None,
**kwargs
) -> Iterable[Lots]:
"""
List Azure credits for a customer (MPA billing accounts only).
Parameters:
- billing_account_id: The billing account ID (str)
- customer_id: The customer ID (str)
- filter: OData filter expression (str, optional)
Returns:
Iterable[Lots]: Collection of customer lots
"""Access events that impact Azure credits or consumption commitments.
def list_by_billing_profile(
billing_account_id: str,
billing_profile_id: str,
start_date: str,
end_date: str,
**kwargs
) -> Iterable[Events]:
"""
List events that impact credits for a billing profile.
Parameters:
- billing_account_id: The billing account ID (str)
- billing_profile_id: The billing profile ID (str)
- start_date: Start date for events query (str)
- end_date: End date for events query (str)
Returns:
Iterable[Events]: Collection of credit events
"""
def list_by_billing_account(
billing_account_id: str,
filter: str = None,
**kwargs
) -> Iterable[Events]:
"""
List events that impact consumption commitments for a billing account.
Parameters:
- billing_account_id: The billing account ID (str)
- filter: OData filter expression (str, optional)
Returns:
Iterable[Events]: Collection of consumption events
"""Access current and historical pricing information for resources.
def get(
expand: str = None,
skiptoken: str = None,
top: int = None,
**kwargs
) -> PriceSheetResult:
"""
Get the price sheet for a subscription.
Parameters:
- expand: Expand pricing information (str, optional)
- skiptoken: Token for pagination (str, optional)
- top: Maximum number of items to return (int, optional)
Returns:
PriceSheetResult: Price sheet information
"""
def get_by_billing_period(
billing_period_name: str,
expand: str = None,
skiptoken: str = None,
top: int = None,
**kwargs
) -> PriceSheetResult:
"""
Get the price sheet for a specific billing period.
Parameters:
- billing_period_name: The billing period name (str)
- expand: Expand pricing information (str, optional)
- skiptoken: Token for pagination (str, optional)
- top: Maximum number of items to return (int, optional)
Returns:
PriceSheetResult: Historical price sheet information
"""Access available REST API operations for the consumption service.
def list(**kwargs) -> Iterable[OperationListResult]:
"""
List all available consumption REST API operations.
Returns:
Iterable[OperationListResult]: Available API operations
"""Usage Example:
# Get credit summary
billing_account_id = "your-billing-account-id"
billing_profile_id = "your-billing-profile-id"
credit_summary = client.credits.get(
billing_account_id=billing_account_id,
billing_profile_id=billing_profile_id
)
if credit_summary:
print(f"Current Balance: ${credit_summary.balance.amount}")
print(f"Currency: {credit_summary.balance.currency}")
if credit_summary.pending_credit_adjustments:
print(f"Pending Adjustments: ${credit_summary.pending_credit_adjustments.amount}")
# List credit lots
lots = client.lots.list_by_billing_profile(
billing_account_id=billing_account_id,
billing_profile_id=billing_profile_id
)
for lot in lots:
for lot_item in lot.value:
print(f"Lot Source: {lot_item.source}")
print(f"Original Amount: ${lot_item.original_amount.amount}")
print(f"Closed Balance: ${lot_item.closed_balance.amount}")
print(f"Status: {lot_item.status}")
# Get credit events
events = client.events.list_by_billing_profile(
billing_account_id=billing_account_id,
billing_profile_id=billing_profile_id,
start_date="2024-01-01",
end_date="2024-01-31"
)
for event_collection in events:
for event in event_collection.value:
print(f"Event Type: {event.event_type}")
print(f"Amount: ${event.amount.amount}")
print(f"Date: {event.transaction_date}")
# Get current price sheet
price_sheet = client.price_sheet.get(expand="meterDetails", top=100)
print(f"Billing Period: {price_sheet.billing_period}")
print(f"Currency: {price_sheet.currency}")
for price_item in price_sheet.price_sheet:
print(f"Meter: {price_item.meter_name}")
print(f"Unit Price: ${price_item.unit_price}")
print(f"Currency: {price_item.currency_code}")
# List available operations
operations = client.operations.list()
for operation_result in operations:
for operation in operation_result.value:
print(f"Operation: {operation.name}")
print(f"Display Name: {operation.display.operation}")
print(f"Description: {operation.display.description}")class CreditSummary:
"""Credit summary information."""
id: str
name: str
type: str
etag: str
balance: CreditBalanceSummary
pending_credit_adjustments: Amount
expired_credit: Amount
pending_eligible_charges: Amount
class CreditBalanceSummary:
"""Credit balance summary."""
estimated_balance: Amount
current_balance: Amount
class Amount:
"""Monetary amount with currency."""
currency: str
amount: float
class AmountWithExchangeRate(Amount):
"""Amount with exchange rate information."""
exchange_rate: float
exchange_rate_month: intclass LotSummary:
"""Lot summary information."""
id: str
name: str
type: str
etag: str
original_amount: Amount
closed_balance: Amount
source: str
start_date: datetime
expiration_date: datetime
po_number: str
purchased_date: datetime
status: str
credit_type: str
billing_profile_id: str
billing_profile_display_name: str
lot_id: str
lot_source: str
reseller: Reseller
class Reseller:
"""Reseller information."""
reseller_id: str
reseller_description: str
class Lots:
"""Collection of lots."""
value: List[LotSummary]
next_link: strclass EventSummary:
"""Event summary information."""
id: str
name: str
type: str
etag: str
transaction_date: datetime
description: str
new_credit: Amount
adjustments: Amount
credit_expired: Amount
charges: Amount
closed_balance: Amount
event_type: str
invoice_number: str
billing_profile_id: str
billing_profile_display_name: str
lot_id: str
lot_source: str
cancellation_reason: str
credit_type: str
class Events:
"""Collection of events."""
value: List[EventSummary]
next_link: strclass PriceSheetResult:
"""Price sheet result information."""
id: str
name: str
type: str
etag: str
price_sheet: List[PriceSheetProperties]
next_link: str
billing_period: str
currency: str
class PriceSheetProperties:
"""Individual price sheet item."""
billing_period: str
meter_id: str
meter_name: str
meter_category: str
meter_subcategory: str
unit: str
currency_code: str
unit_price: float
part_number: str
tier_minimum_units: float
market_price: float
effective_start_date: datetime
included_quantity_property: floatclass Operation:
"""API operation information."""
name: str
id: str
display: OperationDisplay
origin: str
class OperationDisplay:
"""Operation display information."""
provider: str
resource: str
operation: str
description: str
usage: str
class OperationListResult:
"""Collection of operations."""
value: List[Operation]
next_link: strclass EventType:
"""Credit event types."""
SETTLED_CHARGES = "SettledCharges"
PENDING_CHARGES = "PendingCharges"
PENDING_ADJUSTMENTS = "PendingAdjustments"
CREDIT_EXPIRED = "CreditExpired"
PENDING_NEW_CREDIT = "PendingNewCredit"
NEW_CREDIT = "NewCredit"
class LotSource:
"""Lot source types."""
PURCHASE_CREDIT = "PurchaseCredit"
PROMOTIONAL_CREDIT = "PromotionalCredit"
CONSUMED_CREDIT = "ConsumedCredit"
class Status:
"""General status options."""
ACTIVE = "Active"
INACTIVE = "Inactive"
EXPIRED = "Expired"
EXHAUSTED = "Exhausted"
CANCELLED = "Cancelled"
COMPLETE = "Complete"
NONE = "None"
class CultureCode:
"""Culture code options for localization."""
EN_US = "en-us"
JA_JP = "ja-jp"
ZH_CN = "zh-cn"
DE_DE = "de-de"
ES_ES = "es-es"
FR_FR = "fr-fr"
IT_IT = "it-it"
KO_KR = "ko-kr"
PT_BR = "pt-br"
RU_RU = "ru-ru"
ZH_TW = "zh-tw"
CS_CZ = "cs-cz"
PL_PL = "pl-pl"
TR_TR = "tr-tr"
DA_DK = "da-dk"
EN_GB = "en-gb"
HU_HU = "hu-hu"
NB_NO = "nb-no"
NL_NL = "nl-nl"
PT_PT = "pt-pt"
SV_SE = "sv-se"
class PricingModelType:
"""Pricing model types."""
ON_DEMAND = "OnDemand"
RESERVATION = "Reservation"
SPOT = "Spot"Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-consumption