Skip to content

Commit

Permalink
Add support for query parameters on endpoints. Fixes grafana-toolbox#173
Browse files Browse the repository at this point in the history
 (get_all_folders)
  • Loading branch information
chintal committed Apr 12, 2024
1 parent dd9ae79 commit 0fef856
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions grafana_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _extract_from_response(r, accept_empty_json):
raise

def __getattr__(self, item):
def __request_runner(url, json=None, data=None, headers=None, accept_empty_json=False):
def __request_runner(url, json=None, data=None, params=None, headers=None, accept_empty_json=False):
__url = self._make_url(url)
# Sanity checks.
self._ensure_valid_json_arg(json)
Expand All @@ -200,6 +200,7 @@ def __request_runner(url, json=None, data=None, headers=None, accept_empty_json=
__url,
json=json,
data=data,
params=params,
headers=headers,
auth=self.auth,
verify=self.verify,
Expand Down Expand Up @@ -244,7 +245,7 @@ def __init__(
self.s.headers.setdefault("Connection", "keep-alive")

def __getattr__(self, item):
async def __request_runner(url, json=None, data=None, headers=None, accept_empty_json=False):
async def __request_runner(url, json=None, data=None, params=None, headers=None, accept_empty_json=False):
__url = self._make_url(url)
# Sanity checks.
self._ensure_valid_json_arg(json)
Expand All @@ -255,6 +256,7 @@ async def __request_runner(url, json=None, data=None, headers=None, accept_empty
__url,
json=json,
data=data,
params=params,
headers=headers,
auth=self.auth,
verify=self.verify,
Expand Down
6 changes: 3 additions & 3 deletions grafana_client/elements/_async/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ async def get_all_folders(self, parent_uid=None):
:return:
"""
path = "/folders"
data = {}
params = {}
if parent_uid:
data["parentUid"] = parent_uid
return await self.client.GET(path, data=data)
params["parentUid"] = parent_uid
return await self.client.GET(path, params=params)

async def get_folder(self, uid):
"""
Expand Down
6 changes: 3 additions & 3 deletions grafana_client/elements/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def get_all_folders(self, parent_uid=None):
:return:
"""
path = "/folders"
data = {}
params = {}
if parent_uid:
data["parentUid"] = parent_uid
return self.client.GET(path, data=data)
params["parentUid"] = parent_uid
return self.client.GET(path, params=params)

def get_folder(self, uid):
"""
Expand Down

0 comments on commit 0fef856

Please sign in to comment.