Session notifications
Creating a session with a notification URL
You can optionally configure a notification (webhook) URL to receive QoD session updates. This way you or your client can be notified of important session events, such as creation, deletion, etc.
import network_as_code as nac
from network_as_code.models.device import Device, DeviceIpv4Addr
# We begin by creating a client for Network as Code
client = nac.NetworkAsCodeClient(
token="<your-application-key-here>",
)
# We get the device by querying subscriptions with the UE's external identifier and IP addresses
device = client.devices.get("device@testcsp.net",
ipv4_address = DeviceIpv4Addr(public_address="233.252.0.2",
private_address="192.0.2.25",
public_port=80),
# The phone number accepts the "+" sign, but not spaces or "()" marks
phone_number = "36721601234567"
)
session = device.create_qod_session(
service_ipv4="233.252.0.2",
service_ipv6="2001:db8:1234:5678:9abc:def0:fedc:ba98",
profile="DOWNLINK_L_UPLINK_L",
notification_url="https://notify.me/here",
notification_auth_token="replace-with-your-auth-token"
)
Device object parameters
The snippet above identified a mobile network device in multiple ways (IP addresses, port, etc). Learn how to create a device object and understand how the DeviceIPv4Addr
model works using NAT technology.
Session notification parameters
The session
object is created using the device.create_qod_session()
method,
representing a new session for the device.
The following parameters need to be passed within this method:
Parameters | Description |
---|---|
service_ipv4 or service_ipv6 | The IP addresses attributed to identify the QoD session. |
profile | The network profile that will be prioritized (large downlink and large uplink bandwidth, in the case above) |
notification_url | The recipient's HTTP endpoint, which is a web server configured to receive POST requests. |
notification_auth_token | The password used to identify the sender of the notification. |
What is a notification URL?
Learn more about the notification URL/auth token and how to create a web server for them.