From b116216c4a62ff8f7889f3c1f8845699b01426df Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Thu, 20 Apr 2023 15:48:10 +0200 Subject: [PATCH] Allow Updating Admins This patch adjusts the API client to reflect the recent change in DETERRES which allows users to update the list of admins. --- deterrersapi/__init__.py | 21 +++++++++++++++------ setup.py | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/deterrersapi/__init__.py b/deterrersapi/__init__.py index 08529ee..084cab3 100644 --- a/deterrersapi/__init__.py +++ b/deterrersapi/__init__.py @@ -141,21 +141,30 @@ def delete(self, ipv4: str) -> None: ''' return self.__delete('host/', {'ipv4_addr': ipv4}) - def update(self, ipv4: str, profile: str, firewall: str) -> None: + def update(self, ipv4: str, + profile: None | str = None, + firewall: None | str = None, + admins: None | list[str] = None) -> None: '''Update IP address information in DETERRERS. :param ipv4: IPv4 address to update :type ipv4: str :param profile: Firewall profile to use. Must be a valid profile or an empty string string. - :type profile: str + :type profile: str | None :param firewall: Host firewall. Must be one of the UI options or an empty string. - :type firewall: str + :type firewall: str | None + :param admins: List of admins for address + :type admins: list[str] | None ''' - data = {'ipv4_addr': ipv4, - 'service_profile': profile, - 'fw': firewall} + data = {'ipv4_addr': ipv4} + if profile is not None: + data['service_profile'] = profile + if firewall is not None: + data['fw'] = firewall + if admins is not None: + data['admin_ids'] = admins return self.__patch('host/', data) def action(self, ipv4: str, action: str) -> None: diff --git a/setup.py b/setup.py index 0b278b6..66f16d6 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def read(filename): setup( name='deterrers-api', - version='0.3', + version='0.4', description='Python API client for DETERRERS', url='https://github.com/virtUOS/deterrers-api', author='Lars Kiesow',