2022-10-26 09:15:14 -05:00
|
|
|
package folder
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Service interface {
|
2022-12-19 02:52:04 -06:00
|
|
|
// GetChildren returns an array containing all child folders.
|
2024-01-18 08:12:49 -06:00
|
|
|
GetChildren(ctx context.Context, q *GetChildrenQuery) ([]*Folder, error)
|
2023-01-26 02:21:10 -06:00
|
|
|
// GetParents returns an array containing add parent folders if nested folders are enabled
|
|
|
|
// otherwise it returns an empty array
|
|
|
|
GetParents(ctx context.Context, q GetParentsQuery) ([]*Folder, error)
|
2022-11-10 03:41:03 -06:00
|
|
|
Create(ctx context.Context, cmd *CreateFolderCommand) (*Folder, error)
|
2022-11-11 07:28:24 -06:00
|
|
|
|
|
|
|
// GetFolder takes a GetFolderCommand and returns a folder matching the
|
2023-11-01 10:01:54 -05:00
|
|
|
// request. One of UID, ID or Title must be included. If multiple values
|
2022-11-11 07:28:24 -06:00
|
|
|
// are included in the request, Grafana will select one in order of
|
2023-11-01 10:01:54 -05:00
|
|
|
// specificity (UID, ID, Title).
|
2024-01-25 03:29:56 -06:00
|
|
|
// When fetching a folder by Title, callers can optionally define a ParentUID.
|
|
|
|
// If ParentUID is not set then the folder will be fetched from the root level.
|
2024-01-18 08:12:49 -06:00
|
|
|
Get(ctx context.Context, q *GetFolderQuery) (*Folder, error)
|
2022-11-11 07:28:24 -06:00
|
|
|
|
2022-11-10 07:28:55 -06:00
|
|
|
// Update is used to update a folder's UID, Title and Description. To change
|
|
|
|
// a folder's parent folder, use Move.
|
2022-12-20 07:00:33 -06:00
|
|
|
Update(ctx context.Context, cmd *UpdateFolderCommand) (*Folder, error)
|
2022-12-20 09:38:09 -06:00
|
|
|
Delete(ctx context.Context, cmd *DeleteFolderCommand) error
|
2022-11-10 08:06:52 -06:00
|
|
|
// Move changes a folder's parent folder to the requested new parent.
|
|
|
|
Move(ctx context.Context, cmd *MoveFolderCommand) (*Folder, error)
|
2023-04-14 04:17:23 -05:00
|
|
|
RegisterService(service RegistryService) error
|
2024-01-25 01:27:13 -06:00
|
|
|
// GetFolders returns org folders that are accessible by the signed in user by their UIDs.
|
|
|
|
// If WithFullpath is true it computes also the full path of a folder.
|
|
|
|
// The full path is a string that contains the titles of all parent folders separated by a slash.
|
|
|
|
// If a folder contains a slash in its title, it is escaped with a backslash.
|
|
|
|
// If FullpathUIDs is true it computes a string that contains the UIDs of all parent folders separated by slash.
|
|
|
|
GetFolders(ctx context.Context, q GetFoldersQuery) ([]*Folder, error)
|
2024-01-18 08:12:49 -06:00
|
|
|
GetDescendantCounts(ctx context.Context, q *GetDescendantCountsQuery) (DescendantCounts, error)
|
2022-10-26 09:15:14 -05:00
|
|
|
}
|
2023-02-01 07:43:21 -06:00
|
|
|
|
|
|
|
// FolderStore is a folder store.
|
|
|
|
//
|
|
|
|
//go:generate mockery --name FolderStore --structname FakeFolderStore --outpkg foldertest --output foldertest --filename folder_store_mock.go
|
|
|
|
type FolderStore interface {
|
|
|
|
// GetFolderByTitle retrieves a folder by its title
|
2024-01-25 03:29:56 -06:00
|
|
|
// It expects a parentUID as last argument.
|
|
|
|
// If parentUID is empty then the folder will be fetched from the root level
|
|
|
|
// otherwise it will be fetched from the subfolder under the folder with the given UID.
|
|
|
|
GetFolderByTitle(ctx context.Context, orgID int64, title string, parentUID *string) (*Folder, error)
|
2023-02-01 07:43:21 -06:00
|
|
|
// GetFolderByUID retrieves a folder by its UID
|
|
|
|
GetFolderByUID(ctx context.Context, orgID int64, uid string) (*Folder, error)
|
|
|
|
// GetFolderByID retrieves a folder by its ID
|
|
|
|
GetFolderByID(ctx context.Context, orgID int64, id int64) (*Folder, error)
|
2023-08-01 03:04:44 -05:00
|
|
|
// GetFolders returns all folders for the given orgID and UIDs.
|
|
|
|
GetFolders(ctx context.Context, orgID int64, uids []string) (map[string]*Folder, error)
|
2023-02-01 07:43:21 -06:00
|
|
|
}
|