Skip to content

Instantly share code, notes, and snippets.

@sdboyer
Last active May 18, 2022 15:30
Show Gist options
  • Save sdboyer/b42727781811f4f054db1449990dc0eb to your computer and use it in GitHub Desktop.
Save sdboyer/b42727781811f4f054db1449990dc0eb to your computer and use it in GitHub Desktop.
These files were autogenerated (LIKE A MOTHAFUCKA) from a Thema schema. Editing is futile.
{
"info": {
"title": "dashboard",
"version": "0.0"
},
"paths": {},
"components": {
"schemas": {
"dashboard": {
"type": "object",
"required": [
"style",
"editable",
"graphTooltip",
"schemaVersion"
],
"properties": {
"id": {
"description": "Unique numeric identifier for the dashboard.\nTODO must isolate or remove identifiers local to a Grafana instance...?",
"type": "integer",
"format": "int64"
},
"uid": {
"description": "Unique dashboard identifier that can be generated by anyone. string (8-40)",
"type": "string"
},
"title": {
"description": "Title of dashboard.",
"type": "string"
},
"description": {
"description": "Description of dashboard.",
"type": "string"
},
"gnetId": {
"type": "string"
},
"tags": {
"description": "Tags associated with dashboard.",
"type": "array",
"items": {
"type": "string"
}
},
"style": {
"description": "Theme of dashboard.",
"type": "string",
"enum": [
"light",
"dark"
],
"default": "light"
},
"timezone": {
"description": "Timezone of dashboard,",
"type": "string",
"enum": [
"browser",
"utc",
""
],
"default": "browser"
},
"editable": {
"description": "Whether a dashboard is editable or not.",
"type": "boolean",
"default": true
},
"graphTooltip": {
"description": "0 for no shared crosshair or tooltip (default).\n1 for shared crosshair.\n2 for shared crosshair AND shared tooltip.",
"type": "integer",
"minimum": 0,
"maximum": 2,
"default": 0
},
"time": {
"description": "Time range for dashboard, e.g. last 6 hours, last 7 days, etc",
"type": "object",
"required": [
"from",
"to"
],
"properties": {
"from": {
"type": "string",
"default": "now-6h"
},
"to": {
"type": "string",
"default": "now"
}
}
},
"timepicker": {
"description": "Timepicker metadata.",
"type": "object",
"required": [
"collapse",
"enable",
"hidden",
"refresh_intervals"
],
"properties": {
"collapse": {
"description": "Whether timepicker is collapsed or not.",
"type": "boolean",
"default": false
},
"enable": {
"description": "Whether timepicker is enabled or not.",
"type": "boolean",
"default": true
},
"hidden": {
"description": "Whether timepicker is visible or not.",
"type": "boolean",
"default": false
},
"refresh_intervals": {
"description": "Selectable intervals for auto-refresh.",
"type": "array",
"items": {
"type": "string"
},
"default": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
}
}
},
"templating": {
"type": "object",
"required": [
"list"
],
"properties": {
"list": {
"type": "array",
"items": {
"type": "object"
}
}
}
},
"annotations": {
"type": "object",
"required": [
"list"
],
"properties": {
"list": {
"type": "array",
"items": {
"type": "object",
"required": [
"builtIn",
"datasource",
"enable",
"type",
"showIn"
],
"properties": {
"builtIn": {
"type": "integer",
"minimum": 0,
"maximum": 255,
"default": 0
},
"datasource": {
"description": "Datasource to use for annotation.",
"type": "object",
"properties": {
"type": {
"type": "string"
},
"uid": {
"type": "string"
}
}
},
"enable": {
"description": "Whether annotation is enabled.",
"type": "boolean",
"default": true
},
"hide": {
"description": "Whether to hide annotation.",
"type": "boolean",
"default": false
},
"iconColor": {
"description": "Annotation icon color.",
"type": "string"
},
"name": {
"description": "Name of annotation.",
"type": "string"
},
"type": {
"type": "string",
"default": "dashboard"
},
"rawQuery": {
"description": "Query for annotation data.",
"type": "string"
},
"showIn": {
"type": "integer",
"minimum": 0,
"maximum": 255,
"default": 0
}
}
}
}
}
},
"refresh": {
"description": "Auto-refresh interval.",
"oneOf": [
{
"enum": [
false
]
},
{
"type": "string"
}
]
},
"schemaVersion": {
"description": "Version of the JSON schema, incremented each time a Grafana update brings\nchanges to said schema.\nFIXME this is the old schema numbering system, and will be replaced by Thema's themaVersion",
"type": "integer",
"minimum": 0,
"maximum": 65535,
"default": 33
},
"version": {
"description": "Version of the dashboard, incremented each time the dashboard is updated.",
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"panels": {
"type": "array",
"items": {
"type": "object",
"oneOf": [
{
"$ref": "#/components/schemas/dashboard.Panel"
},
{
"$ref": "#/components/schemas/dashboard.GraphPanel"
},
{
"$ref": "#/components/schemas/dashboard.HeatmapPanel"
},
{
"$ref": "#/components/schemas/dashboard.RowPanel"
}
]
}
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.FieldColor": {
"description": "TODO docs",
"type": "object",
"required": [
"mode"
],
"properties": {
"mode": {
"description": "The main color scheme mode",
"type": "string",
"oneOf": [
{
"enum": [
"thresholds",
"palette-classic",
"palette-saturated",
"continuous-GrYlRd",
"fixed"
]
},
{}
]
},
"fixedColor": {
"description": "Stores the fixed color value if mode is fixed",
"type": "string"
},
"seriesBy": {
"$ref": "#/components/schemas/dashboard.FieldColorSeriesByMode"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.FieldColorModeId": {
"description": "TODO docs",
"type": "string",
"enum": [
"thresholds",
"palette-classic",
"palette-saturated",
"continuous-GrYlRd",
"fixed"
],
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.FieldColorSeriesByMode": {
"description": "TODO docs",
"type": "string",
"enum": [
"min",
"max",
"last"
],
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.GraphPanel": {
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"description": "Support for legacy graph and heatmap panels.",
"type": "string",
"enum": [
"graph"
]
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.HeatmapPanel": {
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"heatmap"
]
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.Panel": {
"description": "Dashboard panels. Panels are canonically defined inline\nbecause they share a version timeline with the dashboard\nschema; they do not evolve independently.",
"type": "object",
"required": [
"type",
"transparent",
"repeatDirection",
"transformations",
"options",
"fieldConfig"
],
"properties": {
"type": {
"description": "The panel plugin type id.",
"type": "string",
"minLength": 1
},
"id": {
"description": "TODO docs",
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"pluginVersion": {
"description": "FIXME this almost certainly has to be changed in favor of scuemata versions",
"type": "string"
},
"tags": {
"description": "TODO docs",
"type": "array",
"items": {
"type": "string"
}
},
"targets": {
"description": "TODO docs",
"type": "array",
"items": {
"$ref": "#/components/schemas/dashboard.Target"
}
},
"title": {
"description": "Panel title.",
"type": "string"
},
"description": {
"description": "Description.",
"type": "string"
},
"transparent": {
"description": "Whether to display the panel without a background.",
"type": "boolean",
"default": false
},
"datasource": {
"description": "The datasource used in all targets.",
"type": "object",
"properties": {
"type": {
"type": "string"
},
"uid": {
"type": "string"
}
}
},
"gridPos": {
"description": "Grid position.",
"type": "object",
"required": [
"h",
"w",
"x",
"y"
],
"properties": {
"h": {
"description": "Panel",
"type": "integer",
"minimum": 0,
"exclusiveMinimum": true,
"maximum": 4294967295,
"default": 9
},
"w": {
"description": "Panel",
"type": "integer",
"minimum": 0,
"exclusiveMinimum": true,
"maximum": 24,
"default": 12
},
"x": {
"description": "Panel x",
"type": "integer",
"minimum": 0,
"maximum": 24,
"exclusiveMaximum": true,
"default": 0
},
"y": {
"description": "Panel y",
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"static": {
"description": "true if fixed",
"type": "boolean"
}
}
},
"links": {
"description": "Panel links.\nFIXME this is temporarily specified as a closed list so\nthat validation will pass when no links are present, but\nto force a failure as soon as it's checked against there\nbeing anything in the list so it can be fixed in\naccordance with that object",
"type": "array",
"enum": [
[]
]
},
"repeat": {
"description": "Name of template variable to repeat for.",
"type": "string"
},
"repeatDirection": {
"description": "Direction to repeat in if 'repeat' is set.\n\"h\" for horizontal, \"v\" for vertical.",
"type": "string",
"enum": [
"h",
"v"
],
"default": "h"
},
"maxDataPoints": {
"description": "TODO docs",
"type": "number"
},
"thresholds": {
"description": "TODO docs",
"type": "array",
"items": {}
},
"timeRegions": {
"description": "TODO docs",
"type": "array",
"items": {}
},
"transformations": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"options"
],
"properties": {
"id": {
"type": "string"
},
"options": {
"type": "object"
}
}
}
},
"interval": {
"description": "TODO docs\nTODO tighter constraint",
"type": "string"
},
"timeFrom": {
"description": "TODO docs\nTODO tighter constraint",
"type": "string"
},
"timeShift": {
"description": "TODO docs\nTODO tighter constraint",
"type": "string"
},
"options": {
"description": "options is specified by the PanelOptions field in panel\nplugin schemas.",
"type": "object"
},
"fieldConfig": {
"type": "object",
"required": [
"defaults",
"overrides"
],
"properties": {
"defaults": {
"type": "object",
"properties": {
"displayName": {
"description": "The display value for this field. This supports template variables blank is auto",
"type": "string"
},
"displayNameFromDS": {
"description": "This can be used by data sources that return and explicit naming structure for values and labels\nWhen this property is configured, this value is used rather than the default naming strategy.",
"type": "string"
},
"description": {
"description": "Human readable field metadata",
"type": "string"
},
"path": {
"description": "An explict path to the field in the datasource. When the frame meta includes a path,\nThis will default to `${frame.meta.path}/${field.name}\n\nWhen defined, this value can be used as an identifier within the datasource scope, and\nmay be used to update the results",
"type": "string"
},
"writeable": {
"description": "True if data source can write a value to the path. Auth/authz are supported separately",
"type": "boolean"
},
"filterable": {
"description": "True if data source field supports ad-hoc filters",
"type": "boolean"
},
"unit": {
"description": "Numeric Options",
"type": "string"
},
"decimals": {
"description": "Significant digits (for display)",
"type": "number"
},
"min": {
"type": "number"
},
"max": {
"type": "number"
},
"mappings": {
"description": "Convert input values into a display string\n\nTODO this one corresponds to a complex type with\ngenerics on the typescript side. Ouch. Will\neither need special care, or we'll just need to\naccept a very loosely specified schema. It's very\nunlikely we'll be able to translate cue to\ntypescript generics in the general case, though\nthis particular one *may* be able to work.",
"type": "array",
"items": {
"type": "object"
}
},
"thresholds": {
"$ref": "#/components/schemas/dashboard.ThresholdsConfig"
},
"color": {
"$ref": "#/components/schemas/dashboard.FieldColor"
},
"links": {
"description": "// The behavior when clicking on a result",
"type": "array",
"items": {}
},
"noValue": {
"description": "Alternative to empty string",
"type": "string"
},
"custom": {
"description": "custom is specified by the PanelFieldConfig field\nin panel plugin schemas.",
"type": "object"
}
}
},
"overrides": {
"type": "array",
"items": {
"type": "object",
"required": [
"matcher",
"properties"
],
"properties": {
"matcher": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"default": ""
},
"options": {}
}
},
"properties": {
"type": "array",
"items": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"default": ""
},
"value": {}
}
}
}
}
}
}
}
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.RowPanel": {
"description": "Row panel",
"type": "object",
"required": [
"type",
"collapsed",
"id",
"panels"
],
"properties": {
"type": {
"type": "string",
"enum": [
"row"
]
},
"collapsed": {
"type": "boolean",
"default": false
},
"title": {
"type": "string"
},
"datasource": {
"description": "Name of default datasource.",
"type": "object",
"properties": {
"type": {
"type": "string"
},
"uid": {
"type": "string"
}
}
},
"gridPos": {
"type": "object",
"required": [
"h",
"w",
"x",
"y"
],
"properties": {
"h": {
"description": "Panel",
"type": "integer",
"minimum": 0,
"exclusiveMinimum": true,
"maximum": 4294967295,
"default": 9
},
"w": {
"description": "Panel",
"type": "integer",
"minimum": 0,
"exclusiveMinimum": true,
"maximum": 24,
"default": 12
},
"x": {
"description": "Panel x",
"type": "integer",
"minimum": 0,
"maximum": 24,
"exclusiveMaximum": true,
"default": 0
},
"y": {
"description": "Panel y",
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"static": {
"description": "true if fixed",
"type": "boolean"
}
}
},
"id": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"panels": {
"type": "array",
"items": {
"type": "object",
"oneOf": [
{
"required": [
"type",
"transparent",
"repeatDirection",
"transformations",
"options",
"fieldConfig"
],
"properties": {
"type": {
"description": "The panel plugin type id.",
"type": "string",
"minLength": 1
},
"id": {
"description": "TODO docs",
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"pluginVersion": {
"description": "FIXME this almost certainly has to be changed in favor of scuemata versions",
"type": "string"
},
"tags": {
"description": "TODO docs",
"type": "array",
"items": {
"type": "string"
}
},
"targets": {
"description": "TODO docs",
"type": "array",
"items": {
"$ref": "#/components/schemas/dashboard.Target"
}
},
"title": {
"description": "Panel title.",
"type": "string"
},
"description": {
"description": "Description.",
"type": "string"
},
"transparent": {
"description": "Whether to display the panel without a background.",
"type": "boolean",
"default": false
},
"datasource": {
"description": "The datasource used in all targets.",
"type": "object",
"properties": {
"type": {
"type": "string"
},
"uid": {
"type": "string"
}
}
},
"gridPos": {
"description": "Grid position.",
"type": "object",
"required": [
"h",
"w",
"x",
"y"
],
"properties": {
"h": {
"description": "Panel",
"type": "integer",
"minimum": 0,
"exclusiveMinimum": true,
"maximum": 4294967295,
"default": 9
},
"w": {
"description": "Panel",
"type": "integer",
"minimum": 0,
"exclusiveMinimum": true,
"maximum": 24,
"default": 12
},
"x": {
"description": "Panel x",
"type": "integer",
"minimum": 0,
"maximum": 24,
"exclusiveMaximum": true,
"default": 0
},
"y": {
"description": "Panel y",
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"static": {
"description": "true if fixed",
"type": "boolean"
}
}
},
"links": {
"description": "Panel links.\nFIXME this is temporarily specified as a closed list so\nthat validation will pass when no links are present, but\nto force a failure as soon as it's checked against there\nbeing anything in the list so it can be fixed in\naccordance with that object",
"type": "array",
"enum": [
[]
]
},
"repeat": {
"description": "Name of template variable to repeat for.",
"type": "string"
},
"repeatDirection": {
"description": "Direction to repeat in if 'repeat' is set.\n\"h\" for horizontal, \"v\" for vertical.",
"type": "string",
"enum": [
"h",
"v"
],
"default": "h"
},
"maxDataPoints": {
"description": "TODO docs",
"type": "number"
},
"thresholds": {
"description": "TODO docs",
"type": "array",
"items": {}
},
"timeRegions": {
"description": "TODO docs",
"type": "array",
"items": {}
},
"transformations": {
"type": "array",
"items": {
"type": "object",
"required": [
"id",
"options"
],
"properties": {
"id": {
"type": "string"
},
"options": {
"type": "object"
}
}
}
},
"interval": {
"description": "TODO docs\nTODO tighter constraint",
"type": "string"
},
"timeFrom": {
"description": "TODO docs\nTODO tighter constraint",
"type": "string"
},
"timeShift": {
"description": "TODO docs\nTODO tighter constraint",
"type": "string"
},
"options": {
"description": "options is specified by the PanelOptions field in panel\nplugin schemas.",
"type": "object"
},
"fieldConfig": {
"type": "object",
"required": [
"defaults",
"overrides"
],
"properties": {
"defaults": {
"type": "object",
"properties": {
"displayName": {
"description": "The display value for this field. This supports template variables blank is auto",
"type": "string"
},
"displayNameFromDS": {
"description": "This can be used by data sources that return and explicit naming structure for values and labels\nWhen this property is configured, this value is used rather than the default naming strategy.",
"type": "string"
},
"description": {
"description": "Human readable field metadata",
"type": "string"
},
"path": {
"description": "An explict path to the field in the datasource. When the frame meta includes a path,\nThis will default to `${frame.meta.path}/${field.name}\n\nWhen defined, this value can be used as an identifier within the datasource scope, and\nmay be used to update the results",
"type": "string"
},
"writeable": {
"description": "True if data source can write a value to the path. Auth/authz are supported separately",
"type": "boolean"
},
"filterable": {
"description": "True if data source field supports ad-hoc filters",
"type": "boolean"
},
"unit": {
"description": "Numeric Options",
"type": "string"
},
"decimals": {
"description": "Significant digits (for display)",
"type": "number"
},
"min": {
"type": "number"
},
"max": {
"type": "number"
},
"mappings": {
"description": "Convert input values into a display string\n\nTODO this one corresponds to a complex type with\ngenerics on the typescript side. Ouch. Will\neither need special care, or we'll just need to\naccept a very loosely specified schema. It's very\nunlikely we'll be able to translate cue to\ntypescript generics in the general case, though\nthis particular one *may* be able to work.",
"type": "array",
"items": {
"type": "object"
}
},
"thresholds": {
"$ref": "#/components/schemas/dashboard.ThresholdsConfig"
},
"color": {
"$ref": "#/components/schemas/dashboard.FieldColor"
},
"links": {
"description": "// The behavior when clicking on a result",
"type": "array",
"items": {}
},
"noValue": {
"description": "Alternative to empty string",
"type": "string"
},
"custom": {
"description": "custom is specified by the PanelFieldConfig field\nin panel plugin schemas.",
"type": "object"
}
}
},
"overrides": {
"type": "array",
"items": {
"type": "object",
"required": [
"matcher",
"properties"
],
"properties": {
"matcher": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"default": ""
},
"options": {}
}
},
"properties": {
"type": "array",
"items": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"default": ""
},
"value": {}
}
}
}
}
}
}
}
}
}
},
{
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"graph"
]
}
}
},
{
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"heatmap"
]
}
}
}
]
}
},
"repeat": {
"description": "Name of template variable to repeat for.",
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.Target": {
"description": "Schema for panel targets is specified by datasource\nplugins. We use a placeholder definition, which the Go\nschema loader either left open/as-is with the Base\nvariant of the Dashboard and Panel families, or filled\nwith types derived from plugins in the Instance variant.\nWhen working directly from CUE, importers can extend this\ntype directly to achieve the same effect.",
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.Threshold": {
"description": "TODO docs",
"type": "object",
"required": [
"color"
],
"properties": {
"value": {
"description": "TODO docs\nFIXME the corresponding typescript field is required/non-optional, but nulls currently appear here when serializing -Infinity to JSON",
"type": "number"
},
"color": {
"description": "TODO docs",
"type": "string"
},
"state": {
"description": "TODO docs\nTODO are the values here enumerable into a disjunction?\nSome seem to be listed in typescript comment",
"type": "string"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.ThresholdsConfig": {
"type": "object",
"required": [
"mode",
"steps"
],
"properties": {
"mode": {
"type": "string",
"enum": [
"absolute",
"percentage"
]
},
"steps": {
"description": "Must be sorted by 'value', first value is always -Infinity",
"type": "array",
"items": {
"type": "object",
"required": [
"color"
],
"properties": {
"value": {
"description": "TODO docs\nFIXME the corresponding typescript field is required/non-optional, but nulls currently appear here when serializing -Infinity to JSON",
"type": "number"
},
"color": {
"description": "TODO docs",
"type": "string"
},
"state": {
"description": "TODO docs\nTODO are the values here enumerable into a disjunction?\nSome seem to be listed in typescript comment",
"type": "string"
}
}
}
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.ThresholdsMode": {
"type": "string",
"enum": [
"absolute",
"percentage"
],
"$schema": "http://json-schema.org/draft-04/schema#"
},
"dashboard.Transformation": {
"description": "TODO docs\nFIXME this is extremely underspecfied; wasn't obvious which typescript types corresponded to it",
"type": "object",
"required": [
"id",
"options"
],
"properties": {
"id": {
"type": "string"
},
"options": {
"type": "object"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}
}
}
}
// Package Dash provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.10.1 DO NOT EDIT.
package dashboard
// Defines values for DashboardStyle.
const (
DashboardStyleDark DashboardStyle = "dark"
DashboardStyleLight DashboardStyle = "light"
)
// Defines values for DashboardTimezone.
const (
DashboardTimezoneBrowser DashboardTimezone = "browser"
DashboardTimezoneEmpty DashboardTimezone = ""
DashboardTimezoneUtc DashboardTimezone = "utc"
)
// Defines values for DashboardFieldColorModeId.
const (
DashboardFieldColorModeIdContinuousGrYlRd DashboardFieldColorModeId = "continuous-GrYlRd"
DashboardFieldColorModeIdFixed DashboardFieldColorModeId = "fixed"
DashboardFieldColorModeIdPaletteClassic DashboardFieldColorModeId = "palette-classic"
DashboardFieldColorModeIdPaletteSaturated DashboardFieldColorModeId = "palette-saturated"
DashboardFieldColorModeIdThresholds DashboardFieldColorModeId = "thresholds"
)
// Defines values for DashboardFieldColorSeriesByMode.
const (
DashboardFieldColorSeriesByModeLast DashboardFieldColorSeriesByMode = "last"
DashboardFieldColorSeriesByModeMax DashboardFieldColorSeriesByMode = "max"
DashboardFieldColorSeriesByModeMin DashboardFieldColorSeriesByMode = "min"
)
// Defines values for DashboardGraphPanelType.
const (
DashboardGraphPanelTypeGraph DashboardGraphPanelType = "graph"
)
// Defines values for DashboardHeatmapPanelType.
const (
DashboardHeatmapPanelTypeHeatmap DashboardHeatmapPanelType = "heatmap"
)
// Defines values for DashboardPanelRepeatDirection.
const (
DashboardPanelRepeatDirectionH DashboardPanelRepeatDirection = "h"
DashboardPanelRepeatDirectionV DashboardPanelRepeatDirection = "v"
)
// Defines values for DashboardRowPanelType.
const (
DashboardRowPanelTypeRow DashboardRowPanelType = "row"
)
// Defines values for DashboardThresholdsConfigMode.
const (
DashboardThresholdsConfigModeAbsolute DashboardThresholdsConfigMode = "absolute"
DashboardThresholdsConfigModePercentage DashboardThresholdsConfigMode = "percentage"
)
// Defines values for DashboardThresholdsMode.
const (
DashboardThresholdsModeAbsolute DashboardThresholdsMode = "absolute"
DashboardThresholdsModePercentage DashboardThresholdsMode = "percentage"
)
// Dashboard defines model for dashboard.
type Dashboard struct {
Annotations *struct {
List []struct {
BuiltIn int `json:"builtIn"`
// Datasource to use for annotation.
Datasource struct {
Type *string `json:"type,omitempty"`
Uid *string `json:"uid,omitempty"`
} `json:"datasource"`
// Whether annotation is enabled.
Enable bool `json:"enable"`
// Whether to hide annotation.
Hide *bool `json:"hide,omitempty"`
// Annotation icon color.
IconColor *string `json:"iconColor,omitempty"`
// Name of annotation.
Name *string `json:"name,omitempty"`
// Query for annotation data.
RawQuery *string `json:"rawQuery,omitempty"`
ShowIn int `json:"showIn"`
Type string `json:"type"`
} `json:"list"`
} `json:"annotations,omitempty"`
// Description of dashboard.
Description *string `json:"description,omitempty"`
// Whether a dashboard is editable or not.
Editable bool `json:"editable"`
GnetId *string `json:"gnetId,omitempty"`
// 0 for no shared crosshair or tooltip (default).
// 1 for shared crosshair.
// 2 for shared crosshair AND shared tooltip.
GraphTooltip int `json:"graphTooltip"`
// Unique numeric identifier for the dashboard.
// TODO must isolate or remove identifiers local to a Grafana instance...?
Id *int64 `json:"id,omitempty"`
Panels []DashboardPanel `json:"panels"`
// Panels *[]interface{} `json:"panels,omitempty"`
// Auto-refresh interval.
Refresh *interface{} `json:"refresh,omitempty"`
// Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema.
// FIXME this is the old schema numbering system, and will be replaced by Thema's themaVersion
SchemaVersion int `json:"schemaVersion"`
// Theme of dashboard.
Style DashboardStyle `json:"style"`
// Tags associated with dashboard.
Tags *[]string `json:"tags,omitempty"`
Templating *struct {
List []map[string]interface{} `json:"list"`
} `json:"templating,omitempty"`
// Time range for dashboard, e.g. last 6 hours, last 7 days, etc
Time *struct {
From string `json:"from"`
To string `json:"to"`
} `json:"time,omitempty"`
// Timepicker metadata.
Timepicker *struct {
// Whether timepicker is collapsed or not.
Collapse bool `json:"collapse"`
// Whether timepicker is enabled or not.
Enable bool `json:"enable"`
// Whether timepicker is visible or not.
Hidden bool `json:"hidden"`
// Selectable intervals for auto-refresh.
RefreshIntervals []string `json:"refresh_intervals"`
} `json:"timepicker,omitempty"`
// Timezone of dashboard,
Timezone *DashboardTimezone `json:"timezone,omitempty"`
// Title of dashboard.
Title *string `json:"title,omitempty"`
// Unique dashboard identifier that can be generated by anyone. string (8-40)
Uid *string `json:"uid,omitempty"`
// Version of the dashboard, incremented each time the dashboard is updated.
Version *int `json:"version,omitempty"`
}
// Theme of dashboard.
type DashboardStyle string
// Timezone of dashboard,
type DashboardTimezone string
// TODO docs
type DashboardFieldColor struct {
// Stores the fixed color value if mode is fixed
FixedColor *string `json:"fixedColor,omitempty"`
// The main color scheme mode
Mode interface{} `json:"mode"`
// TODO docs
SeriesBy *DashboardFieldColorSeriesByMode `json:"seriesBy,omitempty"`
}
// TODO docs
type DashboardFieldColorModeId string
// TODO docs
type DashboardFieldColorSeriesByMode string
// DashboardGraphPanel defines model for dashboard.GraphPanel.
type DashboardGraphPanel struct {
// Support for legacy graph and heatmap panels.
Type DashboardGraphPanelType `json:"type"`
}
// Support for legacy graph and heatmap panels.
type DashboardGraphPanelType string
// DashboardHeatmapPanel defines model for dashboard.HeatmapPanel.
type DashboardHeatmapPanel struct {
Type DashboardHeatmapPanelType `json:"type"`
}
// DashboardHeatmapPanelType defines model for DashboardHeatmapPanel.Type.
type DashboardHeatmapPanelType string
// Dashboard panels. Panels are canonically defined inline
// because they share a version timeline with the dashboard
// schema; they do not evolve independently.
type DashboardPanel struct {
// The datasource used in all targets.
Datasource *struct {
Type *string `json:"type,omitempty"`
Uid *string `json:"uid,omitempty"`
} `json:"datasource,omitempty"`
// Description.
Description *string `json:"description,omitempty"`
FieldConfig struct {
Defaults struct {
// TODO docs
Color *DashboardFieldColor `json:"color,omitempty"`
// custom is specified by the PanelFieldConfig field
// in panel plugin schemas.
Custom *map[string]interface{} `json:"custom,omitempty"`
// Significant digits (for display)
Decimals *float32 `json:"decimals,omitempty"`
// Human readable field metadata
Description *string `json:"description,omitempty"`
// The display value for this field. This supports template variables blank is auto
DisplayName *string `json:"displayName,omitempty"`
// This can be used by data sources that return and explicit naming structure for values and labels
// When this property is configured, this value is used rather than the default naming strategy.
DisplayNameFromDS *string `json:"displayNameFromDS,omitempty"`
// True if data source field supports ad-hoc filters
Filterable *bool `json:"filterable,omitempty"`
// // The behavior when clicking on a result
Links *[]interface{} `json:"links,omitempty"`
// Convert input values into a display string
//
// TODO this one corresponds to a complex type with
// generics on the typescript side. Ouch. Will
// either need special care, or we'll just need to
// accept a very loosely specified schema. It's very
// unlikely we'll be able to translate cue to
// typescript generics in the general case, though
// this particular one *may* be able to work.
Mappings *[]map[string]interface{} `json:"mappings,omitempty"`
Max *float32 `json:"max,omitempty"`
Min *float32 `json:"min,omitempty"`
// Alternative to empty string
NoValue *string `json:"noValue,omitempty"`
// An explict path to the field in the datasource. When the frame meta includes a path,
// This will default to `${frame.meta.path}/${field.name}
//
// When defined, this value can be used as an identifier within the datasource scope, and
// may be used to update the results
Path *string `json:"path,omitempty"`
Thresholds *DashboardThresholdsConfig `json:"thresholds,omitempty"`
// Numeric Options
Unit *string `json:"unit,omitempty"`
// True if data source can write a value to the path. Auth/authz are supported separately
Writeable *bool `json:"writeable,omitempty"`
} `json:"defaults"`
Overrides []struct {
Matcher struct {
Id string `json:"id"`
Options *interface{} `json:"options,omitempty"`
} `json:"matcher"`
Properties []struct {
Id string `json:"id"`
Value *interface{} `json:"value,omitempty"`
} `json:"properties"`
} `json:"overrides"`
} `json:"fieldConfig"`
// Grid position.
GridPos *struct {
// Panel
H int `json:"h"`
// true if fixed
Static *bool `json:"static,omitempty"`
// Panel
W int `json:"w"`
// Panel x
X int `json:"x"`
// Panel y
Y int `json:"y"`
} `json:"gridPos,omitempty"`
// TODO docs
Id *int `json:"id,omitempty"`
// TODO docs
// TODO tighter constraint
Interval *string `json:"interval,omitempty"`
// Panel links.
// TODO fill this out - seems there are a couple variants?
Links *[]struct {
Title string `json:"title"`
Type string `json:"type"`
} `json:"links,omitempty"`
// TODO docs
MaxDataPoints *float32 `json:"maxDataPoints,omitempty"`
// options is specified by the PanelOptions field in panel
// plugin schemas.
Options map[string]interface{} `json:"options"`
// FIXME this almost certainly has to be changed in favor of scuemata versions
PluginVersion *string `json:"pluginVersion,omitempty"`
// Name of template variable to repeat for.
Repeat *string `json:"repeat,omitempty"`
// Direction to repeat in if 'repeat' is set.
// "h" for horizontal, "v" for vertical.
RepeatDirection DashboardPanelRepeatDirection `json:"repeatDirection"`
// TODO docs
Tags *[]string `json:"tags,omitempty"`
// TODO docs
Targets *[]DashboardTarget `json:"targets,omitempty"`
// TODO docs
Thresholds *[]interface{} `json:"thresholds,omitempty"`
// TODO docs
// TODO tighter constraint
TimeFrom *string `json:"timeFrom,omitempty"`
// TODO docs
TimeRegions *[]interface{} `json:"timeRegions,omitempty"`
// TODO docs
// TODO tighter constraint
TimeShift *string `json:"timeShift,omitempty"`
// Panel title.
Title *string `json:"title,omitempty"`
Transformations []struct {
Id string `json:"id"`
Options map[string]interface{} `json:"options"`
} `json:"transformations"`
// Whether to display the panel without a background.
Transparent bool `json:"transparent"`
// The panel plugin type id. May not be empty.
Type string `json:"type"`
}
// Direction to repeat in if 'repeat' is set.
// "h" for horizontal, "v" for vertical.
type DashboardPanelRepeatDirection string
// Row panel
type DashboardRowPanel struct {
Collapsed bool `json:"collapsed"`
// Name of default datasource.
Datasource *struct {
Type *string `json:"type,omitempty"`
Uid *string `json:"uid,omitempty"`
} `json:"datasource,omitempty"`
GridPos *struct {
// Panel
H int `json:"h"`
// true if fixed
Static *bool `json:"static,omitempty"`
// Panel
W int `json:"w"`
// Panel x
X int `json:"x"`
// Panel y
Y int `json:"y"`
} `json:"gridPos,omitempty"`
Id int `json:"id"`
Panels []DashboardPanel `json:"panels"`
// Name of template variable to repeat for.
Repeat *string `json:"repeat,omitempty"`
Title *string `json:"title,omitempty"`
Type DashboardRowPanelType `json:"type"`
}
// DashboardRowPanelType defines model for DashboardRowPanel.Type.
type DashboardRowPanelType string
// Schema for panel targets is specified by datasource
// plugins. We use a placeholder definition, which the Go
// schema loader either left open/as-is with the Base
// variant of the Dashboard and Panel families, or filled
// with types derived from plugins in the Instance variant.
// When working directly from CUE, importers can extend this
// type directly to achieve the same effect.
type DashboardTarget map[string]interface{}
// TODO docs
type DashboardThreshold struct {
// TODO docs
Color string `json:"color"`
// TODO docs
// TODO are the values here enumerable into a disjunction?
// Some seem to be listed in typescript comment
State *string `json:"state,omitempty"`
// TODO docs
// FIXME the corresponding typescript field is required/non-optional, but nulls currently appear here when serializing -Infinity to JSON
Value *float32 `json:"value,omitempty"`
}
// DashboardThresholdsConfig defines model for dashboard.ThresholdsConfig.
type DashboardThresholdsConfig struct {
Mode DashboardThresholdsConfigMode `json:"mode"`
// Must be sorted by 'value', first value is always -Infinity
Steps []struct {
// TODO docs
Color string `json:"color"`
// TODO docs
// TODO are the values here enumerable into a disjunction?
// Some seem to be listed in typescript comment
State *string `json:"state,omitempty"`
// TODO docs
// FIXME the corresponding typescript field is required/non-optional, but nulls currently appear here when serializing -Infinity to JSON
Value *float32 `json:"value,omitempty"`
} `json:"steps"`
}
// DashboardThresholdsConfigMode defines model for DashboardThresholdsConfig.Mode.
type DashboardThresholdsConfigMode string
// DashboardThresholdsMode defines model for dashboard.ThresholdsMode.
type DashboardThresholdsMode string
// TODO docs
// FIXME this is extremely underspecfied; wasn't obvious which typescript types corresponded to it
type DashboardTransformation struct {
Id string `json:"id"`
Options map[string]interface{} `json:"options"`
}
export interface AnnotationQuery {
builtIn: number;
datasource: {};
enable: boolean;
hide?: boolean;
iconColor?: string;
name?: string;
rawQuery?: string;
showIn: number;
target?: {};
type: string;
}
export const defaultAnnotationQuery: Partial<AnnotationQuery> = {
builtIn: 0,
enable: true,
hide: false,
showIn: 0,
type: 'dashboard',
};
export interface VariableModel {
label?: string;
name: string;
type: VariableType;
}
export interface DashboardLink {
asDropdown: boolean;
icon?: string;
includeVars: boolean;
keepTime: boolean;
tags: string[];
targetBlank: boolean;
title: string;
tooltip?: string;
type: DashboardLinkType;
url?: string;
}
export const defaultDashboardLink: Partial<DashboardLink> = {
asDropdown: false,
includeVars: false,
keepTime: false,
tags: [],
targetBlank: false,
};
export type DashboardLinkType = 'link' | 'dashboards';
export type VariableType = 'query' | 'adhoc' | 'constant' | 'datasource' | 'interval' | 'textbox' | 'custom' | 'system';
export enum FieldColorModeId {
Continuous-GrYlRd = 'continuous-GrYlRd',
Fixed = 'fixed',
Palette-Classic = 'palette-classic',
Palette-Saturated = 'palette-saturated',
Thresholds = 'thresholds',
}
export type FieldColorSeriesByMode = 'min' | 'max' | 'last';
export interface FieldColor {
fixedColor?: string;
mode: FieldColorModeId | string;
seriesBy?: FieldColorSeriesByMode;
}
export interface Threshold {
color: string;
state?: string;
value?: number;
}
export enum ThresholdsMode {
Absolute = 'absolute',
Percentage = 'percentage',
}
export interface ThresholdsConfig {
mode: ThresholdsMode;
steps: Threshold[];
}
export const defaultThresholdsConfig: Partial<ThresholdsConfig> = {
steps: [],
};
export interface Transformation {
id: string;
options: {};
}
export enum DashboardCursorSync {
Crosshair = 1,
Off = 0,
Tooltip = 2,
}
export const defaultDashboardCursorSync: DashboardCursorSync = DashboardCursorSync.Off;
export interface Panel {
datasource?: {};
description?: string;
fieldConfig: {
defaults: {};
overrides: {
matcher: {
id: string;
};
properties: {
id: string;
}[];
}[];
};
gridPos?: {
h: number;
w: number;
x: number;
y: number;
};
id?: number;
interval?: string;
links?: DashboardLink[];
maxDataPoints?: number;
options: {};
pluginVersion?: string;
repeat?: string;
repeatDirection: 'h' | 'v';
tags?: string[];
targets?: {}[];
thresholds?: any[];
timeFrom?: string;
timeRegions?: any[];
timeShift?: string;
title?: string;
transformations: Transformation[];
transparent: boolean;
type: string;
}
export const defaultPanel: Partial<Panel> = {
links: [],
repeatDirection: 'h',
tags: [],
targets: [],
thresholds: [],
timeRegions: [],
transformations: [],
transparent: false,
};
export interface Dashboard {
annotations?: {
list: AnnotationQuery[];
};
description?: string;
editable: boolean;
fiscalYearStartMonth?: number;
gnetId?: string;
graphTooltip: DashboardCursorSync;
id?: number;
links?: DashboardLink[];
liveNow?: boolean;
panels?: Panel | {
type: 'graph';
} | {
type: 'heatmap';
} | {
type: 'row';
collapsed: boolean;
id: number;
panels: Panel | {
type: 'graph';
} | {
type: 'heatmap';
}[];
}[];
refresh?: string | false;
schemaVersion: number;
style: 'light' | 'dark';
tags?: string[];
templating?: {
list: VariableModel[];
};
time?: {
from: string;
to: string;
};
timepicker?: {
collapse: boolean;
enable: boolean;
hidden: boolean;
refresh_intervals: string[];
};
timezone?: 'browser' | 'utc' | '';
title?: string;
uid?: string;
version?: number;
weekStart?: string;
}
export const defaultDashboard: Partial<Dashboard> = {
editable: true,
graphTooltip: DashboardCursorSync.Off,
links: [],
panels: [],
schemaVersion: 36,
style: 'dark',
tags: [],
timezone: 'browser',
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment