Skip to content

Commit

Permalink
Add custom schedule to monitor scheduling options (#2199)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Oct 5, 2023
1 parent f8af241 commit 04ab383
Show file tree
Hide file tree
Showing 9 changed files with 466 additions and 6 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.6",
"regenerated": "2023-10-04 20:39:02.115398",
"spec_repo_commit": "79ab1c3c"
"regenerated": "2023-10-05 15:54:32.105134",
"spec_repo_commit": "432a5a71"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2023-10-04 20:39:02.139326",
"spec_repo_commit": "79ab1c3c"
"regenerated": "2023-10-05 15:54:32.119953",
"spec_repo_commit": "432a5a71"
}
}
}
29 changes: 29 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6839,6 +6839,33 @@ components:
type: string
readOnly: true
type: object
MonitorOptionsCustomSchedule:
description: Configuration options for the custom schedule. **This feature is
in private beta.**
properties:
recurrences:
description: Array of custom schedule recurrences.
items:
$ref: '#/components/schemas/MonitorOptionsCustomScheduleRecurrence'
type: array
type: object
MonitorOptionsCustomScheduleRecurrence:
description: Configuration for a recurrence set on the monitor options for custom
schedule.
properties:
rrule:
description: Defines the recurrence rule (RRULE) for a given schedule.
example: FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
type: string
start:
description: Defines the start date and time of the recurring schedule.
example: '2023-08-31T16:30:00'
type: string
timezone:
description: Defines the timezone the schedule runs on.
example: Europe/Paris
type: string
type: object
MonitorOptionsNotificationPresets:
default: show_all
description: Toggles the display of additional content sent in the monitor notification.
Expand All @@ -6856,6 +6883,8 @@ components:
MonitorOptionsSchedulingOptions:
description: Configuration options for scheduling.
properties:
custom_schedule:
$ref: '#/components/schemas/MonitorOptionsCustomSchedule'
evaluation_window:
$ref: '#/components/schemas/MonitorOptionsSchedulingOptionsEvaluationWindow'
type: object
Expand Down
104 changes: 104 additions & 0 deletions api/datadogV1/model_monitor_options_custom_schedule.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// 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 (
"github.com/goccy/go-json"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// MonitorOptionsCustomSchedule Configuration options for the custom schedule. **This feature is in private beta.**
type MonitorOptionsCustomSchedule struct {
// Array of custom schedule recurrences.
Recurrences []MonitorOptionsCustomScheduleRecurrence `json:"recurrences,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{}
}

// NewMonitorOptionsCustomSchedule instantiates a new MonitorOptionsCustomSchedule 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 NewMonitorOptionsCustomSchedule() *MonitorOptionsCustomSchedule {
this := MonitorOptionsCustomSchedule{}
return &this
}

// NewMonitorOptionsCustomScheduleWithDefaults instantiates a new MonitorOptionsCustomSchedule 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 NewMonitorOptionsCustomScheduleWithDefaults() *MonitorOptionsCustomSchedule {
this := MonitorOptionsCustomSchedule{}
return &this
}

// GetRecurrences returns the Recurrences field value if set, zero value otherwise.
func (o *MonitorOptionsCustomSchedule) GetRecurrences() []MonitorOptionsCustomScheduleRecurrence {
if o == nil || o.Recurrences == nil {
var ret []MonitorOptionsCustomScheduleRecurrence
return ret
}
return o.Recurrences
}

// GetRecurrencesOk returns a tuple with the Recurrences field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *MonitorOptionsCustomSchedule) GetRecurrencesOk() (*[]MonitorOptionsCustomScheduleRecurrence, bool) {
if o == nil || o.Recurrences == nil {
return nil, false
}
return &o.Recurrences, true
}

// HasRecurrences returns a boolean if a field has been set.
func (o *MonitorOptionsCustomSchedule) HasRecurrences() bool {
return o != nil && o.Recurrences != nil
}

// SetRecurrences gets a reference to the given []MonitorOptionsCustomScheduleRecurrence and assigns it to the Recurrences field.
func (o *MonitorOptionsCustomSchedule) SetRecurrences(v []MonitorOptionsCustomScheduleRecurrence) {
o.Recurrences = v
}

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

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

// UnmarshalJSON deserializes the given payload.
func (o *MonitorOptionsCustomSchedule) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Recurrences []MonitorOptionsCustomScheduleRecurrence `json:"recurrences,omitempty"`
}{}
if err = json.Unmarshal(bytes, &all); err != nil {
return json.Unmarshal(bytes, &o.UnparsedObject)
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"recurrences"})
} else {
return err
}
o.Recurrences = all.Recurrences

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}

return nil
}
174 changes: 174 additions & 0 deletions api/datadogV1/model_monitor_options_custom_schedule_recurrence.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
// 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 (
"github.com/goccy/go-json"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// MonitorOptionsCustomScheduleRecurrence Configuration for a recurrence set on the monitor options for custom schedule.
type MonitorOptionsCustomScheduleRecurrence struct {
// Defines the recurrence rule (RRULE) for a given schedule.
Rrule *string `json:"rrule,omitempty"`
// Defines the start date and time of the recurring schedule.
Start *string `json:"start,omitempty"`
// Defines the timezone the schedule runs on.
Timezone *string `json:"timezone,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{}
}

// NewMonitorOptionsCustomScheduleRecurrence instantiates a new MonitorOptionsCustomScheduleRecurrence 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 NewMonitorOptionsCustomScheduleRecurrence() *MonitorOptionsCustomScheduleRecurrence {
this := MonitorOptionsCustomScheduleRecurrence{}
return &this
}

// NewMonitorOptionsCustomScheduleRecurrenceWithDefaults instantiates a new MonitorOptionsCustomScheduleRecurrence 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 NewMonitorOptionsCustomScheduleRecurrenceWithDefaults() *MonitorOptionsCustomScheduleRecurrence {
this := MonitorOptionsCustomScheduleRecurrence{}
return &this
}

// GetRrule returns the Rrule field value if set, zero value otherwise.
func (o *MonitorOptionsCustomScheduleRecurrence) GetRrule() string {
if o == nil || o.Rrule == nil {
var ret string
return ret
}
return *o.Rrule
}

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

// HasRrule returns a boolean if a field has been set.
func (o *MonitorOptionsCustomScheduleRecurrence) HasRrule() bool {
return o != nil && o.Rrule != nil
}

// SetRrule gets a reference to the given string and assigns it to the Rrule field.
func (o *MonitorOptionsCustomScheduleRecurrence) SetRrule(v string) {
o.Rrule = &v
}

// GetStart returns the Start field value if set, zero value otherwise.
func (o *MonitorOptionsCustomScheduleRecurrence) GetStart() string {
if o == nil || o.Start == nil {
var ret string
return ret
}
return *o.Start
}

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

// HasStart returns a boolean if a field has been set.
func (o *MonitorOptionsCustomScheduleRecurrence) HasStart() bool {
return o != nil && o.Start != nil
}

// SetStart gets a reference to the given string and assigns it to the Start field.
func (o *MonitorOptionsCustomScheduleRecurrence) SetStart(v string) {
o.Start = &v
}

// GetTimezone returns the Timezone field value if set, zero value otherwise.
func (o *MonitorOptionsCustomScheduleRecurrence) GetTimezone() string {
if o == nil || o.Timezone == nil {
var ret string
return ret
}
return *o.Timezone
}

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

// HasTimezone returns a boolean if a field has been set.
func (o *MonitorOptionsCustomScheduleRecurrence) HasTimezone() bool {
return o != nil && o.Timezone != nil
}

// SetTimezone gets a reference to the given string and assigns it to the Timezone field.
func (o *MonitorOptionsCustomScheduleRecurrence) SetTimezone(v string) {
o.Timezone = &v
}

// MarshalJSON serializes the struct using spec logic.
func (o MonitorOptionsCustomScheduleRecurrence) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return json.Marshal(o.UnparsedObject)
}
if o.Rrule != nil {
toSerialize["rrule"] = o.Rrule
}
if o.Start != nil {
toSerialize["start"] = o.Start
}
if o.Timezone != nil {
toSerialize["timezone"] = o.Timezone
}

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

// UnmarshalJSON deserializes the given payload.
func (o *MonitorOptionsCustomScheduleRecurrence) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Rrule *string `json:"rrule,omitempty"`
Start *string `json:"start,omitempty"`
Timezone *string `json:"timezone,omitempty"`
}{}
if err = json.Unmarshal(bytes, &all); err != nil {
return json.Unmarshal(bytes, &o.UnparsedObject)
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"rrule", "start", "timezone"})
} else {
return err
}
o.Rrule = all.Rrule
o.Start = all.Start
o.Timezone = all.Timezone

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}

return nil
}
Loading

0 comments on commit 04ab383

Please sign in to comment.