From 96b163ba0086c27b40bcfdf76733448f20f5fee3 Mon Sep 17 00:00:00 2001 From: Dmitriy Smirnov Date: Fri, 12 Jul 2024 13:52:50 +0300 Subject: [PATCH] Add `not_fail_codes` parameter to `DecortController.decort_api_call` method --- module_utils/decort_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module_utils/decort_utils.py b/module_utils/decort_utils.py index b3cd0be..b920f35 100644 --- a/module_utils/decort_utils.py +++ b/module_utils/decort_utils.py @@ -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)