summaryrefslogtreecommitdiff
diff options
authorBrad Marshall <brad.marshall@canonical.com>2017-07-10 11:39:35 +1000
committerBrad Marshall <brad.marshall@canonical.com>2017-07-10 11:39:35 +1000
commitefd23a7d7889ce164c48bc61eda746aefdaa9b0e (patch)
tree2f294582f05275de14974ae076d6616b72d34475
parent650e00aa91988111910c4b0872d51a69a115498d (diff)
Tidied up redundant reference code, renamed action, more detail on import format
-rw-r--r--actions.yaml6
-rwxr-xr-xactions/import-dashboard (renamed from actions/add-dashboard)8
2 files changed, 5 insertions, 9 deletions
diff --git a/actions.yaml b/actions.yaml
index 55c9ed7..4d5f671 100644
--- a/actions.yaml
+++ b/actions.yaml
@@ -1,8 +1,8 @@
-add-dashboard:
- description: Adds a dashboard to grafana, takes dashboard argument, base64 encoded json dashboard
+import-dashboard:
+ description: Imports a dashboard to grafana, takes dashboard argument, base64 encoded json dashboard
params:
dashboard:
type: string
- description: Contains the dashboard to be imported, in base64 json format
+ description: Contains the dashboard to be imported, in base64 encoded json format
required: [dashboard]
additionalProperties: false
diff --git a/actions/add-dashboard b/actions/import-dashboard
index cf31480..be72e03 100755
--- a/actions/add-dashboard
+++ b/actions/import-dashboard
@@ -29,16 +29,12 @@ api_dash_import_url = "/api/dashboards/import"
dashboard_data = json.loads(base64.b64decode(action_get('dashboard')).decode('utf-8'))
# Needs to be the format:
# { "dashboard": { dashboard },
-# "overwrite": true }
+# "overwrite": true } - use false here if you don't want to overwrite
+# existing dashboards
-# For trusty, use for better compatability
headers = {'Content-Type': 'application/json'}
r = requests.post(grafana + api_dash_import_url, auth=api_auth, headers=headers,
data=json.dumps(dashboard_data))
-
-# For xenial+
-# r = requests.post(grafana + api_dash_import_url, auth=api_auth, json=dashboard_data)
-# if r.status_code == requests.codes.ok: # For python-requests 2.18 or so
title = dashboard_data['dashboard']['title']
if r.status_code == 200:
action_set({"loaded": title})