Accounting
API reference for diameter.message.commands.accounting
.
This module contains Accounting Request and Answer messages, implementing AVPs documented in rfc6733.
Accounting ¶
Accounting(header: MessageHeader = None, avps: list[Avp] = None)
Bases: DefinedMessage
An Accounting message.
This message class lists message attributes based on the current RFC6733 as python properties, acessible as instance attributes. AVPs not listed in the base protocol can be retrieved using the Accounting.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 AccountingRequest
or AccountingAnswer
automatically:
>>> msg = Message.from_bytes(b"...")
>>> assert msg.header.is_request is True
>>> assert isinstance(msg, AccountingRequest)
When creating a new message, the AccountingRequest
or
AccountingAnswer
class should be instantiated directly, and values
for AVPs set as class attributes:
>>> msg = AccountingRequest()
>>> msg.session_id = "dra1.mvno.net;2323;546"
Other, custom AVPs can be appended to the message using the
Accounting.append_avp method, or
by overwriting the avp
attribute entirely. Regardless of the custom AVPs
set, the mandatory values listed in RFC6733 must be set, however they can
be set as None
, if they are not to be used.
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.
AccountingAnswer ¶
AccountingAnswer(
header: MessageHeader = None, avps: list[Avp] = None
)
Bases: Accounting
An Accounting-Answer message.
vendor_specific_application_id
instance-attribute
¶
vendor_specific_application_id: VendorSpecificApplicationId
AccountingRequest ¶
AccountingRequest(
header: MessageHeader = None, avps: list[Avp] = None
)
Bases: Accounting
An Accounting-Request message.
application_server_information
instance-attribute
¶
application_server_information: list[ApplicationServerInformation]
inter_operator_identifier
instance-attribute
¶
inter_operator_identifier: list[InterOperatorIdentifier]
vendor_specific_application_id
instance-attribute
¶
vendor_specific_application_id: VendorSpecificApplicationId