Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.

Commit

Permalink
support metric_line_chart dashboard widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrombley committed Nov 12, 2019
1 parent 2add42a commit 9fce2e5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions api/dashboards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func TestCreateDashboardCondition(t *testing.T) {
EntityIds: []int{
1234,
},
CompareWith: &[]DashboardWidgetDataCompareWith{
CompareWith: []DashboardWidgetDataCompareWith{
DashboardWidgetDataCompareWith{
OffsetDuration: "P7D",
Presentation: DashboardWidgetDataCompareWithPresentation{
Expand All @@ -379,7 +379,7 @@ func TestCreateDashboardCondition(t *testing.T) {
},
},
},
Metrics: &[]DashboardWidgetDataMetric{
Metrics: []DashboardWidgetDataMetric{
DashboardWidgetDataMetric{
Name: "CPU/System/Utilization",
Units: "",
Expand Down
30 changes: 16 additions & 14 deletions api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ type DashboardMetadata struct {
// DashboardWidget represents a widget in a dashboard.
type DashboardWidget struct {
Visualization string `json:"visualization,omitempty"`
ID int `json:"widget_id,omitempty"`
AccountID int `json:"account_id,omitempty"`
Data []DashboardWidgetData `json:"data,omitempty"`
Presentation DashboardWidgetPresentation `json:"presentation,omitempty"`
Expand All @@ -307,17 +308,17 @@ type DashboardWidget struct {

// DashboardWidgetData represents the data backing a dashboard widget.
type DashboardWidgetData struct {
NRQL string `json:"nrql,omitempty"`
Source string `json:"source,omitempty"`
Duration int `json:"duration,omitempty"`
EndTime int `json:"end_time,omitempty"`
EntityIds []int `json:"entity_ids,omitempty"`
CompareWith *[]DashboardWidgetDataCompareWith `json:"compare_with,omitempty"`
Metrics *[]DashboardWidgetDataMetric `json:"metrics,omitempty"`
RawMetricName string `json:"raw_metric_name,omitempty"`
Facet string `json:"facet,omitempty"`
OrderBy string `json:"order_by,omitempty"`
Limit int `json:"limit,omitempty"`
NRQL string `json:"nrql,omitempty"`
Source string `json:"source,omitempty"`
Duration int `json:"duration,omitempty"`
EndTime int `json:"end_time,omitempty"`
EntityIds []int `json:"entity_ids,omitempty"`
CompareWith []DashboardWidgetDataCompareWith `json:"compare_with,omitempty"`
Metrics []DashboardWidgetDataMetric `json:"metrics,omitempty"`
RawMetricName string `json:"raw_metric_name,omitempty"`
Facet string `json:"facet,omitempty"`
OrderBy string `json:"order_by,omitempty"`
Limit int `json:"limit,omitempty"`
}

// DashboardWidgetDataCompareWith represents the compare with configuration of the widget.
Expand All @@ -342,9 +343,10 @@ type DashboardWidgetDataMetric struct {

// DashboardWidgetPresentation represents the visual presentation of a dashboard widget.
type DashboardWidgetPresentation struct {
Title string `json:"title,omitempty"`
Notes string `json:"notes,omitempty"`
Threshold *DashboardWidgetThreshold `json:"threshold,omitempty"`
Title string `json:"title,omitempty"`
Notes string `json:"notes,omitempty"`
DrilldownDashboardID int `json:"drilldown_dashboard_id,omitempty"`
Threshold *DashboardWidgetThreshold `json:"threshold,omitempty"`
}

// DashboardWidgetThreshold represents the threshold configuration of a dashboard widget.
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/paultyng/go-newrelic/v4

go 1.13

require (
github.com/go-resty/resty/v2 v2.1.0
github.com/google/go-cmp v0.3.1
github.com/imdario/mergo v0.3.8
github.com/olekukonko/tablewriter v0.0.2
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.5.0
github.com/stretchr/testify v1.4.0 // indirect
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80
)

go 1.13
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-resty/resty v1.12.0 h1:L1P5qymrXL5H/doXe2pKUr1wxovAI5ilm2LdVLbwThc=
github.com/go-resty/resty/v2 v2.1.0 h1:Z6IefCpUMfnvItVJaJXWv/pMiiD11So35QgwEELsldE=
github.com/go-resty/resty/v2 v2.1.0/go.mod h1:dZGr0i9PLlaaTD4H/hoZIDjQ+r6xq8mgbRzHZf7f2J8=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
Expand All @@ -38,7 +39,10 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
Expand Down

0 comments on commit 9fce2e5

Please sign in to comment.