Merge branch 'BANS-468' into 'BANS-462'

Add `not_fail_codes` parameter to `DecortController.decort_api_call` method

See merge request rudecs/dev/decort-ansible!94
main
commit 89b03213df

@ -335,7 +335,8 @@ class DecortController(object):
return True
def decort_api_call(self, arg_req_function, arg_api_name, arg_params, arg_files=None):
def decort_api_call(self, arg_req_function, arg_api_name, arg_params,
arg_files=None, not_fail_codes: None | list = None):
"""Wrapper around DECORT API calls. It uses authorization mode and credentials validated at the class
instance creation to properly format API call and send it to the DECORT controller URL.
If connection errors are detected, it aborts execution of the script and relay error messages to upstream
@ -386,6 +387,8 @@ class DecortController(object):
if api_resp.status_code == 200:
return api_resp
elif not_fail_codes and api_resp.status_code in not_fail_codes:
return api_resp
elif api_resp.status_code == 503:
retry_timeout = 5 + 10 * (max_retries - retry_counter)
time.sleep(retry_timeout)

Loading…
Cancel
Save