com.grafana.foundation.dashboard.Panel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grafana-foundation-sdk Show documentation
Show all versions of grafana-foundation-sdk Show documentation
A set of tools, types and libraries for building and manipulating Grafana objects.
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
package com.grafana.foundation.dashboard;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
import com.grafana.foundation.cog.variants.Dataquery;
import java.util.LinkedList;
// Dashboard panels are the basic visualization building blocks.
@JsonDeserialize(using = PanelDeserializer.class)
public class Panel {
// The panel plugin type id. This is used to find the plugin to display the panel.
@JsonProperty("type")
public String type;
// Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("id")
public Integer id;
// The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("pluginVersion")
public String pluginVersion;
// Tags for the panel.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("tags")
public List tags;
// Depends on the panel plugin. See the plugin documentation for details.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("targets")
public List targets;
// Panel title.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("title")
public String title;
// Panel description.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("description")
public String description;
// Whether to display the panel without a background.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("transparent")
public Boolean transparent;
// The datasource used in all targets.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("datasource")
public DataSourceRef datasource;
// Grid position.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("gridPos")
public GridPos gridPos;
// Panel links.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("links")
public List links;
// Name of template variable to repeat for.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("repeat")
public String repeat;
// Direction to repeat in if 'repeat' is set.
// `h` for horizontal, `v` for vertical.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("repeatDirection")
public PanelRepeatDirection repeatDirection;
// Option for repeated panels that controls max items per row
// Only relevant for horizontally repeated panels
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("maxPerRow")
public Double maxPerRow;
// The maximum number of data points that the panel queries are retrieving.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("maxDataPoints")
public Double maxDataPoints;
// List of transformations that are applied to the panel data before rendering.
// When there are multiple transformations, Grafana applies them in the order they are listed.
// Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("transformations")
public List transformations;
// The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.
// This value must be formatted as a number followed by a valid time
// identifier like: "40s", "3d", etc.
// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("interval")
public String interval;
// Overrides the relative time range for individual panels,
// which causes them to be different than what is selected in
// the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different
// time periods or days on the same dashboard.
// The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),
// `now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).
// Note: Panel time overrides have no effect when the dashboard’s time range is absolute.
// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("timeFrom")
public String timeFrom;
// Overrides the time range for individual panels by shifting its start and end relative to the time picker.
// For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.
// Note: Panel time overrides have no effect when the dashboard’s time range is absolute.
// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("timeShift")
public String timeShift;
// Controls if the timeFrom or timeShift overrides are shown in the panel header
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("hideTimeOverride")
public Boolean hideTimeOverride;
// Dynamically load the panel
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("libraryPanel")
public LibraryPanelRef libraryPanel;
// It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("options")
public Object options;
// Field options allow you to change how the data is displayed in your visualizations.
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("fieldConfig")
public FieldConfigSource fieldConfig;
public String toJSON() throws JsonProcessingException {
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
return ow.writeValueAsString(this);
}
public static class Builder implements com.grafana.foundation.cog.Builder {
private final Panel internal;
public Builder() {
this.internal = new Panel();
this.transparent(false);
this.height(9);
this.span(12);
}
public Builder type(String type) {
if (!(type.length() >= 1)) {
throw new IllegalArgumentException("type.length() must be >= 1");
}
this.internal.type = type;
return this;
}
public Builder id(Integer id) {
this.internal.id = id;
return this;
}
public Builder targets(com.grafana.foundation.cog.Builder> targets) {
this.internal.targets = targets.build();
return this;
}
public Builder withTarget(com.grafana.foundation.cog.Builder targets) {
if (this.internal.targets == null) {
this.internal.targets = new LinkedList<>();
}
this.internal.targets.add(targets.build());
return this;
}
public Builder title(String title) {
this.internal.title = title;
return this;
}
public Builder description(String description) {
this.internal.description = description;
return this;
}
public Builder transparent(Boolean transparent) {
this.internal.transparent = transparent;
return this;
}
public Builder datasource(DataSourceRef datasource) {
this.internal.datasource = datasource;
return this;
}
public Builder gridPos(GridPos gridPos) {
this.internal.gridPos = gridPos;
return this;
}
public Builder height(Integer h) {
if (!(h > 0)) {
throw new IllegalArgumentException("h must be > 0");
}
if (this.internal.gridPos == null) {
this.internal.gridPos = new com.grafana.foundation.dashboard.GridPos();
}
this.internal.gridPos.h = h;
return this;
}
public Builder span(Integer w) {
if (!(w > 0)) {
throw new IllegalArgumentException("w must be > 0");
}
if (!(w <= 24)) {
throw new IllegalArgumentException("w must be <= 24");
}
if (this.internal.gridPos == null) {
this.internal.gridPos = new com.grafana.foundation.dashboard.GridPos();
}
this.internal.gridPos.w = w;
return this;
}
public Builder links(com.grafana.foundation.cog.Builder> links) {
this.internal.links = links.build();
return this;
}
public Builder repeat(String repeat) {
this.internal.repeat = repeat;
return this;
}
public Builder repeatDirection(PanelRepeatDirection repeatDirection) {
this.internal.repeatDirection = repeatDirection;
return this;
}
public Builder maxPerRow(Double maxPerRow) {
this.internal.maxPerRow = maxPerRow;
return this;
}
public Builder maxDataPoints(Double maxDataPoints) {
this.internal.maxDataPoints = maxDataPoints;
return this;
}
public Builder transformations(List transformations) {
this.internal.transformations = transformations;
return this;
}
public Builder withTransformation(DataTransformerConfig transformations) {
if (this.internal.transformations == null) {
this.internal.transformations = new LinkedList<>();
}
this.internal.transformations.add(transformations);
return this;
}
public Builder interval(String interval) {
this.internal.interval = interval;
return this;
}
public Builder timeFrom(String timeFrom) {
this.internal.timeFrom = timeFrom;
return this;
}
public Builder timeShift(String timeShift) {
this.internal.timeShift = timeShift;
return this;
}
public Builder hideTimeOverride(Boolean hideTimeOverride) {
this.internal.hideTimeOverride = hideTimeOverride;
return this;
}
public Builder libraryPanel(LibraryPanelRef libraryPanel) {
this.internal.libraryPanel = libraryPanel;
return this;
}
public Builder displayName(String displayName) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.displayName = displayName;
return this;
}
public Builder unit(String unit) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.unit = unit;
return this;
}
public Builder decimals(Double decimals) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.decimals = decimals;
return this;
}
public Builder min(Double min) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.min = min;
return this;
}
public Builder max(Double max) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.max = max;
return this;
}
public Builder mappings(List mappings) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.mappings = mappings;
return this;
}
public Builder thresholds(com.grafana.foundation.cog.Builder thresholds) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.thresholds = thresholds.build();
return this;
}
public Builder colorScheme(com.grafana.foundation.cog.Builder color) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.color = color.build();
return this;
}
public Builder noValue(String noValue) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.defaults == null) {
this.internal.fieldConfig.defaults = new com.grafana.foundation.dashboard.FieldConfig();
}
this.internal.fieldConfig.defaults.noValue = noValue;
return this;
}
public Builder overrides(com.grafana.foundation.cog.Builder> overrides) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
this.internal.fieldConfig.overrides = overrides.build();
return this;
}
public Builder withOverride(com.grafana.foundation.cog.Builder overrides) {
if (this.internal.fieldConfig == null) {
this.internal.fieldConfig = new com.grafana.foundation.dashboard.FieldConfigSource();
}
if (this.internal.fieldConfig.overrides == null) {
this.internal.fieldConfig.overrides = new LinkedList<>();
}
this.internal.fieldConfig.overrides.add(overrides.build());
return this;
}
public Panel build() {
return this.internal;
}
}
}