style: add self to make sure python isnt confused and format code

This commit is contained in:
nhnn 2024-07-15 17:00:36 +03:00
parent a24e36fa01
commit 2797b0b331
2 changed files with 15 additions and 6 deletions

View file

@ -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)

View file

@ -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))