8000 add SLO summary widget support by platinummonkey · Pull Request #277 · zorkian/go-datadog-api · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add SLO summary widget support #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 50 additions & 22 deletions board_widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,29 @@ import (
)

const (
ALERT_GRAPH_WIDGET = "alert_graph"
ALERT_VALUE_WIDGET = "alert_value"
CHANGE_WIDGET = "change"
CHECK_STATUS_WIDGET = "check_status"
DISTRIBUTION_WIDGET = "distribution"
EVENT_STREAM_WIDGET = "event_stream"
EVENT_TIMELINE_WIDGET = "event_timeline"
FREE_TEXT_WIDGET = "free_text"
GROUP_WIDGET = "group"
HEATMAP_WIDGET = "heatmap"
HOSTMAP_WIDGET = "hostmap"
IFRAME_WIDGET = "iframe"
IMAGE_WIDGET = "image"
LOG_STREAM_WIDGET = "log_stream"
MANAGE_STATUS_WIDGET = "manage_status"
NOTE_WIDGET = "note"
QUERY_VALUE_WIDGET = "query_value"
QUERY_TABLE_WIDGET = "query_table"
SCATTERPLOT_WIDGET = "scatterplot"
TIMESERIES_WIDGET = "timeseries"
TOPLIST_WIDGET = "toplist"
TRACE_SERVICE_WIDGET = "trace_service"
ALERT_GRAPH_WIDGET = "alert_graph"
ALERT_VALUE_WIDGET = "alert_value"
CHANGE_WIDGET = "change"
CHECK_STATUS_WIDGET = "check_status"
DISTRIBUTION_WIDGET = "distribution"
EVENT_STREAM_WIDGET = "event_stream"
EVENT_TIMELINE_WIDGET = "event_timeline"
FREE_TEXT_WIDGET = "free_text"
GROUP_WIDGET = "group"
HEATMAP_WIDGET = "heatmap"
HOSTMAP_WIDGET = "hostmap"
IFRAME_WIDGET = "iframe"
IMAGE_WIDGET = "image"
LOG_STREAM_WIDGET = "log_stream"
MANAGE_STATUS_WIDGET = "manage_status"
NOTE_WIDGET = "note"
QUERY_VALUE_WIDGET = "query_value"
QUERY_TABLE_WIDGET = "query_table"
SCATTERPLOT_WIDGET = "scatterplot"
SERVICE_LEVEL_OBJECTIVE_WIDGET = "slo"
TIMESERIES_WIDGET = "timeser 8000 ies"
TOPLIST_WIDGET = "toplist"
TRACE_SERVICE_WIDGET = "trace_service"
)

