diff --git a/pyproject.toml b/pyproject.toml index 874be12..4765c5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] readme = "README.md" diff --git a/sophosfirewall_python/firewallapi.py b/sophosfirewall_python/firewallapi.py index 76a89ab..58f9a89 100644 --- a/sophosfirewall_python/firewallapi.py +++ b/sophosfirewall_python/firewallapi.py @@ -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]