Skip to content

Spending Limit

API reference for diameter.message.commands.spending_limit.

This module contains Spending-Limit Request and Answer messages, implementing AVPs documented in 3GPP TS 29.219.

SpendingLimit

SpendingLimit(header: MessageHeader = None, avps: list[Avp] = None)

Bases: DefinedMessage

A Spending-Limit message.

This message class lists message attributes based on the current 3GPP TS 29.219 version 11.2.0 Release 11 as python properties, acessible as instance attributes. AVPs not listed in the base protocol can be retrieved using the SpendingLimit.find_avps search method.

Examples:

AVPs accessible either as instance attributes or by searching:

>>> msg = Message.from_bytes(b"...")
>>> msg.session_id
dra1.mvno.net;2323;546
>>> msg.find_avps((AVP_SESSION_ID, 0))
['dra1.mvno.net;2323;546']

When diameter message is decoded using Message.from_bytes, it returns either an instance of SpendingLimitRequest or SpendingLimitAnswer automatically:

>>> msg = Message.from_bytes(b"...")
>>> assert msg.header.is_request is True
>>> assert isinstance(msg, SpendingLimitRequest)

When creating a new message, the SpendingLimitRequest or SpendingLimitAnswer class should be instantiated directly, and the values for AVPs set as class attributes:

>>> msg = SpendingLimitRequest()
>>> msg.session_id = "dra1.mvno.net;2323;546"

Other, custom AVPs can be appended to the message using the SpendingLimit.append_avp method, or by overwriting the avp attribute entirely.

Warning

Every AVP documented for the subclasses of this command can be accessed as an instance attribute, even if the original network-received message did not contain that specific AVP. Such AVPs will be returned with the value None when accessed.

Every other AVP not mentioned here, and not present in a network-received message will raise an AttributeError when being accessed; their presence should be validated with hasattr before accessing.

SpendingLimitAnswer

SpendingLimitAnswer(
    header: MessageHeader = None, avps: list[Avp] = None
)

Bases: SpendingLimit

A Spending-Limit-Answer message.

auth_application_id instance-attribute

auth_application_id: int

error_message instance-attribute

error_message: str

error_reporting_host instance-attribute

error_reporting_host: bytes

experimental_result instance-attribute

experimental_result: ExperimentalResult

failed_avp instance-attribute

failed_avp: FailedAvp

origin_host instance-attribute

origin_host: bytes

origin_realm instance-attribute

origin_realm: bytes

origin_state_id instance-attribute

origin_state_id: int

policy_counter_status_report instance-attribute

policy_counter_status_report: list[PolicyCounterStatusReport]

proxy_info instance-attribute

proxy_info: list[ProxyInfo]

redirect_host instance-attribute

redirect_host: list[str]

redirect_host_usage instance-attribute

redirect_host_usage: int

redirect_max_cache_time instance-attribute

redirect_max_cache_time: int

result_code instance-attribute

result_code: int

session_id instance-attribute

session_id: str

SpendingLimitRequest

SpendingLimitRequest(
    header: MessageHeader = None, avps: list[Avp] = None
)

Bases: SpendingLimit

A Spending-Limit-Request message.

auth_application_id instance-attribute

auth_application_id: int

destination_host instance-attribute

destination_host: bytes

destination_realm instance-attribute

destination_realm: bytes

origin_aaa_protocol instance-attribute

origin_aaa_protocol: int

origin_host instance-attribute

origin_host: bytes

origin_realm instance-attribute

origin_realm: bytes

origin_state_id instance-attribute

origin_state_id: int

policy_counter_identifier instance-attribute

policy_counter_identifier: list[str]

proxy_info instance-attribute

proxy_info: list[ProxyInfo]

route_record instance-attribute

route_record: list[bytes]

session_id instance-attribute

session_id: str

sl_request_type instance-attribute

sl_request_type: int

subscription_id instance-attribute

subscription_id: list[SubscriptionId]