refactor(grafana): rework grafana package and make it more modular
This commit is contained in:
parent
cfcf3c6c2b
commit
7ce90dacc4
12 changed files with 710 additions and 282 deletions
59
pkg/grafana/schema/dashboard.go
Normal file
59
pkg/grafana/schema/dashboard.go
Normal file
|
@ -0,0 +1,59 @@
|
|||
package schema
|
||||
|
||||
import "time"
|
||||
|
||||
type DashboardCreateRequest struct {
|
||||
Dashboard any `json:"dasboard"`
|
||||
FolderID uint `json:"folderId,omitempty"`
|
||||
FolderUID string `json:"folderUid"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Overwrite bool `json:"overwrite"`
|
||||
}
|
||||
|
||||
type DashboardCreateResponse struct {
|
||||
DashboardID uint `json:"id"`
|
||||
DashboardUID string `json:"uid"`
|
||||
URL string `json:"url"`
|
||||
Status string `json:"status"`
|
||||
Version uint `json:"version"`
|
||||
Slug string `json:"slug"`
|
||||
}
|
||||
|
||||
type DashboardMeta struct {
|
||||
IsStarred bool `json:"isStarred"`
|
||||
Type string `json:"type"`
|
||||
CanSave bool `json:"canSave"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
CanAdmin bool `json:"canAdmin"`
|
||||
CanStar bool `json:"canStar"`
|
||||
CanDelete bool `json:"canDelete"`
|
||||
Slug string `json:"slug"`
|
||||
URL string `json:"url"`
|
||||
Expires time.Time `json:"expires"`
|
||||
Created time.Time `json:"created"`
|
||||
Updated time.Time `json:"updated"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
Version uint `json:"version"`
|
||||
HasACL bool `json:"hasAcl"`
|
||||
IsFolder bool `json:"isFolder"`
|
||||
FolderID uint `json:"folderId"`
|
||||
FolderUID string `json:"folderUid"`
|
||||
FolderTitle string `json:"folderTitle"`
|
||||
FolderURL string `json:"folderUrl"`
|
||||
Provisioned bool `json:"provisioned"`
|
||||
ProvisionedExternalID string `json:"provisionedExternalId"`
|
||||
AnnotationsPermissions struct {
|
||||
Dashboard struct {
|
||||
CanAdd bool `json:"canAdd"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
CanDelete bool `json:"canDelete"`
|
||||
} `json:"dashboard"`
|
||||
Organization struct {
|
||||
CanAdd bool `json:"canAdd"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
CanDelete bool `json:"canDelete"`
|
||||
} `json:"organization"`
|
||||
} `json:"annotationsPermissions"`
|
||||
Dashboard any `json:"dashboard"`
|
||||
}
|
20
pkg/grafana/schema/dashboard_version.go
Normal file
20
pkg/grafana/schema/dashboard_version.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package schema
|
||||
|
||||
import "time"
|
||||
|
||||
type DashboardVersion struct {
|
||||
ID uint `json:"id"`
|
||||
DashboardID uint `json:"dashboardId"`
|
||||
UID string `json:"uid"`
|
||||
ParentVersion uint `json:"parentVersion"`
|
||||
RestoredFrom uint `json:"restoredFrom"`
|
||||
Version uint `json:"version"`
|
||||
Created time.Time `json:"created"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data"`
|
||||
}
|
||||
|
||||
type DashboardVersionListResponse struct {
|
||||
DashboardVersions []DashboardVersion
|
||||
}
|
6
pkg/grafana/schema/error.go
Normal file
6
pkg/grafana/schema/error.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package schema
|
||||
|
||||
type ErrorResponse struct {
|
||||
Message string `json:"message"`
|
||||
TraceID uint `json:"traceid"`
|
||||
}
|
22
pkg/grafana/schema/search.go
Normal file
22
pkg/grafana/schema/search.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package schema
|
||||
|
||||
type SearchResult struct {
|
||||
ID uint `json:"id"`
|
||||
UID string `json:"uid"`
|
||||
Title string `json:"title"`
|
||||
URI string `json:"uri"`
|
||||
URL string `json:"url"`
|
||||
Slug string `json:"slug"`
|
||||
Type string `json:"type"`
|
||||
Tags []string `json:"tags"`
|
||||
IsStarred bool `json:"isStarred"`
|
||||
SortMeta uint `json:"sortMeta"`
|
||||
FolderID int `json:"folderId"`
|
||||
FolderUID string `json:"folderUid"`
|
||||
FolderTitle string `json:"folderTitle"`
|
||||
FolderURL string `json:"folderUrl"`
|
||||
}
|
||||
|
||||
type SearchResultListResponse struct {
|
||||
SearchResults []SearchResult
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue