Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integrationtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
GRAFANA_DASHBOARD_PATH: ${{ secrets.GRAFANA_DASHBOARD_PATH }}
GRAFANA_DASHBOARD_NAME: ${{ secrets.GRAFANA_DASHBOARD_NAME }}
GRAFANA_USERNAME: ${{ secrets.GRAFANA_USERNAME }}
GRAFANA_PASSWORD: ${{ secrets.GRAFANA_PASSWORD }}
GRAFANA_PASSWORD: ${{ secrets.GRAFANA_PASSWORD }}
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ In general my focus inside this project is to implement and deliver old and new
- Create a short url

### User
- Search Users
- Search users
- Get user by id
- Get user by username or email
- Update the user
Expand All @@ -150,6 +150,27 @@ In general my focus inside this project is to implement and deliver old and new
- Delete snapshot by key
- Delete snapshot by delete key

### Team
- Search team
- Get team by id
- Add team
- Update team
- Delete team by id
- Get team members
- Add team member
- Delete team member
- Get team preferences
- Update team preferences

### Playlist
- Search playlist
- Get playlist
- Get playlist items
- Get playlist dashboards
- Create playlist
- Update playlist
- Delete playlist

## Feature timeline

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.
Expand All @@ -163,11 +184,10 @@ The following table describes the plan to implement the rest of the Grafana API
| [Fine-grained access control HTTP API](https://grafana.com/docs/grafana/latest/http_api/access_control/) | | | | |
| [HTTP Preferences API](https://grafana.com/docs/grafana/latest/http_api/preferences/) | | | | |
| [Library Element HTTP API](https://grafana.com/docs/grafana/latest/http_api/library_element/) | | | | |
| [Licensing HTTP API](https://grafana.com/docs/grafana/latest/http_api/licensing/) | | | | |
| [Other HTTP API](https://grafana.com/docs/grafana/latest/http_api/other/) | | | | |
| [Playlist HTTP API](https://grafana.com/docs/grafana/latest/http_api/playlist/) | 20 | [ZPascal](https://github.com/ZPascal) | | |
| [Reporting API](https://grafana.com/docs/grafana/latest/http_api/reporting/) | | | | |
| [Team HTTP API](https://grafana.com/docs/grafana/latest/http_api/team/) | 20 | [ZPascal](https://github.com/ZPascal) | | |
| [Licensing HTTP API](https://grafana.com/docs/grafana/latest/http_api/licensing/) | 22 | [ZPascal](https://github.com/ZPascal) | | |
| [Other HTTP API](https://grafana.com/docs/grafana/latest/http_api/other/) | 22 | [ZPascal](https://github.com/ZPascal) | | |
| [Query History API](https://grafana.com/docs/grafana/latest/http_api/query_history/) | 22 | [ZPascal](https://github.com/ZPascal) | | |
| [Reporting API](https://grafana.com/docs/grafana/latest/http_api/reporting/) | 22 | [ZPascal](https://github.com/ZPascal) | | |

## Installation

Expand Down
52 changes: 52 additions & 0 deletions docs/content/grafana_api/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* [AlertmanagerReceivers](#grafana_api.model.AlertmanagerReceivers)
* [RulerRule](#grafana_api.model.RulerRule)
* [UserObject](#grafana_api.model.UserObject)
* [PlaylistObject](#grafana_api.model.PlaylistObject)
* [PlaylistItemObject](#grafana_api.model.PlaylistItemObject)
* [TeamObject](#grafana_api.model.TeamObject)

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

Expand Down Expand Up @@ -207,3 +210,52 @@ The class includes all necessary variables to generate a User object that is nec
- `login` _str_ - Specify the expression of the rule
- `theme` _str_ - Specify the Grafana alert of the rule

<a id="grafana_api.model.PlaylistObject"></a>

## PlaylistObject Objects

```python
class PlaylistObject(NamedTuple)
```

The class includes all necessary variables to generate a playlist object

**Arguments**:

- `name` _str_ - Specify the name of the playlist
- `interval` _str_ - Specify the interval of the playlist
- `items` _list_ - Specify a list of PlaylistItemObjects

<a id="grafana_api.model.PlaylistItemObject"></a>

## PlaylistItemObject Objects

```python
class PlaylistItemObject(NamedTuple)
```

The class includes all necessary variables to generate a playlist item object that is necessary to update a playlist

**Arguments**:

- `type` _str_ - Specify the type of the playlist item
- `value` _str_ - Specify the value of the playlist item
- `order` _int_ - Specify the order of the playlist item
- `title` _str_ - Specify the title of the playlist item

<a id="grafana_api.model.TeamObject"></a>

## TeamObject Objects

```python
class TeamObject(NamedTuple)
```

The class includes all necessary variables to generate a team object that is necessary to create a team

**Arguments**:

- `name` _str_ - Specify the name of the team
- `email` _str_ - Specify the email of the team
- `org_id` _int_ - Specify the org_id of the team

12 changes: 6 additions & 6 deletions docs/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ The following list describes the currently supported features of the Grafana API
- [ ] [External Group Sync HTTP API](https://grafana.com/docs/grafana/latest/http_api/external_group_sync/)
- [ ] [Fine-grained access control HTTP API](https://grafana.com/docs/grafana/latest/http_api/access_control/)
- [ ] [HTTP Preferences API](https://grafana.com/docs/grafana/latest/http_api/preferences/)
- [ ] [HTTP Snapshot API](https://grafana.com/docs/grafana/latest/http_api/snapshot/)
- [x] [HTTP Snapshot API](https://grafana.com/docs/grafana/latest/http_api/snapshot/)
- [ ] [Library Element HTTP API](https://grafana.com/docs/grafana/latest/http_api/library_element/)
- [ ] [Licensing HTTP API](https://grafana.com/docs/grafana/latest/http_api/licensing/)
- [ ] [Organization HTTP API](https://grafana.com/docs/grafana/latest/http_api/org/)
- [x] [Organization HTTP API](https://grafana.com/docs/grafana/latest/http_api/org/)
- [ ] [Other HTTP API](https://grafana.com/docs/grafana/latest/http_api/other/)
- [ ] [Playlist HTTP API](https://grafana.com/docs/grafana/latest/http_api/playlist/)
- [x] [Playlist HTTP API](https://grafana.com/docs/grafana/latest/http_api/playlist/)
- [ ] [Reporting API](https://grafana.com/docs/grafana/latest/http_api/reporting/)
- [ ] [Short URL HTTP API](https://grafana.com/docs/grafana/latest/http_api/short_url/)
- [ ] [Team HTTP API](https://grafana.com/docs/grafana/latest/http_api/team/)
- [ ] [User HTTP API](https://grafana.com/docs/grafana/latest/http_api/user/)
- [x] [Short URL HTTP API](https://grafana.com/docs/grafana/latest/http_api/short_url/)
- [x] [Team HTTP API](https://grafana.com/docs/grafana/latest/http_api/team/)
- [x] [User HTTP API](https://grafana.com/docs/grafana/latest/http_api/user/)

## Installation

Expand Down
12 changes: 6 additions & 6 deletions docs/grafana_api_sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ The following list describes the currently supported features of the Grafana API
- [ ] [External Group Sync HTTP API](https://grafana.com/docs/grafana/latest/http_api/external_group_sync/)
- [ ] [Fine-grained access control HTTP API](https://grafana.com/docs/grafana/latest/http_api/access_control/)
- [ ] [HTTP Preferences API](https://grafana.com/docs/grafana/latest/http_api/preferences/)
- [ ] [HTTP Snapshot API](https://grafana.com/docs/grafana/latest/http_api/snapshot/)
- [x] [HTTP Snapshot API](https://grafana.com/docs/grafana/latest/http_api/snapshot/)
- [ ] [Library Element HTTP API](https://grafana.com/docs/grafana/latest/http_api/library_element/)
- [ ] [Licensing HTTP API](https://grafana.com/docs/grafana/latest/http_api/licensing/)
- [ ] [Organization HTTP API](https://grafana.com/docs/grafana/latest/http_api/org/)
- [x] [Organization HTTP API](https://grafana.com/docs/grafana/latest/http_api/org/)
- [ ] [Other HTTP API](https://grafana.com/docs/grafana/latest/http_api/other/)
- [ ] [Playlist HTTP API](https://grafana.com/docs/grafana/latest/http_api/playlist/)
- [x] [Playlist HTTP API](https://grafana.com/docs/grafana/latest/http_api/playlist/)
- [ ] [Reporting API](https://grafana.com/docs/grafana/latest/http_api/reporting/)
- [ ] [Short URL HTTP API](https://grafana.com/docs/grafana/latest/http_api/short_url/)
- [ ] [Team HTTP API](https://grafana.com/docs/grafana/latest/http_api/team/)
- [ ] [User HTTP API](https://grafana.com/docs/grafana/latest/http_api/user/)
- [x] [Short URL HTTP API](https://grafana.com/docs/grafana/latest/http_api/short_url/)
- [x] [Team HTTP API](https://grafana.com/docs/grafana/latest/http_api/team/)
- [x] [User HTTP API](https://grafana.com/docs/grafana/latest/http_api/user/)

## Installation

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="grafana-api-sdk",
version="0.0.4",
version="0.0.5",
author="Pascal Zimmermann",
author_email="info@theiotstudio.com",
description="A Grafana API SDK",
Expand Down
3 changes: 2 additions & 1 deletion src/grafana_api/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging

import requests

from .model import RequestsMethods, ERROR_MESSAGES, APIModel
Expand Down Expand Up @@ -107,7 +108,7 @@ def __check_the_api_call_response(response: any = None) -> any:
api_call (any): Returns the value of the api call
"""

if type(response.json()) == dict:
if len(response.text) != 0 and type(response.json()) == dict:
if (
"message" in response.json().keys()
and response.json()["message"] in ERROR_MESSAGES
Expand Down
46 changes: 46 additions & 0 deletions src/grafana_api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class APIEndpoints(Enum):
USERS = f"{api_prefix}/users"
SNAPSHOTS = f"{api_prefix}/snapshots"
DASHBOARD_SNAPSHOTS = f"{api_prefix}/dashboard/snapshots"
PLAYLISTS = f"{api_prefix}/playlists"
TEAMS = f"{api_prefix}/teams"


class RequestsMethods(Enum):
Expand Down Expand Up @@ -218,3 +220,47 @@ class UserObject(NamedTuple):
name: str
login: str
theme: str


class PlaylistObject(NamedTuple):
"""The class includes all necessary variables to generate a playlist object

Args:
name (str): Specify the name of the playlist
interval (str): Specify the interval of the playlist
items (list): Specify a list of PlaylistItemObjects
"""

name: str
interval: str
items: list


class PlaylistItemObject(NamedTuple):
"""The class includes all necessary variables to generate a playlist item object that is necessary to update a playlist

Args:
type (str): Specify the type of the playlist item
value (str): Specify the value of the playlist item
order (int): Specify the order of the playlist item
title (str): Specify the title of the playlist item
"""

type: str
value: str
order: int
title: str


class TeamObject(NamedTuple):
"""The class includes all necessary variables to generate a team object that is necessary to create a team

Args:
name (str): Specify the name of the team
email (str): Specify the email of the team
org_id (int): Specify the org_id of the team
"""

name: str
email: str
org_id: int
Loading