Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from m0nhawk/master
Browse files Browse the repository at this point in the history
Remerge original repo
  • Loading branch information
mbovo authored Jun 6, 2019
2 parents b272b16 + 9c1aba8 commit 791f7b7
Show file tree
Hide file tree
Showing 16 changed files with 426 additions and 328 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
<a name="unreleased"></a>
## [Unreleased]

### Chore
- **changelog:** 0.7.4


<a name="0.7.4"></a>
## [0.7.4] - 2019-06-05
### Chore
- **changelog:** 0.7.3
- **codestyle:** reformat
- **dep:** update
- **deps:** bump requests from 2.21.0 to 2.22.0

### Fix
- **api:** python2 Teams support, fix [#24](https://github.com/m0nhawk/grafana_api/issues/24)


<a name="0.7.3"></a>
Expand Down Expand Up @@ -137,7 +149,8 @@
- always deploy


[Unreleased]: https://github.com/m0nhawk/grafana_api/compare/0.7.3...HEAD
[Unreleased]: https://github.com/m0nhawk/grafana_api/compare/0.7.4...HEAD
[0.7.4]: https://github.com/m0nhawk/grafana_api/compare/0.7.3...0.7.4
[0.7.3]: https://github.com/m0nhawk/grafana_api/compare/0.7.2...0.7.3
[0.7.2]: https://github.com/m0nhawk/grafana_api/compare/0.7.1...0.7.2
[0.7.1]: https://github.com/m0nhawk/grafana_api/compare/0.7.0...0.7.1
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ requests = "~=2.22"
codecov = "~=2.0"
coverage = "~=4.5"
unittest-xml-reporting = "~=2.5"
requests-mock = "~=1.5"
requests-mock = "~=1.6"
2 changes: 1 addition & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions grafana_api/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def settings(self):
:return:
"""
path = '/admin/settings'
path = "/admin/settings"
r = self.api.GET(path)
return r

Expand All @@ -20,7 +20,7 @@ def stats(self):
:return:
"""
path = '/admin/stats'
path = "/admin/stats"
r = self.api.GET(path)
return r

Expand All @@ -30,7 +30,7 @@ def create_user(self, user):
:param user:
:return:
"""
create_user_path = '/admin/users'
create_user_path = "/admin/users"
r = self.api.POST(create_user_path, json=user)
return r

Expand All @@ -41,8 +41,8 @@ def change_user_password(self, user_id, password):
:param password:
:return:
"""
change_user_password_path = '/admin/users/%s/password' % user_id
r = self.api.PUT(change_user_password_path, json={'password': password})
change_user_password_path = "/admin/users/%s/password" % user_id
r = self.api.PUT(change_user_password_path, json={"password": password})
return r

def change_user_permissions(self, user_id, is_grafana_admin):
Expand All @@ -52,8 +52,10 @@ def change_user_permissions(self, user_id, is_grafana_admin):
:param is_grafana_admin:
:return:
"""
change_user_permissions = '/admin/users/%s/permissions' % user_id
r = self.api.PUT(change_user_permissions, json={'isGrafanaAdmin': is_grafana_admin})
change_user_permissions = "/admin/users/%s/permissions" % user_id
r = self.api.PUT(
change_user_permissions, json={"isGrafanaAdmin": is_grafana_admin}
)
return r

def delete_user(self, user_id):
Expand All @@ -62,7 +64,7 @@ def delete_user(self, user_id):
:param user_id:
:return:
"""
delete_user_path = '/admin/users/%s' % user_id
delete_user_path = "/admin/users/%s" % user_id
r = self.api.DELETE(delete_user_path)
return r

Expand All @@ -72,6 +74,6 @@ def pause_all_alerts(self, pause):
:param pause:
:return:
"""
change_user_permissions = self.path + '/pause-all-alerts'
r = self.api.POST(change_user_permissions, json={'paused': pause})
change_user_permissions = self.path + "/pause-all-alerts"
r = self.api.POST(change_user_permissions, json={"paused": pause})
return r
18 changes: 10 additions & 8 deletions grafana_api/api/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class Dashboard(Base):
def __init__(self, api):
super(Dashboard,self).__init__(api)
super(Dashboard, self).__init__(api)
self.api = api

def get_dashboard(self, dashboard_uid):
Expand All @@ -12,7 +12,7 @@ def get_dashboard(self, dashboard_uid):
:param dashboard_uid:
:return:
"""
get_dashboard_path = '/dashboards/uid/%s' % dashboard_uid
get_dashboard_path = "/dashboards/uid/%s" % dashboard_uid
r = self.api.GET(get_dashboard_path)
return r

Expand All @@ -22,7 +22,7 @@ def update_dashboard(self, dashboard):
:param dashboard:
:return:
"""
put_dashboard_path = '/dashboards/db'
put_dashboard_path = "/dashboards/db"
r = self.api.POST(put_dashboard_path, json=dashboard)
return r

Expand All @@ -32,7 +32,7 @@ def delete_dashboard(self, dashboard_uid):
:param dashboard_uid:
:return:
"""
delete_dashboard_path = '/dashboards/uid/%s' % dashboard_uid
delete_dashboard_path = "/dashboards/uid/%s" % dashboard_uid
r = self.api.DELETE(delete_dashboard_path)
return r

Expand All @@ -41,7 +41,7 @@ def get_home_dashboard(self):
:return:
"""
get_home_dashboard_path = '/dashboards/home'
get_home_dashboard_path = "/dashboards/home"
r = self.api.GET(get_home_dashboard_path)
return r

Expand All @@ -50,7 +50,7 @@ def get_dashboards_tags(self):
:return:
"""
get_dashboards_tags_path = '/dashboards/tags'
get_dashboards_tags_path = "/dashboards/tags"
r = self.api.GET(get_dashboards_tags_path)
return r

Expand All @@ -60,7 +60,7 @@ def get_dashboard_permissions(self, dashboard_id):
:param dashboard_id:
:return:
"""
get_dashboard_permissions_path = '/dashboards/id/%s/permissions' % dashboard_id
get_dashboard_permissions_path = "/dashboards/id/%s/permissions" % dashboard_id
r = self.api.GET(get_dashboard_permissions_path)
return r

Expand All @@ -71,6 +71,8 @@ def update_dashboard_permissions(self, dashboard_id, items):
:param items:
:return:
"""
update_dashboard_permissions_path = '/dashboards/id/%s/permissions' % dashboard_id
update_dashboard_permissions_path = (
"/dashboards/id/%s/permissions" % dashboard_id
)
r = self.api.POST(update_dashboard_permissions_path, json=items)
return r
20 changes: 10 additions & 10 deletions grafana_api/api/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class Datasource(Base):
def __init__(self, api):
super(Datasource,self).__init__(api)
super(Datasource, self).__init__(api)
self.api = api

def find_datasource(self, datasource_name):
Expand All @@ -12,7 +12,7 @@ def find_datasource(self, datasource_name):
:param datasource_name:
:return:
"""
get_datasource_path = '/datasources/name/%s' % datasource_name
get_datasource_path = "/datasources/name/%s" % datasource_name
r = self.api.GET(get_datasource_path)
return r

Expand All @@ -22,7 +22,7 @@ def get_datasource_by_id(self, datasource_id):
:param datasource_id:
:return:
"""
get_datasource_path = '/datasources/%s' % datasource_id
get_datasource_path = "/datasources/%s" % datasource_id
r = self.api.GET(get_datasource_path)
return r

Expand All @@ -32,7 +32,7 @@ def get_datasource_by_name(self, datasource_name):
:param datasource_name:
:return:
"""
get_datasource_path = '/datasources/name/%s' % datasource_name
get_datasource_path = "/datasources/name/%s" % datasource_name
r = self.api.GET(get_datasource_path)
return r

Expand All @@ -42,7 +42,7 @@ def get_datasource_id_by_name(self, datasource_name):
:param datasource_name:
:return:
"""
get_datasource_path = '/datasources/id/%s' % datasource_name
get_datasource_path = "/datasources/id/%s" % datasource_name
r = self.api.GET(get_datasource_path)
return r

Expand All @@ -52,7 +52,7 @@ def create_datasource(self, datasource):
:param datasource:
:return:
"""
create_datasources_path = '/datasources'
create_datasources_path = "/datasources"
r = self.api.POST(create_datasources_path, json=datasource)
return r

Expand All @@ -63,7 +63,7 @@ def update_datasource(self, datasource_id, datasource):
:param datasource:
:return:
"""
update_datasource = '/datasources/%s' % datasource_id
update_datasource = "/datasources/%s" % datasource_id
r = self.api.PUT(update_datasource, json=datasource)
return r

Expand All @@ -72,7 +72,7 @@ def list_datasources(self):
:return:
"""
list_datasources_path = '/datasources'
list_datasources_path = "/datasources"
r = self.api.GET(list_datasources_path)
return r

Expand All @@ -82,7 +82,7 @@ def delete_datasource_by_id(self, datasource_id):
:param datasource_id:
:return:
"""
delete_datasource = '/datasources/%s' % datasource_id
delete_datasource = "/datasources/%s" % datasource_id
r = self.api.DELETE(delete_datasource)
return r

Expand All @@ -92,6 +92,6 @@ def delete_datasource_by_name(self, datasource_name):
:param datasource_name:
:return:
"""
delete_datasource = '/datasources/name/%s' % datasource_name
delete_datasource = "/datasources/name/%s" % datasource_name
r = self.api.DELETE(delete_datasource)
return r
24 changes: 11 additions & 13 deletions grafana_api/api/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

class Folder(Base):
def __init__(self, api):
super(Folder,self).__init__(api)
super(Folder, self).__init__(api)
self.api = api

def get_all_folders(self):
"""
:return:
"""
path = '/folders'
path = "/folders"
r = self.api.GET(path)
return r

Expand All @@ -21,7 +21,7 @@ def get_folder(self, uid):
:param uid:
:return:
"""
path = '/folders/%s' % uid
path = "/folders/%s" % uid
r = self.api.GET(path)
return r

Expand All @@ -34,8 +34,8 @@ def create_folder(self, title, uid=None):
"""
json_data = dict(title=title)
if uid is not None:
json_data['uid'] = uid
return self.api.POST('/folders', json=json_data)
json_data["uid"] = uid
return self.api.POST("/folders", json=json_data)

def update_folder(self, uid, title):
"""
Expand All @@ -44,10 +44,8 @@ def update_folder(self, uid, title):
:param title:
:return:
"""
path = '/folders' % uid
r = self.api.PUT(path, json={
"title": title
})
path = "/folders/%s" % uid
r = self.api.PUT(path, json={"title": title})
return r

def delete_folder(self, uid):
Expand All @@ -56,7 +54,7 @@ def delete_folder(self, uid):
:param uid:
:return:
"""
path = '/folders/%s' % uid
path = "/folders/%s" % uid
r = self.api.DELETE(path)
return r

Expand All @@ -66,7 +64,7 @@ def get_folder_by_id(self, folder_id):
:param folder_id:
:return:
"""
path = '/folders/id/%s' % folder_id
path = "/folders/id/%s" % folder_id
r = self.api.GET(path)
return r

Expand All @@ -75,7 +73,7 @@ def get_folder_permissions(self):
:return:
"""
path = '/folders/%s/permissions'
path = "/folders/%s/permissions"
r = self.api.GET(path)
return r

Expand All @@ -86,6 +84,6 @@ def update_folder_permissions(self, uid, items):
:param items:
:return:
"""
update_folder_permissions_path = '/folders/%s/permissions' % uid
update_folder_permissions_path = "/folders/%s/permissions" % uid
r = self.api.POST(update_folder_permissions_path, json=items)
return r
Loading

0 comments on commit 791f7b7

Please sign in to comment.