Skip to content

Commit

Permalink
Adding Plugin installation/Uninstalltion Base classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bhks committed Sep 13, 2023
1 parent 5ed1fba commit 2a8f820
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 24 deletions.
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,32 @@ versions of Grafana might not support certain features or subsystems.

### Overview

| API | Status |
|---|---|
| Admin | + |
| Alerting | +- |
| API | Status |
|--------------------------------|---|
| Admin | + |
| Alerting | +- |
| Alerting Notification Channels | + |
| Alerting Provisioning | + |
| Annotations | + |
| Authentication | +- |
| Dashboard | + |
| Dashboard Versions | + |
| Dashboard Permissions | + |
| Data Source | + |
| Data Source Permissions | + |
| External Group Sync | + |
| Folder | + |
| Folder Permissions | + |
| Folder/Dashboard Search | +- |
| Health | + |
| Organisation | + |
| Other | + |
| Preferences | + |
| Rbac | +- |
| Snapshot | + |
| Teams | + |
| User | + |
| Alerting Provisioning | + |
| Annotations | + |
| Authentication | +- |
| Dashboard | + |
| Dashboard Versions | + |
| Dashboard Permissions | + |
| Data Source | + |
| Data Source Permissions | + |
| External Group Sync | + |
| Folder | + |
| Folder Permissions | + |
| Folder/Dashboard Search | +- |
| Health | + |
| Organisation | + |
| Other | + |
| Plugin | + |
| Preferences | + |
| Rbac | +- |
| Snapshot | + |
| Teams | + |
| User | + |


### Data source health check
Expand Down
3 changes: 3 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ poe test
python -m unittest -k preference -vvv
```

### Formatting
When Creating a PR you can run `poe format` which will help remove code style issues and keep the repo clean.


## Run Grafana
```
Expand Down
2 changes: 2 additions & 0 deletions grafana_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Notifications,
Organization,
Organizations,
Plugin,
Rbac,
Search,
Snapshots,
Expand Down Expand Up @@ -76,6 +77,7 @@ def __init__(
self.annotations = Annotations(self.client)
self.snapshots = Snapshots(self.client)
self.notifications = Notifications(self.client)
self.plugin = Plugin(self.client)

def connect(self):
try:
Expand Down
1 change: 1 addition & 0 deletions grafana_client/elements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .health import Health
from .notifications import Notifications
from .organization import Organization, Organizations
from .plugin import Plugin
from .rbac import Rbac
from .search import Search
from .snapshots import Snapshots
Expand Down
59 changes: 59 additions & 0 deletions grafana_client/elements/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import logging

from .base import Base


class Plugin(Base):
def __init__(self, client):
super(Plugin, self).__init__(client)
self.client = client
self.logger = logging.getLogger(__name__)

def health_check_plugin(self):
"""
:return:
"""
path = "/healthz"
r = self.client.GET(path)
return r

Check warning on line 18 in grafana_client/elements/plugin.py

View check run for this annotation

Codecov / codecov/patch

grafana_client/elements/plugin.py#L16-L18

Added lines #L16 - L18 were not covered by tests

def get_plugins(self):
"""
:return:
"""
path = "/plugins?embedded=0"
r = self.client.GET(path)
return r

Check warning on line 26 in grafana_client/elements/plugin.py

View check run for this annotation

Codecov / codecov/patch

grafana_client/elements/plugin.py#L24-L26

Added lines #L24 - L26 were not covered by tests

def install_plugins(self, pluginId, version):
"""
: return:
"""
try:
path = "/plugins/%s/install" % pluginId
r = self.client.POST(path, json={"version": version})
return r
except Exception as ex:
self.logger.info("Skipped installing %s and err = %s", pluginId, ex)
return None

Check warning on line 38 in grafana_client/elements/plugin.py

View check run for this annotation

Codecov / codecov/patch

grafana_client/elements/plugin.py#L32-L38

Added lines #L32 - L38 were not covered by tests

def uninstall_plugins(self, pluginId):
"""
: return:
"""
try:
path = "/plugins/%s/uninstall" % pluginId
r = self.client.POST(path)
return r
except Exception as ex:
self.logger.info("Skipped uninstalling %s and error = %s", pluginId, ex)
return None

Check warning on line 50 in grafana_client/elements/plugin.py

View check run for this annotation

Codecov / codecov/patch

grafana_client/elements/plugin.py#L44-L50

Added lines #L44 - L50 were not covered by tests

def get_plugin_metrics(self, pluginId):
try:
path = "/plugins/%s/metrics" % pluginId
r = self.client.GET(path)
return r
except Exception as ex:
self.logger.info("Got error in fetching metrics for plugin %s and error = %s", pluginId, ex)
return None

Check warning on line 59 in grafana_client/elements/plugin.py

View check run for this annotation

Codecov / codecov/patch

grafana_client/elements/plugin.py#L53-L59

Added lines #L53 - L59 were not covered by tests

0 comments on commit 2a8f820

Please sign in to comment.