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

Commit 0254e2c

Browse files
Add folder UID option (#67)
Used for grafana/terraform-provider-grafana#323 The existing signature will keep working but an additional argument is supported
1 parent c59af51 commit 0254e2c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

folder.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@ func (c *Client) FolderByUID(uid string) (*Folder, error) {
4747
}
4848

4949
// NewFolder creates a new Grafana folder.
50-
func (c *Client) NewFolder(title string) (Folder, error) {
50+
func (c *Client) NewFolder(title string, uid ...string) (Folder, error) {
51+
if len(uid) > 1 {
52+
return Folder{}, fmt.Errorf("too many arguments. Expected 1 or 2")
53+
}
54+
5155
folder := Folder{}
5256
dataMap := map[string]string{
5357
"title": title,
5458
}
59+
if len(uid) == 1 {
60+
dataMap["uid"] = uid[0]
61+
}
5562
data, err := json.Marshal(dataMap)
5663
if err != nil {
5764
return folder, err

0 commit comments

Comments
 (0)