Skip to content

Commit

Permalink
Merge pull request #5 from maier/master
Browse files Browse the repository at this point in the history
v0.6.0
  • Loading branch information
maier authored Apr 15, 2019
2 parents 6eeb1a6 + 66df3d2 commit e6dd161
Show file tree
Hide file tree
Showing 4 changed files with 399 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v0.6.0

* fix: graph structures incorrectly represented nesting of overlay sets

# v0.5.4

* add: `search` (`*string`) attribute to graph datapoint
Expand Down
128 changes: 90 additions & 38 deletions graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,37 +88,64 @@ type GraphMetricCluster struct {
Stack *uint `json:"stack"` // uint or null
}

// OverlayDataOptions defines overlay options for data. Note, each overlay type requires
// a _subset_ of the options. See Graph API documentation (URL above) for details.
type OverlayDataOptions struct {
Alerts *int `json:"alerts,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
ArrayOutput *int `json:"array_output,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
BasePeriod *int `json:"base_period,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
Delay *int `json:"delay,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
Extension string `json:"extension,omitempty"` // string
GraphTitle string `json:"graph_title,omitempty"` // string
GraphUUID string `json:"graph_id,omitempty"` // string
InPercent *bool `json:"in_percent,string,omitempty"` // boolean encoded as string BUG doc: boolean, api: string
Inverse *int `json:"inverse,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
Method string `json:"method,omitempty"` // string
Model string `json:"model,omitempty"` // string
ModelEnd string `json:"model_end,omitempty"` // string
ModelPeriod string `json:"model_period,omitempty"` // string
ModelRelative *int `json:"model_relative,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
Out string `json:"out,omitempty"` // string
Prequel string `json:"prequel,omitempty"` // string
Presets string `json:"presets,omitempty"` // string
Quantiles string `json:"quantiles,omitempty"` // string
SeasonLength *int `json:"season_length,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
Sensitivity *int `json:"sensitivity,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
SingleValue *int `json:"single_value,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
TargetPeriod string `json:"target_period,omitempty"` // string
TimeOffset string `json:"time_offset,omitempty"` // string
TimeShift *int `json:"time_shift,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
Transform string `json:"transform,omitempty"` // string
Version *int `json:"version,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
Window *int `json:"window,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
XShift string `json:"x_shift,omitempty"` // string
// type OverlayDataOptions struct {
// Alerts *int `json:"alerts,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// ArrayOutput *int `json:"array_output,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// BasePeriod *int `json:"base_period,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// Delay *int `json:"delay,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// Extension string `json:"extension,omitempty"` // string
// GraphTitle string `json:"graph_title,omitempty"` // string
// GraphUUID string `json:"graph_id,omitempty"` // string
// InPercent *bool `json:"in_percent,string,omitempty"` // boolean encoded as string BUG doc: boolean, api: string
// Inverse *int `json:"inverse,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// Method string `json:"method,omitempty"` // string
// Model string `json:"model,omitempty"` // string
// ModelEnd string `json:"model_end,omitempty"` // string
// ModelPeriod string `json:"model_period,omitempty"` // string
// ModelRelative *int `json:"model_relative,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// Out string `json:"out,omitempty"` // string
// Prequel string `json:"prequel,omitempty"` // string
// Presets string `json:"presets,omitempty"` // string
// Quantiles string `json:"quantiles,omitempty"` // string
// SeasonLength *int `json:"season_length,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// Sensitivity *int `json:"sensitivity,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// SingleValue *int `json:"single_value,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// TargetPeriod string `json:"target_period,omitempty"` // string
// TimeOffset string `json:"time_offset,omitempty"` // string
// TimeShift *int `json:"time_shift,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// Transform string `json:"transform,omitempty"` // string
// Version *int `json:"version,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// Window *int `json:"window,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// XShift string `json:"x_shift,omitempty"` // string
// }

// type OverlayUISpecs struct {
// Decouple bool `json:"decouple,omitempty"` // boolean
// ID string `json:"id,omitempty"` // string
// Label string `json:"label,omitempty"` // string
// Type string `json:"type,omitempty"` // string
// Z *int `json:"z,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
// }

// type GraphOverlaySet struct {
// DataOpts OverlayDataOptions `json:"data_opts,omitempty"` // OverlayDataOptions
// ID string `json:"id,omitempty"` // string
// Title string `json:"title,omitempty"` // string
// UISpecs OverlayUISpecs `json:"ui_specs,omitempty"` // OverlayUISpecs
// }

// OverlaySet defines an overlay set for a graph
type GraphOverlaySet struct {
Overlays map[string]GraphOverlay `json:"overlays"`
Title string `json:"title"`
}

// GraphOverlay defines a single overlay in an overlay set
type GraphOverlay struct {
DataOpts OverlayDataOptions `json:"data_opts,omitempty"` // OverlayDataOptions
ID string `json:"id,omitempty"` // string
Title string `json:"title,omitempty"` // string
UISpecs OverlayUISpecs `json:"ui_specs,omitempty"` // OverlayUISpecs
}

// OverlayUISpecs defines UI specs for overlay
Expand All @@ -127,15 +154,40 @@ type OverlayUISpecs struct {
ID string `json:"id,omitempty"` // string
Label string `json:"label,omitempty"` // string
Type string `json:"type,omitempty"` // string
Z *int `json:"z,string,omitempty"` // int encoded as string BUG doc: numeric, api: string
Z *int `json:"z,omitempty"` // int encoded as string BUG doc: numeric, api: string
}

// GraphOverlaySet defines overlays for graph
type GraphOverlaySet struct {
DataOpts OverlayDataOptions `json:"data_opts,omitempty"` // OverlayDataOptions
ID string `json:"id,omitempty"` // string
Title string `json:"title,omitempty"` // string
UISpecs OverlayUISpecs `json:"ui_specs,omitempty"` // OverlayUISpecs
// OverlayDataOptions defines overlay options for data. Note, each overlay type requires
// a _subset_ of the options. See Graph API documentation (URL above) for details.
type OverlayDataOptions struct {
Alerts *int `json:"alerts,omitempty"` // int encoded as string BUG doc: numeric, api: string
ArrayOutput *int `json:"array_output,omitempty"` // int encoded as string BUG doc: numeric, api: string
BasePeriod *int `json:"base_period,omitempty"` // int encoded as string BUG doc: numeric, api: string
Delay *int `json:"delay,omitempty"` // int encoded as string BUG doc: numeric, api: string
Extension string `json:"extension,omitempty"` // string
GraphTitle string `json:"graph_title,omitempty"` // string
GraphUUID string `json:"graph_id,omitempty"` // string
InPercent *string `json:"in_percent,omitempty"` // boolean encoded as string BUG doc: boolean, api: string
Inverse *int `json:"inverse,omitempty"` // int encoded as string BUG doc: numeric, api: string
Method string `json:"method,omitempty"` // string
Model string `json:"model,omitempty"` // string
ModelEnd string `json:"model_end,omitempty"` // string
ModelPeriod string `json:"model_period,omitempty"` // string
ModelRelative *int `json:"model_relative,omitempty"` // int encoded as string BUG doc: numeric, api: string
Out string `json:"out,omitempty"` // string
Prequel *int `json:"prequel,omitempty"` // int
Presets string `json:"presets,omitempty"` // string
Quantiles string `json:"quantiles,omitempty"` // string
SeasonLength *int `json:"season_length,omitempty"` // int encoded as string BUG doc: numeric, api: string
Sensitivity *int `json:"sensitivity,omitempty"` // int encoded as string BUG doc: numeric, api: string
SingleValue *int `json:"single_value,omitempty"` // int encoded as string BUG doc: numeric, api: string
TargetPeriod *string `json:"target_period,omitempty"` // string
TimeOffset string `json:"time_offset,omitempty"` // string
TimeShift *int `json:"time_shift,omitempty"` // int encoded as string BUG doc: numeric, api: string
Transform string `json:"transform,omitempty"` // string
Version *int `json:"version,omitempty"` // int encoded as string BUG doc: numeric, api: string
Window *int `json:"window,omitempty"` // int encoded as string BUG doc: numeric, api: string
XShift string `json:"x_shift,omitempty"` // string
}

// Graph defines a graph. See https://login.circonus.com/resources/api/calls/graph for more information.
Expand Down
25 changes: 25 additions & 0 deletions graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,28 @@ func TestSearchGraphs(t *testing.T) {
})
}
}

func TestGraphOverlaySet(t *testing.T) {
t.Log("testing graph overlay set struct")

testJSON, err := ioutil.ReadFile("testdata/graph_overlayset.json")
if err != nil {
t.Fatal(err)
}

var g Graph
if err := json.Unmarshal(testJSON, &g); err != nil {
t.Fatal(err)
}

data, err := json.Marshal(g)
if err != nil {
t.Fatal(err)
}

var g2 Graph
if err := json.Unmarshal(data, &g2); err != nil {
t.Fatal(err)
}

}
Loading

0 comments on commit e6dd161

Please sign in to comment.