Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit daa5f78

Browse files
authored
Merge pull request #111 from grafana/add-update-datasource-by-uid
add an update datasource by uid function
2 parents 16d3180 + 02a76b4 commit daa5f78

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

datasource.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ func (c *Client) UpdateDataSource(s *DataSource) error {
6565
return c.request("PUT", path, nil, bytes.NewBuffer(data), nil)
6666
}
6767

68+
func (c *Client) UpdateDataSourceByUID(s *DataSource) error {
69+
path := fmt.Sprintf("/api/datasources/uid/%s", s.UID)
70+
data, err := json.Marshal(s)
71+
if err != nil {
72+
return err
73+
}
74+
75+
return c.request("PUT", path, nil, bytes.NewBuffer(data), nil)
76+
}
77+
6878
// DataSource fetches and returns the Grafana data source whose ID it's passed.
6979
func (c *Client) DataSource(id int64) (*DataSource, error) {
7080
path := fmt.Sprintf("/api/datasources/%d", id)

0 commit comments

Comments
 (0)