diff --git a/cterasdk/edge/antivirus.py b/cterasdk/edge/antivirus.py new file mode 100644 index 00000000..76e0686a --- /dev/null +++ b/cterasdk/edge/antivirus.py @@ -0,0 +1,65 @@ +import logging +from .enum import Mode +from .base_command import BaseCommand + + +logger = logging.getLogger('cterasdk.edge') + + +class Antivirus(BaseCommand): + """Edge Filer Antivirus APIs""" + + def __init__(self, edge): + super().__init__(edge) + self.settings = Settings(self._edge) + + def enable(self): + """ + Enable Bit Defender antivirus. + """ + logger.info('Enabling antivirus.') + response = self._edge.api.put('/config/av/realtime/mode', Mode.Enabled) + logger.info('Antivirus enabled.') + return response + + def disable(self): + """ + Disable Bit Defender antivirus. + """ + logger.info('Disabling antivirus.') + response = self._edge.api.put('/config/av/realtime/mode', Mode.Disabled) + logger.info('Antivirus disabled.') + return response + + def update(self): + """ + Check for updates. + """ + return self._edge.api.execute('/config/av/updates', 'updatenow') + + def status(self): + """ + Get Status. + """ + return self._edge.api.get('/status/av') + + +class Settings(BaseCommand): + + def get(self): + """ + Get antivirus settings. + """ + return self._edge.api.get('/config/av/updates') + + def update(self, schedule, disabled=False): + """ + Update antivirus settings. + + :param cterasdk.edge.types.AntivirusUpdateSchedule schedule: Antivirus update schedule + :param bool,optional disabled: Enable or disable automatic updates, defaults to ``False`` + """ + settings = self.get() + settings.mode = Mode.Disabled if disabled is True else Mode.Enabled + settings.schedule = schedule + return self._edge.api.put('/config/av/updates', settings) diff --git a/cterasdk/edge/types.py b/cterasdk/edge/types.py index fe2f1149..e212184b 100644 --- a/cterasdk/edge/types.py +++ b/cterasdk/edge/types.py @@ -313,3 +313,41 @@ def __init__(self, size, usage): self.dedup = dedup self.savings = f"{savings:.2%}" + + +class AntivirusUpdateSchedule(Object): + """ + Edge Filer Antivirus Update Schedule + """ + + @staticmethod + def daily(hour, minute): + """ + Daily update. + + :param int hour: Hour + :param int minute: Minute + """ + return AntivirusUpdateSchedule(mode='daily', daily=Object(hour=hour, minute=minute)) + + @staticmethod + def weekly(day, hour, minute): + """ + Weekly update. + + :param cterasdk.common.enum.DayOfWeek day: Day + :param int hour: Hour + :param int minute: Minute + """ + return AntivirusUpdateSchedule(mode='weekly', weekly=Object(day=day, hour=hour, minute=minute)) + + @staticmethod + def monthly(day, hour, minute): + """ + Monthly update. + + :param int day: Day + :param int hour: Hour + :param int minute: Minute + """ + return AntivirusUpdateSchedule(mode='monthly', monthly=Object(day=day, hour=hour, minute=minute)) diff --git a/cterasdk/objects/synchronous/edge.py b/cterasdk/objects/synchronous/edge.py index 50728c72..8f9eea80 100644 --- a/cterasdk/objects/synchronous/edge.py +++ b/cterasdk/objects/synchronous/edge.py @@ -6,7 +6,7 @@ from ...lib.session.edge import Session from ...edge import ( - afp, aio, array, audit, backup, cache, cli, config, connection, ctera_migrate, + afp, aio, antivirus, array, audit, backup, cache, cli, config, connection, ctera_migrate, dedup, directoryservice, drive, files, firmware, ftp, groups, licenses, login, logs, mail, network, nfs, ntp, power, remote, rsync, ransom_protect, services, shares, shell, smb, snmp, ssh, ssl, support, sync, syslog, taskmgr, telnet, @@ -75,6 +75,7 @@ def __init__(self, host=None, port=None, https=True, Portal=None, *, base=None): self._ctera_clients = Clients(self, Portal) self.afp = afp.AFP(self) self.aio = aio.AIO(self) + self.antivirus = antivirus.Antivirus(self) self.array = array.Array(self) self.audit = audit.Audit(self) self.backup = backup.Backup(self) diff --git a/docs/source/UserGuides/Edge/Configuration.rst b/docs/source/UserGuides/Edge/Configuration.rst index c23030d4..16b611e6 100644 --- a/docs/source/UserGuides/Edge/Configuration.rst +++ b/docs/source/UserGuides/Edge/Configuration.rst @@ -1020,6 +1020,80 @@ Diagnostics edge.network.iperf('192.168.1.145', protocol=edge_enum.IPProtocol.UDP) # Use UDP + +Antivirus +========= + +.. automethod:: cterasdk.edge.antivirus.Antivirus.enable + :noindex: + +.. code-block:: python + + edge.antivirus.settings.enable() + +.. automethod:: cterasdk.edge.antivirus.Antivirus.disable + :noindex: + +.. code-block:: python + + edge.antivirus.settings.disable() + +.. automethod:: cterasdk.edge.antivirus.Antivirus.update + :noindex: + +.. code-block:: python + + edge.antivirus.settings.update() + +.. automethod:: cterasdk.edge.antivirus.Antivirus.status + :noindex: + +.. code-block:: python + + edge.antivirus.settings.status() + +.. automethod:: cterasdk.edge.antivirus.Settings.get + :noindex: + +.. code-block:: python + + edge.antivirus.settings.get() + +.. automethod:: cterasdk.edge.antivirus.Settings.update + :noindex: + +.. code-block:: python + + edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.daily(5, 0)) # Daily at 5:00 am + edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.weekly(common_enum.DayOfWeek.Tuesday, 2, 15)) # Tuesdays at 2:15 am + edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.monthly(15, 15, 30)) # Every 15th at 3:30 pm + + +Ransomware Protection +===================== + +.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.get_configuration + :noindex: + +.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.enable + :noindex: + +.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.disable + :noindex: + +.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.is_disabled + :noindex: + +.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.modify + :noindex: + +.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.incidents + :noindex: + +.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.details + :noindex: + + Mail Server =========== diff --git a/docs/source/UserGuides/Miscellaneous/Changelog.rst b/docs/source/UserGuides/Miscellaneous/Changelog.rst index de41e88a..219e8e9b 100644 --- a/docs/source/UserGuides/Miscellaneous/Changelog.rst +++ b/docs/source/UserGuides/Miscellaneous/Changelog.rst @@ -7,7 +7,9 @@ Changelog Improvements ^^^^^^^^^^^^ -* Support retrieving, adding, and removing Edge Filer hosts file entries +* Support retrieving, adding, and removing Edge Filer hosts file entries. +* Add documentation for the Edge Filer Ransomware Protection APIs. +* Add support for managing the Edge Filer's Antivirus (Bit Defender). Bug Fixes ^^^^^^^^^ @@ -17,7 +19,8 @@ Bug Fixes Related issues and pull requests on GitHub: `#306 `_, `#307 `_, -`#308 `_ +`#308 `_, +`#309 `_ 2.20.14