grafana-toolbox / grafana-client

Python client library for accessing the Grafana HTTP API.
MIT License
106 stars 30 forks source link

Get all folders endpoint is incorrect #173

Closed chintal closed 7 months ago

chintal commented 7 months ago

Describe the bug The folders.get_all_folders endpoint provides the parent_uid, if set, in data. This puts it in the body of the resulting API request. This needs to be a query parameter, however.

https://grafana.com/docs/grafana/latest/developers/http_api/folder/#get-all-folders

To Reproduce Steps to reproduce the behavior:

  1. Create a Folder in grafana. Create a subfolder folder within it. Note that nested folders needs to be enabled on the Grafana instance
  2. Run client.folders.get_all_folders(parent_uid=<uid of created parent>)
  3. You'll get the contents of the root folder

Expected behavior Folders contained within the provided parent_uid should be returned.

Versions

Additional context I've quickly tested that the problem is resolved if I change data=data to params=data in the __request_runner call to s.request() in client.py. Obviously, this is not a viable solution.

The infrastructure needs to be modified to allow params to be passed through to the final request call, the same way data presently is.

amotl commented 7 months ago

Dear Chintalagiri,

thank you so much for discovering and fixing that flaw already. It clearly demonstrates yet another time that grafana-client needs an integration test suite.

With kind regards, Andreas.