admin 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 admin.AclRule(api_client)[source]

Bases: object

Class for working with Local Service ACL Exception Rules.

create(name, description, position, source_zone, source_list, dest_list, service_list, action, debug)[source]

Create Local Service ACL Exception Rule (System > Administration > Device Access > Local service ACL exception)

Parameters:
  • name (str) – Name of the ACL exception rule to update.

  • description (str) – Rule description.

  • position (str) – Location to place the ACL (Top or Bottom).

  • source_zone (str) – Source Zone. Defaults to Any.

  • source_list (list, optional) – List of source network or host groups. Defaults to None.

  • dest_list (list, optional) – List of destination hosts. Defaults to None.

  • service_list (list, optional) – List of services. Defaults to None.

  • action (str, optional) – Accept or Drop. Default is Accept.

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

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

Get Local ACL Exception rules

Parameters:
  • name (str, optional) – Name of rule to retrieve. 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, description, source_zone, source_list, dest_list, service_list, action, update_action, debug)[source]

Update Local Service ACL Exception Rule (System > Administration > Device Access > Local service ACL exception)

Parameters:
  • name (str) – Name of the ACL rule to update.

  • description (str) – Rule description.

  • source_zone (str) – Name of the source zone. Defaults to None.

  • source_list (list, optional) – List of network or host groups. Defaults to [].

  • dest_list (list, optional) – List of destinations. Defaults to [].

  • service_list (list, optional) – List of services. Defaults to [].

  • action (str, optional) – Accept or Drop.

  • update_action (str, optional) – Indicate whether to ‘add’ or ‘remove’ from source, dest, or service lists, or to ‘replace’ the lists. Default is ‘add’.

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

class admin.AdminSettings(api_client)[source]

Bases: object

Class for working with Admin and user settings (System > Administration).

get()[source]

Get Admin and user settings

Returns:

XML response converted to Python dictionary

Return type:

dict

update_hostname_settings(hostname=None, description=None, debug=False)[source]

Update hostname admin settings.

Parameters:
  • hostname (str, optional) – Hostname. Defaults to None.

  • description (str, optional) – Hostname description. Defaults to None.

Returns:

XML response converted to Python dictionary

Return type:

dict

update_login_disclaimer(enabled: bool = False, debug: bool = False)[source]

Update login disclaimer. System > Administration > Admin and user settings.

Parameters:

enabled (bool, optional) – Enable or disable Login Disclaimer. Defaults to True.

Returns:

XML response converted to Python dictionary

Return type:

dict

update_loginsecurity_settings(logout_session=None, block_login=None, unsuccessful_attempt=None, duration=None, minutes=None, debug=False)[source]

Update login security admin settings. System > Administration > Admin and user settings.

Parameters:
  • logout_session (str, optional) – Enable/disable logout session. Specify number of minutes to enable. Defaults to None.

  • block_login (str, optional) – Enable/disable block login. Defaults to None.

  • unsuccessful_attempt (str, optional) – Set number of unsuccessful attempts. Defaults to None.

  • duration (str, optional) – Set block login duration. Defaults to None.

  • minutes (str, optional) – Set number of minutes for block login. Defaults to None.

Returns:

XML response converted to Python dictionary

Return type:

dict

update_passwordcomplexity_settings(complexity_check=None, enforce_min_length=None, include_alpha=None, include_numeric=None, include_special=None, min_length=None, debug=False)[source]

Update password complexity settings. System > Administration > Admin and user settings.

Parameters:
  • complexity_check (str, optional) – Enable/disable password complexity check. Defaults to None.

  • enforce_min_length (str, optional) – Enforce minimum required password length. Defaults to None.

  • include_alpha (str, optional) – Enforce inclusion of alphanumeric characters. Defaults to None.

  • include_numeric (str, optional) – Enforce inclusion numeric characters. Defaults to None.

  • include_special (str, optional) – Enforce inclusion of special characters. Defaults to None.

  • min_length (str, optional) – Minimul required password length. Defaults to None.

Returns:

XML response converted to Python dictionary

Return type:

dict

update_webadmin_settings(certificate=None, https_port=None, userportal_https_port=None, vpnportal_https_port=None, portal_redirect_mode=None, portal_custom_hostname=None, debug=False)[source]

Update webadmin settings. System > Administration > Admin and user settings.

Parameters:
  • certificate (str, optional) – SSL Certificate name. Defaults to None.

  • https_port (str, optional) – HTTPS port for admin interface. Defaults to None.

  • userportal_https_port (str, optional) – HTTPS port for User portal. Defaults to None.

  • vpnportal_https_port (str, optional) – HTTPS port for VPN portal. Defaults to None.

  • portal_redirect_mode (str, optional) – Portal redirect mode. Defaults to None.

  • portal_custom_hostname (str, optional) – Portal custom hostname. Defaults to None.

Returns:

XML response converted to Python dictionary

Return type:

dict

class admin.Notification(api_client)[source]

Bases: object

Class for working with Notification settings.

get(name)[source]

Get notification.

Parameters:

name (str, optional) – Name of notification. Returns all if not specified.

Returns:

XML response converted to Python dictionary

Return type:

dict