web_interface.rest.helper module
- web_interface.rest.helper.error_message(error, targeted_url, request_data=None, return_code=400)
Create error response including error message and useful meta information, such as the request parameters.
- Parameters:
error (str) – String containing a reason why the request failed.
targeted_url (str) – Requested URL.
request_data (dict | None) – Parameters of the request.
return_code (int) – HTTP status code for response. Defaults to 400 Bad Request.
- Returns:
dict containing a response adhering to the FACT rest api guidelines.
- Return type:
tuple[dict, int]
- web_interface.rest.helper.get_boolean_from_request(request_parameters, name)
Retrieve a specific flag from the request parameters as a boolean.
- Parameters:
request_parameters (ImmutableMultiDict) – dict containing the request parameters.
name (str) – Identifier of the flag that is to be retrieved.
- Returns:
The retrieved flag as boolean.
- Return type:
bool
- web_interface.rest.helper.get_current_gmt()
Get the current unix time. The system value might depend on NTP.
- Returns:
Current time as unix timestamp integer.
- Return type:
int
- web_interface.rest.helper.get_paging(request_parameters)
Parse paging parameter offset and limit from request parameters.
- Parameters:
request_parameters (ImmutableMultiDict) – dict containing the request parameters.
- Returns:
The paging parameters offset and limit as integers.
- Return type:
tuple[int, int]
- web_interface.rest.helper.get_query(request_parameters)
Parse the query parameter from request parameters. Query is a dictionary representing a MongoDB query.
- Parameters:
request_parameters (ImmutableMultiDict) – dict containing the request parameters.
- Returns:
The MongoDB query as dict.
- Return type:
dict
- web_interface.rest.helper.get_update(request_parameters)
Parse the update parameter from request parameters. Update is a list of analysis plugins whose analysis results shall be updated.
- Parameters:
request_parameters (ImmutableMultiDict) – dict containing the request parameters.
- Returns:
The list of analysis plugins.
- Return type:
list
- web_interface.rest.helper.success_message(data, targeted_url, request_data=None, return_code=200)
Create success response including requested data and useful meta information, such as the request parameters.
- Parameters:
data (dict) – dict containing the requested data.
targeted_url (str) – Requested URL.
request_data (dict | None) – Parameters of the request.
return_code (int) – HTTP status code for response. Defaults to 200 OK.
- Returns:
dict containing a response adhering to the FACT rest api guidelines.
- Return type:
tuple[dict, int]