Skip to content

Commit

Permalink
Fix: allow unnamed updates (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamullen13316 authored Dec 13, 2023
1 parent 6099759 commit c41645e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "sophosfirewall-python"
packages = [
{ include = "sophosfirewall_python" },
]
version = "0.1.24"
version = "0.1.25"
description = "Python SDK for Sophos Firewall"
authors = ["Matt Mullen <[email protected]>"]
readme = "README.md"
Expand Down
19 changes: 12 additions & 7 deletions sophosfirewall_python/firewallapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,25 @@ def remove(self, xml_tag: str, name: str, output_format: str = "dict"):
return resp.content.decode()
return xmltodict.parse(resp.content.decode())

def update(self, xml_tag: str, name: str, update_params: dict, output_format: str = "dict"):
def update(self, xml_tag: str, update_params: dict, name: str = None, output_format: str = "dict"):
"""Update an existing object on the firewall.
Args:
xml_tag (str): The XML tag indicating the type of object to be updated.
name (str): The name of the object to be updated.
update_params (dict): Keys/values to be updated. Keys must match an existing XML key.
name (str, optional): The name of the object to be updated, if applicable.
output_format(str): Output format. Valid options are "dict" or "xml". Defaults to dict.
"""
resp = self.get_tag_with_filter(
xml_tag=xml_tag,
key="Name",
value=name,
operator="=")
if name:
resp = self.get_tag_with_filter(
xml_tag=xml_tag,
key="Name",
value=name,
operator="=")
else:
resp = self.get_tag(
xml_tag=xml_tag
)

for key in update_params:
resp["Response"][xml_tag][key] = update_params[key]
Expand Down

0 comments on commit c41645e

Please sign in to comment.