Documentation
¶
Index ¶
- Variables
- type CreateLibraryElementCommand
- type DeleteLibraryElementResponse
- type FolderFilter
- type LibraryConnectionKind
- type LibraryElement
- type LibraryElementArrayResponse
- type LibraryElementConnectionDTO
- type LibraryElementConnectionsResponse
- type LibraryElementDTO
- type LibraryElementDTOMeta
- type LibraryElementDTOMetaUser
- type LibraryElementResponse
- type LibraryElementSearchResponse
- type LibraryElementSearchResult
- type LibraryElementService
- func (l *LibraryElementService) ConnectElementsToDashboard(c context.Context, signedInUser *models.SignedInUser, elementUIDs []string, ...) error
- func (l *LibraryElementService) CreateElement(c context.Context, signedInUser *models.SignedInUser, ...) (LibraryElementDTO, error)
- func (l *LibraryElementService) DeleteLibraryElementsInFolder(c context.Context, signedInUser *models.SignedInUser, folderUID string) error
- func (l *LibraryElementService) DisconnectElementsFromDashboard(c context.Context, dashboardID int64) error
- func (l *LibraryElementService) GetElement(c context.Context, signedInUser *models.SignedInUser, UID string) (LibraryElementDTO, error)
- func (l *LibraryElementService) GetElementsForDashboard(c context.Context, dashboardID int64) (map[string]LibraryElementDTO, error)
- type LibraryElementWithMeta
- type Pair
- type PatchLibraryElementCommand
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // ErrLibraryElementNotFound is an error for when a library element can't be found. ErrLibraryElementNotFound = errors.New("library element could not be found") // ErrFolderHasConnectedLibraryElements is an error for when a user deletes a folder that contains connected library elements. ErrFolderHasConnectedLibraryElements = errors.New("folder contains library elements that are linked in use") )
Functions ¶
This section is empty.
Types ¶
type CreateLibraryElementCommand ¶
type CreateLibraryElementCommand struct {
// ID of the folder where the library element is stored.
FolderID int64 `json:"folderId"`
// Name of the library element.
Name string `json:"name"`
// The JSON model for the library element.
// swagger:type object
Model json.RawMessage `json:"model"`
// Kind of element to create, Use 1 for library panels or 2 for c.
// Description:
// * 1 - library panels
// * 2 - library variables
// Enum: 1,2
Kind int64 `json:"kind" binding:"Required"`
// required: false
UID string `json:"uid"`
}
CreateLibraryElementCommand is the command for adding a LibraryElement swagger:model
type DeleteLibraryElementResponse ¶
DeleteLibraryElementResponse is the response struct for deleting a library element.
type FolderFilter ¶
type FolderFilter struct {
// contains filtered or unexported fields
}
type LibraryConnectionKind ¶
type LibraryConnectionKind int
const (
Dashboard LibraryConnectionKind = iota + 1
)
type LibraryElement ¶
type LibraryElement struct {
ID int64 `xorm:"pk autoincr 'id'"`
OrgID int64 `xorm:"org_id"`
FolderID int64 `xorm:"folder_id"`
UID string `xorm:"uid"`
Name string
Kind int64
Type string
Description string
Model json.RawMessage
Version int64
Created time.Time
Updated time.Time
CreatedBy int64
UpdatedBy int64
}
LibraryElement is the model for library element definitions.
type LibraryElementArrayResponse ¶
type LibraryElementArrayResponse struct {
Result []LibraryElementDTO `json:"result"`
}
LibraryElementArrayResponse is a response struct for an array of LibraryElementDTO.
type LibraryElementConnectionDTO ¶
type LibraryElementConnectionDTO struct {
ID int64 `json:"id"`
Kind int64 `json:"kind"`
ElementID int64 `json:"elementId"`
ConnectionID int64 `json:"connectionId"`
Created time.Time `json:"created"`
CreatedBy LibraryElementDTOMetaUser `json:"createdBy"`
}
LibraryElementConnectionDTO is the frontend DTO for element connections.
type LibraryElementConnectionsResponse ¶
type LibraryElementConnectionsResponse struct {
Result []LibraryElementConnectionDTO `json:"result"`
}
LibraryElementConnectionsResponse is a response struct for an array of LibraryElementConnectionDTO.
type LibraryElementDTO ¶
type LibraryElementDTO struct {
ID int64 `json:"id"`
OrgID int64 `json:"orgId"`
FolderID int64 `json:"folderId"`
UID string `json:"uid"`
Name string `json:"name"`
Kind int64 `json:"kind"`
Type string `json:"type"`
Description string `json:"description"`
Model json.RawMessage `json:"model"`
Version int64 `json:"version"`
Meta LibraryElementDTOMeta `json:"meta"`
}
LibraryElementDTO is the frontend DTO for entities.
type LibraryElementDTOMeta ¶
type LibraryElementDTOMeta struct {
FolderName string `json:"folderName"`
FolderUID string `json:"folderUid"`
ConnectedDashboards int64 `json:"connectedDashboards"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
CreatedBy LibraryElementDTOMetaUser `json:"createdBy"`
UpdatedBy LibraryElementDTOMetaUser `json:"updatedBy"`
}
LibraryElementDTOMeta is the meta information for LibraryElementDTO.
type LibraryElementDTOMetaUser ¶
type LibraryElementDTOMetaUser struct {
ID int64 `json:"id"`
Name string `json:"name"`
AvatarURL string `json:"avatarUrl"`
}
LibraryElementDTOMetaUser is the meta information for user that creates/changes the library element.
type LibraryElementResponse ¶
type LibraryElementResponse struct {
Result LibraryElementDTO `json:"result"`
}
LibraryElementResponse is a response struct for LibraryElementDTO.
type LibraryElementSearchResponse ¶
type LibraryElementSearchResponse struct {
Result LibraryElementSearchResult `json:"result"`
}
LibraryElementSearchResponse is a response struct for LibraryElementSearchResult.
type LibraryElementSearchResult ¶
type LibraryElementSearchResult struct {
TotalCount int64 `json:"totalCount"`
Elements []LibraryElementDTO `json:"elements"`
Page int `json:"page"`
PerPage int `json:"perPage"`
}
LibraryElementSearchResult is the search result for entities.
type LibraryElementService ¶
type LibraryElementService struct {
Cfg *setting.Cfg
SQLStore *sqlstore.SQLStore
RouteRegister routing.RouteRegister
// contains filtered or unexported fields
}
LibraryElementService is the service for the Library Element feature.
func ProvideService ¶
func ProvideService(cfg *setting.Cfg, sqlStore *sqlstore.SQLStore, routeRegister routing.RouteRegister, folderService dashboards.FolderService) *LibraryElementService
func (*LibraryElementService) ConnectElementsToDashboard ¶
func (l *LibraryElementService) ConnectElementsToDashboard(c context.Context, signedInUser *models.SignedInUser, elementUIDs []string, dashboardID int64) error
ConnectElementsToDashboard connects elements to a specific dashboard.
func (*LibraryElementService) CreateElement ¶
func (l *LibraryElementService) CreateElement(c context.Context, signedInUser *models.SignedInUser, cmd CreateLibraryElementCommand) (LibraryElementDTO, error)
CreateElement creates a Library Element.
func (*LibraryElementService) DeleteLibraryElementsInFolder ¶
func (l *LibraryElementService) DeleteLibraryElementsInFolder(c context.Context, signedInUser *models.SignedInUser, folderUID string) error
DeleteLibraryElementsInFolder deletes all elements for a specific folder.
func (*LibraryElementService) DisconnectElementsFromDashboard ¶
func (l *LibraryElementService) DisconnectElementsFromDashboard(c context.Context, dashboardID int64) error
DisconnectElementsFromDashboard disconnects elements from a specific dashboard.
func (*LibraryElementService) GetElement ¶
func (l *LibraryElementService) GetElement(c context.Context, signedInUser *models.SignedInUser, UID string) (LibraryElementDTO, error)
GetElement gets an element from a UID.
func (*LibraryElementService) GetElementsForDashboard ¶
func (l *LibraryElementService) GetElementsForDashboard(c context.Context, dashboardID int64) (map[string]LibraryElementDTO, error)
GetElementsForDashboard gets all connected elements for a specific dashboard.
type LibraryElementWithMeta ¶
type LibraryElementWithMeta struct {
ID int64 `xorm:"pk autoincr 'id'"`
OrgID int64 `xorm:"org_id"`
FolderID int64 `xorm:"folder_id"`
UID string `xorm:"uid"`
Name string
Kind int64
Type string
Description string
Model json.RawMessage
Version int64
Created time.Time
Updated time.Time
FolderName string
FolderUID string `xorm:"folder_uid"`
ConnectedDashboards int64
CreatedBy int64
UpdatedBy int64
CreatedByName string
CreatedByEmail string
UpdatedByName string
UpdatedByEmail string
}
LibraryElementWithMeta is the model used to retrieve entities with additional meta information.
type PatchLibraryElementCommand ¶
type PatchLibraryElementCommand struct {
// ID of the folder where the library element is stored.
FolderID int64 `json:"folderId" binding:"Default(-1)"`
// Name of the library element.
Name string `json:"name"`
// The JSON model for the library element.
Model json.RawMessage `json:"model,omitempty"`
// Kind of element to create, Use 1 for library panels or 2 for c.
// Description:
// * 1 - library panels
// * 2 - library variables
// Enum: 1,2
Kind int64 `json:"kind" binding:"Required"`
// Version of the library element you are updating.
Version int64 `json:"version" binding:"Required"`
// required: false
UID string `json:"uid"`
}
PatchLibraryElementCommand is the command for patching a LibraryElement
type Service ¶
type Service interface {
CreateElement(c context.Context, signedInUser *models.SignedInUser, cmd CreateLibraryElementCommand) (LibraryElementDTO, error)
GetElement(c context.Context, signedInUser *models.SignedInUser, UID string) (LibraryElementDTO, error)
GetElementsForDashboard(c context.Context, dashboardID int64) (map[string]LibraryElementDTO, error)
ConnectElementsToDashboard(c context.Context, signedInUser *models.SignedInUser, elementUIDs []string, dashboardID int64) error
DisconnectElementsFromDashboard(c context.Context, dashboardID int64) error
DeleteLibraryElementsInFolder(c context.Context, signedInUser *models.SignedInUser, folderUID string) error
}
Service is a service for operating on library elements.