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

Implement read & delete by UID as per Grafana depreciating #25

Merged
merged 1 commit into from
Jan 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}