|
1 |
| -# grafana_api_sdk |
2 |
| -The repository includes an SDK for the Grafana API |
3 |
| - |
4 |
| -## TODO |
5 |
| -- Documentation |
6 |
| -- Docstrings |
7 |
| -- PYPI support |
| 1 | +# Grafana API SDK  |
| 2 | +The repository includes an SDK for the Grafana API. It's possible to communicate with the Grafana API endpoints. Another feature of the SDK is the possibility to specify the used folder for the dashboard. |
8 | 3 |
|
9 | 4 | ## Currently, supported features
|
10 | 5 |
|
11 |
| -- Get a Dashboard by uid |
12 |
| -- Get folder id by dashboard path |
13 |
| -- Get all folder ids and folder names |
14 |
| -- Specify the grafana dashboard folder |
| 6 | +### Dashboard |
15 | 7 | - Create/ Update a dashboard
|
16 | 8 | - Delete a dashboard
|
| 9 | +- Get permissions of a dashboard |
| 10 | +- Update the permissions of a dashboard |
| 11 | +- Get all dashboard versions |
| 12 | +- Get dashboard version of a specific dashboard |
| 13 | +- Restore a dashboard version of a specific dashboard |
| 14 | +- Compare two dashboard versions and extract the diff between booth dashboards |
| 15 | + |
| 16 | +### Folder |
| 17 | +- Get folder id by dashboard path |
| 18 | +- Get all folder ids and folder names |
| 19 | +- Get all folders |
| 20 | +- Get folder by uid |
| 21 | +- Get folder by id |
| 22 | +- Create a folder |
| 23 | +- Update a folder |
| 24 | +- Delete a folder |
| 25 | +- Get permissions for a folder |
| 26 | +- Update permissions for a folder |
| 27 | + |
| 28 | +### Search |
| 29 | +- Execute a custom query against the Grafana search endpoint |
| 30 | + |
| 31 | +## Feature timeline |
| 32 | + |
| 33 | +The following table describes the plan to implement the rest of the Grafana API functionality. Please, open an issue and vote them up, if you prefer a faster implementation of an API functionality. |
| 34 | + |
| 35 | +| API endpoint group | Implementation week | Maintainer | PR | State | |
| 36 | +|:------------------:|:-------------------:|:----------:|:--:|:-----:| |
| 37 | +| [Admin HTTP API](https://grafana.com/docs/grafana/latest/http_api/admin/) | | | | | |
| 38 | +| [Alerting HTTP API](https://grafana.com/docs/grafana/latest/http_api/alerting/) | 4 | [ZPascal](https://github.com/ZPascal) | | Planned | |
| 39 | +| [Alerting Notification Channels HTTP API](https://grafana.com/docs/grafana/latest/http_api/alerting_notification_channels/) | 4 | [ZPascal](https://github.com/ZPascal) | | Planned | |
| 40 | +| [Annotations HTTP API](https://grafana.com/docs/grafana/latest/http_api/annotations/) | | | | | |
| 41 | +| [Authentication HTTP API](https://grafana.com/docs/grafana/latest/http_api/auth/) | | | | | |
| 42 | +| [Data source HTTP API](https://grafana.com/docs/grafana/latest/http_api/data_source/) | 5 | [ZPascal](https://github.com/ZPascal) | | Planned | |
| 43 | +| [Datasource Permissions HTTP API](https://grafana.com/docs/grafana/latest/http_api/datasource_permissions/) | | | | | |
| 44 | +| [External Group Sync HTTP API](https://grafana.com/docs/grafana/latest/http_api/external_group_sync/) | | | | | |
| 45 | +| [Fine-grained access control HTTP API](https://grafana.com/docs/grafana/latest/http_api/access_control/) | | | | | |
| 46 | +| [HTTP Preferences API](https://grafana.com/docs/grafana/latest/http_api/preferences/) | | | | | |
| 47 | +| [HTTP Snapshot API](https://grafana.com/docs/grafana/latest/http_api/snapshot/) | | | | | |
| 48 | +| [Library Element HTTP API](https://grafana.com/docs/grafana/latest/http_api/library_element/) | | | | | |
| 49 | +| [Licensing HTTP API](https://grafana.com/docs/grafana/latest/http_api/licensing/) | | | | | |
| 50 | +| [Organization HTTP API](https://grafana.com/docs/grafana/latest/http_api/org/) | | | | | |
| 51 | +| [Other HTTP API](https://grafana.com/docs/grafana/latest/http_api/other/) | | | | | |
| 52 | +| [Playlist HTTP API](https://grafana.com/docs/grafana/latest/http_api/playlist/) | | | | | |
| 53 | +| [Reporting API](https://grafana.com/docs/grafana/latest/http_api/reporting/) | | | | | |
| 54 | +| [Short URL HTTP API](https://grafana.com/docs/grafana/latest/http_api/short_url/) | | | | | |
| 55 | +| [Team HTTP API](https://grafana.com/docs/grafana/latest/http_api/team/) | | | | | |
| 56 | +| [User HTTP API](https://grafana.com/docs/grafana/latest/http_api/user/) | | | | | |
| 57 | + |
| 58 | +## Installation |
| 59 | + |
| 60 | +`pip install grafana-api-sdk` |
| 61 | + |
| 62 | +## Example |
| 63 | + |
| 64 | +```python |
| 65 | +import json |
| 66 | + |
| 67 | +from grafana_api.model import APIModel |
| 68 | +from grafana_api.dashboard import Dashboard |
| 69 | + |
| 70 | +model: APIModel = APIModel(host="test", token="test") |
| 71 | + |
| 72 | +dashboard: Dashboard = Dashboard(model) |
17 | 73 |
|
18 |
| -## Installation & Requirements |
| 74 | +with open("/tmp/test/test.json") as file: |
| 75 | + json_dashboard = json.load(file) |
19 | 76 |
|
20 |
| -### Programs & tools to install |
| 77 | +dashboard.create_or_update_dashboard(message="Create a new test dashboard", dashboard_json=json_dashboard, dashboard_path="test") |
| 78 | +``` |
21 | 79 |
|
22 |
| -- json-extensions |
23 |
| -- requests |
| 80 | +## Templating |
| 81 | +If you want to template your JSON document based on a predefined folder structure you can check out one of my other [project](https://github.com/ZPascal/grafana_dashboard_templater) and integrate the functionality inside your code. |
24 | 82 |
|
25 | 83 | ## Contribution
|
26 | 84 | If you would like to contribute something, have an improvement request, or want to make a change inside the code, please open a pull request.
|
|
0 commit comments