|
4 | 4 | import com.datadog.api.client.ApiException; |
5 | 5 | import com.datadog.api.client.ApiResponse; |
6 | 6 | import com.datadog.api.client.Pair; |
| 7 | +import com.datadog.api.client.v2.model.Email; |
7 | 8 | import com.datadog.api.client.v2.model.EscalationPolicy; |
8 | 9 | import com.datadog.api.client.v2.model.EscalationPolicyCreateRequest; |
9 | 10 | import com.datadog.api.client.v2.model.EscalationPolicyUpdateRequest; |
@@ -452,6 +453,169 @@ public CompletableFuture<ApiResponse<Schedule>> createOnCallScheduleWithHttpInfo |
452 | 453 | new GenericType<Schedule>() {}); |
453 | 454 | } |
454 | 455 |
|
| 456 | + /** |
| 457 | + * Create email notification channel for user. |
| 458 | + * |
| 459 | + * <p>See {@link #createUserEmailNotificationChannelWithHttpInfo}. |
| 460 | + * |
| 461 | + * @param userId The user ID (required) |
| 462 | + * @param body (required) |
| 463 | + * @throws ApiException if fails to make API call |
| 464 | + */ |
| 465 | + public void createUserEmailNotificationChannel(String userId, Email body) throws ApiException { |
| 466 | + createUserEmailNotificationChannelWithHttpInfo(userId, body); |
| 467 | + } |
| 468 | + |
| 469 | + /** |
| 470 | + * Create email notification channel for user. |
| 471 | + * |
| 472 | + * <p>See {@link #createUserEmailNotificationChannelWithHttpInfoAsync}. |
| 473 | + * |
| 474 | + * @param userId The user ID (required) |
| 475 | + * @param body (required) |
| 476 | + * @return CompletableFuture |
| 477 | + */ |
| 478 | + public CompletableFuture<Void> createUserEmailNotificationChannelAsync( |
| 479 | + String userId, Email body) { |
| 480 | + return createUserEmailNotificationChannelWithHttpInfoAsync(userId, body) |
| 481 | + .thenApply( |
| 482 | + response -> { |
| 483 | + return response.getData(); |
| 484 | + }); |
| 485 | + } |
| 486 | + |
| 487 | + /** |
| 488 | + * Create a new email notification channel for an on-call user |
| 489 | + * |
| 490 | + * @param userId The user ID (required) |
| 491 | + * @param body (required) |
| 492 | + * @return ApiResponse<Void> |
| 493 | + * @throws ApiException if fails to make API call |
| 494 | + * @http.response.details |
| 495 | + * <table border="1"> |
| 496 | + * <caption>Response details</caption> |
| 497 | + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> |
| 498 | + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> |
| 499 | + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> |
| 500 | + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> |
| 501 | + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> |
| 502 | + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> |
| 503 | + * <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr> |
| 504 | + * </table> |
| 505 | + */ |
| 506 | + public ApiResponse<Void> createUserEmailNotificationChannelWithHttpInfo(String userId, Email body) |
| 507 | + throws ApiException { |
| 508 | + Object localVarPostBody = body; |
| 509 | + |
| 510 | + // verify the required parameter 'userId' is set |
| 511 | + if (userId == null) { |
| 512 | + throw new ApiException( |
| 513 | + 400, |
| 514 | + "Missing the required parameter 'userId' when calling" |
| 515 | + + " createUserEmailNotificationChannel"); |
| 516 | + } |
| 517 | + |
| 518 | + // verify the required parameter 'body' is set |
| 519 | + if (body == null) { |
| 520 | + throw new ApiException( |
| 521 | + 400, |
| 522 | + "Missing the required parameter 'body' when calling createUserEmailNotificationChannel"); |
| 523 | + } |
| 524 | + // create path and map variables |
| 525 | + String localVarPath = |
| 526 | + "/api/v2/on-call/users/{user_id}/notification-channels/emails" |
| 527 | + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); |
| 528 | + |
| 529 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 530 | + |
| 531 | + Invocation.Builder builder = |
| 532 | + apiClient.createBuilder( |
| 533 | + "v2.OnCallApi.createUserEmailNotificationChannel", |
| 534 | + localVarPath, |
| 535 | + new ArrayList<Pair>(), |
| 536 | + localVarHeaderParams, |
| 537 | + new HashMap<String, String>(), |
| 538 | + new String[] {"*/*"}, |
| 539 | + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); |
| 540 | + return apiClient.invokeAPI( |
| 541 | + "POST", |
| 542 | + builder, |
| 543 | + localVarHeaderParams, |
| 544 | + new String[] {"application/json"}, |
| 545 | + localVarPostBody, |
| 546 | + new HashMap<String, Object>(), |
| 547 | + false, |
| 548 | + null); |
| 549 | + } |
| 550 | + |
| 551 | + /** |
| 552 | + * Create email notification channel for user. |
| 553 | + * |
| 554 | + * <p>See {@link #createUserEmailNotificationChannelWithHttpInfo}. |
| 555 | + * |
| 556 | + * @param userId The user ID (required) |
| 557 | + * @param body (required) |
| 558 | + * @return CompletableFuture<ApiResponse<Void>> |
| 559 | + */ |
| 560 | + public CompletableFuture<ApiResponse<Void>> createUserEmailNotificationChannelWithHttpInfoAsync( |
| 561 | + String userId, Email body) { |
| 562 | + Object localVarPostBody = body; |
| 563 | + |
| 564 | + // verify the required parameter 'userId' is set |
| 565 | + if (userId == null) { |
| 566 | + CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>(); |
| 567 | + result.completeExceptionally( |
| 568 | + new ApiException( |
| 569 | + 400, |
| 570 | + "Missing the required parameter 'userId' when calling" |
| 571 | + + " createUserEmailNotificationChannel")); |
| 572 | + return result; |
| 573 | + } |
| 574 | + |
| 575 | + // verify the required parameter 'body' is set |
| 576 | + if (body == null) { |
| 577 | + CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>(); |
| 578 | + result.completeExceptionally( |
| 579 | + new ApiException( |
| 580 | + 400, |
| 581 | + "Missing the required parameter 'body' when calling" |
| 582 | + + " createUserEmailNotificationChannel")); |
| 583 | + return result; |
| 584 | + } |
| 585 | + // create path and map variables |
| 586 | + String localVarPath = |
| 587 | + "/api/v2/on-call/users/{user_id}/notification-channels/emails" |
| 588 | + .replaceAll("\\{" + "user_id" + "\\}", apiClient.escapeString(userId.toString())); |
| 589 | + |
| 590 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 591 | + |
| 592 | + Invocation.Builder builder; |
| 593 | + try { |
| 594 | + builder = |
| 595 | + apiClient.createBuilder( |
| 596 | + "v2.OnCallApi.createUserEmailNotificationChannel", |
| 597 | + localVarPath, |
| 598 | + new ArrayList<Pair>(), |
| 599 | + localVarHeaderParams, |
| 600 | + new HashMap<String, String>(), |
| 601 | + new String[] {"*/*"}, |
| 602 | + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); |
| 603 | + } catch (ApiException ex) { |
| 604 | + CompletableFuture<ApiResponse<Void>> result = new CompletableFuture<>(); |
| 605 | + result.completeExceptionally(ex); |
| 606 | + return result; |
| 607 | + } |
| 608 | + return apiClient.invokeAPIAsync( |
| 609 | + "POST", |
| 610 | + builder, |
| 611 | + localVarHeaderParams, |
| 612 | + new String[] {"application/json"}, |
| 613 | + localVarPostBody, |
| 614 | + new HashMap<String, Object>(), |
| 615 | + false, |
| 616 | + null); |
| 617 | + } |
| 618 | + |
455 | 619 | /** |
456 | 620 | * Delete On-Call escalation policy. |
457 | 621 | * |
|
0 commit comments