66 "errors"
77 "fmt"
88 "io/ioutil"
9- "log"
109 "net/url"
11- "os"
1210)
1311
1412type DashboardMeta struct {
@@ -48,7 +46,8 @@ type Dashboard struct {
4846 Overwrite bool `json:"overwrite"`
4947}
5048
51- // Deprecated: use NewDashboard instead
49+ // SaveDashboard.
50+ // Deprecated: Use NewDashboard instead.
5251func (c * Client ) SaveDashboard (model map [string ]interface {}, overwrite bool ) (* DashboardSaveResponse , error ) {
5352 wrapper := map [string ]interface {}{
5453 "dashboard" : model ,
@@ -137,11 +136,18 @@ func (c *Client) Dashboards() ([]DashboardSearchResponse, error) {
137136 return dashboards , err
138137}
139138
140- // Deprecated: Starting from Grafana v5.0. Please update to use DashboardByUID instead.
139+ func (c * Client ) DashboardByUid (uid string ) (* Dashboard , error ) {
140+ return c .dashboard (fmt .Sprintf ("/api/dashboards/uid/%s" , uid ))
141+ }
142+
143+ // Dashboard will be removed.
144+ // Deprecated: Starting from Grafana v5.0. Use DashboardByUid instead.
141145func (c * Client ) Dashboard (slug string ) (* Dashboard , error ) {
142146 return c .dashboard (fmt .Sprintf ("/api/dashboards/db/%s" , slug ))
143147}
144148
149+ // DashboardByUID will be removed.
150+ // Deprecated: Interface typo. Use DashboardByUid instead.
145151func (c * Client ) DashboardByUID (uid string ) (* Dashboard , error ) {
146152 return c .dashboard (fmt .Sprintf ("/api/dashboards/uid/%s" , uid ))
147153}
@@ -168,17 +174,22 @@ func (c *Client) dashboard(path string) (*Dashboard, error) {
168174 result := & Dashboard {}
169175 err = json .Unmarshal (data , & result )
170176 result .Folder = result .Meta .Folder
171- if os .Getenv ("GF_LOG" ) != "" {
172- log .Printf ("got back dashboard response %s" , data )
173- }
177+
174178 return result , err
175179}
176180
177- // Deprecated: Starting from Grafana v5.0. Please update to use DeleteDashboardByUID instead.
181+ func (c * Client ) DeleteDashboardByUid (uid string ) error {
182+ return c .deleteDashboard (fmt .Sprintf ("/api/dashboards/uid/%s" , uid ))
183+ }
184+
185+ // DeleteDashboard will be removed.
186+ // Deprecated: Starting from Grafana v5.0. Use DeleteDashboardByUid instead.
178187func (c * Client ) DeleteDashboard (slug string ) error {
179188 return c .deleteDashboard (fmt .Sprintf ("/api/dashboards/db/%s" , slug ))
180189}
181190
191+ // DeleteDashboardByUID will be removed.
192+ // Deprecated: Interface typo. Use DeleteDashboardByUid instead.
182193func (c * Client ) DeleteDashboardByUID (uid string ) error {
183194 return c .deleteDashboard (fmt .Sprintf ("/api/dashboards/uid/%s" , uid ))
184195}
0 commit comments