Documentation for PythonAPI
22.40.00py2

netobject

This module contains NetObject implementation.

There is no need to import this module directly. Use the methods of the Ruleset object to create and manipulate NetObjects.

>>> o = r.object_add("/NetObjects/Test")
>>> o.add("192.168.20.0/255.255.255.0")
>>> o.add("192.168.25.10-192.168.25.20")
>>> o.add("192.168.26.1")
>>> print o.items
['192.168.20.0/255.255.255.0', '192.168.25.10-192.168.25.20', '192.168.26.1']

Classes defined here:

NetObject

NetObject Implementation

Object path: /NetObjects

Inherits from: PLObject
Methods:
Ungrouped add(self, value)
Adds a NetObject item to this NetObject
Inherited from PLObject move(self, newparent)
Moves a object to somewhere else in the tree
remove(self, item)
Removes an Item from this Object
remove_id(self, id)
Removes an Item from this Object by its idnumber
rename(self, newname)
Rename the current object
set_visible(self, visible)
Set or reset the visible flag on the current object
Class Variables:
Item NetObject Item implementation.
Properties:
attributes Arbitrary key/value attributes stored for this object
base_path Only the type portion of the path
creation_date Date and time when this object was created
creator Username that created this object
fullpath Complete path including name of object
id Database id of object
is_global True if this is object is not from the local system
items List of items associated with this object
machineid Deprecated method to access 'systemid'
modification_date Date and time when this object was last modified
modified Deprecated method to access 'modification_date'
modified_by Username that last modified this object
name Name of the object
parent id of parent object (or zero)
path Complete path to where the object is excluding the object name
systemid System ID of the PacketLogic this object belongs to
type Number representing the type of object
visible True if the object is visible in the GUI

add(self, value)

Adds a NetObject item to this NetObject.

Parameters:
  • value (str) - The value is a string describing the NetObject item. The type of the item will be automatically detected from the string. The following syntax is valid:
    • IPv4 Address, Just give the plain IPaddress xxx.xxx.xxx.xxx
    • IPv4 Network, Give the network address with the netmask after xxx.xxx.xxx.xxx/yyy.yyy.yyy.yyy
    • IPv4 CIDR notation, Give the network address and prefix length separated with slash xxx.xxx.xxx.xxx/nn (note that this will be converted to network/netmask notation internally)
    • IPv4 Range, Give the start and stop address with a dash as delimiter xxx.xxx.xxx.xxx-yyy.yyy.yyy.yyy

move(self, newparent)

Moves a object to somewhere else in the tree

destroys the cache

Parameters:
  • newparent (str) - a path where the new object should reside. Must start with the same objecttype. I.e. you can't move a NetObject to VlanIdObject.
Exceptions raised:
  • ValueError - If the rule is global.
  • ValueError - If you specify an invalid path.

remove(self, item)

Removes an Item from this Object

Parameters:
  • item (Item or str) - Either you send in the Item class there or you send a string with the value. The first Item that matches will be removed.
remove is deprecated: The item argument can also be an integer specifying the id number of the item to be removed. This is usage deprecated, instead use the remove_id method.

remove_id(self, id)

Removes an Item from this Object by its idnumber.

>>> i=o.add(7)
>>> o.remove_id(i.id)
Parameters:
  • item (int) - ID-number of the item to remove

rename(self, newname)

Rename the current object

destroys netobject cache

Parameters:
  • newname (str) - The name that the object should have after rename process
Exceptions raised:
  • ValueError - If the rule is global.

set_visible(self, visible)

Set or reset the visible flag on the current object.

Parameters:
  • visible (bool) - True or False value for the flag.
Exceptions raised:
  • ValueError - If the rule is global.

attributes

Arbitrary key/value attributes stored for this object.

Attributes stored on objects doesn't affect ruleset evaluation, and are designed to be used by integrations to assign integration specific data to objects. The client does special handling for some attributes, such as "hidden" and "automatic".

>>> o.attributes
{}
>>> o.attributes['test'] = "Arbitrary string value"
>>> o.attributes
{'test': "Arbitrary string value"}

base_path

Only the type portion of the path

creation_date

Date and time when this object was created

creator

Username that created this object

fullpath

Complete path including name of object

id

Database id of object.

The unique (for this object type) id number used to refer to the object in rule conditions.

is_global

True if this is object is not from the local system

items

List of items associated with this object

machineid

Deprecated method to access 'systemid'.

modification_date

Date and time when this object was last modified

modified

Deprecated method to access 'modification_date'.

modified_by

Username that last modified this object

name

Name of the object.

This is the name of the object, excluding path. Note that name is utf-8 encoded data in a string, to get a unicode string use o.name.decode("utf-8").

To change the name of an object use the rename method.

parent

id of parent object (or zero)

path

Complete path to where the object is excluding the object name.

systemid

System ID of the PacketLogic this object belongs to

type

Number representing the type of object

visible

True if the object is visible in the GUI

NetObjectItem

Netobject Item implementation. Should not be instantiated, use NetObject.add instead.

Inherits from: PLObjectItem
Properties:
created The property 'created' is undocumented and deprecated, use 'creation_date'
creation_date Date and time when item was created
creator Username of this items creator
exclude True = exclude, False = include
id Unique number used internally to identify this item
modification_date Date and time when this item was last modified
modified The property 'modified' is undocumented and deprecated, use
modified_by Username that last modified this item
type Internal number representing the item type (single, network, or range)
value1 IP address, first IP address if part of a range or prefix if it's a
value2 Empty string, last IP address if part of a range or netmask if it's a

created

The property 'created' is undocumented and deprecated, use 'creation_date' instead.

creation_date

Date and time when item was created.

creator

Username of this items creator.

exclude

True = exclude, False = include

id

Unique number used internally to identify this item.

modification_date

Date and time when this item was last modified.

modified

The property 'modified' is undocumented and deprecated, use 'modification_date' instead.

modified_by

Username that last modified this item.

type

Internal number representing the item type (single, network, or range)

value1

IP address, first IP address if part of a range or prefix if it's a network.

value2

Empty string, last IP address if part of a range or netmask if it's a network.