Skip to content

Commit

Permalink
Add scheduling_options to monitor definition (#1735)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec committed Nov 1, 2022
1 parent 0b329f7 commit 3d65624
Show file tree
Hide file tree
Showing 9 changed files with 452 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.4",
"regenerated": "2022-10-31 18:53:29.504722",
"spec_repo_commit": "06929484"
"regenerated": "2022-10-31 20:12:34.768350",
"spec_repo_commit": "420bd229"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-10-31 18:53:29.521764",
"spec_repo_commit": "06929484"
"regenerated": "2022-10-31 20:12:34.781417",
"spec_repo_commit": "420bd229"
}
}
}
35 changes: 35 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6340,6 +6340,8 @@ components:
to `false` for sparse metrics,\notherwise some evaluations are skipped.
Default is false."
type: boolean
scheduling_options:
$ref: '#/components/schemas/MonitorOptionsSchedulingOptions'
silenced:
additionalProperties:
description: UTC epoch timestamp in seconds when the downtime for the
Expand Down Expand Up @@ -6391,6 +6393,39 @@ components:
type: string
readOnly: true
type: object
MonitorOptionsSchedulingOptions:
description: Configuration options for scheduling.
properties:
evaluation_window:
$ref: '#/components/schemas/MonitorOptionsSchedulingOptionsEvaluationWindow'
type: object
MonitorOptionsSchedulingOptionsEvaluationWindow:
description: Configuration options for the evaluation window. If `hour_starts`
is set, no other fields may be set. Otherwise, `day_starts` and `month_starts`
must be set together.
properties:
day_starts:
description: The time of the day at which a one day cumulative evaluation
window starts. Must be defined in UTC time in `HH:mm` format.
example: 04:00
type: string
hour_starts:
description: The minute of the hour at which a one hour cumulative evaluation
window starts.
example: 0
format: int32
maximum: 59
minimum: 0
type: integer
month_starts:
description: The day of the month at which a one month cumulative evaluation
window starts.
example: 1
format: int32
maximum: 1
minimum: 1
type: integer
type: object
MonitorOverallStates:
description: The different states your monitor can be in.
enum:
Expand Down
42 changes: 42 additions & 0 deletions api/datadogV1/model_monitor_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ type MonitorOptions struct {
// We highly recommend you set this to `false` for sparse metrics,
// otherwise some evaluations are skipped. Default is false.
RequireFullWindow *bool `json:"require_full_window,omitempty"`
// Configuration options for scheduling.
SchedulingOptions *MonitorOptionsSchedulingOptions `json:"scheduling_options,omitempty"`
// Information about the downtime applied to the monitor.
// Deprecated
Silenced map[string]int64 `json:"silenced,omitempty"`
Expand Down Expand Up @@ -877,6 +879,34 @@ func (o *MonitorOptions) SetRequireFullWindow(v bool) {
o.RequireFullWindow = &v
}

// GetSchedulingOptions returns the SchedulingOptions field value if set, zero value otherwise.
func (o *MonitorOptions) GetSchedulingOptions() MonitorOptionsSchedulingOptions {
if o == nil || o.SchedulingOptions == nil {
var ret MonitorOptionsSchedulingOptions
return ret
}
return *o.SchedulingOptions
}

// GetSchedulingOptionsOk returns a tuple with the SchedulingOptions field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MonitorOptions) GetSchedulingOptionsOk() (*MonitorOptionsSchedulingOptions, bool) {
if o == nil || o.SchedulingOptions == nil {
return nil, false
}
return o.SchedulingOptions, true
}

// HasSchedulingOptions returns a boolean if a field has been set.
func (o *MonitorOptions) HasSchedulingOptions() bool {
return o != nil && o.SchedulingOptions != nil
}

// SetSchedulingOptions gets a reference to the given MonitorOptionsSchedulingOptions and assigns it to the SchedulingOptions field.
func (o *MonitorOptions) SetSchedulingOptions(v MonitorOptionsSchedulingOptions) {
o.SchedulingOptions = &v
}

