Skip to content
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
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Brewtils Changelog
------
TBD

- Added support for SystemClient to define choice_validation_enabled flag during initialization or command execution.
Default behavior is to skip choice validation if a parent request is present. (#585)
Examples: SystemClient(..., choice_validation_enabled=True) or SystemClient().call_command(..., _choice_validation_enabled=True)
- Added Target-Garden header to set target garden when provided in kwargs

3.32.0
Expand Down
14 changes: 13 additions & 1 deletion brewtils/rest/system_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class SystemClient(object):
to each namespace to help load balance the requests. It will rotate per
Request to the target system.

choice_validation_enabled:
Flag controlling whether choice validation is enabled when creating
requests. Valid options are True, False, and None. True will enable
full choice validation, False will disable it, and None will use the
default behavior. Default is None for System Clients.

Loading the System:
The System definition is lazily loaded, so nothing happens until the first
attempt to send a Request. At that point the SystemClient will query Beer-garden
Expand Down Expand Up @@ -179,7 +185,8 @@ class SystemClient(object):
Only has an effect when blocking=False.
raise_on_error (bool): Flag controlling whether created Requests that complete
with an ERROR state should raise an exception

choice_validation_enabled (bool): Flag controlling whether choice validation is
enabled when creating requests.
bg_host (str): Beer-garden hostname
bg_port (int): Beer-garden port
bg_url_prefix (str): URL path that will be used as a prefix when communicating
Expand Down Expand Up @@ -267,6 +274,7 @@ def __init__(self, *args, **kwargs):
self._max_delay = kwargs.get("max_delay", 30)
self._blocking = kwargs.get("blocking", True)
self._raise_on_error = kwargs.get("raise_on_error", False)
self._choice_validation_enabled = kwargs.get("choice_validation_enabled", None)

# This is for Python 3.4 compatibility - max_workers MUST be non-None
# in that version. This logic is what was added in Python 3.5
Expand Down Expand Up @@ -415,6 +423,9 @@ def send_bg_request(self, *args, **kwargs):
raise_on_error = kwargs.pop("_raise_on_error", self._raise_on_error)
blocking = kwargs.pop("_blocking", self._blocking)
timeout = kwargs.pop("_timeout", self._timeout)
choice_validation_enabled = kwargs.pop(
"_choice_validation_enabled", self._choice_validation_enabled
)

# If the request fails validation and the version constraint allows,
# check for a new version and retry
Expand All @@ -426,6 +437,7 @@ def send_bg_request(self, *args, **kwargs):
request,
blocking=blocking,
timeout=timeout,
choice_validation_enabled=choice_validation_enabled,
target_garden=self._system.garden_name,
)

Expand Down
Loading