Getting a Specialized Network (slice)

Getting a slice by its name (ID)

Here, we will show how to get a slice using the client.slices.get() method. If you previously created a slice 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
from network_as_code.models.slice import (
client = nac.NetworkAsCodeClient(...)
my_device = client.devices.get(...)
my_slice = client.slices.create(...)
# This should get all the slices of a device
all_slices = client.slices.getAll()
# Or you can get a slice by its index,
# this one should get the first slice
one_slice = client.slices.get()[0]

Alternatively, you can get a slice by using its ID or slice name:

# Alternatively, you can also get a slice by its ID:
slice = client.slices.get(

Note that the snippets above assume you have already created a slice 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 May 23, 2024