feat: expand onion service api
This commit is contained in:
parent
c1b385ed99
commit
e5976c4739
11 changed files with 646 additions and 348 deletions
|
@ -99,3 +99,23 @@ def list_resources( # pylint: disable=too-many-arguments,too-many-locals
|
|||
except Exception: # pylint: disable=broad-exception-caught
|
||||
logger.exception("An unexpected error occurred")
|
||||
abort(500)
|
||||
|
||||
|
||||
def get_single_resource(model: Type[Any], id_: int, resource_name: str) -> ResponseReturnValue:
|
||||
try:
|
||||
resource = db.session.get(model, id_)
|
||||
if not resource:
|
||||
return jsonify({
|
||||
"Error": "resource_not_found",
|
||||
"Message": f"No {resource_name} found with ID {id_}"
|
||||
}), 404
|
||||
return jsonify({resource_name: resource.to_dict()}), 200
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
logger.exception("An unexpected error occurred while retrieving the onion")
|
||||
abort(500)
|
||||
|
||||
|
||||
def validate_description(description: Optional[str]) -> bool:
|
||||
if description is None:
|
||||
return False
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue