12
12
import colored
13
13
import requests
14
14
import requests_cache
15
- from munch import Munch , munchify , unmunchify
15
+ from munch import Munch , munchify
16
16
from tqdm import tqdm
17
17
18
18
from grafana_wtf .model import (
22
22
DatasourceItem ,
23
23
GrafanaDataModel ,
24
24
)
25
- from grafana_wtf .monkey import monkeypatch_grafana_api
25
+ from grafana_wtf .monkey import monkeypatch_grafana_client
26
26
27
- # Apply monkeypatch to grafana-api
27
+ # Apply monkeypatch to ` grafana-client`.
28
28
# https://github.com/m0nhawk/grafana_api/pull/85/files
29
- monkeypatch_grafana_api ()
29
+ monkeypatch_grafana_client ()
30
30
31
- from grafana_api . grafana_api import GrafanaClientError , GrafanaUnauthorizedError
32
- from grafana_api . grafana_face import GrafanaFace
31
+ from grafana_client . api import GrafanaApi
32
+ from grafana_client . client import GrafanaClientError , GrafanaUnauthorizedError
33
33
34
34
from grafana_wtf .util import JsonPathFinder
35
35
@@ -84,7 +84,7 @@ def grafana_client_factory(grafana_url, grafana_token=None):
84
84
password = url .password or "admin"
85
85
auth = (username , password )
86
86
87
- grafana = GrafanaFace (
87
+ grafana = GrafanaApi (
88
88
auth , protocol = url .scheme , host = url .hostname , port = url .port , url_path_prefix = url .path .lstrip ("/" )
89
89
)
90
90
@@ -99,8 +99,8 @@ def setup(self):
99
99
# https://urllib3.readthedocs.io/en/latest/advanced-usage.html#customizing-pool-behavior
100
100
# https://laike9m.com/blog/requests-secret-pool_connections-and-pool_maxsize,89/
101
101
adapter = requests .adapters .HTTPAdapter (pool_connections = 100 , pool_maxsize = 100 , max_retries = 5 , pool_block = True )
102
- self .grafana .api .s .mount ("http://" , adapter )
103
- self .grafana .api .s .mount ("https://" , adapter )
102
+ self .grafana .client .s .mount ("http://" , adapter )
103
+ self .grafana .client .s .mount ("https://" , adapter )
104
104
105
105
return self
106
106
@@ -251,7 +251,7 @@ class GrafanaWtf(GrafanaEngine):
251
251
def info (self ):
252
252
253
253
try :
254
- health = self .grafana .api .GET ("/health" )
254
+ health = self .grafana .client .GET ("/health" )
255
255
except Exception as ex :
256
256
log .error (f"Request to /health endpoint failed: { ex } " )
257
257
health = {}
@@ -380,7 +380,7 @@ def get_red_message(message):
380
380
def get_dashboard_versions (self , dashboard_id ):
381
381
# https://grafana.com/docs/http_api/dashboard_versions/
382
382
get_dashboard_versions_path = "/dashboards/id/%s/versions" % dashboard_id
383
- r = self .grafana .dashboard .api .GET (get_dashboard_versions_path )
383
+ r = self .grafana .dashboard .client .GET (get_dashboard_versions_path )
384
384
return r
385
385
386
386
def explore_datasources (self ):
0 commit comments