kepler.api.common module¶
The module contains common utility functionality for the REST API implementation.
-
class
kepler.api.common.Response(request)¶ Bases:
objectThe class generates REST API response values.
-
error(reason, message=None)¶ Returns a response with “error” status.
-
failure(**kwargs)¶ Returns a result response with
result.success == False. The optional keyword arguments are inserted to the response result object.
-
invalid_parameters(message=None)¶ Returns an error response with “invalid parameters” as reason and optional message.
-
ok(**kwargs)¶ Returns a response with “ok” status.
-
result(success, **kwargs)¶ Returns a result response containing a result object with a mandatory success field.
-
success(**kwargs)¶ Returns a result response with
result.success == True. The optional keyword arguments are inserted to the response result object.
-
-
kepler.api.common.make_base_response()¶ The function returns a base for standard kepler REST API response.
-
kepler.api.common.make_error_response(reason, message=None)¶ The function returns a standard kepler REST API error response with status code “error”.
Parameters: - reason – The reason of the error.
- reason – The message describing the error.
-
kepler.api.common.make_invalid_parameters_response(message=None)¶
-
kepler.api.common.make_ok_response()¶ The function returns a standard kerpler REST API success response with status code “ok”.
-
kepler.api.common.make_response(**kwargs)¶ The function returns a generic kepler REST API success response. All specified keword arguments are appended to the response.
-
kepler.api.common.make_result_response(success, **kwargs)¶ The Response with
resultobject that contains a booleansuccessfield. The value of the field is given by the function parametersuccess.The function should be used to compose REST API result responses where the REST API call edits any resources. If the call is successful the
successmust beTrueand otherwiseFalse.Parameters: - success – Specifies if the call was successful or not.
- kwargs – Optional parameters added to the
resultobject.
Returns: The JSON serializable response dictionary.