permission_app.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. from flask import request
  17. from fate_flow.controller.permission_controller import PermissionController
  18. from fate_flow.entity.permission_parameters import PermissionParameters
  19. from fate_flow.utils import api_utils
  20. from fate_flow.utils.api_utils import get_json_result
  21. @manager.route('/grant', methods=['post'])
  22. @api_utils.validate_request('party_id')
  23. def grant_permission():
  24. parameters = PermissionParameters(**request.json)
  25. PermissionController(parameters.party_id).grant_or_delete(parameters)
  26. return get_json_result(retcode=0, retmsg='success')
  27. @manager.route('/delete', methods=['post'])
  28. @api_utils.validate_request('party_id')
  29. def delete_permission():
  30. parameters = PermissionParameters(is_delete=True, **request.json)
  31. PermissionController(parameters.party_id).grant_or_delete(parameters)
  32. return get_json_result(retcode=0, retmsg='success')
  33. @manager.route('/query', methods=['post'])
  34. @api_utils.validate_request('party_id')
  35. def query_privilege():
  36. parameters = PermissionParameters(**request.json)
  37. data = PermissionController(parameters.party_id).query()
  38. return get_json_result(retcode=0, retmsg='success', data=data)