mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
style: add self to make sure python isnt confused and format code
This commit is contained in:
parent
a24e36fa01
commit
2797b0b331
|
@ -7,18 +7,27 @@ from selfprivacy_api.utils.prometheus import PrometheusQueries, PrometheusQueryR
|
|||
class Monitoring:
|
||||
@strawberry.field
|
||||
def disk_usage(
|
||||
start: Optional[int] = None, end: Optional[int] = None, step: int = 60
|
||||
self,
|
||||
start: Optional[int] = None,
|
||||
end: Optional[int] = None,
|
||||
step: int = 60,
|
||||
) -> PrometheusQueryResult:
|
||||
return PrometheusQueries.disk_usage(start, end, step)
|
||||
|
||||
@strawberry.field
|
||||
def memory_usage(
|
||||
start: Optional[int] = None, end: Optional[int] = None, step: int = 60
|
||||
self,
|
||||
start: Optional[int] = None,
|
||||
end: Optional[int] = None,
|
||||
step: int = 60,
|
||||
) -> PrometheusQueryResult:
|
||||
return PrometheusQueries.memory_usage(start, end, step)
|
||||
|
||||
@strawberry.field
|
||||
def cpu_usage(
|
||||
start: Optional[int] = None, end: Optional[int] = None, step: int = 60
|
||||
self,
|
||||
start: Optional[int] = None,
|
||||
end: Optional[int] = None,
|
||||
step: int = 60,
|
||||
) -> PrometheusQueryResult:
|
||||
return PrometheusQueries.cpu_usage(start, end, step)
|
||||
|
|
|
@ -36,11 +36,11 @@ class PrometheusQueries:
|
|||
if response.status_code != 200:
|
||||
raise Exception("Prometheus returned unexpected HTTP status code")
|
||||
json = response.json()
|
||||
if json['status'] != 'success':
|
||||
if json["status"] != "success":
|
||||
raise Exception("Prometheus returned unexpected status")
|
||||
result = json['data']
|
||||
result = json["data"]
|
||||
return PrometheusQueryResult(
|
||||
result_type=result['resultType'], result=result['result']
|
||||
result_type=result["resultType"], result=result["result"]
|
||||
)
|
||||
except Exception as error:
|
||||
raise Exception("Prometheus request failed! " + str(error))
|
||||
|
|
Loading…
Reference in a new issue