Ports

PortObjects and PortGroups are used to store TCP or UDP ports as variables, that can be used in Access Policy rules etc.

class firepyer.Fdm
create_icmp_port(name, type, code=None, af='4', description=None) → dict

Create an ICMPv4/6 Port object

Parameters
  • name (str) – Name of the object

  • type (str) – Must be a valid ICMPv4 or ICMPv6 type, see enum for options

  • code (str, optional) – Must be a valid ICMPv4 or ICMPv6 code, see enum for options, defaults to None

  • af (str, optional) – Address family, ‘4’ for an ICMPv4 object, ‘6’ for an ICMPv6 object, defaults to ‘4’

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

Returns

The ICMP Port object instance created

Return type

dict

>>> fdm.create_icmp_port(name='ping-reply', type='ECHO_REPLY')
{'description': None,
 'icmpv4Code': None,
 'icmpv4Type': 'ECHO_REPLY',
 'id': '32bc6efd-794b-11eb-b948-a194e41e088a',
 'isSystemDefined': False,
 'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/icmpv4ports/32bc6efd-794b-11eb-b948-a194e41e088a'},
 'name': 'ping-reply',
 'type': 'icmpv4portobject',
 'version': 'ficvgobxazqtj'}
create_port_group(name: str, objects: List[str], description: str = None) → dict

Creates a PortGroup object, containing at least one existing tcp/udp/icmp Port or PortGroup

Parameters
  • name (str) – Name of the PortGroup to create

  • objects (List[str]) – Names of the tcp/udp/icmp Port or PortGroup objects to be added to the group

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

Returns

The PortGroup object instance created

Return type

dict

>>> fdm.create_port_group(name='HTTP-S Group', objects=['HTTP', 'HTTPS'], description='HTTP and HTTPS ports')
{'description': 'HTTP and HTTPS ports',
 'id': 'cf42834b-794c-11eb-b948-efc7c141f6b3',
 'isSystemDefined': False,
 'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/portgroups/cf42834b-794c-11eb-b948-efc7c141f6b3'},
 'name': 'HTTP-S Group',
 'objects': [{'id': '18312adc-38bb-11e2-86aa-62f0c593a59a',
              'name': 'HTTP',
              'type': 'tcpportobject',
              'version': 'jfkuxugpghogc'},
             {'id': '1834bd00-38bb-11e2-86aa-62f0c593a59a',
              'name': 'HTTPS',
              'type': 'tcpportobject',
              'version': 'f7j76od54tkia'}],
 'type': 'portobjectgroup',
 'version': 'cwappx23fqvaz'}
create_port_object(name: str, port: str, type: str, description: str = None) → dict

Create a TCP or UDP Port object to use in access rules

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

  • port (str) – A single port number or ‘-‘ separated range of ports e.g. ‘80’ or ‘8000-8008’

  • type (str) – The protocol, must be one of [‘tcp’, ‘udp’]

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

Returns

The TCP/UDP Port object instance created

Return type

dict

>>> fdm.create_port_object(name='my-http-port', port='8001', type='tcp', description='My custom HTTP port 8001')
{'description': 'My custom HTTP port 8001',
 'id': 'e10fd062-794b-11eb-b948-b5d9fac6117d',
 'isSystemDefined': False,
 'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/tcpports/e10fd062-794b-11eb-b948-b5d9fac6117d'},
 'name': 'my-http-port',
 'port': '8001',
 'type': 'tcpportobject',
 'version': 'bb4wded6dz4zt'}
get_icmp_ports(name='', af='4')

Gets all ICMPv4/6 type Ports or a single ICMPv4/6 Port object if a name is provided

Parameters
  • name (str, optional) – The name of a ICMPv4 Port to find, defaults to ‘’

  • af (str, optional) – Address family, ‘4’ for an ICMPv4 object, ‘6’ for an ICMPv6 object, defaults to ‘4’

Returns

A list of all ICMPv4 Ports if no name is provided, or a dict of the single ICMPv4 Port with the given name

Return type

list|dict

