AA
API reference for diameter.message.commands.aa
.
This module contains AA Request and Answer messages, implementing AVPs documented in rfc7155.
Aa ¶
Aa(header: MessageHeader = None, avps: list[Avp] = None)
Bases: DefinedMessage
An AA message.
This message class lists message attributes based on the current rfc7155 as python properties, acessible as instance attributes. AVPs not listed in the RFC can be retrieved using the Aa.find_avps search method.
Examples:
AVPs accessible either as instance attributes or by searching:
>>> msg = Message.from_bytes(b"...")
>>> msg.origin_realm
b'mvno.net'
>>> msg.find_avps((AVP_ORIGIN_REALM, 0))
[b'mvno.net']
When a diameter message is decoded using
Message.from_bytes, it returns
either an instance of AaRequest
or AaAnswer
automatically:
>>> msg = Message.from_bytes(b"...")
>>> assert msg.header.is_request is True
>>> assert isinstance(msg, AaRequest)
When creating a new message by hand, the AaRequest
or AaAnswer
class should be instantiated directly, and values for AVPs set as
class attributes:
>>> msg = AaRequest()
>>> msg.origin_realm = b"mvno.net"
Other, custom AVPs can be appended to the message using the
Aa.append_avp method, or by
overwriting the avp
attribute entirely. Regardless of the custom AVPs
set, the mandatory values listed in rfc7155 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.
AaAnswer ¶
AaAnswer(header: MessageHeader = None, avps: list[Avp] = None)
Bases: Aa
An AA-Answer message.
Note
The "Class" AVP can be accessed via state_class
attribute, as
"class" is a reserved keyword.
AaRequest ¶
AaRequest(header: MessageHeader = None, avps: list[Avp] = None)
Bases: Aa
An AA-Request message.
media_component_description
instance-attribute
¶
media_component_description: MediaComponentDescription
add_subscription_id ¶
add_subscription_id(
subscription_id_type: int, subscription_id_data: str
)
Add a subscription ID to the request.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subscription_id_type
|
int
|
One of the |
required |
subscription_id_data
|
str
|
Actual subscription ID |
required |