Skip to content

Commit

Permalink
Allow Updating Admins
Browse files Browse the repository at this point in the history
This patch adjusts the API client to reflect the recent change in
DETERRES which allows users to update the list of admins.
  • Loading branch information
lkiesow committed Apr 20, 2023
1 parent a2e337a commit b116216
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions deterrersapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit b116216

Please sign in to comment.