Skip to content

Commit 5b68221

Browse files
committed
Format code with black and isort
1 parent c066912 commit 5b68221

24 files changed

+356
-583
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
format:
2+
black grafana_client test
3+
isort grafana_client test

docs/backlog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
pep517.build is deprecated. Consider switching to https://pypi.org/project/build/
55
- Format code with `black` and `isort``
66
- Clarify *"To use admin API you need to use basic auth"*, see README.
7+
- Check contents of PyPI package vs. `MANIFEST.in`

grafana_client/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
from .client import GrafanaClient
22
from .elements import (
33
Admin,
4+
Annotations,
45
Dashboard,
56
Datasource,
67
Folder,
8+
Notifications,
79
Organization,
810
Organizations,
911
Search,
12+
Snapshots,
13+
Teams,
1014
User,
1115
Users,
12-
Teams,
13-
Snapshots,
14-
Annotations,
15-
Notifications
1616
)
1717

1818

grafana_client/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class GrafanaBadInputError(GrafanaClientError):
3333
"""
3434

3535
def __init__(self, response):
36-
super(GrafanaBadInputError, self).__init__(
37-
400, response, "Bad Input: `{0}`".format(response)
38-
)
36+
super(GrafanaBadInputError, self).__init__(400, response, "Bad Input: `{0}`".format(response))
3937

4038

4139
class GrafanaUnauthorizedError(GrafanaClientError):
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
from .base import Base
21
from .admin import Admin
2+
from .annotations import Annotations
3+
from .base import Base
34
from .dashboard import Dashboard
45
from .datasource import Datasource
56
from .folder import Folder
7+
from .notifications import Notifications
68
from .organization import Organization, Organizations
79
from .search import Search
8-
from .user import User, Users
9-
from .team import Teams
10-
from .annotations import Annotations
1110
from .snapshots import Snapshots
12-
from .notifications import Notifications
13-
11+
from .team import Teams
12+
from .user import User, Users

grafana_client/elements/admin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ def change_user_permissions(self, user_id, is_grafana_admin):
5353
:return:
5454
"""
5555
change_user_permissions = "/admin/users/%s/permissions" % user_id
56-
r = self.client.PUT(
57-
change_user_permissions, json={"isGrafanaAdmin": is_grafana_admin}
58-
)
56+
r = self.client.PUT(change_user_permissions, json={"isGrafanaAdmin": is_grafana_admin})
5957
return r
6058

6159
def delete_user(self, user_id):

grafana_client/elements/annotations.py

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ def get_annotation(
7272
return r
7373

7474
def add_annotation(
75-
self,
76-
dashboard_id=None,
77-
panel_id=None,
78-
time_from=None,
79-
time_to=None,
80-
tags=[],
81-
text=None,
75+
self,
76+
dashboard_id=None,
77+
panel_id=None,
78+
time_from=None,
79+
time_to=None,
80+
tags=[],
81+
text=None,
8282
):
8383

8484
"""
@@ -108,11 +108,11 @@ def add_annotation(
108108
return r
109109

110110
def add_annotation_graphite(
111-
self,
112-
what=None,
113-
tags=[],
114-
when=None,
115-
data=None,
111+
self,
112+
what=None,
113+
tags=[],
114+
when=None,
115+
data=None,
116116
):
117117
"""
118118
https://grafana.com/docs/grafana/latest/http_api/annotations/#create-annotation-in-graphite-format
@@ -125,24 +125,19 @@ def add_annotation_graphite(
125125
"""
126126

127127
annotations_path = "/annotations/graphite"
128-
payload = {
129-
"what": what,
130-
"tags": tags,
131-
"when": when,
132-
"data": data
133-
}
128+
payload = {"what": what, "tags": tags, "when": when, "data": data}
134129

135130
r = self.client.POST(annotations_path, json=payload)
136131

137132
return r
138133

139134
def update_annotation(
140-
self,
141-
annotations_id,
142-
time_from=None,
143-
time_to=None,
144-
tags=[],
145-
text=None,
135+
self,
136+
annotations_id,
137+
time_from=None,
138+
time_to=None,
139+
tags=[],
140+
text=None,
146141
):
147142
"""
148143
https://grafana.com/docs/grafana/latest/http_api/annotations/#update-annotation
@@ -154,24 +149,19 @@ def update_annotation(
154149
:return:
155150
"""
156151
annotations_path = "/annotations/{}".format(annotations_id)
157-
payload = {
158-
"time": time_from,
159-
"timeEnd": time_to,
160-
"tags": tags,
161-
"text": text
162-
}
152+
payload = {"time": time_from, "timeEnd": time_to, "tags": tags, "text": text}
163153

164154
r = self.client.PUT(annotations_path, json=payload)
165155

166156
return r
167157

168158
def partial_update_annotation(
169-
self,
170-
annotations_id,
171-
time_from=None,
172-
time_to=None,
173-
tags=[],
174-
text=None,
159+
self,
160+
annotations_id,
161+
time_from=None,
162+
time_to=None,
163+
tags=[],
164+
text=None,
175165
):
176166
"""
177167
https://grafana.com/docs/grafana/latest/http_api/annotations/#patch-annotation
@@ -186,21 +176,13 @@ def partial_update_annotation(
186176
annotations_path = "/annotations/{}".format(annotations_id)
187177
payload = {}
188178

189-
payload = {
190-
"time": time_from,
191-
"timeEnd": time_to,
192-
"tags": tags,
193-
"text": text
194-
}
179+
payload = {"time": time_from, "timeEnd": time_to, "tags": tags, "text": text}
195180

196181
r = self.client.PATCH(annotations_path, json=payload)
197182

198183
return r
199184

200-
def delete_annotations_by_id(
201-
self,
202-
annotations_id=None
203-
):
185+
def delete_annotations_by_id(self, annotations_id=None):
204186

205187
"""
206188
https://grafana.com/docs/grafana/latest/http_api/annotations/#delete-annotation-by-id

grafana_client/elements/dashboard.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ def update_dashboard_permissions(self, dashboard_id, items):
7171
:param items:
7272
:return:
7373
"""
74-
update_dashboard_permissions_path = (
75-
"/dashboards/id/%s/permissions" % dashboard_id
76-
)
74+
update_dashboard_permissions_path = "/dashboards/id/%s/permissions" % dashboard_id
7775
r = self.client.POST(update_dashboard_permissions_path, json=items)
7876
return r

grafana_client/elements/folder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ def update_folder(self, uid, title, version=None, overwrite=False):
4848
"""
4949
body = {"title": title}
5050
if version is not None:
51-
body['version'] = version
51+
body["version"] = version
5252
if overwrite:
53-
body['overwrite'] = True
53+
body["overwrite"] = True
5454

5555
path = "/folders/%s" % uid
5656
r = self.client.PUT(path, json=body)
@@ -76,7 +76,7 @@ def get_folder_by_id(self, folder_id):
7676
r = self.client.GET(path)
7777
return r
7878

79-
def get_folder_permissions(self,uid):
79+
def get_folder_permissions(self, uid):
8080
"""
8181
8282
:return:

grafana_client/elements/notifications.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ def delete_notification_by_uid(self, notification_uid):
8383
:param notification_uid: notification channel uid
8484
:return: result of deletion
8585
"""
86-
delete_notification_by_uid_path = (
87-
"/alert-notifications/uid/%s" % notification_uid
88-
)
86+
delete_notification_by_uid_path = "/alert-notifications/uid/%s" % notification_uid
8987
return self.client.DELETE(delete_notification_by_uid_path)
9088

9189
def delete_notification_by_id(self, notification_id):

0 commit comments

Comments
 (0)