network 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 network.Interface(api_client)[source]

Bases: object

Class for working with Interface(s).

get(name, operator)[source]

Get Interface object(s)

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

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

class network.Vlan(api_client)[source]

Bases: object

Class for working with Vlan(s).

get(name, operator)[source]

Get VLAN object(s)

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

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

class network.Zone(api_client)[source]

Bases: object

Class for working with Zone(s).

check_exists(existing_dict, container, key)[source]

Search API response to get current value for key.

Parameters:
  • existing_dict (dict) – The response from getting the current settings

  • container (str) – The top-level container to begin searching

  • key (str) – The key to search for, and if found return the value

Returns:

Returns the value of the key or None

Return type:

str

create(name: str, zone_type: str, zone_params: dict = None, debug: bool = False)[source]

Create a zone.

Parameters:
  • name (str) – Zone name

  • zone_type (str) – Zone type

  • zone_params (dict) – Configuration parmeters for the zone, see Keyword Args for supported parameters.

Keyword Arguments:
  • name (str) – Name of the Zone

  • zone_type (str) – Type of the zone (LAN/DMZ)

  • description (str, optional) – Description for the Zone

  • https (str, optional) – Enable/Disable HTTPS administrative service

  • ssh (str, optional) – Enable/Disable SSH administrative service

  • client_authen (str, optional) – Enable/Disable client authentication service

  • captive_portal (str, optional) – Enable/Disable captive portal

  • ad_sso (str, optional) – Enable/Disable SSO with Active Directory

  • radius_sso (str, optional) – Enable/Disable SSO with Radius

  • chromebook_sso (str, optional) – Enable/Disable Chromebook SSO

  • dns (str, optional) – Enable/Disable DNS

  • ping (str, optional) – Enable/Disable ping

  • ipsec (str, optional) – Enable/Disable ipsec

  • red (str, optional) – Enable/Disable RED

  • sslvpn (str, optional) – Enable/Disable SSL VPN

  • vpn_portal (str, optional) – Enable/Disable VPN Portal

  • web_proxy (str, optional) – Enable/Disable Web proxy

  • wireless_protection (str, optional) – Enable/Disable wireless protection

  • user_portal (str, optional) – Enable/Disable user portal

  • dynamic_routing (str, optional) – Enable/Disable dynamic routing

  • smtp_relay (str, optional) – Enable/Disable SMTP Relay

  • snmp (str, optional) – Enable/Disable SNMP

Returns:

XML response converted to Python dictionary

Return type:

dict

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

Get zone(s)

Parameters:
  • name (str, optional) – Name of zone to query. Returns all if not specified.

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

Returns:

XML response converted to Python dictionary

Return type:

dict

update(name: str, zone_params: dict = None, debug: bool = False)[source]

Update a zone.

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

  • zone_params (dict) – Configuration parmeters for the zone, see Keyword Args for supported parameters.

Keyword Arguments:
  • description (str, optional) – Description for the Zone

  • https (str, optional) – Enable/Disable HTTPS administrative service

  • ssh (str, optional) – Enable/Disable SSH administrative service

  • client_authen (str, optional) – Enable/Disable client authentication service

  • captive_portal (str, optional) – Enable/Disable captive portal

  • ad_sso (str, optional) – Enable/Disable SSO with Active Directory

  • radius_sso (str, optional) – Enable/Disable SSO with Radius

  • chromebook_sso (str, optional) – Enable/Disable Chromebook SSO

  • dns (str, optional) – Enable/Disable DNS

  • ping (str, optional) – Enable/Disable ping

  • ipsec (str, optional) – Enable/Disable ipsec

  • red (str, optional) – Enable/Disable RED

  • sslvpn (str, optional) – Enable/Disable SSL VPN

  • vpn_portal (str, optional) – Enable/Disable VPN Portal

  • web_proxy (str, optional) – Enable/Disable Web proxy

  • wireless_protection (str, optional) – Enable/Disable wireless protection

  • user_portal (str, optional) – Enable/Disable user portal

  • dynamic_routing (str, optional) – Enable/Disable dynamic routing

  • smtp_relay (str, optional) – Enable/Disable SMTP Relay

  • snmp (str, optional) – Enable/Disable SNMP

Returns:

XML response converted to Python dictionary

Return type:

dict