From 0590d705d8aca595800596a4c62b69a4dab41abe Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 30 Sep 2022 16:42:39 +0000 Subject: [PATCH] Regenerate client from commit a3591c26 of spec repo --- .apigentools-info | 8 ++-- .generator/schemas/v1/openapi.yaml | 18 +++++++++ api/datadogV1/model_monitor_options.go | 39 +++++++++++++++++++ .../v1/monitors/ValidateMonitor_4247196452.go | 15 ++++--- tests/scenarios/features/v1/monitors.feature | 2 +- .../v1/multi_alert_monitor_payload.json | 3 +- 6 files changed, 73 insertions(+), 12 deletions(-) diff --git a/.apigentools-info b/.apigentools-info index a2173a00f38..de846e3317d 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2022-09-29 15:48:27.395302", - "spec_repo_commit": "e57e3c55" + "regenerated": "2022-09-30 16:41:29.759239", + "spec_repo_commit": "a3591c26" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2022-09-29 15:48:27.407155", - "spec_repo_commit": "e57e3c55" + "regenerated": "2022-09-30 16:41:29.771977", + "spec_repo_commit": "a3591c26" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index b9301ef3c18..47234e1721a 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -6278,6 +6278,24 @@ components: description: A Boolean indicating whether tagged users is notified on changes to this monitor. type: boolean + notify_by: + description: 'Controls what granularity a monitor alerts on. Only available + for multi-alerts. + + For instance, a monitor grouped by `cluster`, `namespace`, `pod` can be + configured to only notify on each + + new `cluster` violating the alert conditions by setting `notify_by` to + `["cluster"]`. Tags mentioned + + in `notify_by` have to be a subset of the grouping tags in the query. + + For example, a query grouped by `cluster`, `namespace` cannot notify on + `region`.' + items: + description: A grouping tag. + type: string + type: array notify_no_data: default: false description: A Boolean indicating whether this monitor notifies when data diff --git a/api/datadogV1/model_monitor_options.go b/api/datadogV1/model_monitor_options.go index 5f7ff7e8f87..aa074bee2b8 100644 --- a/api/datadogV1/model_monitor_options.go +++ b/api/datadogV1/model_monitor_options.go @@ -69,6 +69,12 @@ type MonitorOptions struct { NoDataTimeframe datadog.NullableInt64 `json:"no_data_timeframe,omitempty"` // A Boolean indicating whether tagged users is notified on changes to this monitor. NotifyAudit *bool `json:"notify_audit,omitempty"` + // Controls what granularity a monitor alerts on. Only available for multi-alerts. + // For instance, a monitor grouped by `cluster`, `namespace`, `pod` can be configured to only notify on each + // new `cluster` violating the alert conditions by setting `notify_by` to `["cluster"]`. Tags mentioned + // in `notify_by` have to be a subset of the grouping tags in the query. + // For example, a query grouped by `cluster`, `namespace` cannot notify on `region`. + NotifyBy []string `json:"notify_by,omitempty"` // A Boolean indicating whether this monitor notifies when data stops reporting. NotifyNoData *bool `json:"notify_no_data,omitempty"` // Controls how groups or monitors are treated if an evaluation does not return any data points. @@ -651,6 +657,34 @@ func (o *MonitorOptions) SetNotifyAudit(v bool) { o.NotifyAudit = &v } +// GetNotifyBy returns the NotifyBy field value if set, zero value otherwise. +func (o *MonitorOptions) GetNotifyBy() []string { + if o == nil || o.NotifyBy == nil { + var ret []string + return ret + } + return o.NotifyBy +} + +// GetNotifyByOk returns a tuple with the NotifyBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MonitorOptions) GetNotifyByOk() (*[]string, bool) { + if o == nil || o.NotifyBy == nil { + return nil, false + } + return &o.NotifyBy, true +} + +// HasNotifyBy returns a boolean if a field has been set. +func (o *MonitorOptions) HasNotifyBy() bool { + return o != nil && o.NotifyBy != nil +} + +// SetNotifyBy gets a reference to the given []string and assigns it to the NotifyBy field. +func (o *MonitorOptions) SetNotifyBy(v []string) { + o.NotifyBy = v +} + // GetNotifyNoData returns the NotifyNoData field value if set, zero value otherwise. func (o *MonitorOptions) GetNotifyNoData() bool { if o == nil || o.NotifyNoData == nil { @@ -1089,6 +1123,9 @@ func (o MonitorOptions) MarshalJSON() ([]byte, error) { if o.NotifyAudit != nil { toSerialize["notify_audit"] = o.NotifyAudit } + if o.NotifyBy != nil { + toSerialize["notify_by"] = o.NotifyBy + } if o.NotifyNoData != nil { toSerialize["notify_no_data"] = o.NotifyNoData } @@ -1151,6 +1188,7 @@ func (o *MonitorOptions) UnmarshalJSON(bytes []byte) (err error) { NewHostDelay datadog.NullableInt64 `json:"new_host_delay,omitempty"` NoDataTimeframe datadog.NullableInt64 `json:"no_data_timeframe,omitempty"` NotifyAudit *bool `json:"notify_audit,omitempty"` + NotifyBy []string `json:"notify_by,omitempty"` NotifyNoData *bool `json:"notify_no_data,omitempty"` OnMissingData *OnMissingDataOption `json:"on_missing_data,omitempty"` RenotifyInterval datadog.NullableInt64 `json:"renotify_interval,omitempty"` @@ -1203,6 +1241,7 @@ func (o *MonitorOptions) UnmarshalJSON(bytes []byte) (err error) { o.NewHostDelay = all.NewHostDelay o.NoDataTimeframe = all.NoDataTimeframe o.NotifyAudit = all.NotifyAudit + o.NotifyBy = all.NotifyBy o.NotifyNoData = all.NotifyNoData o.OnMissingData = all.OnMissingData o.RenotifyInterval = all.RenotifyInterval diff --git a/examples/v1/monitors/ValidateMonitor_4247196452.go b/examples/v1/monitors/ValidateMonitor_4247196452.go index 5f9a1da00ce..a338f4354b9 100644 --- a/examples/v1/monitors/ValidateMonitor_4247196452.go +++ b/examples/v1/monitors/ValidateMonitor_4247196452.go @@ -16,7 +16,7 @@ func main() { body := datadogV1.Monitor{ Name: datadog.PtrString("Example-Validate_a_multi_alert_monitor_returns_OK_response"), Type: datadogV1.MONITORTYPE_LOG_ALERT, - Query: `logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2`, + Query: `logs("service:foo AND type:error").index("main").rollup("count").by("source,status").last("5m") > 2`, Message: datadog.PtrString("some message Notify: @hipchat-channel"), Tags: []string{ "test:examplevalidateamultialertmonitorreturnsokresponse", @@ -34,11 +34,14 @@ func main() { NewHostDelay: *datadog.NewNullableInt64(datadog.PtrInt64(600)), NoDataTimeframe: *datadog.NewNullableInt64(nil), NotifyAudit: datadog.PtrBool(false), - NotifyNoData: datadog.PtrBool(false), - OnMissingData: datadogV1.ONMISSINGDATAOPTION_SHOW_AND_NOTIFY_NO_DATA.Ptr(), - RenotifyInterval: *datadog.NewNullableInt64(datadog.PtrInt64(60)), - RequireFullWindow: datadog.PtrBool(true), - TimeoutH: *datadog.NewNullableInt64(datadog.PtrInt64(24)), + NotifyBy: []string{ + "status", + }, + NotifyNoData: datadog.PtrBool(false), + OnMissingData: datadogV1.ONMISSINGDATAOPTION_SHOW_AND_NOTIFY_NO_DATA.Ptr(), + RenotifyInterval: *datadog.NewNullableInt64(datadog.PtrInt64(60)), + RequireFullWindow: datadog.PtrBool(true), + TimeoutH: *datadog.NewNullableInt64(datadog.PtrInt64(24)), Thresholds: &datadogV1.MonitorThresholds{ Critical: datadog.PtrFloat64(2), Warning: *datadog.NewNullableFloat64(datadog.PtrFloat64(1)), diff --git a/tests/scenarios/features/v1/monitors.feature b/tests/scenarios/features/v1/monitors.feature index fc0a197ef30..15e92f86b21 100644 --- a/tests/scenarios/features/v1/monitors.feature +++ b/tests/scenarios/features/v1/monitors.feature @@ -115,7 +115,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": {"escalation_message": "none", "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, "notify_audit": false, "notify_no_data": false, "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "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"}}]}, "restricted_roles": [], "tags": [], "type": "query alert"} + And body with value {"options": {"escalation_message": "none", "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, "notify_audit": false, "notify_by": [], "notify_no_data": false, "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "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"}}]}, "restricted_roles": [], "tags": [], "type": "query alert"} When the request is sent Then the response status is 400 Bad Request diff --git a/tests/scenarios/features/v1/multi_alert_monitor_payload.json b/tests/scenarios/features/v1/multi_alert_monitor_payload.json index 7ba5fe74d48..a0eb80488e5 100644 --- a/tests/scenarios/features/v1/multi_alert_monitor_payload.json +++ b/tests/scenarios/features/v1/multi_alert_monitor_payload.json @@ -1,7 +1,7 @@ { "name": "{{ unique }}", "type": "log alert", - "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\") > 2", + "query": "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source,status\").last(\"5m\") > 2", "message": "some message Notify: @hipchat-channel", "tags": ["test:{{ unique_lower_alnum }}", "env:ci"], "priority": 3, @@ -16,6 +16,7 @@ "new_host_delay": 600, "no_data_timeframe": null, "notify_audit": false, + "notify_by": ["status"], "notify_no_data": false, "on_missing_data": "show_and_notify_no_data", "renotify_interval": 60,