Skip to content

Commit 191502d

Browse files
committed
Make GrafanaApi(auth=) an optional argument
This makes it easier to connect to Grafana instances that do not require authentication.
1 parent bcd9506 commit 191502d

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
## in progress
44

55

6+
## 2.3.0 (2022-05-26)
7+
8+
* Make `GrafanaApi(auth=)` an optional argument. This makes it easier to
9+
connect to Grafana instances that do not require authentication.
10+
11+
612
## 2.2.1 (2022-05-20)
713

814
* Fix annotations query string parameter `dashboardId`. Thanks, @richbon75!

grafana_client/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class GrafanaApi:
2121
def __init__(
2222
self,
23-
auth,
23+
auth=None,
2424
host="localhost",
2525
port=None,
2626
url_path_prefix="",

grafana_client/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ def construct_api_url():
9191
self.url = construct_api_url()
9292

9393
self.s = requests.Session()
94-
if not isinstance(self.auth, tuple):
95-
self.auth = TokenAuth(self.auth)
96-
else:
97-
self.auth = requests.auth.HTTPBasicAuth(*self.auth)
94+
if self.auth is not None:
95+
if not isinstance(self.auth, tuple):
96+
self.auth = TokenAuth(self.auth)
97+
else:
98+
self.auth = requests.auth.HTTPBasicAuth(*self.auth)
9899

99100
def __getattr__(self, item):
100101
def __request_runnner(url, json=None, headers=None):

0 commit comments

Comments
 (0)