|
|
|
@ -436,21 +436,37 @@ class DecortController(object):
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
Ansible process.
|
|
|
|
|
If HTTP 503 error is detected the method will retry with increasing timeout, and if after max_retries there
|
|
|
|
|
still is HTTP 503 error, it will abort as above.
|
|
|
|
|
If any other HTTP error is detected, the method will abort immediately as above.
|
|
|
|
|
|
|
|
|
|
@param arg_req_function: function object to be called as part of API, e.g. requests.post or requests.get
|
|
|
|
|
@param arg_api_name: a string containing the path to the API name under DECORT controller URL
|
|
|
|
|
@param arg_params: a dictionary containing parameters to be passed to the API call
|
|
|
|
|
|
|
|
|
|
@return: api call response object as returned by the REST functions from Python "requests" module
|
|
|
|
|
def decort_api_call(
|
|
|
|
|
self,
|
|
|
|
|
arg_api_name,
|
|
|
|
|
arg_params,
|
|
|
|
|
arg_req_function,
|
|
|
|
|
arg_files=None,
|
|
|
|
|
not_fail_codes: None | list = None,
|
|
|
|
|
) -> requests.Response:
|
|
|
|
|
"""
|
|
|
|
|
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 Ansible process.
|
|
|
|
|
If HTTP 503 error is detected the method will retry with
|
|
|
|
|
increasing timeout, and if after max_retries there still is
|
|
|
|
|
HTTP 503 error, it will abort as above. If any other HTTP error
|
|
|
|
|
is detected, the method will abort immediately as above.
|
|
|
|
|
|
|
|
|
|
@param arg_api_name: a string containing the path to
|
|
|
|
|
the API name under DECORT controller URL
|
|
|
|
|
|
|
|
|
|
@param arg_params: a dictionary containing parameters to be
|
|
|
|
|
passed to the API call
|
|
|
|
|
|
|
|
|
|
@param arg_req_function: function object to be called as
|
|
|
|
|
part of API, e.g. requests.post or requests.get
|
|
|
|
|
|
|
|
|
|
@return: api call response object as returned by
|
|
|
|
|
the REST functions from Python "requests" module
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
max_retries = 5
|
|
|
|
|