Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
Implement read & delete by UID as per Grafana depreciating (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleeh authored and mlclmj committed Jan 25, 2020
1 parent bd4e74c commit 5aaccba
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions dashboard.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,16 @@ func (c *Client) NewDashboard(dashboard Dashboard) (*DashboardSaveResponse, erro
return result, err
}

// Deprecated: Starting from Grafana v5.0. Please update to use DashboardByUID instead.
func (c *Client) Dashboard(slug string) (*Dashboard, error) {
path := fmt.Sprintf("/api/dashboards/db/%s", slug)
return c.dashboard(fmt.Sprintf("/api/dashboards/db/%s", slug))
}

func (c *Client) DashboardByUID(uid string) (*Dashboard, error) {
return c.dashboard(fmt.Sprintf("/api/dashboards/uid/%s", uid))
}

func (c *Client) dashboard(path string) (*Dashboard, error) {
req, err := c.newRequest("GET", path, nil, nil)
if err != nil {
return nil, err
Expand Down Expand Up @@ -122,8 +130,16 @@ func (c *Client) Dashboard(slug string) (*Dashboard, error) {
return result, err
}

// Deprecated: Starting from Grafana v5.0. Please update to use DeleteDashboardByUID instead.
func (c *Client) DeleteDashboard(slug string) error {
path := fmt.Sprintf("/api/dashboards/db/%s", slug)
return c.deleteDashboard(fmt.Sprintf("/api/dashboards/db/%s", slug))
}

func (c *Client) DeleteDashboardByUID(uid string) error {
return c.deleteDashboard(fmt.Sprintf("/api/dashboards/uid/%s", uid))
}

func (c *Client) deleteDashboard(path string) error {
req, err := c.newRequest("DELETE", path, nil, nil)
if err != nil {
return err
Expand All @@ -138,4 +154,4 @@ func (c *Client) DeleteDashboard(slug string) error {
}

return nil
}
}

0 comments on commit 5aaccba

Please sign in to comment.