// BoardWidget represents the structure of any widget. However, the widget Definition structure is
Expand Down Expand Up @@ -94,6 +95,8 @@ func (widget *BoardWidget) GetWidgetType() (string, error) {
return QUERY_TABLE_WIDGET, nil
case ScatterplotDefinition:
return SCATTERPLOT_WIDGET, nil
case ServiceLevelObjectiveDefinition:
return SERVICE_LEVEL_OBJECTIVE_WIDGET, nil
case TimeseriesDefinition:
return TIMESERIES_WIDGET, nil
case ToplistDefinition:
Expand Down Expand Up @@ -396,6 +399,23 @@ type ScatterplotRequest struct {
ProcessQuery *WidgetProcessQuery `json:"process_query,omitempty"`
}

// ServiceLevelObjectiveDefinition represents the definition for a Service Level Objective widget
type ServiceLevelObjectiveDefinition struct {
// Common

Type *string `json:"type"`
Title *string `json:"title,omitempty"`
TitleSize *string `json:"title_size,omitempty"`
TitleAlign *string `json:"title_align,omitempty"`

// SLO specific
ViewType *string `json:"view_type,omitempty"` // currently only "detail" is supported
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need omitempty here? view_type is required in the schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it as omitempty to let the default handlers on the API raise validation error if it's not specified

ServiceLevelObjectiveID *string `json:"slo_id,omitempty"`
ShowErrorBudget *bool `json:"show_error_budget,omitempty"`
ViewMode *string `json:"view_mode,omitempty"` // overall,component,both
TimeWindows []string `json:"time_windows,omitempty"` // 7d,30d,90d,week_to_date,previous_week,month_to_date,previous_month
}

// TimeseriesDefinition represents the definition for a Timeseries widget
type TimeseriesDefinition struct {
Type *string `json:"type"`
Expand Down Expand Up @@ -640,6 +660,14 @@ func (widget *BoardWidget) UnmarshalJSON(data []byte) error {
return err
}
widget.Definition = scatterplotWidget.Definition
case SERVICE_LEVEL_OBJECTIVE_WIDGET:
var serviceLevelObjectiveWidget struct {
Definition ServiceLevelObjectiveDefinition `json:"definition"`
}
if err := json.Unmarshal(data, &serviceLevelObjectiveWidget); err != nil {
return err
}
widget.Definition = serviceLevelObjectiveWidget.Definition
case TIMESERIES_WIDGET:
var timeseriesWidget struct {
Definition TimeseriesDefinition `json:"definition"`
Ex 8000 pand Down
248 changes: 248 additions & 0 deletions datadog-accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16785,6 +16785,254 @@ func (s *ServiceLevelObjective) SetTypeID(v int) {
s.TypeID = &v
}

// GetServiceLevelObjectiveID returns the ServiceLevelObjectiveID field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDefinition) GetServiceLevelObjectiveID() string {
if s == nil || s.ServiceLevelObjectiveID == nil {
return ""
}
return *s.ServiceLevelObjectiveID
}

// GetServiceLevelObjectiveIDOk returns a tuple with the ServiceLevelObjectiveID field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (s *ServiceLevelObjectiveDefinition) GetServiceLevelObjectiveIDOk() (string, bool) {
if s == nil || s.ServiceLevelObjectiveID == nil {
return "", false
}
return *s.ServiceLevelObjectiveID, true
}

// HasServiceLevelObjectiveID returns a boolean if a field has been set.
func (s *ServiceLevelObjectiveDefinition) HasServiceLevelObjectiveID() bool {
if s != nil && s.ServiceLevelObjectiveID != nil {
return true
}

return false
}

// SetServiceLevelObjectiveID allocates a new s.ServiceLevelObjectiveID and returns the pointer to it.
func (s *ServiceLevelObjectiveDefinition) SetServiceLevelObjectiveID(v string) {
s.ServiceLevelObjectiveID = &v
}

// GetShowErrorBudget returns the ShowErrorBudget field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDefinition) GetShowErrorBudget() bool {
if s == nil || s.ShowErrorBudget == nil {
return false
}
return *s.ShowErrorBudget
}

// GetShowErrorBudgetOk returns a tuple with the ShowErrorBudget field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (s *ServiceLevelObjectiveDefinition) GetShowErrorBudgetOk() (bool, bool) {
if s == nil || s.ShowErrorBudget == nil {
return false, false
}
return *s.ShowErrorBudget, true
}

// HasShowErrorBudget returns a boolean if a field has been set.
func (s *ServiceLevelObjectiveDefinition) HasShowErrorBudget() bool {
if s != nil && s.ShowErrorBudget != nil {
return true
}

return false
}

// SetShowErrorBudget allocates a new s.ShowErrorBudget and returns the pointer to it.
func (s *ServiceLevelObjectiveDefinition) SetShowErrorBudget(v bool) {
s.ShowErrorBudget = &v
}

// GetTitle returns the Title field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDefinition) GetTitle() string {
if s == nil || s.Title == nil {
return ""
}
return *s.Title
}

// GetTitleOk returns a tuple with the Title field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (s *ServiceLevelObjectiveDefinition) GetTitleOk() (string, bool) {
if s == nil || s.Title == nil {
return "", false
}
return *s.Title, true
}

// HasTitle returns a boolean if a field has been set.
func (s *ServiceLevelObjectiveDefinition) HasTitle() bool {
if s != nil && s.Title != nil {
return true
}

return false
}

// SetTitle allocates a new s.Title and returns the pointer to it.
func (s *ServiceLevelObjectiveDefinition) SetTitle(v string) {
s.Title = &v
}