>>> fdm.get_icmp_ports()
[{'description': None,
  'icmpv4Code': None,
  'icmpv4Type': 'ECHO_REPLY',
  'id': '7d1e807d-545b-11eb-aab5-95f8b07b5659',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/icmpv4ports/7d1e807d-545b-11eb-aab5-95f8b07b5659'},
  'name': 'ec reply',
  'type': 'icmpv4portobject',
  'version': 'loxpplznuzrjn'},
 {'description': None,
  'icmpv4Code': 'NET_UNREACHABLE',
  'icmpv4Type': 'DESTINATION_UNREACHABLE',
  'id': 'fb816ea2-545c-11eb-aab5-5dd867fd255a',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/icmpv4ports/fb816ea2-545c-11eb-aab5-5dd867fd255a'},
  'name': 'ICMP_UNREACHABLE',
  'type': 'icmpv4portobject',
  'version': 'bf3gltejkuiws'}]
>>> fdm.get_icmp_ports(af='6')
[{'description': 'A very large ICMPv6',
  'icmpv6Code': None,
  'icmpv6Type': 'PACKET_TOO_BIG',
  'id': '10d19dae-5458-11eb-aab5-e946ff8eb526',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/icmpv6ports/10d19dae-5458-11eb-aab5-e946ff8eb526'},
  'name': 'BIG6',
  'type': 'icmpv6portobject',
  'version': 'lrerbmosmioew'}]
get_port_groups(name='')

Gets all PortGroups or a single PortGroup if a name is provided

Parameters

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

Returns

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

Return type

list|dict

>>> fdm.get_port_groups()
[{'description': None,
  'id': '9722eb6c-503c-11eb-aab5-e5660269d013',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/portgroups/9722eb6c-503c-11eb-aab5-e5660269d013'},
  'name': 'MY-APP-GROUP',
  'objects': [{'id': '96128cd6-503c-11eb-aab5-3106163baeae',
               'name': 'MY-APP8080',
               'type': 'tcpportobject',
               'version': 'o6uofdgc7jjqg'}],
  'type': 'portobjectgroup',
  'version': 'najpv3ahvumwg'},
 {'description': None,
  'id': '96b24f49-503c-11eb-aab5-538789755de0',
  'isSystemDefined': False,
  'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/portgroups/96b24f49-503c-11eb-aab5-538789755de0'},
  'name': 'MY-HTTP-GROUP',
  'objects': [{'id': '959aebd0-503c-11eb-aab5-5962006643ab',
               'name': 'MY-HTTP8001',
               'type': 'tcpportobject',
               'version': 'j52i2zhi2vdmj'},
              {'id': '95cc3503-503c-11eb-aab5-99f174e74471',
               'name': 'MY-HTTP8002',
               'type': 'tcpportobject',
               'version': 'og4ujvn4b7gvt'}],
  'type': 'portobjectgroup',
  'version': 'lb2muyfaazmcz'}]
get_port_obj_or_grp(name) → dict

Get a Port (tcp/udp/icmpv4/icmpv6) object or PortGroup by the given name

Parameters

name (str) – Name of the object/group to find

Returns

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

Return type

dict

>>> fdm.get_port_obj_or_grp('BIG6')
{'description': 'A very large ICMPv6',
 'icmpv6Code': None,
 'icmpv6Type': 'PACKET_TOO_BIG',
 'id': '10d19dae-5458-11eb-aab5-e946ff8eb526',
 'isSystemDefined': False,
 'links': {'self': 'https://192.168.133.7/api/fdm/latest/object/icmpv6ports/10d19dae-5458-11eb-aab5-e946ff8eb526'},
 'name': 'BIG6',
 'type': 'icmpv6portobject',
 'version': 'lrerbmosmioew'}
get_tcp_ports(name='')

Gets all TCP type Ports or a single TCP Port object if a name is provided

Parameters

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

Returns

A list of all TCP Ports if no name is provided, or a dict of the single TCP Port with the given name

Return type

list|dict

get_udp_ports(name='')

Gets all UDP type Ports or a single UDP Port object if a name is provided

Parameters

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

Returns

A list of all UDP Ports if no name is provided, or a dict of the single UDP Port with the given name

Return type

list|dict