|
| 1 | +// Update an event email address 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.EventsApi; |
| 6 | +import com.datadog.api.client.v2.model.EventEmailAddressAlertType; |
| 7 | +import com.datadog.api.client.v2.model.EventEmailAddressResourceType; |
| 8 | +import com.datadog.api.client.v2.model.EventEmailAddressSingleResponse; |
| 9 | +import com.datadog.api.client.v2.model.EventEmailAddressUpdateAttributes; |
| 10 | +import com.datadog.api.client.v2.model.EventEmailAddressUpdateData; |
| 11 | +import com.datadog.api.client.v2.model.EventEmailAddressUpdateRequest; |
| 12 | +import java.util.Arrays; |
| 13 | +import java.util.Collections; |
| 14 | +import java.util.UUID; |
| 15 | + |
| 16 | +public class Example { |
| 17 | + public static void main(String[] args) { |
| 18 | + ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
| 19 | + defaultClient.setUnstableOperationEnabled("v2.updateEventEmailAddress", true); |
| 20 | + EventsApi apiInstance = new EventsApi(defaultClient); |
| 21 | + |
| 22 | + EventEmailAddressUpdateRequest body = |
| 23 | + new EventEmailAddressUpdateRequest() |
| 24 | + .data( |
| 25 | + new EventEmailAddressUpdateData() |
| 26 | + .attributes( |
| 27 | + new EventEmailAddressUpdateAttributes() |
| 28 | + .alertType(EventEmailAddressAlertType.INFO) |
| 29 | + .description("Updated description for the email address.") |
| 30 | + .notifyHandles(Collections.singletonList("@slack-my-channel")) |
| 31 | + .tags(Arrays.asList("env:production", "team:my-team"))) |
| 32 | + .type(EventEmailAddressResourceType.EVENT_EMAILS)); |
| 33 | + |
| 34 | + try { |
| 35 | + EventEmailAddressSingleResponse result = |
| 36 | + apiInstance.updateEventEmailAddress( |
| 37 | + UUID.fromString("00000000-0000-0000-0000-000000000001"), body); |
| 38 | + System.out.println(result); |
| 39 | + } catch (ApiException e) { |
| 40 | + System.err.println("Exception when calling EventsApi#updateEventEmailAddress"); |
| 41 | + System.err.println("Status code: " + e.getCode()); |
| 42 | + System.err.println("Reason: " + e.getResponseBody()); |
| 43 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 44 | + e.printStackTrace(); |
| 45 | + } |
| 46 | + } |
| 47 | +} |
0 commit comments