host module

Copyright 2023 Sophos Ltd. All rights reserved. Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class host.FQDNHost(api_client)[source]

Bases: object

Class for working with FQDN Hosts.

create(name, fqdn, fqdn_group_list, description, debug)[source]

Create FQDN Host object.

Parameters:
  • name (str) – Name of the object.

  • fqdn (str) – FQDN string.

  • fqdn_group_list (list, optional) – List containing FQDN Host Group(s) to associate the FQDN Host.

  • description (str) – Description.

  • debug (bool, optional) – Turn on debugging. Defaults to False.

Returns:

XML response converted to Python dictionary.

Return type:

dict

get(name, operator='=')[source]

Get FQDN Host object(s)

Parameters:
  • name (str, optional) – FQDN Host name. Returns all objects if not specified.

  • operator (str, optional) – Operator for search. Default is “=”. Valid operators: =, !=, like.

update(name, fqdn_host_list, description, action, debug)[source]

Add or remove a FQDN Host from an FQDN Host Group.

Parameters:
  • name (str) – FQDN Host Group name.

  • description (str) – FQDN Host Group description.

  • fqdn_host_list (str) – List of FQDN Hosts to be added to or removed from the FQDN Host list.

  • action (str) – Options are ‘add’, ‘remove’ or ‘replace’. Specify None to disable updating FQDN Host List. Defaults to ‘add’.

  • debug (bool, optional) – Enable debug mode. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict

class host.FQDNHostGroup(api_client)[source]

Bases: object

Class for working with FQDN HostGroup(s).

create(name, fqdn_host_list, description, debug)[source]

Create FQDN HostGroup object.

Parameters:
  • name (str) – Name of the object.

  • fqdn_host_list (list, optional) – List containing FQDN Host(s) to associate the FQDN Host Group.

  • description (str) – Description.

  • debug (bool, optional) – Turn on debugging. Defaults to False.

Returns:

XML response converted to Python dictionary.

Return type:

dict

get(name, operator='=')[source]

Get FQDN HostGroup object(s)

Parameters:
  • name (str, optional) – FQDN HostGroup name. Returns all objects if not specified.

  • operator (str, optional) – Operator for search. Default is “=”. Valid operators: =, !=, like.

update(name, description, fqdn_host_list, action, debug)[source]

Add or remove a FQDN Host from an FQDN Host Group.

Parameters:
  • name (str) – FQDN Host Group name.

  • description (str) – FQDN Host Group description.

  • fqdn_host_list (str) – List of FQDN Hosts to be added to or removed from the FQDN Host list.

  • action (str) – Options are ‘add’, ‘remove’ or ‘replace’. Specify None to disable updating FQDN Host List. Defaults to ‘add’.

  • debug (bool, optional) – Enable debug mode. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict

class host.IPHost(api_client)[source]

Bases: object

Class for working with IP Host(s).

create(name, ip_address, mask, start_ip, end_ip, host_type, debug)[source]

Create IP Host.

Parameters:
  • name (str) – Name of the object

  • ip_address (str) – Host IP address or network in case of host_type=Network.

  • mask (str) – Subnet mask in dotted decimal format (ex. 255.255.255.0). Only used with type: Network.

  • start_ip (str) – Starting IP address in case of host_type=IPRange.

  • end_ip (str) – Ending IP address in case of host_type=IPRange.

  • host_type (str, optional) – Type of Host. Valid options: IP, Network, IPRange.

  • debug (bool, optional) – Turn on debugging. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict

get(name, ip_address, operator)[source]

Get IP Host object(s)

Parameters:
  • name (str, optional) – IP object name. Returns all objects if not specified.

  • ip_address (str, optional) – Query by IP Address.

  • operator (str, optional) – Operator for search. Default is “=”. Valid operators: =, !=, like.

class host.IPHostGroup(api_client)[source]

Bases: object

Class for working with IP Host Group(s).

create(name, host_list, description, debug)[source]

Create an IP Host Group

Parameters:
  • name (str) – IP Host Group name

  • description (str) – Host Group description

  • host_list (list) – List of existing IP hosts to add to the group

  • debug (bool, optional) – Enable debug mode. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict

get(name, operator='=')[source]

Get IP Host object(s)

Parameters:
  • name (str, optional) – IP object name. Returns all objects if not specified.

  • ip_address (str, optional) – Query by IP Address.

  • operator (str, optional) – Operator for search. Default is “=”. Valid operators: =, !=, like.

update(name, host_list, description, action, debug)[source]

Add or remove an IP Host from an IP HostGroup.

Parameters:
  • name (str) – IP Host Group name.

  • description (str) – IP Host Group description.

  • host_list (str) – List of IP Hosts to be added to or removed from the Host List.

  • action (str) – Options are ‘add’, ‘remove’ or ‘replace’. Specify None to disable updating Host List. Defaults to ‘add’.

  • debug (bool, optional) – Enable debug mode. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict

class host.IPNetwork(api_client)[source]

Bases: object

Class for working with Host of type Network.

create(name, ip_network, mask, debug)[source]

Create IP Host of type Network.

Parameters:
  • name (str) – Name of the object

  • ip_network (str) – IP network address

  • mask (str) – Subnet mask in dotted decimal format (ex. 255.255.255.0)

  • debug (bool, optional) – Turn on debugging. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict

class host.IPRange(api_client)[source]

Bases: object

Class for working with Host of type IPRange.

create(name, start_ip, end_ip, debug)[source]

Create IP Host of type IPRange.

Parameters:
  • name (str) – Name of the object

  • start_ip (str) – Starting IP address

  • end_ip (str) – Ending IP address

  • debug (bool, optional) – Turn on debugging. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict

class host.URLGroup(api_client)[source]

Bases: object

Class for working with URL Group(s).

create(name, domain_list, debug)[source]

Create a web URL Group

Parameters:
  • name (str) – URL Group name.

  • domain_list (list) – List of domains to added/removed/replaced.

  • debug (bool, optional) – Enable debug mode. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict

get(name, operator='=')[source]

Get URLGroup(s)

Parameters:
  • name (str, optional) – Get URLGroup by name. Defaults to None.

  • operator (str, optional) – Operator for search. Default is “=”. Valid operators: =, !=, like.

Returns:

dict

update(name, domain_list, action, debug)[source]

Add or remove a specified domain to/from a web URL Group

Parameters:
  • name (str) – URL Group name.

  • domain_list (list) – List of domains to added/removed/replaced.

  • action (str) – Options are ‘add’, ‘remove’ or ‘replace’. Defaults to ‘add’.

  • debug (bool, optional) – Enable debug mode. Defaults to False.

Returns:

XML response converted to Python dictionary

Return type:

dict