Skip to content

Commit

Permalink
Merge branch 'K-Phoen:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lueurxax authored Aug 2, 2024
2 parents 155d6a5 + bb1093e commit 2b10368
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net/http"
"net/url"
"strings"
)

Expand All @@ -15,9 +16,10 @@ var ErrFolderNotFound = errors.New("folder not found")
// Folder represents a dashboard folder.
// See https://grafana.com/docs/grafana/latest/reference/dashboard_folders/
type Folder struct {
ID uint `json:"id"`
UID string `json:"uid"`
Title string `json:"title"`
ID uint `json:"id"`
UID string `json:"uid"`
ParentUID string `json:"parentUid"`
Title string `json:"title"`
}

// FindOrCreateFolder returns the folder by its name or creates it if it doesn't exist.
Expand Down Expand Up @@ -69,7 +71,7 @@ func (client *Client) CreateFolder(ctx context.Context, name string) (*Folder, e

// GetFolderByTitle finds a folder, given its title.
func (client *Client) GetFolderByTitle(ctx context.Context, title string) (*Folder, error) {
resp, err := client.get(ctx, "/api/folders?limit=1000")
resp, err := client.get(ctx, fmt.Sprintf("/api/search?type=dash-folder&query=%s", url.QueryEscape(title)))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2b10368

Please sign in to comment.