otupy.profiles.xbom.data.ip_net_address.IPNetAddress
- class IPNetAddress(net_address)
Bases:
ChoiceDefine generic IP network address
IPNetAddress can contain both an IPv4Net or an IPv6Net. It adds a higher level of abstraction to avoid keeping track of two kinds of addresses.
Methods
Convert IPNetAddress to CycloneDX properties format.
Builds instance from dictionary
Get the class corresponding to the current choice
Returns the name of the choice
Returns the objet instance embedded in the register.
Converts to dictionary
Attributes
List of registered name/class options available
Selected name for the Choice
Class corresponding to the choice
- __init__(net_address)
Initialize an IP address
It automatically detects the type of Address and raise an exception if an invalid address is provided.
- Parameters:
net_address – The IP address provided as str, IPv4Net, or IPv6Net
- as_cyclonedx(prefix: str = 'otupy:net') list
Convert IPNetAddress to CycloneDX properties format.
- Args:
prefix: The prefix to use for property names.
- Returns:
list: List of CycloneDX Property objects.
- 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
Encoderinstance that is used to recursively build instances of the inner objects (theEncoderprovides 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
Encoderthat 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.
- obj
Class corresponding to the choice
- register = {'ipv4': <class 'otupy.types.targets.ipv4_net.IPv4Net'>, 'ipv6': <class 'otupy.types.targets.ipv6_net.IPv6Net'>}
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
Encoderargument that is used to recursively serialize inner data and structures (theEncoderprovides standard methods for converting base types to dictionaries)..- Parameters:
e – The
Encoderthat is being used.- Returns:
A dictionary compliants to the Language Specification’s serialization rules.