|
20 | 20 | import com.datadog.api.client.v2.model.PersonalAccessTokenResponse; |
21 | 21 | import com.datadog.api.client.v2.model.PersonalAccessTokenUpdateRequest; |
22 | 22 | import com.datadog.api.client.v2.model.PersonalAccessTokensSort; |
| 23 | +import com.datadog.api.client.v2.model.ValidateV2Response; |
23 | 24 | import jakarta.ws.rs.client.Invocation; |
24 | 25 | import jakarta.ws.rs.core.GenericType; |
25 | 26 | import java.util.ArrayList; |
@@ -3464,4 +3465,131 @@ public ApiResponse<PersonalAccessTokenResponse> updatePersonalAccessTokenWithHtt |
3464 | 3465 | false, |
3465 | 3466 | new GenericType<PersonalAccessTokenResponse>() {}); |
3466 | 3467 | } |
| 3468 | + |
| 3469 | + /** |
| 3470 | + * Validate API key. |
| 3471 | + * |
| 3472 | + * <p>See {@link #validateV2WithHttpInfo}. |
| 3473 | + * |
| 3474 | + * @return ValidateV2Response |
| 3475 | + * @throws ApiException if fails to make API call |
| 3476 | + */ |
| 3477 | + public ValidateV2Response validateV2() throws ApiException { |
| 3478 | + return validateV2WithHttpInfo().getData(); |
| 3479 | + } |
| 3480 | + |
| 3481 | + /** |
| 3482 | + * Validate API key. |
| 3483 | + * |
| 3484 | + * <p>See {@link #validateV2WithHttpInfoAsync}. |
| 3485 | + * |
| 3486 | + * @return CompletableFuture<ValidateV2Response> |
| 3487 | + */ |
| 3488 | + public CompletableFuture<ValidateV2Response> validateV2Async() { |
| 3489 | + return validateV2WithHttpInfoAsync() |
| 3490 | + .thenApply( |
| 3491 | + response -> { |
| 3492 | + return response.getData(); |
| 3493 | + }); |
| 3494 | + } |
| 3495 | + |
| 3496 | + /** |
| 3497 | + * Check if the API key is valid. Returns the organization UUID, API key ID, and associated |
| 3498 | + * scopes. |
| 3499 | + * |
| 3500 | + * @return ApiResponse<ValidateV2Response> |
| 3501 | + * @throws ApiException if fails to make API call |
| 3502 | + * @http.response.details |
| 3503 | + * <table border="1"> |
| 3504 | + * <caption>Response details</caption> |
| 3505 | + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> |
| 3506 | + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> |
| 3507 | + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> |
| 3508 | + * <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr> |
| 3509 | + * </table> |
| 3510 | + */ |
| 3511 | + public ApiResponse<ValidateV2Response> validateV2WithHttpInfo() throws ApiException { |
| 3512 | + // Check if unstable operation is enabled |
| 3513 | + String operationId = "validateV2"; |
| 3514 | + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { |
| 3515 | + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); |
| 3516 | + } else { |
| 3517 | + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); |
| 3518 | + } |
| 3519 | + Object localVarPostBody = null; |
| 3520 | + // create path and map variables |
| 3521 | + String localVarPath = "/api/v2/validate"; |
| 3522 | + |
| 3523 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 3524 | + |
| 3525 | + Invocation.Builder builder = |
| 3526 | + apiClient.createBuilder( |
| 3527 | + "v2.KeyManagementApi.validateV2", |
| 3528 | + localVarPath, |
| 3529 | + new ArrayList<Pair>(), |
| 3530 | + localVarHeaderParams, |
| 3531 | + new HashMap<String, String>(), |
| 3532 | + new String[] {"application/json"}, |
| 3533 | + new String[] {"apiKeyAuth"}); |
| 3534 | + return apiClient.invokeAPI( |
| 3535 | + "GET", |
| 3536 | + builder, |
| 3537 | + localVarHeaderParams, |
| 3538 | + new String[] {}, |
| 3539 | + localVarPostBody, |
| 3540 | + new HashMap<String, Object>(), |
| 3541 | + false, |
| 3542 | + new GenericType<ValidateV2Response>() {}); |
| 3543 | + } |
| 3544 | + |
| 3545 | + /** |
| 3546 | + * Validate API key. |
| 3547 | + * |
| 3548 | + * <p>See {@link #validateV2WithHttpInfo}. |
| 3549 | + * |
| 3550 | + * @return CompletableFuture<ApiResponse<ValidateV2Response>> |
| 3551 | + */ |
| 3552 | + public CompletableFuture<ApiResponse<ValidateV2Response>> validateV2WithHttpInfoAsync() { |
| 3553 | + // Check if unstable operation is enabled |
| 3554 | + String operationId = "validateV2"; |
| 3555 | + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { |
| 3556 | + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); |
| 3557 | + } else { |
| 3558 | + CompletableFuture<ApiResponse<ValidateV2Response>> result = new CompletableFuture<>(); |
| 3559 | + result.completeExceptionally( |
| 3560 | + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); |
| 3561 | + return result; |
| 3562 | + } |
| 3563 | + Object localVarPostBody = null; |
| 3564 | + // create path and map variables |
| 3565 | + String localVarPath = "/api/v2/validate"; |
| 3566 | + |
| 3567 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 3568 | + |
| 3569 | + Invocation.Builder builder; |
| 3570 | + try { |
| 3571 | + builder = |
| 3572 | + apiClient.createBuilder( |
| 3573 | + "v2.KeyManagementApi.validateV2", |
| 3574 | + localVarPath, |
| 3575 | + new ArrayList<Pair>(), |
| 3576 | + localVarHeaderParams, |
| 3577 | + new HashMap<String, String>(), |
| 3578 | + new String[] {"application/json"}, |
| 3579 | + new String[] {"apiKeyAuth"}); |
| 3580 | + } catch (ApiException ex) { |
| 3581 | + CompletableFuture<ApiResponse<ValidateV2Response>> result = new CompletableFuture<>(); |
| 3582 | + result.completeExceptionally(ex); |
| 3583 | + return result; |
| 3584 | + } |
| 3585 | + return apiClient.invokeAPIAsync( |
| 3586 | + "GET", |
| 3587 | + builder, |
| 3588 | + localVarHeaderParams, |
| 3589 | + new String[] {}, |
| 3590 | + localVarPostBody, |
| 3591 | + new HashMap<String, Object>(), |
| 3592 | + false, |
| 3593 | + new GenericType<ValidateV2Response>() {}); |
| 3594 | + } |
3467 | 3595 | } |
0 commit comments