diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6401afac969..caaa68e3b23 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -32232,11 +32232,17 @@ components: recipients: $ref: '#/components/schemas/MonitorNotificationRuleRecipients' scope: - $ref: '#/components/schemas/MonitorNotificationRuleScope' + $ref: '#/components/schemas/MonitorNotificationRuleConditionScope' required: - scope - recipients type: object + MonitorNotificationRuleConditionScope: + description: The scope to which the monitor applied. + example: transition_type:alert + maxLength: 3000 + minLength: 1 + type: string MonitorNotificationRuleConditionalRecipients: description: Use conditional recipients to define different recipients for different situations. @@ -32289,6 +32295,20 @@ components: description: Filter used to associate the notification rule with monitors. oneOf: - $ref: '#/components/schemas/MonitorNotificationRuleFilterTags' + - $ref: '#/components/schemas/MonitorNotificationRuleFilterScope' + MonitorNotificationRuleFilterScope: + additionalProperties: false + description: Filter monitors by scope. Monitors must match the scope evaluation. + properties: + scope: + description: The scope to which the monitor notification rule applies. + example: env:prod AND datacenter:us-east-1 + maxLength: 3000 + minLength: 1 + type: string + required: + - scope + type: object MonitorNotificationRuleFilterTags: additionalProperties: false description: Filter monitors by tags. Monitors must match all tags. @@ -32417,12 +32437,6 @@ components: description: An object related to a monitor notification rule. oneOf: - $ref: '#/components/schemas/User' - MonitorNotificationRuleScope: - description: The scope to which the monitor applied. - example: transition_type:alert - maxLength: 3000 - minLength: 1 - type: string MonitorNotificationRuleUpdateRequest: description: Request for updating a monitor notification rule. properties: diff --git a/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.java b/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.java new file mode 100644 index 00000000000..420d8ce334f --- /dev/null +++ b/examples/v2/monitors/CreateMonitorNotificationRule_1379932371.java @@ -0,0 +1,45 @@ +// Create a monitor notification rule with scope returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.MonitorsApi; +import com.datadog.api.client.v2.model.MonitorNotificationRuleAttributes; +import com.datadog.api.client.v2.model.MonitorNotificationRuleCreateRequest; +import com.datadog.api.client.v2.model.MonitorNotificationRuleCreateRequestData; +import com.datadog.api.client.v2.model.MonitorNotificationRuleFilter; +import com.datadog.api.client.v2.model.MonitorNotificationRuleFilterScope; +import com.datadog.api.client.v2.model.MonitorNotificationRuleResourceType; +import com.datadog.api.client.v2.model.MonitorNotificationRuleResponse; +import java.util.Arrays; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + MonitorsApi apiInstance = new MonitorsApi(defaultClient); + + MonitorNotificationRuleCreateRequest body = + new MonitorNotificationRuleCreateRequest() + .data( + new MonitorNotificationRuleCreateRequestData() + .attributes( + new MonitorNotificationRuleAttributes() + .filter( + new MonitorNotificationRuleFilter( + new MonitorNotificationRuleFilterScope() + .scope("test:example-monitor"))) + .name("test rule") + .recipients(Arrays.asList("slack-test-channel", "jira-test"))) + .type(MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE)); + + try { + MonitorNotificationRuleResponse result = apiInstance.createMonitorNotificationRule(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MonitorsApi#createMonitorNotificationRule"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.java b/examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.java new file mode 100644 index 00000000000..a0a66fd51f2 --- /dev/null +++ b/examples/v2/monitors/UpdateMonitorNotificationRule_1446058210.java @@ -0,0 +1,50 @@ +// Update a monitor notification rule with scope returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.MonitorsApi; +import com.datadog.api.client.v2.model.MonitorNotificationRuleAttributes; +import com.datadog.api.client.v2.model.MonitorNotificationRuleFilter; +import com.datadog.api.client.v2.model.MonitorNotificationRuleFilterScope; +import com.datadog.api.client.v2.model.MonitorNotificationRuleResourceType; +import com.datadog.api.client.v2.model.MonitorNotificationRuleResponse; +import com.datadog.api.client.v2.model.MonitorNotificationRuleUpdateRequest; +import com.datadog.api.client.v2.model.MonitorNotificationRuleUpdateRequestData; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + MonitorsApi apiInstance = new MonitorsApi(defaultClient); + + // there is a valid "monitor_notification_rule" in the system + String MONITOR_NOTIFICATION_RULE_DATA_ID = System.getenv("MONITOR_NOTIFICATION_RULE_DATA_ID"); + + MonitorNotificationRuleUpdateRequest body = + new MonitorNotificationRuleUpdateRequest() + .data( + new MonitorNotificationRuleUpdateRequestData() + .attributes( + new MonitorNotificationRuleAttributes() + .filter( + new MonitorNotificationRuleFilter( + new MonitorNotificationRuleFilterScope() + .scope("test:example-monitor"))) + .name("updated rule") + .recipients(Collections.singletonList("slack-test-channel"))) + .id(MONITOR_NOTIFICATION_RULE_DATA_ID) + .type(MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE)); + + try { + MonitorNotificationRuleResponse result = + apiInstance.updateMonitorNotificationRule(MONITOR_NOTIFICATION_RULE_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MonitorsApi#updateMonitorNotificationRule"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilter.java b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilter.java index 408c3182c76..32e0c79b4b2 100644 --- a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilter.java +++ b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilter.java @@ -127,6 +127,54 @@ public MonitorNotificationRuleFilter deserialize(JsonParser jp, DeserializationC Level.FINER, "Input data does not match schema 'MonitorNotificationRuleFilterTags'", e); } + // deserialize MonitorNotificationRuleFilterScope + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MonitorNotificationRuleFilterScope.class.equals(Integer.class) + || MonitorNotificationRuleFilterScope.class.equals(Long.class) + || MonitorNotificationRuleFilterScope.class.equals(Float.class) + || MonitorNotificationRuleFilterScope.class.equals(Double.class) + || MonitorNotificationRuleFilterScope.class.equals(Boolean.class) + || MonitorNotificationRuleFilterScope.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MonitorNotificationRuleFilterScope.class.equals(Integer.class) + || MonitorNotificationRuleFilterScope.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MonitorNotificationRuleFilterScope.class.equals(Float.class) + || MonitorNotificationRuleFilterScope.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (MonitorNotificationRuleFilterScope.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MonitorNotificationRuleFilterScope.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(MonitorNotificationRuleFilterScope.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((MonitorNotificationRuleFilterScope) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'MonitorNotificationRuleFilterScope'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'MonitorNotificationRuleFilterScope'", + e); + } + MonitorNotificationRuleFilter ret = new MonitorNotificationRuleFilter(); if (match == 1) { ret.setActualInstance(deserialized); @@ -162,10 +210,18 @@ public MonitorNotificationRuleFilter(MonitorNotificationRuleFilterTags o) { setActualInstance(o); } + public MonitorNotificationRuleFilter(MonitorNotificationRuleFilterScope o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put( "MonitorNotificationRuleFilterTags", new GenericType() {}); + schemas.put( + "MonitorNotificationRuleFilterScope", + new GenericType() {}); JSON.registerDescendants( MonitorNotificationRuleFilter.class, Collections.unmodifiableMap(schemas)); } @@ -177,7 +233,8 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: MonitorNotificationRuleFilterTags + * against the oneOf child schemas: MonitorNotificationRuleFilterTags, + * MonitorNotificationRuleFilterScope * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -189,18 +246,27 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf( + MonitorNotificationRuleFilterScope.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } - throw new RuntimeException("Invalid instance type. Must be MonitorNotificationRuleFilterTags"); + throw new RuntimeException( + "Invalid instance type. Must be MonitorNotificationRuleFilterTags," + + " MonitorNotificationRuleFilterScope"); } /** - * Get the actual instance, which can be the following: MonitorNotificationRuleFilterTags + * Get the actual instance, which can be the following: MonitorNotificationRuleFilterTags, + * MonitorNotificationRuleFilterScope * - * @return The actual instance (MonitorNotificationRuleFilterTags) + * @return The actual instance (MonitorNotificationRuleFilterTags, + * MonitorNotificationRuleFilterScope) */ @Override public Object getActualInstance() { @@ -218,4 +284,16 @@ public MonitorNotificationRuleFilterTags getMonitorNotificationRuleFilterTags() throws ClassCastException { return (MonitorNotificationRuleFilterTags) super.getActualInstance(); } + + /** + * Get the actual instance of `MonitorNotificationRuleFilterScope`. If the actual instance is not + * `MonitorNotificationRuleFilterScope`, the ClassCastException will be thrown. + * + * @return The actual instance of `MonitorNotificationRuleFilterScope` + * @throws ClassCastException if the instance is not `MonitorNotificationRuleFilterScope` + */ + public MonitorNotificationRuleFilterScope getMonitorNotificationRuleFilterScope() + throws ClassCastException { + return (MonitorNotificationRuleFilterScope) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilterScope.java b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilterScope.java new file mode 100644 index 00000000000..dfe3746dfac --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MonitorNotificationRuleFilterScope.java @@ -0,0 +1,90 @@ +/* + * 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 com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** Filter monitors by scope. Monitors must match the scope evaluation. */ +@JsonPropertyOrder({MonitorNotificationRuleFilterScope.JSON_PROPERTY_SCOPE}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MonitorNotificationRuleFilterScope { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_SCOPE = "scope"; + private String scope; + + public MonitorNotificationRuleFilterScope() {} + + @JsonCreator + public MonitorNotificationRuleFilterScope( + @JsonProperty(required = true, value = JSON_PROPERTY_SCOPE) String scope) { + this.scope = scope; + } + + public MonitorNotificationRuleFilterScope scope(String scope) { + this.scope = scope; + return this; + } + + /** + * The scope to which the monitor notification rule applies. + * + * @return scope + */ + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + /** Return true if this MonitorNotificationRuleFilterScope object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonitorNotificationRuleFilterScope monitorNotificationRuleFilterScope = + (MonitorNotificationRuleFilterScope) o; + return Objects.equals(this.scope, monitorNotificationRuleFilterScope.scope); + } + + @Override + public int hashCode() { + return Objects.hash(scope); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MonitorNotificationRuleFilterScope {\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.freeze new file mode 100644 index 00000000000..94917c9e8b9 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-11T21:28:39.129Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.json new file mode 100644 index 00000000000..cfd28750f81 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_a_monitor_notification_rule_with_scope_returns_OK_response.json @@ -0,0 +1,57 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"filter\":{\"scope\":\"test:test-create_a_monitor_notification_rule_with_scope_returns_ok_response-1762896519\"},\"name\":\"test rule\",\"recipients\":[\"slack-test-channel\",\"jira-test\"]},\"type\":\"monitor-notification-rule\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/monitor/notification_rule", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"modified_at\":\"1970-01-01T00:00:00+00:00\",\"filter\":{\"scope\":\"test:test-create_a_monitor_notification_rule_with_scope_returns_ok_response-1762896519\"},\"name\":\"test rule\",\"recipients\":[\"slack-test-channel\",\"jira-test\"],\"created_at\":\"2025-11-11T21:28:40.032148+00:00\"},\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}},\"id\":\"bbea2907-c191-48d0-9e0f-1ec5881ee37c\"},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e4be868d-ca8d-7434-0ab1-7b06ab95288e" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/monitor/notification_rule/bbea2907-c191-48d0-9e0f-1ec5881ee37c", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "00d5556e-17c8-27a0-dc4a-a1c17361ac26" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.freeze new file mode 100644 index 00000000000..ab91f3c3d08 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-11T21:28:40.357Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.json new file mode 100644 index 00000000000..0817a949c6c --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Update_a_monitor_notification_rule_with_scope_returns_OK_response.json @@ -0,0 +1,87 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"filter\":{\"tags\":[\"app:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"]},\"name\":\"test rule\",\"recipients\":[\"slack-monitor-app\"]},\"type\":\"monitor-notification-rule\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/monitor/notification_rule", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"recipients\":[\"slack-monitor-app\"],\"modified_at\":\"1970-01-01T00:00:00+00:00\",\"created_at\":\"2025-11-11T21:28:40.540848+00:00\",\"name\":\"test rule\",\"filter\":{\"tags\":[\"app:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"]}},\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\"},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "00cda7cf-fe4c-75a8-bc28-baa5933cbfec" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"filter\":{\"scope\":\"test:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"},\"name\":\"updated rule\",\"recipients\":[\"slack-test-channel\"]},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\",\"type\":\"monitor-notification-rule\"}}" + }, + "headers": {}, + "method": "PATCH", + "path": "/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"monitor-notification-rule\",\"attributes\":{\"filter\":{\"scope\":\"test:test-update_a_monitor_notification_rule_with_scope_returns_ok_response-1762896520\"},\"recipients\":[\"slack-test-channel\"],\"created_at\":\"2025-11-11T21:28:40.540848+00:00\",\"name\":\"updated rule\",\"modified_at\":\"2025-11-11T21:28:40.815544+00:00\"},\"id\":\"827442a0-5d3e-408c-a930-7ac44775fff1\",\"relationships\":{\"created_by\":{\"data\":{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}},\"included\":[{\"type\":\"users\",\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"attributes\":{\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"created_at\":\"2020-12-29T22:58:44.733921+00:00\",\"modified_at\":\"2021-04-27T13:54:01.547888+00:00\",\"email\":\"team-intg-tools-libs-spam@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/b7c189b5b4c2c429d7c1e0bc3749330e?s=48&d=retro\",\"title\":null,\"verified\":true,\"service_account\":true,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Active\",\"last_login_time\":null}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "91f1a6b8-c117-246d-fceb-72c3ec665801" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/monitor/notification_rule/827442a0-5d3e-408c-a930-7ac44775fff1", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d37e3788-b9fd-b869-41be-d09511fde9b5" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/monitors.feature b/src/test/resources/com/datadog/api/client/v2/api/monitors.feature index 346a646f83b..e84062637c1 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/monitors.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/monitors.feature @@ -52,6 +52,14 @@ Feature: Monitors Then the response status is 200 OK And the response "data.attributes.name" is equal to "test rule" + @team:DataDog/monitor-app + Scenario: Create a monitor notification rule with scope returns "OK" response + Given new "CreateMonitorNotificationRule" request + And body with value {"data": {"attributes": {"filter": {"scope": "test:{{ unique_lower }}"}, "name": "test rule", "recipients": ["slack-test-channel", "jira-test"]}, "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "test rule" + @skip-validation @team:DataDog/monitor-app Scenario: Create a monitor user template returns "Bad Request" response Given new "CreateMonitorUserTemplate" request @@ -272,6 +280,16 @@ Feature: Monitors Then the response status is 200 OK And the response "data.attributes.name" is equal to "updated rule" + @team:DataDog/monitor-app + Scenario: Update a monitor notification rule with scope returns "OK" response + Given there is a valid "monitor_notification_rule" in the system + And new "UpdateMonitorNotificationRule" request + And request contains "rule_id" parameter from "monitor_notification_rule.data.id" + And body with value {"data": {"attributes": {"filter": {"scope": "test:{{ unique_lower }}"}, "name": "updated rule", "recipients": ["slack-test-channel"]}, "id": "{{ monitor_notification_rule.data.id }}", "type": "monitor-notification-rule"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "updated rule" + @skip-validation @team:DataDog/monitor-app Scenario: Update a monitor user template to a new version returns "Bad Request" response Given there is a valid "monitor_user_template" in the system