2023-10-01 17:47:35 +00:00
|
|
|
from flask.views import MethodView
|
|
|
|
import marshmallow as ma
|
|
|
|
|
2023-10-01 19:40:06 +00:00
|
|
|
from database import Database
|
2023-10-01 17:47:35 +00:00
|
|
|
from . import routes_requests as blp
|
|
|
|
|
2023-10-01 19:40:06 +00:00
|
|
|
db = Database.get_instance().db
|
|
|
|
|
|
|
|
class RequestsAll(ma.Schema):
|
|
|
|
uuid = ma.fields.String(description="UUID v4", example="3f6dd2e5-8cb1-4ce0-82e4-b68edf4ce37a")
|
|
|
|
status = ma.fields.String()
|
2023-10-01 17:47:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
@blp.route("/all")
|
|
|
|
class AllRequests(MethodView):
|
|
|
|
@blp.doc(summary="Returns all requests")
|
2023-10-01 19:40:06 +00:00
|
|
|
@blp.response(200, RequestsAll(many=True), description="Successful operation")
|
2023-10-01 17:47:35 +00:00
|
|
|
def get(self):
|
2023-10-01 19:40:06 +00:00
|
|
|
db_data = db.at("requests").read()
|
|
|
|
response = []
|
|
|
|
for key, value in db_data.items():
|
|
|
|
response.append({"uuid": key, **value})
|
2023-10-01 17:47:35 +00:00
|
|
|
return response
|