Skip to content

Commit

Permalink
fix: provide ability to configure the lookup key for objects when upd…
Browse files Browse the repository at this point in the history
…ating
  • Loading branch information
mamullen13316 committed Oct 15, 2024
1 parent 5a935c7 commit 1659f63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sophosfirewall_python/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def update(
xml_tag: str,
update_params: dict,
name: str = None,
lookup_key: str = "Name",
output_format: str = "dict",
debug: bool = False,
):
Expand All @@ -344,12 +345,13 @@ def update(
xml_tag (str): The XML tag indicating the type of 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.
lookup_key (str, optional): The XML key name to look up the name of the object. Default is "Name".
output_format(str): Output format. Valid options are "dict" or "xml". Defaults to dict.
debug (bool): Displays the XML payload that was submitted
"""
if name:
resp = self.get_tag_with_filter(
xml_tag=xml_tag, key="Name", value=name, operator="="
xml_tag=xml_tag, key=lookup_key, value=name, operator="="
)
else:
resp = self.get_tag(xml_tag=xml_tag)
Expand Down
4 changes: 3 additions & 1 deletion sophosfirewall_python/firewallapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def update(
xml_tag: str,
update_params: dict,
name: str = None,
lookup_key: str = "Name",
output_format: str = "dict",
debug: bool = False,
):
Expand All @@ -156,10 +157,11 @@ def update(
xml_tag (str): The XML tag indicating the type of 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.
lookup_key (str, optional): The XML key name to look up the name of the object. Default is "Name".
output_format(str): Output format. Valid options are "dict" or "xml". Defaults to dict.
debug (bool): Displays the XML payload that was submitted
"""
return self.client.update(xml_tag, update_params, name, output_format, debug)
return self.client.update(xml_tag, update_params, name, lookup_key, output_format, debug)

# METHODS FOR OBJECT RETRIEVAL (GET)

Expand Down

0 comments on commit 1659f63

Please sign in to comment.