Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Provide ability to configure the XML key for object lookup when updating #85

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.55"
version = "0.1.56"
description = "Python SDK for Sophos Firewall"
authors = ["Matt Mullen <matt.mullen@sophos.com>"]
readme = "README.md"
Expand Down
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
Loading