The NetworkAsCodeClient is the entry-point to all the functionality Network as Code provides. It allows you to identify the client and devices to use Network as Code. The Network as Code client and device creation comes right after the installation step described in our Getting-started guide.

Creating a Network as Code Client object

import network_as_code as nac
from network_as_code.models.device import Device, DeviceIpv4Addr
client = nac.NetworkAsCodeClient(
  • A client object will be instantiated from the nac.NetworkAsCodeClient() class, previously imported in the code. This functionality will also hold the token parameter. Pass the application key, which enables to identify and authenticate the client. This "token application key" is the one that was created and you can view it from your Dashboard.

Creating a Device object

The client.devices.get() method is equally important and it will identify your client's device. It holds the DeviceIpv4Addr() model, previously imported in your code, and the multiple optional parameters for the client's device.

import network_as_code as nac
from network_as_code.models.device import Device, DeviceIpv4Addr
client = nac.NetworkAsCodeClient(...)
my_device = client.devices.get(
    ipv4_address = DeviceIpv4Addr(
    ipv6_address = "2001:db8:1234:5678:9abc:def0:fedc:ba98",
    # The phone number accepts the "+" sign, but not spaces or "()" marks
    phone_number = "36721601234567"

NOTE: All the parameters in the client.devices.get() method are optional, but you will need to use at least one of them.

Device parameters

network_access_identifierThe Device ID can work as an alternate for phone number.
ipv4_addressPublic, private IPv4 addresses and ports can be passed within the DeviceIPv4Addr model.
ipv6_addressWhere a public or private IPv6 address can be informed.
phone_numberSimple phone-number identifier for devices or users owning the mobile subscription.

What's next?

Now you're ready to set up your Network as Code client and device and use its multiple functionalities. How about diving deeper into the multiple ways you can identify mobile network devices?

Last updated on May 23, 2024