Networks

Network Objects and Network Groups are used to store IP networks or hosts as variables, that can be used in Access Policy rules etc.

class firepyer.Fdm
create_net_group(name: str, objects: List[str], description: str = None) → dict

Creates a NetworkGroup object, containing at least 1 existing Network or NetworkGroup object

Parameters
  • name (str) – Name of the NetworkGroup to be created

  • objects (List[str]) – Names of the Network or NetworkGroup objects to be added to the group

  • description (str, optional) – A description for the NetworkGroup, defaults to None

Raises

FirepyerResourceNotFound – If any of the given object names do not exist

Returns

The created NetworkGroup object

Return type

dict

>>> fdm.create_net_group(name='GROUP-HOST1', description='GROUP-HOST1', objects=['Host1-NIC1', 'Host1-NIC2'])
{'description': 'GROUP-HOST1',
  'id': '26dbfd53-4db6-11eb-aab5-4dba63992bb3',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networkgroups/26dbfd53-4db6-11eb-aab5-4dba63992bb3'},
  'name': 'GROUP-HOST1',
  'objects': [{'id': '9f42dab3-4db5-11eb-aab5-19160f885ae8',
               'name': 'Host1-NIC1',
               'type': 'networkobject',
               'version': 'jpfwstwwapru5'},
              {'id': '9ffc3fa6-4db5-11eb-aab5-23e5ffdb3f0d',
               'name': 'Host1-NIC2',
               'type': 'networkobject',
               'version': 'joq4kyvc4ztx5'}],
  'type': 'networkobjectgroup',
  'version': 'lcplbsj24ebva'}
create_network(name: str, value: str, type: str = 'HOST', description: str = None) → dict

Creates a network Host, FQDN, Network or Range object

Parameters
  • name (str) – Name of the object

  • value (str) – Value of the object, depending on type e.g. Host would be an IP address, Network would be a CIDR network etc.

  • type (str, optional) – Type of Network object to create, defaults to ‘HOST’

  • description (str, optional) – Description of the object, defaults to None

Raises

FirepyerInvalidOption – If the type is not one of “HOST”, “FQDN”, “NETWORK” or “RANGE”

Returns

The Network object that has been created

Return type

dict

>>> fdm.create_network(name='RFC-1918-172', value='172.16.0.0/12', type='network')
{'description': None,
 'dnsResolution': 'IPV4_ONLY',
 'id': 'f8b81657-793a-11eb-b948-fbbf2c1ae1be',
 'isSystemDefined': False,
 'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networks/f8b81657-793a-11eb-b948-fbbf2c1ae1be'},
 'name': 'RFC-1918-172',
 'subType': 'NETWORK',
 'type': 'networkobject',
 'value': '172.16.0.0/12',
 'version': 'oani42zndwyl5'}
delete_network(net_id: str) → bool

Delete a NetworkObject

Parameters

net_id (str) – NetworkObject id

Raises

FirepyerResourceNotFound – If a NetworkObject with the given id does not exist

Returns

True if the object is successfully deleted

Return type

bool

delete_network_group(grp_id: str) → bool

Delete a NetworkGroup

Parameters

grp_id (str) – NetworkGroup id

Raises

FirepyerResourceNotFound – If a NetworkGroup with the given id does not exist

Returns

True if the object is successfully deleted

Return type

bool

get_net_groups(name='')

Gets all NetworkGroups or a single NetworkGroup if a name is provided

Parameters

name (str, optional) – The name of a NetworkGroup to find, defaults to ‘’

Returns

A list of all NetworkGroups if no name is provided, or a dict of the single NetworkGroup with the given name

Return type

list|dict

>>> fdm.get_net_groups()
[{'description': 'GROUP-HOST1',
  'id': '26dbfd53-4db6-11eb-aab5-4dba63992bb3',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networkgroups/26dbfd53-4db6-11eb-aab5-4dba63992bb3'},
  'name': 'GROUP-HOST1',
  'objects': [{'id': '9f42dab3-4db5-11eb-aab5-19160f885ae8',
               'name': 'Host1-NIC1',
               'type': 'networkobject',
               'version': 'jpfwstwwapru5'},
              {'id': '9ffc3fa6-4db5-11eb-aab5-23e5ffdb3f0d',
               'name': 'Host1-NIC2',
               'type': 'networkobject',
               'version': 'joq4kyvc4ztx5'}],
  'type': 'networkobjectgroup',
  'version': 'lcplbsj24ebva'},
 {'description': 'GROUP-HOST2',
  'id': '28368446-4db6-11eb-aab5-b7a83f9515f7',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networkgroups/28368446-4db6-11eb-aab5-b7a83f9515f7'},
  'name': 'GROUP-HOST2',
  'objects': [{'id': 'a13ab322-4db5-11eb-aab5-5330425fbd55',
               'name': 'Host2-NIC1',
               'type': 'networkobject',
               'version': 'ddha6de2szejr'},
              {'id': 'a183f125-4db5-11eb-aab5-4b89ea1eb596',
               'name': 'Host2-NIC2',
               'type': 'networkobject',
               'version': 'makivftpuepn'}],
  'type': 'networkobjectgroup',
  'version': 'd7fsrmu7qvlna'},
 {'description': 'GROUP-ALL-HOSTS',
  'id': '2904a9b9-4db6-11eb-aab5-93170f9c3b34',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networkgroups/2904a9b9-4db6-11eb-aab5-93170f9c3b34'},
  'name': 'GROUP-ALL-HOSTS',
  'objects': [{'id': '26dbfd53-4db6-11eb-aab5-4dba63992bb3',
               'name': 'GROUP-HOST1',
               'type': 'networkobjectgroup',
               'version': 'lcplbsj24ebva'},
              {'id': '28368446-4db6-11eb-aab5-b7a83f9515f7',
               'name': 'GROUP-HOST2',
               'type': 'networkobjectgroup',
               'version': 'd7fsrmu7qvlna'}],
  'type': 'networkobjectgroup',
  'version': 'i4oe7b4lpaxos'}]
