Getting QoD sessions

Here, we will show how to get a QoD session using multiple methods. If you previously created a session and you need to modify or delete it, you can easily retrieve it by its ID or index. You can do so by using the following examples:

import network_as_code as nac
 
from network_as_code.models.device import Device, DeviceIpv4Addr
 
client = nac.NetworkAsCodeClient(...)
 
device = client.devices.get(...)
 
# Create a session
my_session = device.create_session(...)
 
# Get all sessions
all_sessions = device.sessions()
 
# Notice how we can use the number '0'
# to retrieve our first session in this case:
first_session = all_sessions[0]

Getting specific sessions

# Alternatively, you can get a session by its ID:
session_id = client.sessions.get(my_session.id)

Note that the snippets above assume you have already created a QoD session before, which you can learn how to do here. It also implies that you have already created a Network-as-Code client, and identified your mobile network device.

Last updated on July 09, 2024