// GetTitleAlign returns the TitleAlign field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDefinition) GetTitleAlign() string {
if s == nil || s.TitleAlign == nil {
return ""
}
return *s.TitleAlign
}

// GetTitleAlignOk returns a tuple with the TitleAlign field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (s *ServiceLevelObjectiveDefinition) GetTitleAlignOk() (string, bool) {
if s == nil || s.TitleAlign == nil {
return "", false
}
return *s.TitleAlign, true
}

// HasTitleAlign returns a boolean if a field has been set.
func (s *ServiceLevelObjectiveDefinition) HasTitleAlign() bool {
if s != nil && s.TitleAlign != nil {
return true
}

return false
}

// SetTitleAlign allocates a new s.TitleAlign and returns the pointer to it.
func (s *ServiceLevelObjectiveDefinition) SetTitleAlign(v string) {
s.TitleAlign = &v
}

// GetTitleSize returns the TitleSize field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDefinition) GetTitleSize() string {
if s == nil || s.TitleSize == nil {
return ""
}
return *s.TitleSize
}

// GetTitleSizeOk returns a tuple with the TitleSize field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (s *ServiceLevelObjectiveDefinition) GetTitleSizeOk() (string, bool) {
if s == nil || s.TitleSize == nil {
return "", false
}
return *s.TitleSize, true
}

// HasTitleSize returns a boolean if a field has been set.
func (s *ServiceLevelObjectiveDefinition) HasTitleSize() bool {
if s != nil && s.TitleSize != nil {
return true
}

return false
}

// SetTitleSize allocates a new s.TitleSize and returns the pointer to it.
func (s *ServiceLevelObjectiveDefinition) SetTitleSize(v string) {
s.TitleSize = &v
}

// GetType returns the Type field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDefinition) GetType() string {
if s == nil || s.Type == nil {
return ""
}
return *s.Type
}

// GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (s *ServiceLevelObjectiveDefinition) GetTypeOk() (string, bool) {
if s == nil || s.Type == nil {
return "", false
}
return *s.Type, true
}

// HasType returns a boolean if a field has been set.
func (s *ServiceLevelObjectiveDefinition) HasType() bool {
if s != nil && s.Type != nil {
return true
}

return false
}

// SetType allocates a new s.Type and returns the pointer to it.
func (s *ServiceLevelObjectiveDefinition) SetType(v string) {
s.Type = &v
}

// GetViewMode returns the ViewMode field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDefinition) GetViewMode() string {
if s == nil || s.ViewMode == nil {
return ""
}
return *s.ViewMode
}

// GetViewModeOk returns a tuple with the ViewMode field if it's non-nil, zero value otherwise
9E88 // and a boolean to check if the value has been set.
func (s *ServiceLevelObjectiveDefinition) GetViewModeOk() (string, bool) {
if s == nil || s.ViewMode == nil {
return "", false
}
return *s.ViewMode, true
}

// HasViewMode returns a boolean if a field has been set.
func (s *ServiceLevelObjectiveDefinition) HasViewMode() bool {
if s != nil && s.ViewMode != nil {
return true
}

return false
}

// SetViewMode allocates a new s.ViewMode and returns the pointer to it.
func (s *ServiceLevelObjectiveDefinition) SetViewMode(v string) {
s.ViewMode = &v
}

// GetViewType returns the ViewType field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDefinition) GetViewType() string {
if s == nil || s.ViewType == nil {
return ""
}
return *s.ViewType
}

// GetViewTypeOk returns a tuple with the ViewType field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (s *ServiceLevelObjectiveDefinition) GetViewTypeOk() (string, bool) {
if s == nil || s.ViewType == nil {
return "", false
}
return *s.ViewType, true
}

// HasViewType returns a boolean if a field has been set.
func (s *ServiceLevelObjectiveDefinition) HasViewType() bool {
if s != nil && s.ViewType != nil {
return true
}

return false
}

// SetViewType allocates a new s.ViewType and returns the pointer to it.
func (s *ServiceLevelObjectiveDefinition) SetViewType(v string) {
s.ViewType = &v
}

// GetID returns the ID field if non-nil, zero value otherwise.
func (s *ServiceLevelObjectiveDeleteTimeFramesError) GetID() string {
if s == nil || s.ID == nil {
Expand Down
0