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:
|
class Monitoring:
|
||||||
@strawberry.field
|
@strawberry.field
|
||||||
def disk_usage(
|
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:
|
) -> PrometheusQueryResult:
|
||||||
return PrometheusQueries.disk_usage(start, end, step)
|
return PrometheusQueries.disk_usage(start, end, step)
|
||||||
|
|
||||||
@strawberry.field
|
@strawberry.field
|
||||||
def memory_usage(
|
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:
|
) -> PrometheusQueryResult:
|
||||||
return PrometheusQueries.memory_usage(start, end, step)
|
return PrometheusQueries.memory_usage(start, end, step)
|
||||||
|
|
||||||
@strawberry.field
|
@strawberry.field
|
||||||
def cpu_usage(
|
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:
|
) -> PrometheusQueryResult:
|
||||||
return PrometheusQueries.cpu_usage(start, end, step)
|
return PrometheusQueries.cpu_usage(start, end, step)
|
||||||
|
|
|
@ -36,11 +36,11 @@ class PrometheusQueries:
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise Exception("Prometheus returned unexpected HTTP status code")
|
raise Exception("Prometheus returned unexpected HTTP status code")
|
||||||
json = response.json()
|
json = response.json()
|
||||||
if json['status'] != 'success':
|
if json["status"] != "success":
|
||||||
raise Exception("Prometheus returned unexpected status")
|
raise Exception("Prometheus returned unexpected status")
|
||||||
result = json['data']
|
result = json["data"]
|
||||||
return PrometheusQueryResult(
|
return PrometheusQueryResult(
|
||||||
result_type=result['resultType'], result=result['result']
|
result_type=result["resultType"], result=result["result"]
|
||||||
)
|
)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
raise Exception("Prometheus request failed! " + str(error))
|
raise Exception("Prometheus request failed! " + str(error))
|
||||||
|
|
Loading…
Reference in a new issue