From a1b5968682a5430e5dff9aa0c2940c8ce32c66a4 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 23 May 2023 19:10:37 +0000 Subject: [PATCH] Regenerate client from commit d1e6ae92 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 49 +++++ examples/v1/monitors/GetMonitor.java | 5 +- .../v1/monitors/GetMonitor_2200114573.java | 30 +++ .../api/client/v1/api/MonitorsApi.java | 17 ++ .../api/client/v1/model/MatchingDowntime.java | 186 ++++++++++++++++++ .../datadog/api/client/v1/model/Monitor.java | 40 ++++ ...nitor_s_details_returns_OK_response.freeze | 2 +- ...monitor_s_details_returns_OK_response.json | 23 ++- ...s_with_downtime_returns_OK_response.freeze | 1 + ...ils_with_downtime_returns_OK_response.json | 144 ++++++++++++++ .../com/datadog/api/client/v1/api/given.json | 12 ++ .../api/client/v1/api/monitors.feature | 15 ++ 13 files changed, 517 insertions(+), 15 deletions(-) create mode 100644 examples/v1/monitors/GetMonitor_2200114573.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/MatchingDowntime.java create mode 100644 src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_with_downtime_returns_OK_response.freeze create mode 100644 src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_with_downtime_returns_OK_response.json diff --git a/.apigentools-info b/.apigentools-info index 3ec55ff65a4..bf43ee68556 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-05-23 13:54:26.726857", - "spec_repo_commit": "2ccd9d0a" + "regenerated": "2023-05-23 19:09:15.215571", + "spec_repo_commit": "d1e6ae92" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-05-23 13:54:26.739494", - "spec_repo_commit": "2ccd9d0a" + "regenerated": "2023-05-23 19:09:15.228698", + "spec_repo_commit": "d1e6ae92" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 268d9602444..830743dce0c 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -5829,6 +5829,43 @@ components: type: string x-enum-varnames: - USER_AGENT_PARSER + MatchingDowntime: + description: Object describing a downtime that matches this monitor. + properties: + end: + description: POSIX timestamp to end the downtime. + example: 1412792983 + format: int64 + nullable: true + type: integer + id: + description: The downtime ID. + example: 1625 + format: int64 + readOnly: true + type: integer + scope: + description: 'The scope(s) to which the downtime applies. Must be in `key:value` + format. For example, `host:app2`. + + Provide multiple scopes as a comma-separated list like `env:dev,env:prod`. + + The resulting downtime applies to sources that matches ALL provided scopes + (`env:dev` **AND** `env:prod`).' + example: + - env:staging + items: + description: A scope. For example, `"env:staging"`. + type: string + type: array + start: + description: POSIX timestamp to start the downtime. + example: 1412792983 + format: int64 + type: integer + required: + - id + type: object MetricContentEncoding: default: deflate description: HTTP header used to compress the media-type. @@ -6109,6 +6146,11 @@ components: format: int64 readOnly: true type: integer + matching_downtimes: + description: A list of active downtimes that match this monitor. + items: + $ref: '#/components/schemas/MatchingDowntime' + type: array message: description: A message to include with notifications for this monitor. type: string @@ -25354,6 +25396,13 @@ paths: required: false schema: type: string + - description: If this argument is set to true, then the returned data includes + all current active downtimes for the monitor. + in: query + name: with_downtimes + required: false + schema: + type: boolean responses: '200': content: diff --git a/examples/v1/monitors/GetMonitor.java b/examples/v1/monitors/GetMonitor.java index 7cbdd020aa4..cf2ffd41f6e 100644 --- a/examples/v1/monitors/GetMonitor.java +++ b/examples/v1/monitors/GetMonitor.java @@ -3,6 +3,7 @@ import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; import com.datadog.api.client.v1.api.MonitorsApi; +import com.datadog.api.client.v1.api.MonitorsApi.GetMonitorOptionalParameters; import com.datadog.api.client.v1.model.Monitor; public class Example { @@ -14,7 +15,9 @@ public static void main(String[] args) { Long MONITOR_ID = Long.parseLong(System.getenv("MONITOR_ID")); try { - Monitor result = apiInstance.getMonitor(MONITOR_ID); + Monitor result = + apiInstance.getMonitor( + MONITOR_ID, new GetMonitorOptionalParameters().withDowntimes(true)); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling MonitorsApi#getMonitor"); diff --git a/examples/v1/monitors/GetMonitor_2200114573.java b/examples/v1/monitors/GetMonitor_2200114573.java new file mode 100644 index 00000000000..a5e5c82a285 --- /dev/null +++ b/examples/v1/monitors/GetMonitor_2200114573.java @@ -0,0 +1,30 @@ +// Get a monitor's details with downtime returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.MonitorsApi; +import com.datadog.api.client.v1.api.MonitorsApi.GetMonitorOptionalParameters; +import com.datadog.api.client.v1.model.Monitor; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + MonitorsApi apiInstance = new MonitorsApi(defaultClient); + + // there is a valid "monitor" in the system + Long MONITOR_ID = Long.parseLong(System.getenv("MONITOR_ID")); + + try { + Monitor result = + apiInstance.getMonitor( + MONITOR_ID, new GetMonitorOptionalParameters().withDowntimes(true)); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling MonitorsApi#getMonitor"); + 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/v1/api/MonitorsApi.java b/src/main/java/com/datadog/api/client/v1/api/MonitorsApi.java index 932db4cc5c0..09cbe676fb0 100644 --- a/src/main/java/com/datadog/api/client/v1/api/MonitorsApi.java +++ b/src/main/java/com/datadog/api/client/v1/api/MonitorsApi.java @@ -805,6 +805,7 @@ public CompletableFuture> deleteMonitorWithHttpInfoA /** Manage optional parameters to getMonitor. */ public static class GetMonitorOptionalParameters { private String groupStates; + private Boolean withDowntimes; /** * Set groupStates. @@ -818,6 +819,18 @@ public GetMonitorOptionalParameters groupStates(String groupStates) { this.groupStates = groupStates; return this; } + + /** + * Set withDowntimes. + * + * @param withDowntimes If this argument is set to true, then the returned data includes all + * current active downtimes for the monitor. (optional) + * @return GetMonitorOptionalParameters + */ + public GetMonitorOptionalParameters withDowntimes(Boolean withDowntimes) { + this.withDowntimes = withDowntimes; + return this; + } } /** @@ -910,6 +923,7 @@ public ApiResponse getMonitorWithHttpInfo( 400, "Missing the required parameter 'monitorId' when calling getMonitor"); } String groupStates = parameters.groupStates; + Boolean withDowntimes = parameters.withDowntimes; // create path and map variables String localVarPath = "/api/v1/monitor/{monitor_id}" @@ -919,6 +933,7 @@ public ApiResponse getMonitorWithHttpInfo( Map localVarHeaderParams = new HashMap(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "group_states", groupStates)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "with_downtimes", withDowntimes)); Invocation.Builder builder = apiClient.createBuilder( @@ -962,6 +977,7 @@ public CompletableFuture> getMonitorWithHttpInfoAsync( return result; } String groupStates = parameters.groupStates; + Boolean withDowntimes = parameters.withDowntimes; // create path and map variables String localVarPath = "/api/v1/monitor/{monitor_id}" @@ -971,6 +987,7 @@ public CompletableFuture> getMonitorWithHttpInfoAsync( Map localVarHeaderParams = new HashMap(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "group_states", groupStates)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "with_downtimes", withDowntimes)); Invocation.Builder builder; try { diff --git a/src/main/java/com/datadog/api/client/v1/model/MatchingDowntime.java b/src/main/java/com/datadog/api/client/v1/model/MatchingDowntime.java new file mode 100644 index 00000000000..aa99a2705e3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/MatchingDowntime.java @@ -0,0 +1,186 @@ +/* + * 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.v1.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.ArrayList; +import java.util.List; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Object describing a downtime that matches this monitor. */ +@JsonPropertyOrder({ + MatchingDowntime.JSON_PROPERTY_END, + MatchingDowntime.JSON_PROPERTY_ID, + MatchingDowntime.JSON_PROPERTY_SCOPE, + MatchingDowntime.JSON_PROPERTY_START +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class MatchingDowntime { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_END = "end"; + private JsonNullable end = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + public static final String JSON_PROPERTY_SCOPE = "scope"; + private List scope = null; + + public static final String JSON_PROPERTY_START = "start"; + private Long start; + + public MatchingDowntime() {} + + @JsonCreator + public MatchingDowntime(@JsonProperty(required = true, value = JSON_PROPERTY_ID) Long id) { + this.id = id; + } + + public MatchingDowntime end(Long end) { + this.end = JsonNullable.of(end); + return this; + } + + /** + * POSIX timestamp to end the downtime. + * + * @return end + */ + @jakarta.annotation.Nullable + @JsonIgnore + public Long getEnd() { + return end.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_END) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getEnd_JsonNullable() { + return end; + } + + @JsonProperty(JSON_PROPERTY_END) + public void setEnd_JsonNullable(JsonNullable end) { + this.end = end; + } + + public void setEnd(Long end) { + this.end = JsonNullable.of(end); + } + + /** + * The downtime ID. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getId() { + return id; + } + + public MatchingDowntime scope(List scope) { + this.scope = scope; + return this; + } + + public MatchingDowntime addScopeItem(String scopeItem) { + if (this.scope == null) { + this.scope = new ArrayList<>(); + } + this.scope.add(scopeItem); + return this; + } + + /** + * The scope(s) to which the downtime applies. Must be in key:value format. For + * example, host:app2. Provide multiple scopes as a comma-separated list like + * env:dev,env:prod. The resulting downtime applies to sources that matches ALL provided + * scopes (env:dev AND env:prod). + * + * @return scope + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getScope() { + return scope; + } + + public void setScope(List scope) { + this.scope = scope; + } + + public MatchingDowntime start(Long start) { + this.start = start; + return this; + } + + /** + * POSIX timestamp to start the downtime. + * + * @return start + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getStart() { + return start; + } + + public void setStart(Long start) { + this.start = start; + } + + /** Return true if this MatchingDowntime object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MatchingDowntime matchingDowntime = (MatchingDowntime) o; + return Objects.equals(this.end, matchingDowntime.end) + && Objects.equals(this.id, matchingDowntime.id) + && Objects.equals(this.scope, matchingDowntime.scope) + && Objects.equals(this.start, matchingDowntime.start); + } + + @Override + public int hashCode() { + return Objects.hash(end, id, scope, start); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MatchingDowntime {\n"); + sb.append(" end: ").append(toIndentedString(end)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).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/main/java/com/datadog/api/client/v1/model/Monitor.java b/src/main/java/com/datadog/api/client/v1/model/Monitor.java index 1f7fddc6ee0..86ea6858209 100644 --- a/src/main/java/com/datadog/api/client/v1/model/Monitor.java +++ b/src/main/java/com/datadog/api/client/v1/model/Monitor.java @@ -25,6 +25,7 @@ Monitor.JSON_PROPERTY_CREATOR, Monitor.JSON_PROPERTY_DELETED, Monitor.JSON_PROPERTY_ID, + Monitor.JSON_PROPERTY_MATCHING_DOWNTIMES, Monitor.JSON_PROPERTY_MESSAGE, Monitor.JSON_PROPERTY_MODIFIED, Monitor.JSON_PROPERTY_MULTI, @@ -58,6 +59,9 @@ public class Monitor { public static final String JSON_PROPERTY_ID = "id"; private Long id; + public static final String JSON_PROPERTY_MATCHING_DOWNTIMES = "matching_downtimes"; + private List matchingDowntimes = null; + public static final String JSON_PROPERTY_MESSAGE = "message"; private String message; @@ -169,6 +173,39 @@ public Long getId() { return id; } + public Monitor matchingDowntimes(List matchingDowntimes) { + this.matchingDowntimes = matchingDowntimes; + for (MatchingDowntime item : matchingDowntimes) { + this.unparsed |= item.unparsed; + } + return this; + } + + public Monitor addMatchingDowntimesItem(MatchingDowntime matchingDowntimesItem) { + if (this.matchingDowntimes == null) { + this.matchingDowntimes = new ArrayList<>(); + } + this.matchingDowntimes.add(matchingDowntimesItem); + this.unparsed |= matchingDowntimesItem.unparsed; + return this; + } + + /** + * A list of active downtimes that match this monitor. + * + * @return matchingDowntimes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MATCHING_DOWNTIMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getMatchingDowntimes() { + return matchingDowntimes; + } + + public void setMatchingDowntimes(List matchingDowntimes) { + this.matchingDowntimes = matchingDowntimes; + } + public Monitor message(String message) { this.message = message; return this; @@ -451,6 +488,7 @@ public boolean equals(Object o) { && Objects.equals(this.creator, monitor.creator) && Objects.equals(this.deleted, monitor.deleted) && Objects.equals(this.id, monitor.id) + && Objects.equals(this.matchingDowntimes, monitor.matchingDowntimes) && Objects.equals(this.message, monitor.message) && Objects.equals(this.modified, monitor.modified) && Objects.equals(this.multi, monitor.multi) @@ -472,6 +510,7 @@ public int hashCode() { creator, deleted, id, + matchingDowntimes, message, modified, multi, @@ -494,6 +533,7 @@ public String toString() { sb.append(" creator: ").append(toIndentedString(creator)).append("\n"); sb.append(" deleted: ").append(toIndentedString(deleted)).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" matchingDowntimes: ").append(toIndentedString(matchingDowntimes)).append("\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" modified: ").append(toIndentedString(modified)).append("\n"); sb.append(" multi: ").append(toIndentedString(multi)).append("\n"); diff --git a/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_returns_OK_response.freeze index 0b370dd72b8..ec45a2b566b 100644 --- a/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_returns_OK_response.freeze +++ b/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_returns_OK_response.freeze @@ -1 +1 @@ -2023-01-18T18:37:19.697Z \ No newline at end of file +2023-05-22T17:02:26.784Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_returns_OK_response.json index 91de6dac43e..1fd7ec74018 100644 --- a/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_returns_OK_response.json @@ -3,7 +3,7 @@ "httpRequest": { "body": { "type": "JSON", - "json": "{\"message\": \"some message Notify: @hipchat-channel\", \"name\": \"Test-Get_a_monitor_s_details_returns_OK_response-1674067039\", \"options\": {\"enable_logs_sample\": true, \"escalation_message\": \"the situation has escalated\", \"evaluation_delay\": 700, \"groupby_simple_monitor\": true, \"include_tags\": true, \"locked\": false, \"new_host_delay\": 600, \"no_data_timeframe\": null, \"notification_preset_name\": \"hide_handles\", \"notify_audit\": false, \"notify_no_data\": false, \"on_missing_data\": \"show_and_notify_no_data\", \"renotify_interval\": 60, \"require_full_window\": true, \"thresholds\": {\"critical\": 2, \"warning\": 1}, \"timeout_h\": 24}, \"priority\": 3, \"query\": \"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\", \"tags\": [\"test:testgetamonitorsdetailsreturnsokresponse1674067039\", \"env:ci\"], \"type\": \"log alert\"}" + "json": "{\"message\": \"some message Notify: @hipchat-channel\", \"name\": \"Test-Get_a_monitor_s_details_returns_OK_response-1684774946\", \"options\": {\"enable_logs_sample\": true, \"escalation_message\": \"the situation has escalated\", \"evaluation_delay\": 700, \"groupby_simple_monitor\": true, \"include_tags\": true, \"locked\": false, \"new_host_delay\": 600, \"no_data_timeframe\": null, \"notification_preset_name\": \"hide_handles\", \"notify_audit\": false, \"notify_no_data\": false, \"on_missing_data\": \"show_and_notify_no_data\", \"renotify_interval\": 60, \"require_full_window\": true, \"thresholds\": {\"critical\": 2, \"warning\": 1}, \"timeout_h\": 24}, \"priority\": 3, \"query\": \"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\", \"tags\": [\"test:testgetamonitorsdetailsreturnsokresponse1684774946\", \"env:ci\"], \"type\": \"log alert\"}" }, "headers": {}, "method": "POST", @@ -12,7 +12,7 @@ "secure": true }, "httpResponse": { - "body": "{\"id\":108260305,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1674067039\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1674067039\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1674067039000,\"created\":\"2023-01-18T18:37:19.812019+00:00\",\"modified\":\"2023-01-18T18:37:19.812019+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "body": "{\"id\":119735290,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1684774946\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1684774946\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1684774946000,\"created\":\"2023-05-22T17:02:26.996650+00:00\",\"modified\":\"2023-05-22T17:02:26.996650+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", "headers": { "Content-Type": [ "application/json" @@ -27,18 +27,23 @@ "timeToLive": { "unlimited": true }, - "id": "6fbf4041-1708-208e-3520-487160b77c03" + "id": "89558550-211e-3f22-f6fd-9315d5d89876" }, { "httpRequest": { "headers": {}, "method": "GET", - "path": "/api/v1/monitor/108260305", + "path": "/api/v1/monitor/119735290", + "queryStringParameters": { + "with_downtimes": [ + "true" + ] + }, "keepAlive": false, "secure": true }, "httpResponse": { - "body": "{\"id\":108260305,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1674067039\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1674067039\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1674067039000,\"created\":\"2023-01-18T18:37:19.812019+00:00\",\"modified\":\"2023-01-18T18:37:19.812019+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416}}\n", + "body": "{\"id\":119735290,\"org_id\":321813,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_returns_OK_response-1684774946\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailsreturnsokresponse1684774946\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1684774946000,\"created\":\"2023-05-22T17:02:26.996650+00:00\",\"modified\":\"2023-05-22T17:02:26.996650+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"id\":1445416},\"matching_downtimes\":[]}\n", "headers": { "Content-Type": [ "application/json" @@ -53,18 +58,18 @@ "timeToLive": { "unlimited": true }, - "id": "2832aef5-5c52-bab8-7b61-f12eb73d1586" + "id": "26af3569-4386-1afa-d31f-838b381a4cbe" }, { "httpRequest": { "headers": {}, "method": "DELETE", - "path": "/api/v1/monitor/108260305", + "path": "/api/v1/monitor/119735290", "keepAlive": false, "secure": true }, "httpResponse": { - "body": "{\"deleted_monitor_id\":108260305}\n", + "body": "{\"deleted_monitor_id\":119735290}\n", "headers": { "Content-Type": [ "application/json" @@ -79,6 +84,6 @@ "timeToLive": { "unlimited": true }, - "id": "d99fd48f-4b67-0de4-5f64-f09a5daf9ce4" + "id": "375ae2d7-12d7-d1bd-8b21-9f3e77e88b61" } ] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_with_downtime_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_with_downtime_returns_OK_response.freeze new file mode 100644 index 00000000000..901591b10ad --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_with_downtime_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-05-22T21:15:19.763Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_with_downtime_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_with_downtime_returns_OK_response.json new file mode 100644 index 00000000000..34b2f9d1442 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Get_a_monitor_s_details_with_downtime_returns_OK_response.json @@ -0,0 +1,144 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"message\": \"some message Notify: @hipchat-channel\", \"name\": \"Test-Get_a_monitor_s_details_with_downtime_returns_OK_response-1684790119\", \"options\": {\"enable_logs_sample\": true, \"escalation_message\": \"the situation has escalated\", \"evaluation_delay\": 700, \"groupby_simple_monitor\": true, \"include_tags\": true, \"locked\": false, \"new_host_delay\": 600, \"no_data_timeframe\": null, \"notification_preset_name\": \"hide_handles\", \"notify_audit\": false, \"notify_no_data\": false, \"on_missing_data\": \"show_and_notify_no_data\", \"renotify_interval\": 60, \"require_full_window\": true, \"thresholds\": {\"critical\": 2, \"warning\": 1}, \"timeout_h\": 24}, \"priority\": 3, \"query\": \"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\", \"tags\": [\"test:testgetamonitorsdetailswithdowntimereturnsokresponse1684790119\", \"env:ci\"], \"type\": \"log alert\"}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/monitor", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":119766008,\"org_id\":717122,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_with_downtime_returns_OK_response-1684790119\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailswithdowntimereturnsokresponse1684790119\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{}},\"multi\":true,\"created_at\":1684790119000,\"created\":\"2023-05-22T21:15:19.942502+00:00\",\"modified\":\"2023-05-22T21:15:19.942502+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"Kevin Zou\",\"handle\":\"kevin.zou@datadoghq.com\",\"email\":\"kevin.zou@datadoghq.com\",\"id\":4351227}}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "21b6a7ed-d1dd-5cdc-439e-b02f80c1db29" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"end\":1685394919,\"message\":\"Test-Get_a_monitor_s_details_with_downtime_returns_OK_response-1684790119\",\"monitor_id\":119766008,\"mute_first_recovery_notification\":true,\"notify_end_states\":[\"alert\"],\"notify_end_types\":[\"canceled\"],\"scope\":[\"*\"],\"start\":1684790119,\"timezone\":\"Etc/UTC\"}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/downtime", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":2942947856,\"monitor_id\":119766008,\"org_id\":717122,\"start\":1684790119,\"end\":1685394919,\"canceled\":null,\"created\":1684790120,\"modified\":1684790120,\"message\":\"Test-Get_a_monitor_s_details_with_downtime_returns_OK_response-1684790119\",\"active\":true,\"disabled\":false,\"recurrence\":null,\"timezone\":\"Etc/UTC\",\"parent_id\":null,\"child_id\":null,\"creator_id\":4351227,\"updater_id\":null,\"downtime_type\":0,\"status\":\"active\",\"monitor_tags\":[\"*\"],\"mute_first_recovery_notification\":true,\"notify_end_types\":[\"canceled\"],\"notify_end_states\":[\"alert\"],\"uuid\":\"c1ddf27c-f8e5-11ed-8c5a-da7ad0900002\",\"scope\":[\"*\"]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "826b9817-1e9f-925b-af33-5fbd8d0dc4dc" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v1/monitor/119766008", + "queryStringParameters": { + "with_downtimes": [ + "true" + ] + }, + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":119766008,\"org_id\":717122,\"type\":\"log alert\",\"name\":\"Test-Get_a_monitor_s_details_with_downtime_returns_OK_response-1684790119\",\"message\":\"some message Notify: @hipchat-channel\",\"tags\":[\"test:testgetamonitorsdetailswithdowntimereturnsokresponse1684790119\",\"env:ci\"],\"query\":\"logs(\\\"service:foo AND type:error\\\").index(\\\"main\\\").rollup(\\\"count\\\").by(\\\"source\\\").last(\\\"5m\\\") > 2\",\"options\":{\"enable_logs_sample\":true,\"escalation_message\":\"the situation has escalated\",\"evaluation_delay\":700,\"groupby_simple_monitor\":true,\"include_tags\":true,\"locked\":false,\"new_host_delay\":600,\"no_data_timeframe\":null,\"notification_preset_name\":\"hide_handles\",\"notify_audit\":false,\"notify_no_data\":false,\"on_missing_data\":\"show_and_notify_no_data\",\"renotify_interval\":60,\"require_full_window\":true,\"thresholds\":{\"critical\":2.0,\"warning\":1.0},\"timeout_h\":24,\"silenced\":{\"*\":1685394919}},\"multi\":true,\"created_at\":1684790119000,\"created\":\"2023-05-22T21:15:19.942502+00:00\",\"modified\":\"2023-05-22T21:15:19.942502+00:00\",\"deleted\":null,\"restricted_roles\":null,\"priority\":3,\"overall_state_modified\":\"2023-05-22T21:15:22+00:00\",\"overall_state\":\"No Data\",\"creator\":{\"name\":\"Kevin Zou\",\"handle\":\"kevin.zou@datadoghq.com\",\"email\":\"kevin.zou@datadoghq.com\",\"id\":4351227},\"matching_downtimes\":[{\"id\":2942947856,\"active\":true,\"monitor_id\":119766008,\"start\":1684790119,\"end\":1685394919,\"scope\":[\"*\"],\"groups\":[\"total\"]}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "f1fa36cf-d841-59ce-2882-94bfdc6dadf0" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/downtime/2942947856", + "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": "5f735d16-ffaa-4374-764e-2656b8672bd5" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/monitor/119766008", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"deleted_monitor_id\":119766008}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "22efcba0-47f3-841e-59fa-06d8f27d87fe" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v1/api/given.json b/src/test/resources/com/datadog/api/client/v1/api/given.json index b80cd82fe38..1c5be660728 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/given.json +++ b/src/test/resources/com/datadog/api/client/v1/api/given.json @@ -87,6 +87,18 @@ "tag": "Downtimes", "operationId": "CreateDowntime" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"message\": \"{{ unique }}\",\n \"monitor_id\": {{ monitor.id }},\n \"start\": {{ timestamp(\"now\") }},\n \"end\": {{ timestamp(\"now + 7d\") }},\n \"timezone\": \"Etc/UTC\",\n \"scope\": [\"*\"],\n \"mute_first_recovery_notification\": true,\n \"notify_end_states\": [\"alert\"],\n \"notify_end_types\": [\"canceled\"]\n}" + } + ], + "step": "there is a valid \"downtime\" for a \"monitor\" in the system", + "key": "downtime_monitor", + "tag": "Downtimes", + "operationId": "CreateDowntime" + }, { "parameters": [ { diff --git a/src/test/resources/com/datadog/api/client/v1/api/monitors.feature b/src/test/resources/com/datadog/api/client/v1/api/monitors.feature index 129aae472e0..8a640140dad 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/monitors.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/monitors.feature @@ -187,9 +187,24 @@ Feature: Monitors Given there is a valid "monitor" in the system And new "GetMonitor" request And request contains "monitor_id" parameter from "monitor.id" + And request contains "with_downtimes" parameter with value true When the request is sent Then the response status is 200 OK And the response "id" has the same value as "monitor.id" + And the response "matching_downtimes" has length 0 + + @replay-only @team:DataDog/monitor-app + Scenario: Get a monitor's details with downtime returns "OK" response + Given there is a valid "monitor" in the system + And there is a valid "downtime" for a "monitor" in the system + And new "GetMonitor" request + And request contains "monitor_id" parameter from "monitor.id" + And request contains "with_downtimes" parameter with value true + When the request is sent + Then the response status is 200 OK + And the response "id" has the same value as "monitor.id" + And the response "matching_downtimes" has length 1 + And the response "matching_downtimes[0].id" has the same value as "downtime_monitor.id" @team:DataDog/monitor-app Scenario: Get a synthetics monitor's details