Add annotation for result of the method DecortController.decort_api_call and improve its docstring code style

This commit is contained in:
2024-07-21 11:31:47 +03:00
parent 53938d9d94
commit 0cdfa6a0ec

View File

@@ -436,21 +436,37 @@ class DecortController(object):
return True return True
def decort_api_call(self, arg_req_function, arg_api_name, arg_params, def decort_api_call(
arg_files=None, not_fail_codes: None | list = None): self,
"""Wrapper around DECORT API calls. It uses authorization mode and credentials validated at the class arg_api_name,
instance creation to properly format API call and send it to the DECORT controller URL. arg_params,
If connection errors are detected, it aborts execution of the script and relay error messages to upstream arg_req_function,
Ansible process. arg_files=None,
If HTTP 503 error is detected the method will retry with increasing timeout, and if after max_retries there not_fail_codes: None | list = None,
still is HTTP 503 error, it will abort as above. ) -> requests.Response:
If any other HTTP error is detected, the method will abort immediately as above. """
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
@param arg_api_name: a string containing the path to the API name under DECORT controller URL 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 @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 max_retries = 5