grafana/pkg/models/dashboards_public.go
Jeff Levin 52ed651958
public dashboards: insert default public dashboard config into database on save (#49131)
This PR adds endpoints for saving and retrieving a public dashboard configuration and and api endpoint to retrieve the public dashboard.

All of this is highly experimental and APIs will change. Notably, we will be removing isPublic from the dashboard model and moving it over to the public dashboard table in the next release.

Further context can be found here: https://github.com/grafana/grafana/pull/49131#issuecomment-1145456952
2022-06-02 18:27:23 -08:00

44 lines
1.1 KiB
Go

package models
var (
ErrPublicDashboardFailedGenerateUniqueUid = DashboardErr{
Reason: "Failed to generate unique dashboard id",
StatusCode: 500,
}
ErrPublicDashboardNotFound = DashboardErr{
Reason: "Public dashboard not found",
StatusCode: 404,
Status: "not-found",
}
ErrPublicDashboardIdentifierNotSet = DashboardErr{
Reason: "No Uid for public dashboard specified",
StatusCode: 400,
}
)
type PublicDashboardConfig struct {
IsPublic bool `json:"isPublic"`
PublicDashboard PublicDashboard `json:"publicDashboard"`
}
type PublicDashboard struct {
Uid string `json:"uid" xorm:"uid"`
DashboardUid string `json:"dashboardUid" xorm:"dashboard_uid"`
OrgId int64 `json:"orgId" xorm:"org_id"`
TimeSettings string `json:"timeSettings" xorm:"time_settings"`
}
func (pd PublicDashboard) TableName() string {
return "dashboard_public_config"
}
//
// COMMANDS
//
type SavePublicDashboardConfigCommand struct {
DashboardUid string
OrgId int64
PublicDashboardConfig PublicDashboardConfig
}