|
| 1 | +// Update a Synthetics downtime returns "OK" response |
| 2 | + |
| 3 | +import com.datadog.api.client.ApiClient; |
| 4 | +import com.datadog.api.client.ApiException; |
| 5 | +import com.datadog.api.client.v2.api.SyntheticsApi; |
| 6 | +import com.datadog.api.client.v2.model.SyntheticsDowntimeDataAttributesRequest; |
| 7 | +import com.datadog.api.client.v2.model.SyntheticsDowntimeDataRequest; |
| 8 | +import com.datadog.api.client.v2.model.SyntheticsDowntimeRequest; |
| 9 | +import com.datadog.api.client.v2.model.SyntheticsDowntimeResourceType; |
| 10 | +import com.datadog.api.client.v2.model.SyntheticsDowntimeResponse; |
| 11 | +import com.datadog.api.client.v2.model.SyntheticsDowntimeTimeSlotDate; |
| 12 | +import com.datadog.api.client.v2.model.SyntheticsDowntimeTimeSlotRequest; |
| 13 | +import java.util.Collections; |
| 14 | + |
| 15 | +public class Example { |
| 16 | + public static void main(String[] args) { |
| 17 | + ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
| 18 | + SyntheticsApi apiInstance = new SyntheticsApi(defaultClient); |
| 19 | + |
| 20 | + SyntheticsDowntimeRequest body = |
| 21 | + new SyntheticsDowntimeRequest() |
| 22 | + .data( |
| 23 | + new SyntheticsDowntimeDataRequest() |
| 24 | + .attributes( |
| 25 | + new SyntheticsDowntimeDataAttributesRequest() |
| 26 | + .isEnabled(true) |
| 27 | + .name("Weekly maintenance") |
| 28 | + .testIds(Collections.singletonList("abc-def-123")) |
| 29 | + .timeSlots( |
| 30 | + Collections.singletonList( |
| 31 | + new SyntheticsDowntimeTimeSlotRequest() |
| 32 | + .duration(3600L) |
| 33 | + .start( |
| 34 | + new SyntheticsDowntimeTimeSlotDate() |
| 35 | + .day(15L) |
| 36 | + .hour(10L) |
| 37 | + .minute(30L) |
| 38 | + .month(1L) |
| 39 | + .year(2024L)) |
| 40 | + .timezone("Europe/Paris")))) |
| 41 | + .type(SyntheticsDowntimeResourceType.DOWNTIME)); |
| 42 | + |
| 43 | + try { |
| 44 | + SyntheticsDowntimeResponse result = |
| 45 | + apiInstance.updateSyntheticsDowntime("00000000-0000-0000-0000-000000000001", body); |
| 46 | + System.out.println(result); |
| 47 | + } catch (ApiException e) { |
| 48 | + System.err.println("Exception when calling SyntheticsApi#updateSyntheticsDowntime"); |
| 49 | + System.err.println("Status code: " + e.getCode()); |
| 50 | + System.err.println("Reason: " + e.getResponseBody()); |
| 51 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 52 | + e.printStackTrace(); |
| 53 | + } |
| 54 | + } |
| 55 | +} |
0 commit comments