]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/controllers/feedback.py
1 # # -*- coding: utf-8 -*-
4 from ..exceptions
import DashboardException
5 from ..security
import Scope
6 from . import APIDoc
, APIRouter
, BaseController
, Endpoint
, ReadPermission
, RESTController
, UIRouter
7 from ._version
import APIVersion
10 @APIRouter('/feedback', Scope
.CONFIG_OPT
)
11 @APIDoc("Feedback API", "Report")
12 class FeedbackController(RESTController
):
14 @RESTController.MethodMap(version
=APIVersion
.EXPERIMENTAL
)
17 List all issues details.
20 response
= mgr
.remote('feedback', 'get_issues')
21 except RuntimeError as error
:
22 raise DashboardException(msg
=f
'Error in fetching issue list: {str(error)}',
23 http_status_code
=error
.status_code
,
27 @RESTController.MethodMap(version
=APIVersion
.EXPERIMENTAL
)
28 def create(self
, project
, tracker
, subject
, description
, api_key
=None):
31 :param project: The affected ceph component.
32 :param tracker: The tracker type.
33 :param subject: The title of the issue.
34 :param description: The description of the issue.
35 :param api_key: Ceph tracker api key.
38 response
= mgr
.remote('feedback', 'validate_and_create_issue',
39 project
, tracker
, subject
, description
, api_key
)
40 except RuntimeError as error
:
41 if "Invalid issue tracker API key" in str(error
):
42 raise DashboardException(msg
='Error in creating tracker issue: Invalid API key',
44 if "KeyError" in str(error
):
45 raise DashboardException(msg
=f
'Error in creating tracker issue: {error}',
47 raise DashboardException(msg
=f
'{error}',
54 @APIRouter('/feedback/api_key', Scope
.CONFIG_OPT
)
55 @APIDoc(group
="Report")
56 class FeedbackApiController(RESTController
):
58 @RESTController.MethodMap(version
=APIVersion
.EXPERIMENTAL
)
61 Returns Ceph tracker API key.
64 api_key
= mgr
.remote('feedback', 'get_api_key')
66 raise DashboardException(msg
='Feedback module not found.',
69 except RuntimeError as error
:
70 raise DashboardException(msg
=f
'{error}',
74 raise DashboardException(msg
='Issue tracker API key is not set',
78 @RESTController.MethodMap(version
=APIVersion
.EXPERIMENTAL
)
79 def create(self
, api_key
):
81 Sets Ceph tracker API key.
82 :param api_key: The Ceph tracker API key.
85 response
= mgr
.remote('feedback', 'set_api_key', api_key
)
86 except RuntimeError as error
:
87 raise DashboardException(msg
=f
'{error}',
91 @RESTController.MethodMap(version
=APIVersion
.EXPERIMENTAL
)
92 def bulk_delete(self
):
94 Deletes Ceph tracker API key.
97 response
= mgr
.remote('feedback', 'delete_api_key')
98 except RuntimeError as error
:
99 raise DashboardException(msg
=f
'{error}',
100 http_status_code
=500,
101 component
='feedback')
105 @UIRouter('/feedback/api_key', Scope
.CONFIG_OPT
)
106 class FeedbackUiController(BaseController
):
111 Checks if Ceph tracker API key is stored.
114 response
= mgr
.remote('feedback', 'is_api_key_set')
116 raise DashboardException(msg
='Feedback module is not enabled',
117 http_status_code
=404,
118 component
='feedback')