From 0254e2c19e8ea33aabe6142cd99e0ea2861b96af Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Fri, 4 Mar 2022 18:20:49 -0500 Subject: [PATCH] Add folder UID option (#67) Used for https://github.com/grafana/terraform-provider-grafana/issues/323 The existing signature will keep working but an additional argument is supported --- folder.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/folder.go b/folder.go index 56a2999b..d85c72cf 100644 --- a/folder.go +++ b/folder.go @@ -47,11 +47,18 @@ func (c *Client) FolderByUID(uid string) (*Folder, error) { } // NewFolder creates a new Grafana folder. -func (c *Client) NewFolder(title string) (Folder, error) { +func (c *Client) NewFolder(title string, uid ...string) (Folder, error) { + if len(uid) > 1 { + return Folder{}, fmt.Errorf("too many arguments. Expected 1 or 2") + } + folder := Folder{} dataMap := map[string]string{ "title": title, } + if len(uid) == 1 { + dataMap["uid"] = uid[0] + } data, err := json.Marshal(dataMap) if err != nil { return folder, err