Skip to content

Commit b7223a3

Browse files
Add annotation, external_group, authentication and preferences support (#13)
* Add annotation, external_group, authentication and preferences support * Add coverage badge and documentation Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 8dafd01 commit b7223a3

20 files changed

+1933
-14
lines changed

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,39 @@ In general my focus inside this project is to implement and deliver old and new
193193
- Manually force license refresh
194194
- Remove the license from the database
195195

196+
### Annotation
197+
- Find annotations
198+
- Create annotation
199+
- Create graphite annotation
200+
- Update annotation
201+
- Delete annotation
202+
- Find annotation tags
203+
204+
### External Groups
205+
- Get external groups
206+
- Add external group
207+
- Remove external group
208+
209+
### Authentication
210+
- Get api tokens
211+
- Create a api token
212+
- Delete a api token
213+
214+
### Preferences
215+
- Get current user preferences
216+
- Update current user preferences
217+
- Get current org preferences
218+
- Update current org preferences
219+
196220
## Feature timeline
197221

198222
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.
199223

200224
| API endpoint group | Implementation week | Maintainer | PR | State |
201225
|:------------------:|:-------------------:|:----------:|:--:|:-----:|
202-
| [Admin HTTP API](https://grafana.com/docs/grafana/latest/http_api/admin/) | | | | |
203-
| [Annotations HTTP API](https://grafana.com/docs/grafana/latest/http_api/annotations/) | 23 | [ZPascal](https://github.com/ZPascal) | | |
204-
| [Authentication HTTP API](https://grafana.com/docs/grafana/latest/http_api/auth/) | 23 | [ZPascal](https://github.com/ZPascal) | | |
205-
| [External Group Sync HTTP API](https://grafana.com/docs/grafana/latest/http_api/external_group_sync/) | 23 | [ZPascal](https://github.com/ZPascal) | | |
206-
| [Fine-grained access control HTTP API](https://grafana.com/docs/grafana/latest/http_api/access_control/) | | | | |
207-
| [HTTP Preferences API](https://grafana.com/docs/grafana/latest/http_api/preferences/) | 23 | [ZPascal](https://github.com/ZPascal) | | |
208-
| [Library Element HTTP API](https://grafana.com/docs/grafana/latest/http_api/library_element/) | | | | |
226+
| [Admin HTTP API](https://grafana.com/docs/grafana/latest/http_api/admin/) | 25 | | | |
227+
| [Fine-grained access control HTTP API](https://grafana.com/docs/grafana/latest/http_api/access_control/) | 25 | | | |
228+
| [Library Element HTTP API](https://grafana.com/docs/grafana/latest/http_api/library_element/) | 25 | | | |
209229

210230
## Installation
211231

docs/content/grafana_api/api.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ The class includes all necessary methods to make API calls to the Grafana API en
3535
def call_the_api(api_call: str,
3636
method: RequestsMethods = RequestsMethods.GET,
3737
json_complete: str = None,
38-
timeout: float = None) -> any
38+
timeout: float = None,
39+
org_id_header: int = None) -> any
3940
```
4041

4142
The method execute a defined API call against the Grafana endpoints
@@ -46,6 +47,7 @@ The method execute a defined API call against the Grafana endpoints
4647
- `method` _RequestsMethods_ - Specify the used method (default GET)
4748
- `json_complete` _str_ - Specify the inserted JSON as string
4849
- `timeout` _float_ - Specify the timeout for the corresponding API call
50+
- `org_id_header` _int_ - Specify the optional organization id for the corresponding API call
4951

5052

5153
**Raises**:

docs/content/grafana_api/model.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* [TeamObject](#grafana_api.model.TeamObject)
1818
* [QueryDatasourceObject](#grafana_api.model.QueryDatasourceObject)
1919
* [QueryObject](#grafana_api.model.QueryObject)
20+
* [FindAnnotationObject](#grafana_api.model.FindAnnotationObject)
21+
* [AnnotationObject](#grafana_api.model.AnnotationObject)
22+
* [AnnotationGraphiteObject](#grafana_api.model.AnnotationGraphiteObject)
2023

2124
<a id="grafana_api.model"></a>
2225

@@ -293,3 +296,61 @@ The class includes all necessary variables to generate a query object that is ne
293296
- `scenario_id` _str_ - Specify the scenario_id of the query history
294297
- `datasource` _QueryDatasourceObject_ - Specify the datasource of the type QueryDatasourceObject
295298

299+
<a id="grafana_api.model.FindAnnotationObject"></a>
300+
301+
## FindAnnotationObject Objects
302+
303+
```python
304+
class FindAnnotationObject(NamedTuple)
305+
```
306+
307+
The class includes all necessary variables to generate a find annotation object
308+
309+
**Arguments**:
310+
311+
- `from_value` _int_ - Specify the optional from value (default None)
312+
- `to_value` _int_ - Specify the optional to value (default None)
313+
- `limit` _int_ - Specify the optional limit (default 100)
314+
- `alert_id` _int_ - Specify the optional alert id (default None)
315+
- `dashboard_id` _int_ - Specify the optional dashboard id (default None)
316+
- `panel_id` _int_ - Specify the optional panel_id (default None)
317+
- `user_id` _int_ - Specify the optional user id (default None)
318+
- `type` _str_ - Specify the optional type e.g. alert or annotation (default None)
319+
- `tags` _list_ - Specify the optional tags (default None)
320+
321+
<a id="grafana_api.model.AnnotationObject"></a>
322+
323+
## AnnotationObject Objects
324+
325+
```python
326+
class AnnotationObject(NamedTuple)
327+
```
328+
329+
The class includes all necessary variables to generate an annotation object
330+
331+
**Arguments**:
332+
333+
- `time` _int_ - Specify the time as number in milliseconds
334+
- `time_end` _int_ - Specify the end time as number in milliseconds
335+
- `tags` _list_ - Specify the organization annotation tags from a data source that are not connected specifically to a dashboard or panel
336+
- `text` _str_ - Specify the annotation description message
337+
- `dashboard_uid` _str_ - Specify the optional dashboard_uid (default None)
338+
- `panel_id` _int_ - Specify the optional panel_id (default None)
339+
340+
<a id="grafana_api.model.AnnotationGraphiteObject"></a>
341+
342+
## AnnotationGraphiteObject Objects
343+
344+
```python
345+
class AnnotationGraphiteObject(NamedTuple)
346+
```
347+
348+
The class includes all necessary variables to generate a Graphite annotation object
349+
350+
**Arguments**:
351+
352+
- `what` _str_ - Specify the event of the annotation
353+
- `tags` _list_ - Specify the organization annotation tags from a data source that are not connected specifically to a dashboard or panel
354+
- `when` _int_ - Specify the optional time as number in milliseconds
355+
- `data` _str_ - Specify the optional annotation description message
356+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="grafana-api-sdk",
11-
version="0.0.5",
11+
version="0.0.6",
1212
author="Pascal Zimmermann",
1313
author_email="[email protected]",
1414
description="A Grafana API SDK",

0 commit comments

Comments
 (0)