Documentation
¶
Index ¶
- Constants
- Variables
- type AlertRuleFilterParams
- type AlertRuleWithNestedFolder
- type ConnectionPermissionItem
- type ContextHandler
- type DashboardAndPermissions
- type DashboardPermissionsGdg
- type DashboardResourceV2
- type DashboardV2Gdg
- type FilterReader
- type FilterType
- type InputValidation
- type NestedHit
- type OrgsDTOWithPreferences
- type PluginRegistryEntry
- type PluginVersionEntry
- type Processor
- type ProcessorEntity
- type ResourceType
- type ServiceAccountDTOWithTokens
- type UserProfileWithAuth
- type WithNested
Constants ¶
const ( DashboardV2Group = "dashboard.grafana.app" DashboardV2Version = "v2" // GA in Grafana 13; discover served versions via GET /apis/dashboard.grafana.app DashboardV2Resource = "dashboards" DashboardV2Kind = "Dashboard" // AnnotationFolder holds the parent folder UID on a dashboard resource. AnnotationFolder = "grafana.app/folder" // GdgApiVersionV1 tags a stored dashboard as originating from the legacy /api/dashboards endpoint. GdgApiVersionV1 = "v1" // GdgApiVersionV2 tags a stored dashboard as originating from the App Platform /apis endpoint. GdgApiVersionV2 = DashboardV2Group + "/" + DashboardV2Version )
App Platform (Kubernetes-style) coordinates for the v2 Dashboard API served under /apis. These replace the deprecated /api/dashboards endpoints.
const ( // GdgPermApiVersionV1 tags a stored dashboard-permissions file as originating // from the legacy ACL API (GET /api/dashboards/uid/{uid}/permissions). // Used by Grafana v12 and earlier, or v13 as a fallback. GdgPermApiVersionV1 = "v1" // GdgPermApiVersionV2 tags a stored dashboard-permissions file as originating // from the RBAC access-control API (GET /api/access-control/dashboards/{uid}). // Used by Grafana v13+. GdgPermApiVersionV2 = "dashboard-permissions.grafana/v2" )
const ( // PluginTypeCipher is the only plugin type currently supported. PluginTypeCipher = "cipher" // RegistryDefaultURL is the canonical location of the GDG plugin registry JSON file. RegistryDefaultURL = "https://raw.githubusercontent.com/esnet/gdg-plugins/refs/heads/main/plugin_registry.json" )
Variables ¶
var ApiConsts = apiConsts{
DefaultFolderName: "General",
SearchTypeDashboard: "dash-db",
SearchTypeFolder: "dash-folder",
}
Functions ¶
This section is empty.
Types ¶
type AlertRuleFilterParams ¶
type AlertRuleFilterParams struct {
Folder string
UID string
Label []string
IgnoreWatchedFolders bool
}
AlertRuleFilterParams defines the filtering criteria used to narrow down alert rules during import or export operations. It allows filtering by folder name, a set of labels, and provides an option to ignore folder-based rules.
type AlertRuleWithNestedFolder ¶
type AlertRuleWithNestedFolder struct {
*models.ProvisionedAlertRule
NestedPath string
}
type ConnectionPermissionItem ¶
type ConnectionPermissionItem struct {
Connection *models.DataSourceListItemDTO
Permissions []*models.ResourcePermissionDTO
}
ConnectionPermissionItem holds a connection and its associated permissions.
type ContextHandler ¶
type ContextHandler struct {
// contains filtered or unexported fields
}
func NewContextHandler ¶
type DashboardAndPermissions ¶
type DashboardAndPermissions struct {
Dashboard *NestedHit
Permissions []*models.ResourcePermissionDTO
}
DashboardAndPermissions holds a dashboard reference and its unified permission list. Permissions is always []*models.ResourcePermissionDTO regardless of the Grafana API version in use — the v1 path maps DashboardACLInfoDTO to ResourcePermissionDTO internally before returning, so callers always work with a single type.
type DashboardPermissionsGdg ¶ added in v0.9.4
type DashboardPermissionsGdg struct {
DashboardUID string `json:"dashboard_uid"`
DashboardName string `json:"dashboard_name"`
GdgApiVersion string `json:"gdg_api_version"`
Permissions []*models.ResourcePermissionDTO `json:"permissions"`
}
DashboardPermissionsGdg is the GDG on-disk wrapper for a dashboard's permission set. It is written by DownloadDashboardPermissions and read by UploadDashboardPermissions.
- DashboardUID is the Grafana dashboard UID — used to target the correct dashboard when uploading permissions.
- DashboardName is the human-readable title, stored for readability only.
- GdgApiVersion records the API version at download time (GdgPermApiVersionV1 or GdgPermApiVersionV2). At upload time this is compared against the target server version to route to the correct API and detect format mismatches.
- Permissions is always []*models.ResourcePermissionDTO regardless of API version — the v1 path maps DashboardACLInfoDTO → ResourcePermissionDTO before writing, keeping the on-disk format unified.
type DashboardResourceV2 ¶ added in v0.9.4
type DashboardResourceV2 struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec dashboardv2.Dashboard `json:"spec"`
Status map[string]any `json:"status,omitempty"`
}
DashboardResourceV2 is the pure App Platform wire envelope for a dashboard. It contains only the fields that Grafana sends and receives — no GDG-internal bookkeeping. This makes marshalling/unmarshalling clean and removes the need for the intermediate dashboardV2Payload type in the adapter layer.
func (*DashboardResourceV2) FolderUID ¶ added in v0.9.4
func (d *DashboardResourceV2) FolderUID() string
FolderUID returns the parent folder UID from the resource annotations, if any. An empty string means the dashboard lives in the default (General) folder.
func (*DashboardResourceV2) SetFolderUID ¶ added in v0.9.4
func (d *DashboardResourceV2) SetFolderUID(uid string)
SetFolderUID sets the parent folder UID annotation on the resource. An empty value clears it, placing the dashboard in the default (General) folder.
type DashboardV2Gdg ¶ added in v0.9.4
type DashboardV2Gdg struct {
Resource *DashboardResourceV2 `json:"resource"`
NestedPath string `json:"nested_path"`
GdgApiVersion string `json:"gdg_api_version"`
}
DashboardV2Gdg is the GDG-internal wrapper around a DashboardResourceV2. It carries bookkeeping fields that are written to local storage alongside the resource but are never sent to the Grafana API.
- Resource holds the pure API envelope (what Grafana sends/receives).
- NestedPath is the resolved folder path used for the on-disk storage layout.
- GdgApiVersion records the API version in use at download time (GdgApiVersionV1 or GdgApiVersionV2). At upload time this is compared against the target server to detect format mismatches early.
type FilterReader ¶
type FilterType ¶
type FilterType string
FilterType Currently supported filters
const ( TagsFilter FilterType = "TagsFilter" DashFilter FilterType = "DashFilter" FolderFilter FilterType = "FolderFilter" AlertRuleFilterType = "AlertRuleFilter" Name FilterType = "Name" UID FilterType = "UID" ConnectionName FilterType = "ConnectionName" // used for Connection name AuthLabel FilterType = "AuthLabel" OrgFilter FilterType = "OrgFilter" )
func (FilterType) String ¶
func (s FilterType) String() string
type InputValidation ¶
type NestedHit ¶
NestedHit represents a Dashboard or Folder with an associated nested path in dashboard filtering.
type OrgsDTOWithPreferences ¶
type OrgsDTOWithPreferences struct {
Organization *models.OrgDTO `json:"organization"`
Preferences *models.PreferencesSpec `json:"preferences"` // Preferences are preferences associated with a given org. theme, dashboard, timezone, etc
}
OrgsDTOWithPreferences represents an organization and its preferences.
type PluginRegistryEntry ¶ added in v0.9.4
type PluginRegistryEntry struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
Source string `json:"source"`
URLPattern string `json:"urlPattern"`
Versions []PluginVersionEntry `json:"versions"`
}
PluginRegistryEntry represents a single plugin entry in the remote registry JSON array.
func (*PluginRegistryEntry) FindVersion ¶ added in v0.9.4
func (e *PluginRegistryEntry) FindVersion(version string) *PluginVersionEntry
FindVersion returns the PluginVersionEntry whose Version field matches the given string, or nil if no matching entry is found.
func (*PluginRegistryEntry) LatestVersion ¶ added in v0.9.4
func (e *PluginRegistryEntry) LatestVersion() *PluginVersionEntry
LatestVersion returns the last element of Versions, which is assumed to be the most recently released version. Returns nil if Versions is empty.
func (*PluginRegistryEntry) ResolveURL ¶ added in v0.9.4
func (e *PluginRegistryEntry) ResolveURL(version string) string
ResolveURL returns the concrete WASM download URL for this entry by replacing the "{version}" placeholder in URLPattern with the given version string.
type PluginVersionEntry ¶ added in v0.9.4
type PluginVersionEntry struct {
Version string `json:"version"`
ConfigFields []string `json:"config_fields"`
MinimumVersion string `json:"minimum_version"`
MaximumVersion string `json:"maximum_version"`
}
PluginVersionEntry describes one released version of a plugin and which config fields the caller must supply when using it.
func (*PluginVersionEntry) IsValid ¶ added in v0.9.4
func (e *PluginVersionEntry) IsValid() bool
type ProcessorEntity ¶
type ProcessorEntity struct {
Name string
// priority int8
// postProcess bool
Processor Processor
}
func (ProcessorEntity) Validate ¶
func (p ProcessorEntity) Validate() error
type ResourceType ¶
type ResourceType string
const ( ConnectionPermissionResource ResourceType = "connections-permissions" ConnectionResource ResourceType = "connections" DashboardPermissionsResource ResourceType = "dashboards-permissions" DashboardResource ResourceType = "dashboards" FolderPermissionResource ResourceType = "folders-permissions" FolderResource ResourceType = "folders" LibraryElementResource ResourceType = "libraryelements" OrganizationResource ResourceType = "organizations" OrganizationMetaResource ResourceType = "org" TeamResource ResourceType = "teams" UserResource ResourceType = "users" TemplatesResource ResourceType = "templates" SecureSecretsResource ResourceType = "secure" AlertingResource ResourceType = "alerting" AlertingRulesResource ResourceType = "alerting-rules" )
func (*ResourceType) GetPath ¶
func (s *ResourceType) GetPath(basePath string, orgName string) string
GetPath returns the path of the resource type, if Namespaced, will delimit the path by org Id
func (*ResourceType) String ¶
func (s *ResourceType) String() string
String returns the string representation of the resource type
type ServiceAccountDTOWithTokens ¶
type ServiceAccountDTOWithTokens struct {
ServiceAccount *models.ServiceAccountDTO
Tokens []*models.TokenDTO
}
ServiceAccountDTOWithTokens represents a service account and its associated tokens.
type UserProfileWithAuth ¶
type UserProfileWithAuth struct {
models.UserProfileDTO
Password string // #nosec G117 is the user's temporary generated password
}
UserProfileWithAuth embeds UserProfileDTO and adds a Password field for authentication.
type WithNested ¶
WithNested represents an entity with a nested path for filtering purposes.