otupy.profiles.ctxd.data.network_type.NetworkType

class NetworkType(type)

Bases: Choice

Network type

The network type carries different configuration parameters, depending on the specific network technology.

WARNING: This definition is currently partially, since it does not include network paramters for most of network types. When the network is defined as str, it returns something like: “ethernet”: “ethernet”.

Methods

fromdict

Builds instance from dictionary

getClass

Get the class corresponding to the current choice

getName

Returns the name of the choice

getObj

Returns the objet instance embedded in the register.

get_type_name

Get the name associated to a given class

todict

Converts to dictionary

Attributes

register

List of registered name/class options available

choice

Selected name for the Choice

obj

Class corresponding to the choice

__init__(type)

Initialize the Choice object

Objects used as Choice must be registered in advance in the register dictionary.

Parameters:

obj – An object among those defined in the register.

choice: str

Selected name for the Choice

classmethod fromdict(dic, e)

Builds instance from dictionary

It is used during deserialization to create an otupy instance from the text message. It takes an Encoder instance that is used to recursively build instances of the inner objects (the Encoder provides standard methods to create instances of base objects like strings, integers, boolean).

Parameters:
  • dic – The intermediary dictionary representation from which the object is built.

  • e – The Encoder that is being used.

Returns:

An instance of this class initialized from the dictionary values.

classmethod getClass(choice)

Get the class corresponding to the current choice

It may be implemented by any derived class, if a different logic than the Register class is followed to store the name/class bindings.

Parameters:

choice – The name of the alternative that is being looked for.

Returns:

The class corresponding to the provided choice.

getName()

Returns the name of the choice

Returns the name of object, which is the selector carried by the Choice element. This does not include the object itself.

getObj()

Returns the objet instance embedded in the register.

static get_type_name(net_type: object)

Get the name associated to a given class

If the class is not registered, None is returned.

@:param service_type: The class to get the name for. @:return: The string used to register the class.

obj

Class corresponding to the choice

register = {'5G': <class 'otupy.profiles.ctxd.data.mobile_network.MobileNetwork'>, '802.11': <class 'str'>, '802.15': <class 'str'>, 'eth': <class 'otupy.profiles.ctxd.data.ethernet_network.EthernetNetwork'>, 'ip': <class 'otupy.profiles.ctxd.data.ip_network.IPNetwork'>, 'lorawan': <class 'str'>, 'tun': <class 'otupy.profiles.ctxd.data.tunnel_network.TunnelNetwork'>, 'veth': <class 'otupy.profiles.ctxd.data.veth_network.VEthNetwork'>, 'vlan': <class 'otupy.profiles.ctxd.data.vlan_network.VLANNetwork'>, 'vpn': <class 'str'>, 'vxlan': <class 'otupy.profiles.ctxd.data.vxlan_network.VXLANNetwork'>, 'wan': <class 'str'>, 'zigbee': <class 'str'>}

List of registered name/class options available

todict(e)

Converts to dictionary

It is used to convert this object to an intermediary representation during serialization. It takes an Encoder argument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..

Parameters:

e – The Encoder that is being used.

Returns:

A dictionary compliants to the Language Specification’s serialization rules.