]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/feedback/service.py
1 # -*- coding: utf-8 -*-
5 from requests
.exceptions
import RequestException
7 from .model
import Feedback
10 url
= 'tracker.ceph.com'
13 class CephTrackerClient():
15 def list_issues(self
):
17 Fetch an issue from the Ceph Issue tracker
20 'Content-Type': 'application/json',
22 response
= requests
.get(
23 f
'https://{config.url}/issues.json', headers
=headers
)
25 if response
.status_code
== 404:
26 raise FileNotFoundError
27 raise RequestException(response
.status_code
)
28 return {"message": response
.json()}
30 def create_issue(self
, feedback
: Feedback
, api_key
: str):
32 Create an issue in the Ceph Issue tracker
36 'Content-Type': 'application/json',
37 'X-Redmine-API-Key': api_key
,
40 raise Exception("Ceph Tracker API Key not set")
41 data
= json
.dumps(feedback
.as_dict())
42 response
= requests
.post(
43 f
'https://{config.url}/projects/{feedback.project_id}/issues.json',
44 headers
=headers
, data
=data
)
46 if response
.status_code
== 401:
47 raise RequestException("Unauthorized. Invalid issue tracker API key")
48 raise RequestException(response
.reason
)
49 return {"message": response
.json()}