QoD notifications and life cycle
QoD session life cycle
When you first create a session,
its status will become REQUESTED until the quality of service requested
through the desired QoS profiles
is provided by the network.
If the allocation of resources by the network is successful,
the QoD status will change to AVAILABLE,
and the QoD session will be ready to use
for the amount of time specified during creation, or until it is deleted or interrupted.
When the QoD session duration expires
or if the session is deleted,
the QoD status will become UNAVAILABLE.
The reason for the QoD session termination will also be specified
in the notification callback,
through the statusInfo string.
QoD statuses
| QoD session status | Description |
|---|---|
REQUESTED | A QoD session was requested and it is waiting to be provided by the network. |
AVAILABLE | Resource allocation in the network was successful and the QoD session is active. |
UNAVAILABLE | The QoD session was terminated because its duration expired, or it was deleted. |
| QoD session status information | Description |
|---|---|
DURATION_EXPIRED | The QoD session duration expired and the session was automatically terminated. |
DELETE_REQUESTED | The QoD session was deleted by the user. |
NETWORK_TERMINATED | The QoD session was terminated due to the network before the duration expired. |
Session notifications
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. Learn more about the notification URL/auth token and how to create an HTTP server with a POST endpoint for session notifications.
With a notification URL, you can also keep track of different QoD session statuses.
Creating a session with a notification URL
Create a QoD session providing parameters for your API endpoint and password (authorization token) to identify the sender of the notifications.
import network_as_code as nac
from network_as_code.models.device import DeviceIpv4Addr
# Begin by creating a client for Network as Code:
client = nac.NetworkAsCodeClient(
token="<your-application-key-here>",
)
# Then, create a device object.
# Remember to assign its phone number and current IP address(es):
my_device = client.devices.get(
ipv4_address=DeviceIpv4Addr(
public_address="233.252.0.2",
private_address="192.0.2.25",
public_port=80
),
ipv6_address="2001:db8:1234:5678:9abc:def0:fedc:ba98",
# The phone number does not accept spaces or parentheses
phone_number="+36721601234567"
)
# Create a QoD session with QOS_L (large bandwidth)
# and get notifications
my_session = my_device.create_qod_session(
service_ipv4="233.252.0.2",
service_ipv6="2001:db8:1234:5678:9abc:def0:fedc:ba98",
profile="QOS_L",
duration=3600,
# Use HTTPS to send notifications
notification_url="https://notify.me/here",
notification_auth_token="replace-with-your-auth-token"
)
# Show a list of all the QoD sessions associated with a device
print(my_device.sessions())Setting up a web server
The code snippet below will set up an HTTP server with a POST endpoint, so you can get session-event updates:
import time
from fastapi import FastAPI, Header
from pydantic import BaseModel
from typing_extensions import Annotated
from typing import Union
# Our web server for receiving QoD notifications
app = FastAPI()
class EventDetail(BaseModel):
sessionId: str
qosStatus: str
statusInfo: str
class Event(BaseModel):
eventType: str
eventTime: str
eventDetail: EventDetail
class Notification(BaseModel):
id: str
source: str
type: str
specversion: str
datacontenttype: str
time: str
event: Event
data: EventDetail
@app.post("/qod")
def receive_notification(
notification: Notification,
authorization: Annotated[Union[str, None], Header]
):
if authorization == "Bearer my-token":
# We can now react to the notifications
# based on the Notification object
print(notification)Session notification parameters
The Session object is created with a specific duration,
representing a new session for the device.
The following parameters can be passed to this method:
| Parameters | Type | Description | Mandatory or Optional |
|---|---|---|---|
profile | string | The QoS profile that indicates the connection type to be prioritized between two points. | Mandatory |
service_ipv4 | string | The service identified by the application IPv4 address. | Mandatory (if no IPv6) |
service_ipv6 | string | The service identified by the application IPv6 address. | Mandatory (if no IPv4) |
duration | integer | The length of the QoD session in seconds (maximum: 86400 seconds = 24 hours). | Mandatory |
notification_url | string | The recipient's HTTP endpoint, which is a web server configured to receive POST requests. | Mandatory |
notification_auth_token | string | The password used to identify the sender of the notification. | Optional |
Quality-of-service-on-Demand (QoD) notification schema
Here you will find the JSON schema for QoD notifications, which purpose is to monitor changes made to sessionId, qosStatus and statusInfo.
Underneath the JSON schema, there is a table with further information on the specific keyword values.
Remember that the string values represented below are just examples that can be used. So, they should contain your real QoD session values.
{
"id":"string",
"source":"string",
"type":"org.camaraproject.qod.v0.qos-status-changed",
"specversion":"1.0",
"datacontenttype":"application/json",
"time":"2024-04-30T13:05:29.189Z",
"data":{
"sessionId":"string",
"qosStatus":"UNAVAILABLE",
"statusInfo":"DELETE_REQUESTED"
}
}
| QoD-keyword values | Type | Description |
|---|---|---|
id | string | The event subscription identifier. |
source | string | Identifies the source where the event happened. It contains the Network as Code API implementation and subscription ID. |
type | string | Value returned by the API with different statuses. |
specversion | string | Represents the specification version. |
datacontenttype | string | It indicates the media type for the event payload encoding. It must be "application/json" in the context of CAMARA APIs |
time | string | Time when the event occurred. Date and time are specified in ISO 8601 format, e.g.: "2023-08-20T21:01:02.345Z". |
sessionId | string | The session resource ID. It can be a session name or number, which is attributed when you create a session. |
qosStatus | string | The QoD session status, whether it is REQUESTED, AVAILABLE, UNAVAILABLE. |
statusInfo | string | Provides information on the QoD session expiration or termination. The accepted values are: DURATION_EXPIRED, DELETE_REQUESTED, NETWORK_TERMINATED or it can also be empty (null). |
Simulated QoD notification scenarios
The Network as Code simulators have been configured to provide specific QoD notifications for specific simulated devices based on their device identifier. This will be helpful in testing your code against the different responses, including possible errors, by simply substituting the device identifier in your code.
The device identifiers and their responses can be found in the following table:
| Device identifier type | Device identifier | HTTP status code | HTTP status code description | Response description |
|---|---|---|---|---|
| Network Access Identifier | [email protected] | 200 | Success | "QOS_STATUS_CHANGED notification with status UNAVAILABLE, No status information" |
| Network Access Identifier | [email protected] | 200 | Success | "QOS_STATUS_CHANGED notification with status UNAVAILABLE, Status info = NETWORK_TERMINATED" |
| Network Access Identifier | [email protected] | 200 | Success | "QOS_STATUS_CHANGED notification with status AVAILABLE, No status information" |
Last updated November 05, 2025