org.openziti.edge.api.CurrentIdentityApi Maven / Gradle / Ivy
The newest version!
/*
* Ziti Edge Client
* OpenZiti Edge Client API
*
* The version of the OpenAPI document: 0.26.27
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openziti.edge.api;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import org.openziti.edge.ApiClient;
import org.openziti.edge.ApiException;
import org.openziti.edge.ApiResponse;
import org.openziti.edge.model.CreateEnvelope;
import org.openziti.edge.model.CurrentIdentityDetailEnvelope;
import org.openziti.edge.model.DetailMfaEnvelope;
import org.openziti.edge.model.DetailMfaRecoveryCodesEnvelope;
import org.openziti.edge.model.Empty;
import org.openziti.edge.model.ListCurrentIdentityEdgeRoutersEnvelope;
import org.openziti.edge.model.MfaCode;
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
date = "2024-09-04T10:11:22.635226-04:00[America/New_York]",
comments = "Generator version: 7.8.0")
public class CurrentIdentityApi {
private final HttpClient memberVarHttpClient;
private final ObjectMapper memberVarObjectMapper;
private final String memberVarBaseUri;
private final Consumer memberVarInterceptor;
private final Duration memberVarReadTimeout;
private final Consumer> memberVarResponseInterceptor;
private final Consumer> memberVarAsyncResponseInterceptor;
public CurrentIdentityApi() {
this(new ApiClient());
}
public CurrentIdentityApi(ApiClient apiClient) {
memberVarHttpClient = apiClient.getHttpClient();
memberVarObjectMapper = apiClient.getObjectMapper();
memberVarBaseUri = apiClient.getBaseUri();
memberVarInterceptor = apiClient.getRequestInterceptor();
memberVarReadTimeout = apiClient.getReadTimeout();
memberVarResponseInterceptor = apiClient.getResponseInterceptor();
memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor();
}
private ApiException getApiException(String operationId, HttpResponse response) {
String message =
formatExceptionMessage(operationId, response.statusCode(), response.body());
return new ApiException(
response.statusCode(), message, response.headers(), response.body());
}
private String formatExceptionMessage(String operationId, int statusCode, String body) {
if (body == null || body.isEmpty()) {
body = "[no body]";
}
return operationId + " call failed with: " + statusCode + " - " + body;
}
/**
* For a completed MFA enrollment regenerate the recovery codes Allows regeneration of recovery
* codes of an MFA enrollment. Requires a current valid time based one time password to interact
* with. Available after a completed MFA enrollment. This replaces all existing recovery codes.
*
* @param mfaValidation An MFA validation request (required)
* @return CompletableFuture<Empty>
* @throws ApiException if fails to make API call
*/
public CompletableFuture createMfaRecoveryCodes(MfaCode mfaValidation)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
createMfaRecoveryCodesRequestBuilder(mfaValidation);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"createMfaRecoveryCodes", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference() {}));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* For a completed MFA enrollment regenerate the recovery codes Allows regeneration of recovery
* codes of an MFA enrollment. Requires a current valid time based one time password to interact
* with. Available after a completed MFA enrollment. This replaces all existing recovery codes.
*
* @param mfaValidation An MFA validation request (required)
* @return CompletableFuture<ApiResponse<Empty>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> createMfaRecoveryCodesWithHttpInfo(
MfaCode mfaValidation) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
createMfaRecoveryCodesRequestBuilder(mfaValidation);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"createMfaRecoveryCodes", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
Empty>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder createMfaRecoveryCodesRequestBuilder(MfaCode mfaValidation)
throws ApiException {
// verify the required parameter 'mfaValidation' is set
if (mfaValidation == null) {
throw new ApiException(
400,
"Missing the required parameter 'mfaValidation' when calling"
+ " createMfaRecoveryCodes");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity/mfa/recovery-codes";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(mfaValidation);
localVarRequestBuilder.method(
"POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
} catch (IOException e) {
throw new ApiException(e);
}
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Disable MFA for the current identity Disable MFA for the current identity. Requires a current
* valid time based one time password if MFA enrollment has been completed. If not, code should
* be an empty string. If one time passwords are not available and admin account can be used to
* remove MFA from the identity via `DELETE /identities/<id>/mfa`.
*
* @param mfaValidationCode (optional)
* @return CompletableFuture<Empty>
* @throws ApiException if fails to make API call
*/
public CompletableFuture deleteMfa(String mfaValidationCode) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = deleteMfaRequestBuilder(mfaValidationCode);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("deleteMfa", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference() {}));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* Disable MFA for the current identity Disable MFA for the current identity. Requires a current
* valid time based one time password if MFA enrollment has been completed. If not, code should
* be an empty string. If one time passwords are not available and admin account can be used to
* remove MFA from the identity via `DELETE /identities/<id>/mfa`.
*
* @param mfaValidationCode (optional)
* @return CompletableFuture<ApiResponse<Empty>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> deleteMfaWithHttpInfo(String mfaValidationCode)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = deleteMfaRequestBuilder(mfaValidationCode);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("deleteMfa", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
Empty>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder deleteMfaRequestBuilder(String mfaValidationCode)
throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity/mfa";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
if (mfaValidationCode != null) {
localVarRequestBuilder.header("mfa-validation-code", mfaValidationCode.toString());
}
localVarRequestBuilder.header("Accept", "application/json");
localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Returns the current status of MFA enrollment Returns details about the current MFA
* enrollment. If enrollment has not been completed it will return the current MFA configuration
* details necessary to complete a `POST /current-identity/mfa/verify`.
*
* @return CompletableFuture<DetailMfaEnvelope>
* @throws ApiException if fails to make API call
*/
public CompletableFuture detailMfa() throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = detailMfaRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("detailMfa", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
DetailMfaEnvelope>() {}));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* Returns the current status of MFA enrollment Returns details about the current MFA
* enrollment. If enrollment has not been completed it will return the current MFA configuration
* details necessary to complete a `POST /current-identity/mfa/verify`.
*
* @return CompletableFuture<ApiResponse<DetailMfaEnvelope>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> detailMfaWithHttpInfo()
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = detailMfaRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("detailMfa", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
DetailMfaEnvelope>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder detailMfaRequestBuilder() throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity/mfa";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "application/json");
localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Show a QR code for unverified MFA enrollments Shows an QR code image for unverified MFA
* enrollments. 404s if the MFA enrollment has been completed or not started.
*
* @return CompletableFuture<Void>
* @throws ApiException if fails to make API call
*/
public CompletableFuture detailMfaQrCode() throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = detailMfaQrCodeRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("detailMfaQrCode", localVarResponse));
}
return CompletableFuture.completedFuture(null);
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* Show a QR code for unverified MFA enrollments Shows an QR code image for unverified MFA
* enrollments. 404s if the MFA enrollment has been completed or not started.
*
* @return CompletableFuture<ApiResponse<Void>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> detailMfaQrCodeWithHttpInfo() throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = detailMfaQrCodeRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("detailMfaQrCode", localVarResponse));
}
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null));
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder detailMfaQrCodeRequestBuilder() throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity/mfa/qr-code";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "application/json");
localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* For a completed MFA enrollment view the current recovery codes Allows the viewing of recovery
* codes of an MFA enrollment. Requires a current valid time based one time password to interact
* with. Available after a completed MFA enrollment.
*
* @param mfaValidationCode (optional)
* @param mfaValidation An MFA validation request (optional)
* @return CompletableFuture<DetailMfaRecoveryCodesEnvelope>
* @throws ApiException if fails to make API call
*/
public CompletableFuture detailMfaRecoveryCodes(
String mfaValidationCode, MfaCode mfaValidation) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
detailMfaRecoveryCodesRequestBuilder(mfaValidationCode, mfaValidation);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"detailMfaRecoveryCodes", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
DetailMfaRecoveryCodesEnvelope>() {}));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* For a completed MFA enrollment view the current recovery codes Allows the viewing of recovery
* codes of an MFA enrollment. Requires a current valid time based one time password to interact
* with. Available after a completed MFA enrollment.
*
* @param mfaValidationCode (optional)
* @param mfaValidation An MFA validation request (optional)
* @return CompletableFuture<ApiResponse<DetailMfaRecoveryCodesEnvelope>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture>
detailMfaRecoveryCodesWithHttpInfo(String mfaValidationCode, MfaCode mfaValidation)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
detailMfaRecoveryCodesRequestBuilder(mfaValidationCode, mfaValidation);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"detailMfaRecoveryCodes", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
DetailMfaRecoveryCodesEnvelope>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder detailMfaRecoveryCodesRequestBuilder(
String mfaValidationCode, MfaCode mfaValidation) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity/mfa/recovery-codes";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
if (mfaValidationCode != null) {
localVarRequestBuilder.header("mfa-validation-code", mfaValidationCode.toString());
}
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(mfaValidation);
localVarRequestBuilder.method(
"GET", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
} catch (IOException e) {
throw new ApiException(e);
}
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Initiate MFA enrollment Allows authenticator based MFA enrollment. If enrollment has already
* been completed, it must be disabled before attempting to re-enroll. Subsequent enrollment
* request is completed via `POST /current-identity/mfa/verify`
*
* @return CompletableFuture<CreateEnvelope>
* @throws ApiException if fails to make API call
*/
public CompletableFuture enrollMfa() throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = enrollMfaRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("enrollMfa", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
CreateEnvelope>() {}));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* Initiate MFA enrollment Allows authenticator based MFA enrollment. If enrollment has already
* been completed, it must be disabled before attempting to re-enroll. Subsequent enrollment
* request is completed via `POST /current-identity/mfa/verify`
*
* @return CompletableFuture<ApiResponse<CreateEnvelope>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> enrollMfaWithHttpInfo()
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = enrollMfaRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("enrollMfa", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
CreateEnvelope>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder enrollMfaRequestBuilder() throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity/mfa";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "application/json");
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Return the current identity Returns the identity associated with the API sessions used to
* issue the current request
*
* @return CompletableFuture<CurrentIdentityDetailEnvelope>
* @throws ApiException if fails to make API call
*/
public CompletableFuture getCurrentIdentity()
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = getCurrentIdentityRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"getCurrentIdentity", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
CurrentIdentityDetailEnvelope>() {}));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* Return the current identity Returns the identity associated with the API sessions used to
* issue the current request
*
* @return CompletableFuture<ApiResponse<CurrentIdentityDetailEnvelope>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture>
getCurrentIdentityWithHttpInfo() throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = getCurrentIdentityRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"getCurrentIdentity", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
CurrentIdentityDetailEnvelope>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder getCurrentIdentityRequestBuilder() throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "application/json, default");
localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Return this list of Edge Routers the identity has access to Lists the Edge Routers that the
* current identity has access to via policies. The data returned includes their address and
* online status
*
* @return CompletableFuture<ListCurrentIdentityEdgeRoutersEnvelope>
* @throws ApiException if fails to make API call
*/
public CompletableFuture getCurrentIdentityEdgeRouters()
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
getCurrentIdentityEdgeRoutersRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"getCurrentIdentityEdgeRouters",
localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
ListCurrentIdentityEdgeRoutersEnvelope>() {}));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* Return this list of Edge Routers the identity has access to Lists the Edge Routers that the
* current identity has access to via policies. The data returned includes their address and
* online status
*
* @return CompletableFuture<ApiResponse<ListCurrentIdentityEdgeRoutersEnvelope>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture>
getCurrentIdentityEdgeRoutersWithHttpInfo() throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder =
getCurrentIdentityEdgeRoutersRequestBuilder();
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException(
"getCurrentIdentityEdgeRouters",
localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
ListCurrentIdentityEdgeRoutersEnvelope>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder getCurrentIdentityEdgeRoutersRequestBuilder() throws ApiException {
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity/edge-routers";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "application/json");
localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Complete MFA enrollment by verifying a time based one time token Completes MFA enrollment by
* accepting a time based one time password as verification. Called after MFA enrollment has
* been initiated via `POST /current-identity/mfa`.
*
* @param mfaValidation An MFA validation request (required)
* @return CompletableFuture<Empty>
* @throws ApiException if fails to make API call
*/
public CompletableFuture verifyMfa(MfaCode mfaValidation) throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = verifyMfaRequestBuilder(mfaValidation);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("verifyMfa", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference() {}));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
/**
* Complete MFA enrollment by verifying a time based one time token Completes MFA enrollment by
* accepting a time based one time password as verification. Called after MFA enrollment has
* been initiated via `POST /current-identity/mfa`.
*
* @param mfaValidation An MFA validation request (required)
* @return CompletableFuture<ApiResponse<Empty>>
* @throws ApiException if fails to make API call
*/
public CompletableFuture> verifyMfaWithHttpInfo(MfaCode mfaValidation)
throws ApiException {
try {
HttpRequest.Builder localVarRequestBuilder = verifyMfaRequestBuilder(mfaValidation);
return memberVarHttpClient
.sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
.thenComposeAsync(
localVarResponse -> {
if (memberVarAsyncResponseInterceptor != null) {
memberVarAsyncResponseInterceptor.accept(localVarResponse);
}
if (localVarResponse.statusCode() / 100 != 2) {
return CompletableFuture.failedFuture(
getApiException("verifyMfa", localVarResponse));
}
try {
String responseBody = localVarResponse.body();
return CompletableFuture.completedFuture(
new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
responseBody == null || responseBody.isBlank()
? null
: memberVarObjectMapper.readValue(
responseBody,
new TypeReference<
Empty>() {})));
} catch (IOException e) {
return CompletableFuture.failedFuture(new ApiException(e));
}
});
} catch (ApiException e) {
return CompletableFuture.failedFuture(e);
}
}
private HttpRequest.Builder verifyMfaRequestBuilder(MfaCode mfaValidation) throws ApiException {
// verify the required parameter 'mfaValidation' is set
if (mfaValidation == null) {
throw new ApiException(
400, "Missing the required parameter 'mfaValidation' when calling verifyMfa");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/current-identity/mfa/verify";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(mfaValidation);
localVarRequestBuilder.method(
"POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
} catch (IOException e) {
throw new ApiException(e);
}
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
}