Nokia logo
DocumentationBlogPricing
Request access

Getting a Specialized Network (slice)

Getting a slice by its name (ID)

Here, we will show how to get a slice using the slice = client.slices.get() method.

If you previously created a slice or if there are multiple ones and you need to modify or delete a specific one, you can easily retrieve it with its unique name (ID) or with a number.

In the code snippet below, we suppose you previously created a slice or even multiple ones. Then, if you want to retrieve the first slice you created, because you do not have its exact ID or for any other reason, you can do so with a number client.slices.getAll()[0].

import network_as_code as nac
 
from network_as_code.models.slice import Point, AreaOfService, NetworkIdentifier, SliceInfo
 
client = nac.NetworkAsCodeClient(...)
 
device = client.devices.get(...)
 
slice = client.slices.create(...)
 
# Notice how we can use the number '0' to retrieve our first slice in this case:
client.slices.getAll()[0]

Alternatively, you can also use the slice_id variable:

slice = client.slices.get(slice_id)

Additionally, use its specific name (ID) if you have it, which is a string value:

slice = client.slices.get("slice-name_1")

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 December 04, 2023

On this page
Getting a slice by its name (ID)