>>> fdm.get_net_groups('GROUP-ALL-HOSTS')
{'description': 'GROUP-ALL-HOSTS',
  'id': '2904a9b9-4db6-11eb-aab5-93170f9c3b34',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networkgroups/2904a9b9-4db6-11eb-aab5-93170f9c3b34'},
  'name': 'GROUP-ALL-HOSTS',
  'objects': [{'id': '26dbfd53-4db6-11eb-aab5-4dba63992bb3',
               'name': 'GROUP-HOST1',
               'type': 'networkobjectgroup',
               'version': 'lcplbsj24ebva'},
              {'id': '28368446-4db6-11eb-aab5-b7a83f9515f7',
               'name': 'GROUP-HOST2',
               'type': 'networkobjectgroup',
               'version': 'd7fsrmu7qvlna'}],
  'type': 'networkobjectgroup',
  'version': 'i4oe7b4lpaxos'}
get_net_objects(name='', must_find: bool = False)

Gets all NetworkObjects or a single NetworkObject if a name is provided

Parameters
  • name (str, optional) – The name of the NetworkObject to find, defaults to ‘’

  • must_find (bool, optional) – Specifies if an exception should be raised if the resource isn’t found, defaults to False

Returns

A list of all NetworkObjects if no name is provided, or a dict of the single NetworkObject with the given name

Return type

list|dict

>>> fdm.get_net_objects()
[{'description': None,
  'dnsResolution': None,
  'id': '00f7b297-4d44-11eb-9e04-13721b05d633',
  'isSystemDefined': True,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networks/00f7b297-4d44-11eb-9e04-13721b05d633'},
  'name': 'any-ipv4',
  'subType': 'NETWORK',
  'type': 'networkobject',
  'value': '0.0.0.0/0',
  'version': 'kxd2dzxm2gtwn'},
 {'description': None,
  'dnsResolution': None,
  'id': '0107df38-4d44-11eb-9e04-5b0093cb3558',
  'isSystemDefined': True,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networks/0107df38-4d44-11eb-9e04-5b0093cb3558'},
  'name': 'any-ipv6',
  'subType': 'NETWORK',
  'type': 'networkobject',
  'value': '::/0',
  'version': 'ezvnwzxqrq6pj'},
 {'description': 'HOST1-NIC1',
  'dnsResolution': 'IPV4_ONLY',
  'id': '9f42dab3-4db5-11eb-aab5-19160f885ae8',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networks/9f42dab3-4db5-11eb-aab5-19160f885ae8'},
  'name': 'Host1-NIC1',
  'subType': 'HOST',
  'type': 'networkobject',
  'value': '10.0.1.1',
  'version': 'jpfwstwwapru5'},
]
>>> fdm.get_net_objects('Host1-NIC1')
{'description': 'HOST1-NIC1',
 'dnsResolution': 'IPV4_ONLY',
 'id': '9f42dab3-4db5-11eb-aab5-19160f885ae8',
 'isSystemDefined': False,
 'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networks/9f42dab3-4db5-11eb-aab5-19160f885ae8'},
 'name': 'Host1-NIC1',
 'subType': 'HOST',
 'type': 'networkobject',
 'value': '10.0.1.1',
 'version': 'jpfwstwwapru5'}
get_net_obj_or_grp(name) → dict

Get a NetworkObject or NetworkGroup by the given name

Parameters

name (str) – The name of the object/group to retrieve

Returns

Single dict describing the object, if a resource with the name is found

Return type

dict

>>> fdm.get_net_obj_or_grp('Host1-NIC1')
{'description': 'HOST1-NIC1',
 'dnsResolution': 'IPV4_ONLY',
 'id': '9f42dab3-4db5-11eb-aab5-19160f885ae8',
 'isSystemDefined': False,
 'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/networks/9f42dab3-4db5-11eb-aab5-19160f885ae8'},
 'name': 'Host1-NIC1',
 'subType': 'HOST',
 'type': 'networkobject',
 'value': '10.0.1.1',
 'version': 'jpfwstwwapru5'}