routes.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from flask_security import auth_token_required
  2. from flexmeasures.auth.decorators import roles_required
  3. from flexmeasures.auth.policy import ADMIN_ROLE
  4. from flexmeasures.api.play import (
  5. flexmeasures_api as flexmeasures_api_play,
  6. implementations as play_implementations,
  7. )
  8. @flexmeasures_api_play.route("/restoreData", methods=["PUT"])
  9. @auth_token_required
  10. @roles_required(ADMIN_ROLE)
  11. def restore_data():
  12. """API endpoint to restore the database to one of the saved backups.
  13. .. :quickref: Admin; Restore the database to a known backup
  14. **Example request**
  15. This message restores the database to a backup named demo_v0.
  16. .. code-block:: json
  17. {
  18. "backup": "demo_v0"
  19. }
  20. **Example response**
  21. This message indicates that the backup has been restored without any error.
  22. .. sourcecode:: json
  23. {
  24. "message": "Request has been processed. Database restored to demo_v0.",
  25. "status": "PROCESSED"
  26. }
  27. :reqheader Authorization: The authentication token
  28. :reqheader Content-Type: application/json
  29. :resheader Content-Type: application/json
  30. :status 200: PROCESSED
  31. :status 400: NO_BACKUP, UNRECOGNIZED_BACKUP
  32. :status 401: UNAUTHORIZED
  33. :status 405: INVALID_METHOD
  34. """
  35. return play_implementations.restore_data_response()