Merge ~raychan96/charm-grafana:bug/2007846 into charm-grafana:master

Proposed by Chi Wai CHAN
Status: Merged
Approved by: Eric Chen
Approved revision: 9631e9f7a2112a6ce910135b4d4c3cc381bfec2d
Merged at revision: 2d085466a066577172866fb973953e9dea158548
Proposed branch: ~raychan96/charm-grafana:bug/2007846
Merge into: charm-grafana:master
Diff against target: 40 lines (+3/-5)
1 file modified
src/lib/charms/layer/grafana.py (+3/-5)
Reviewer Review Type Date Requested Status
Ramesh Sattaru (community) Approve
🤖 prod-jenkaas-bootstack (community) continuous-integration Approve
BootStack Reviewers Pending
Review via email: mp+437600@code.launchpad.net

Commit message

Use `json` instead of `data` when performing `requests.post()` since it will set the correct content type automatically.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Nobuto Murata (nobuto) wrote :

My only question is; is the change compatible with older releases of Grafana too?

Revision history for this message
Chi Wai CHAN (raychan96) wrote :

> My only question is; is the change compatible with older releases of Grafana
> too?

I've manually tried on 20.04/stable, 7/stable, 6/stable, 5/stable, replacing `data` with `json` is compatible.

Revision history for this message
Nobuto Murata (nobuto) wrote :

> I've manually tried on 20.04/stable, 7/stable, 6/stable, 5/stable, replacing `data` with `json` is compatible.

💯

Thanks for checking!

Revision history for this message
Eric Chen (eric-chen) wrote :

LGTM, wait for jenkins pass the CI.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ramesh Sattaru (rameshcan) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 2d085466a066577172866fb973953e9dea158548

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/lib/charms/layer/grafana.py b/src/lib/charms/layer/grafana.py
2index 170a125..c88b176 100644
3--- a/src/lib/charms/layer/grafana.py
4+++ b/src/lib/charms/layer/grafana.py
5@@ -2,7 +2,6 @@
6 """Grafana layer module."""
7 import base64
8 import enum
9-import json
10 import os
11 import re
12 import subprocess
13@@ -136,7 +135,7 @@ def create_folder(folder_name):
14 "{}://localhost:{}/api/folders".format(get_protocol(), config("port")),
15 auth=("admin", get_admin_password()),
16 headers={"Accept": "application/json"},
17- data={"title": folder_name},
18+ json={"title": folder_name},
19 verify=False,
20 )
21 r.raise_for_status()
22@@ -169,7 +168,6 @@ def ensure_and_get_dash_folder(remote_model):
23
24 def post_dashboard(name, dashboard):
25 """Upload a dashboard to Grafana."""
26- headers = {"Content-Type": "application/json"}
27 import_url = "{}://localhost:{}/api/dashboards/db".format(
28 get_protocol(), config("port")
29 )
30@@ -180,8 +178,8 @@ def post_dashboard(name, dashboard):
31 r = requests.post(
32 import_url,
33 auth=api_auth,
34- headers=headers,
35- data=json.dumps(dashboard),
36+ headers={"Accept": "application/json"},
37+ json=dashboard,
38 verify=False,
39 )
40 if r.status_code == 200:

Subscribers

People subscribed via source and target branches

to all changes: