Skip to content
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

Update timezone for cumulative window #2946

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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": "2025-02-24 14:19:07.230112",
"spec_repo_commit": "b34a35ef"
"regenerated": "2025-02-24 18:17:18.536080",
"spec_repo_commit": "5f4a614e"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-24 14:19:07.246168",
"spec_repo_commit": "b34a35ef"
"regenerated": "2025-02-24 18:17:18.551562",
"spec_repo_commit": "5f4a614e"
}
}
}
7 changes: 6 additions & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7437,7 +7437,7 @@ components:
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.
window starts.
example: 04:00
type: string
hour_starts:
Expand All @@ -7456,6 +7456,11 @@ components:
maximum: 1
minimum: 1
type: integer
timezone:
description: The timezone of the time of the day of the cumulative evaluation
window start.
example: Europe/Paris
type: string
type: object
MonitorOverallStates:
description: The different states your monitor can be in.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (

// MonitorOptionsSchedulingOptionsEvaluationWindow 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.
type MonitorOptionsSchedulingOptionsEvaluationWindow struct {
// The time of the day at which a one day cumulative evaluation window starts. Must be defined in UTC time in `HH:mm` format.
// The time of the day at which a one day cumulative evaluation window starts.
DayStarts *string `json:"day_starts,omitempty"`
// The minute of the hour at which a one hour cumulative evaluation window starts.
HourStarts *int32 `json:"hour_starts,omitempty"`
// The day of the month at which a one month cumulative evaluation window starts.
MonthStarts *int32 `json:"month_starts,omitempty"`
// The timezone of the time of the day of the cumulative evaluation window start.
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{} `json:"-"`
Expand Down Expand Up @@ -122,6 +124,34 @@ func (o *MonitorOptionsSchedulingOptionsEvaluationWindow) SetMonthStarts(v int32
o.MonthStarts = &v
}

// GetTimezone returns the Timezone field value if set, zero value otherwise.
func (o *MonitorOptionsSchedulingOptionsEvaluationWindow) 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 *MonitorOptionsSchedulingOptionsEvaluationWindow) 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 *MonitorOptionsSchedulingOptionsEvaluationWindow) 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 *MonitorOptionsSchedulingOptionsEvaluationWindow) SetTimezone(v string) {
o.Timezone = &v
}

// MarshalJSON serializes the struct using spec logic.
func (o MonitorOptionsSchedulingOptionsEvaluationWindow) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
Expand All @@ -137,6 +167,9 @@ func (o MonitorOptionsSchedulingOptionsEvaluationWindow) MarshalJSON() ([]byte,
if o.MonthStarts != nil {
toSerialize["month_starts"] = o.MonthStarts
}
if o.Timezone != nil {
toSerialize["timezone"] = o.Timezone
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -150,19 +183,21 @@ func (o *MonitorOptionsSchedulingOptionsEvaluationWindow) UnmarshalJSON(bytes []
DayStarts *string `json:"day_starts,omitempty"`
HourStarts *int32 `json:"hour_starts,omitempty"`
MonthStarts *int32 `json:"month_starts,omitempty"`
Timezone *string `json:"timezone,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"day_starts", "hour_starts", "month_starts"})
datadog.DeleteKeys(additionalProperties, &[]string{"day_starts", "hour_starts", "month_starts", "timezone"})
} else {
return err
}
o.DayStarts = all.DayStarts
o.HourStarts = all.HourStarts
o.MonthStarts = all.MonthStarts
o.Timezone = all.Timezone

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
Expand Down
2 changes: 1 addition & 1 deletion tests/scenarios/features/v1/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Feature: Monitors
Scenario: Edit a monitor returns "Bad Request" response
Given new "UpdateMonitor" request
And request contains "monitor_id" parameter from "REPLACE.ME"
And body with value {"options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"}
And body with value {"options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1, "timezone": "Europe/Paris"}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"}
When the request is sent
Then the response status is 400 Bad Request

Expand Down
Loading