Skip to content

Commit

Permalink
remove subclassing due to missing support in Lombok (see: projectlomb…
Browse files Browse the repository at this point in the history
…ok/lombok#853 and projectlombok/lombok#1337) to ensure fluent usage patterns illustrated in GrafanaClientDashboardIntegrationTest continue to work
  • Loading branch information
bascarsija committed Feb 7, 2018
1 parent f53a2d3 commit 71e6129
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 264 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/* Licensed under Apache-2.0 */
package com.appnexus.grafana.client.models;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Accessors(fluent = true)
abstract public class DashboardAnnotation extends FlexibleSchemaComponent {
final static String DATASOURCE_FIELD_NAME = "datasource";

public class DashboardAnnotation extends FlexibleSchemaComponent {
// common
private String name;
private String datasource;
private Boolean enable;
Expand All @@ -21,4 +23,29 @@ abstract public class DashboardAnnotation extends FlexibleSchemaComponent {
private Integer builtIn;
private Integer showIn;
private Integer limit;
// BUILTIN
private Type type;
// GRAPHITE
private List<String> tags;
private String target;

public DashboardAnnotation builtInDatasource() {
datasource = Datasource.BUILTIN_DATASOURCE_NAME;
return this;
}

public enum Type {
DASHBOARD("dashboard"),
TAGS("tags");
private final String value;

Type(String s) {
value = s;
}

@JsonValue
public String value() {
return value;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* Licensed under Apache-2.0 */
package com.appnexus.grafana.client.models;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand All @@ -13,9 +12,6 @@
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Accessors(fluent = true)
@JsonDeserialize(using = DashboardAnnotationListDeserializer.class)
public class DashboardAnnotationList extends FlexibleSchemaComponent {
final static String LIST_FIELD_NAME = "list";

private List<DashboardAnnotation> list;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
/* Licensed under Apache-2.0 */
package com.appnexus.grafana.client.models;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Set;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Accessors(fluent = true)
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@Type(value = GraphDashboardPanel.class, name = "graph"),
@Type(value = AlertListDashboardPanel.class, name = "alertlist")
})
abstract public class DashboardPanel extends FlexibleSchemaComponent {
public class DashboardPanel extends FlexibleSchemaComponent {
// common
private Boolean editable;
private Integer id;
private Integer span;
Expand All @@ -33,6 +24,86 @@ abstract public class DashboardPanel extends FlexibleSchemaComponent {
private String description;
private List<DashboardPanelLink> links;
private Type type;
// GRAPH
private DashboardPanelAlert alert;
private String datasource; //required for alerts
private Boolean error;
private Integer fill;
private Boolean lines;
private Integer linewidth;
private Boolean points;
private Integer pointRadius;
private NullPointMode nullPointMode;
private Boolean steppedLine;
private Boolean stack;
private Boolean percentage;
private Boolean dashes;
private List<DashboardPanelTarget> targets;
private DashboardPanelXAxis xaxis;
private List<DashboardPanelYAxis> yaxes;
private DashboardPanelLegend legend;
private List<GraphDrawOptionsSeriesOverride> seriesOverrides;
private List<DashboardPanelThreshold> thresholds;
// ALERT_LIST
private Integer limit;
private Boolean onlyAlertsOnDashboard;
private Show show;
private Integer sortOrder;
private Set<State> stateFilter;

public DashboardPanel builtInDatasource() {
datasource = Datasource.BUILTIN_DATASOURCE_NAME;
return this;
}

public enum NullPointMode {
CONNECTED("connected"),
NULL("null"),
NULL_AS_ZERO("null as zero");
private final String value;

NullPointMode(String s) {
value = s;
}

@JsonValue
public String value() {
return value;
}
}

public enum Show {
CURRENT("current"),
CHANGES("changes");
private final String value;

Show(String s) {
value = s;
}

@JsonValue
public String value() {
return value;
}
}

public enum State {
OK("ok"),
NO_DATA("no_data"),
PAUSED("paused"),
EXECUTION_ERROR("execution_error"),
ALERTING("alerting");
private final String value;

State(String s) {
value = s;
}

@JsonValue
public String value() {
return value;
}
}

public enum Type {
GRAPH("graph"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* Licensed under Apache-2.0 */
package com.appnexus.grafana.client.models;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -14,20 +11,17 @@
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Accessors(fluent = true)
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@Type(value = AbsoluteDashboardPanelLink.class, name = "absolute"),
@Type(value = RelativeDashboardPanelLink.class, name = "dashboard")
})
abstract public class DashboardPanelLink extends FlexibleSchemaComponent {
public class DashboardPanelLink extends FlexibleSchemaComponent {
// common
private Type type;
private Boolean keepTime;
private String params;
private Boolean targetBlank;
private String title;
// DASHBOARD
private String dashboard;
// ABSOLUTE
private String url;

public enum Type {
DASHBOARD("dashboard"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.appnexus.grafana.client.models;

final public class Datasource {
public static final String BUILTIN_DATASOURCE_NAME = "-- Grafana --";
}
Loading

0 comments on commit 71e6129

Please sign in to comment.