// GetSilenced returns the Silenced field value if set, zero value otherwise.
// Deprecated
func (o *MonitorOptions) GetSilenced() map[string]int64 {
Expand Down Expand Up @@ -1145,6 +1175,9 @@ func (o MonitorOptions) MarshalJSON() ([]byte, error) {
if o.RequireFullWindow != nil {
toSerialize["require_full_window"] = o.RequireFullWindow
}
if o.SchedulingOptions != nil {
toSerialize["scheduling_options"] = o.SchedulingOptions
}
if o.Silenced != nil {
toSerialize["silenced"] = o.Silenced
}
Expand Down Expand Up @@ -1196,6 +1229,7 @@ func (o *MonitorOptions) UnmarshalJSON(bytes []byte) (err error) {
RenotifyOccurrences datadog.NullableInt64 `json:"renotify_occurrences,omitempty"`
RenotifyStatuses []MonitorRenotifyStatusType `json:"renotify_statuses,omitempty"`
RequireFullWindow *bool `json:"require_full_window,omitempty"`
SchedulingOptions *MonitorOptionsSchedulingOptions `json:"scheduling_options,omitempty"`
Silenced map[string]int64 `json:"silenced,omitempty"`
SyntheticsCheckId datadog.NullableString `json:"synthetics_check_id,omitempty"`
ThresholdWindows *MonitorThresholdWindowOptions `json:"threshold_windows,omitempty"`
Expand Down Expand Up @@ -1249,6 +1283,14 @@ func (o *MonitorOptions) UnmarshalJSON(bytes []byte) (err error) {
o.RenotifyOccurrences = all.RenotifyOccurrences
o.RenotifyStatuses = all.RenotifyStatuses
o.RequireFullWindow = all.RequireFullWindow
if all.SchedulingOptions != nil && all.SchedulingOptions.UnparsedObject != nil && o.UnparsedObject == nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
}
o.SchedulingOptions = all.SchedulingOptions
o.Silenced = all.Silenced
o.SyntheticsCheckId = all.SyntheticsCheckId
if all.ThresholdWindows != nil && all.ThresholdWindows.UnparsedObject != nil && o.UnparsedObject == nil {
Expand Down
105 changes: 105 additions & 0 deletions api/datadogV1/model_monitor_options_scheduling_options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

package datadogV1

import (
"encoding/json"
)

// MonitorOptionsSchedulingOptions Configuration options for scheduling.
type MonitorOptionsSchedulingOptions struct {
// Configuration options for the evaluation window. If `hour_starts` is set, no other fields may be set. Otherwise, `day_starts` and `month_starts` must be set together.
EvaluationWindow *MonitorOptionsSchedulingOptionsEvaluationWindow `json:"evaluation_window,omitempty"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{}
}

// NewMonitorOptionsSchedulingOptions instantiates a new MonitorOptionsSchedulingOptions object.
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewMonitorOptionsSchedulingOptions() *MonitorOptionsSchedulingOptions {
this := MonitorOptionsSchedulingOptions{}
return &this
}

// NewMonitorOptionsSchedulingOptionsWithDefaults instantiates a new MonitorOptionsSchedulingOptions object.
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set.
func NewMonitorOptionsSchedulingOptionsWithDefaults() *MonitorOptionsSchedulingOptions {
this := MonitorOptionsSchedulingOptions{}
return &this
}

// GetEvaluationWindow returns the EvaluationWindow field value if set, zero value otherwise.
func (o *MonitorOptionsSchedulingOptions) GetEvaluationWindow() MonitorOptionsSchedulingOptionsEvaluationWindow {
if o == nil || o.EvaluationWindow == nil {
var ret MonitorOptionsSchedulingOptionsEvaluationWindow
return ret
}
return *o.EvaluationWindow
}

// GetEvaluationWindowOk returns a tuple with the EvaluationWindow field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MonitorOptionsSchedulingOptions) GetEvaluationWindowOk() (*MonitorOptionsSchedulingOptionsEvaluationWindow, bool) {
if o == nil || o.EvaluationWindow == nil {
return nil, false
}
return o.EvaluationWindow, true
}

// HasEvaluationWindow returns a boolean if a field has been set.
func (o *MonitorOptionsSchedulingOptions) HasEvaluationWindow() bool {
return o != nil && o.EvaluationWindow != nil
}

// SetEvaluationWindow gets a reference to the given MonitorOptionsSchedulingOptionsEvaluationWindow and assigns it to the EvaluationWindow field.
func (o *MonitorOptionsSchedulingOptions) SetEvaluationWindow(v MonitorOptionsSchedulingOptionsEvaluationWindow) {
o.EvaluationWindow = &v
}

// MarshalJSON serializes the struct using spec logic.
func (o MonitorOptionsSchedulingOptions) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return json.Marshal(o.UnparsedObject)
}
if o.EvaluationWindow != nil {
toSerialize["evaluation_window"] = o.EvaluationWindow
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return json.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *MonitorOptionsSchedulingOptions) UnmarshalJSON(bytes []byte) (err error) {
raw := map[string]interface{}{}
all := struct {
EvaluationWindow *MonitorOptionsSchedulingOptionsEvaluationWindow `json:"evaluation_window,omitempty"`
}{}
err = json.Unmarshal(bytes, &all)
if err != nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
return nil
}
if all.EvaluationWindow != nil && all.EvaluationWindow.UnparsedObject != nil && o.UnparsedObject == nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
}
o.EvaluationWindow = all.EvaluationWindow
return nil
}
Loading

0 comments on commit 3d65624

Please sign in to comment.