All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openziti.edge.api.EnrollApi 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.ArrayList;
import java.util.List;
import java.util.StringJoiner;
import java.util.UUID;
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.Pair;
import org.openziti.edge.model.Empty;
import org.openziti.edge.model.EnrollUpdbRequest;
import org.openziti.edge.model.EnrollmentCertsEnvelope;
import org.openziti.edge.model.ErOttEnrollmentRequest;
import org.openziti.edge.model.IdentityExtendEnrollmentEnvelope;
import org.openziti.edge.model.IdentityExtendEnrollmentRequest;
import org.openziti.edge.model.IdentityExtendValidateEnrollmentRequest;
import org.openziti.edge.model.Jwks;
import org.openziti.edge.model.NonceChallenge;
import org.openziti.edge.model.NonceSignature;
import org.openziti.edge.model.OttEnrollmentRequest;
import org.openziti.edge.model.RouterExtendEnrollmentRequest;

@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 EnrollApi {
    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 EnrollApi() {
        this(new ApiClient());
    }

    public EnrollApi(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;
    }

    /**
     * Enroll an identity via one-time-token present a OTT and CSR to receive a long-lived client
     * certificate
     *
     * @param token (optional)
     * @param method (optional)
     * @return CompletableFuture<String>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture enroll(UUID token, String method) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = enrollRequestBuilder(token, method);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException("enroll", 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);
        }
    }

    /**
     * Enroll an identity via one-time-token present a OTT and CSR to receive a long-lived client
     * certificate
     *
     * @param token (optional)
     * @param method (optional)
     * @return CompletableFuture<ApiResponse<String>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> enrollWithHttpInfo(UUID token, String method)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = enrollRequestBuilder(token, method);
            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("enroll", 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<
                                                                            String>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder enrollRequestBuilder(UUID token, String method)
            throws ApiException {

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll";

        List localVarQueryParams = new ArrayList<>();
        StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
        String localVarQueryParameterBaseName;
        localVarQueryParameterBaseName = "token";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("token", token));
        localVarQueryParameterBaseName = "method";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("method", method));

        if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) {
            StringJoiner queryJoiner = new StringJoiner("&");
            localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
            if (localVarQueryStringJoiner.length() != 0) {
                queryJoiner.add(localVarQueryStringJoiner.toString());
            }
            localVarRequestBuilder.uri(
                    URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
        } else {
            localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
        }

        localVarRequestBuilder.header("Accept", "application/x-pem-file, application/json");

        localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.noBody());
        if (memberVarReadTimeout != null) {
            localVarRequestBuilder.timeout(memberVarReadTimeout);
        }
        if (memberVarInterceptor != null) {
            memberVarInterceptor.accept(localVarRequestBuilder);
        }
        return localVarRequestBuilder;
    }

    /**
     * Enroll an identity with a pre-exchanged certificate For CA auto enrollment, an identity is
     * not created beforehand. Instead one will be created during enrollment. The client will
     * present a client certificate that is signed by a Certificate Authority that has been added
     * and verified (See POST /cas and POST /cas/{id}/verify). During this process no CSRs are
     * requires as the client should already be in possession of a valid certificate.
     *
     * @return CompletableFuture<Empty>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture enrollCa() throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = enrollCaRequestBuilder();
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException("enrollCa", 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);
        }
    }

    /**
     * Enroll an identity with a pre-exchanged certificate For CA auto enrollment, an identity is
     * not created beforehand. Instead one will be created during enrollment. The client will
     * present a client certificate that is signed by a Certificate Authority that has been added
     * and verified (See POST /cas and POST /cas/{id}/verify). During this process no CSRs are
     * requires as the client should already be in possession of a valid certificate.
     *
     * @return CompletableFuture<ApiResponse<Empty>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> enrollCaWithHttpInfo() throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = enrollCaRequestBuilder();
            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("enrollCa", 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 enrollCaRequestBuilder() throws ApiException {

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll/ca";

        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;
    }

    /**
     * Enroll an edge-router Enrolls an edge-router via a one-time-token to establish a certificate
     * based identity.
     *
     * @param erOttEnrollmentRequest An OTT enrollment request (required)
     * @return CompletableFuture<EnrollmentCertsEnvelope>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture enrollErOtt(
            ErOttEnrollmentRequest erOttEnrollmentRequest) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    enrollErOttRequestBuilder(erOttEnrollmentRequest);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException("enrollErOtt", localVarResponse));
                                }
                                try {
                                    String responseBody = localVarResponse.body();
                                    return CompletableFuture.completedFuture(
                                            responseBody == null || responseBody.isBlank()
                                                    ? null
                                                    : memberVarObjectMapper.readValue(
                                                            responseBody,
                                                            new TypeReference<
                                                                    EnrollmentCertsEnvelope>() {}));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    /**
     * Enroll an edge-router Enrolls an edge-router via a one-time-token to establish a certificate
     * based identity.
     *
     * @param erOttEnrollmentRequest An OTT enrollment request (required)
     * @return CompletableFuture<ApiResponse<EnrollmentCertsEnvelope>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> enrollErOttWithHttpInfo(
            ErOttEnrollmentRequest erOttEnrollmentRequest) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    enrollErOttRequestBuilder(erOttEnrollmentRequest);
            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("enrollErOtt", 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<
                                                                            EnrollmentCertsEnvelope>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder enrollErOttRequestBuilder(
            ErOttEnrollmentRequest erOttEnrollmentRequest) throws ApiException {
        // verify the required parameter 'erOttEnrollmentRequest' is set
        if (erOttEnrollmentRequest == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'erOttEnrollmentRequest' when calling"
                            + " enrollErOtt");
        }

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll/erott";

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Content-Type", "application/json");
        localVarRequestBuilder.header("Accept", "application/json");

        try {
            byte[] localVarPostBody =
                    memberVarObjectMapper.writeValueAsBytes(erOttEnrollmentRequest);
            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;
    }

    /**
     * Enroll an identity via one-time-token Enroll an identity via a one-time-token which is
     * supplied via a query string parameter. This enrollment method expects a PEM encoded CSRs to
     * be provided for fulfillment. It is up to the enrolling identity to manage the private key
     * backing the CSR request.
     *
     * @param ottEnrollmentRequest An OTT enrollment request (required)
     * @return CompletableFuture<EnrollmentCertsEnvelope>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture enrollOtt(
            OttEnrollmentRequest ottEnrollmentRequest) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    enrollOttRequestBuilder(ottEnrollmentRequest);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException("enrollOtt", localVarResponse));
                                }
                                try {
                                    String responseBody = localVarResponse.body();
                                    return CompletableFuture.completedFuture(
                                            responseBody == null || responseBody.isBlank()
                                                    ? null
                                                    : memberVarObjectMapper.readValue(
                                                            responseBody,
                                                            new TypeReference<
                                                                    EnrollmentCertsEnvelope>() {}));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    /**
     * Enroll an identity via one-time-token Enroll an identity via a one-time-token which is
     * supplied via a query string parameter. This enrollment method expects a PEM encoded CSRs to
     * be provided for fulfillment. It is up to the enrolling identity to manage the private key
     * backing the CSR request.
     *
     * @param ottEnrollmentRequest An OTT enrollment request (required)
     * @return CompletableFuture<ApiResponse<EnrollmentCertsEnvelope>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> enrollOttWithHttpInfo(
            OttEnrollmentRequest ottEnrollmentRequest) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    enrollOttRequestBuilder(ottEnrollmentRequest);
            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("enrollOtt", 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<
                                                                            EnrollmentCertsEnvelope>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder enrollOttRequestBuilder(OttEnrollmentRequest ottEnrollmentRequest)
            throws ApiException {
        // verify the required parameter 'ottEnrollmentRequest' is set
        if (ottEnrollmentRequest == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'ottEnrollmentRequest' when calling enrollOtt");
        }

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll/ott";

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Content-Type", "application/json");
        localVarRequestBuilder.header("Accept", "application/json");

        try {
            byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(ottEnrollmentRequest);
            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;
    }

    /**
     * Enroll an identity via one-time-token with a pre-exchanged client certificate Enroll an
     * identity via a one-time-token that also requires a pre-exchanged client certificate to match
     * a Certificate Authority that has been added and verified (See POST /cas and POST
     * /cas{id}/verify). The client must present a client certificate signed by CA associated with
     * the enrollment. This enrollment is similar to CA auto enrollment except that is required the
     * identity to be pre-created. As the client certificate has been pre-exchanged there is no CSR
     * input to this enrollment method.
     *
     * @param ottEnrollmentRequest An OTT enrollment request (required)
     * @return CompletableFuture<Empty>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture enrollOttCa(OttEnrollmentRequest ottEnrollmentRequest)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    enrollOttCaRequestBuilder(ottEnrollmentRequest);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException("enrollOttCa", 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);
        }
    }

    /**
     * Enroll an identity via one-time-token with a pre-exchanged client certificate Enroll an
     * identity via a one-time-token that also requires a pre-exchanged client certificate to match
     * a Certificate Authority that has been added and verified (See POST /cas and POST
     * /cas{id}/verify). The client must present a client certificate signed by CA associated with
     * the enrollment. This enrollment is similar to CA auto enrollment except that is required the
     * identity to be pre-created. As the client certificate has been pre-exchanged there is no CSR
     * input to this enrollment method.
     *
     * @param ottEnrollmentRequest An OTT enrollment request (required)
     * @return CompletableFuture<ApiResponse<Empty>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> enrollOttCaWithHttpInfo(
            OttEnrollmentRequest ottEnrollmentRequest) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    enrollOttCaRequestBuilder(ottEnrollmentRequest);
            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("enrollOttCa", 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 enrollOttCaRequestBuilder(OttEnrollmentRequest ottEnrollmentRequest)
            throws ApiException {
        // verify the required parameter 'ottEnrollmentRequest' is set
        if (ottEnrollmentRequest == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'ottEnrollmentRequest' when calling"
                            + " enrollOttCa");
        }

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll/ottca";

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Content-Type", "application/json");
        localVarRequestBuilder.header("Accept", "application/json");

        try {
            byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(ottEnrollmentRequest);
            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;
    }

    /**
     * Enroll an identity via one-time-token Enrolls an identity via a one-time-token to establish
     * an initial username and password combination
     *
     * @param token (required)
     * @param updbCredentials (required)
     * @return CompletableFuture<Empty>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture enrollUpdb(UUID token, EnrollUpdbRequest updbCredentials)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    enrollUpdbRequestBuilder(token, updbCredentials);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException("enrollUpdb", 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);
        }
    }

    /**
     * Enroll an identity via one-time-token Enrolls an identity via a one-time-token to establish
     * an initial username and password combination
     *
     * @param token (required)
     * @param updbCredentials (required)
     * @return CompletableFuture<ApiResponse<Empty>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> enrollUpdbWithHttpInfo(
            UUID token, EnrollUpdbRequest updbCredentials) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    enrollUpdbRequestBuilder(token, updbCredentials);
            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("enrollUpdb", 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 enrollUpdbRequestBuilder(
            UUID token, EnrollUpdbRequest updbCredentials) throws ApiException {
        // verify the required parameter 'token' is set
        if (token == null) {
            throw new ApiException(
                    400, "Missing the required parameter 'token' when calling enrollUpdb");
        }
        // verify the required parameter 'updbCredentials' is set
        if (updbCredentials == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'updbCredentials' when calling enrollUpdb");
        }

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll/updb";

        List localVarQueryParams = new ArrayList<>();
        StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
        String localVarQueryParameterBaseName;
        localVarQueryParameterBaseName = "token";
        localVarQueryParams.addAll(ApiClient.parameterToPairs("token", token));

        if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) {
            StringJoiner queryJoiner = new StringJoiner("&");
            localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
            if (localVarQueryStringJoiner.length() != 0) {
                queryJoiner.add(localVarQueryStringJoiner.toString());
            }
            localVarRequestBuilder.uri(
                    URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
        } else {
            localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
        }

        localVarRequestBuilder.header("Content-Type", "application/json");
        localVarRequestBuilder.header("Accept", "application/json");

        try {
            byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(updbCredentials);
            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;
    }

    /**
     * Allows verification of a controller or cluster of controllers as being the valid target for
     * enrollment. A caller may submit a nonce and a key id (kid) from the enrollment JWKS endpoint
     * or enrollment JWT that will be used to sign the nonce. The resulting signature may be
     * validated with the associated public key in order to verify a networks identity during
     * enrollment. The nonce must be a valid formatted UUID.
     *
     * @param nonce (required)
     * @return CompletableFuture<NonceSignature>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture enrollmentChallenge(NonceChallenge nonce)
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = enrollmentChallengeRequestBuilder(nonce);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException(
                                                    "enrollmentChallenge", localVarResponse));
                                }
                                try {
                                    String responseBody = localVarResponse.body();
                                    return CompletableFuture.completedFuture(
                                            responseBody == null || responseBody.isBlank()
                                                    ? null
                                                    : memberVarObjectMapper.readValue(
                                                            responseBody,
                                                            new TypeReference<
                                                                    NonceSignature>() {}));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    /**
     * Allows verification of a controller or cluster of controllers as being the valid target for
     * enrollment. A caller may submit a nonce and a key id (kid) from the enrollment JWKS endpoint
     * or enrollment JWT that will be used to sign the nonce. The resulting signature may be
     * validated with the associated public key in order to verify a networks identity during
     * enrollment. The nonce must be a valid formatted UUID.
     *
     * @param nonce (required)
     * @return CompletableFuture<ApiResponse<NonceSignature>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> enrollmentChallengeWithHttpInfo(
            NonceChallenge nonce) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = enrollmentChallengeRequestBuilder(nonce);
            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(
                                                    "enrollmentChallenge", 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<
                                                                            NonceSignature>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder enrollmentChallengeRequestBuilder(NonceChallenge nonce)
            throws ApiException {
        // verify the required parameter 'nonce' is set
        if (nonce == null) {
            throw new ApiException(
                    400, "Missing the required parameter 'nonce' when calling enrollmentChallenge");
        }

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll/challenge";

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Content-Type", "application/json");
        localVarRequestBuilder.header("Accept", "application/json");

        try {
            byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(nonce);
            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;
    }

    /**
     * Allows the current identity to recieve a new certificate associated with a certificate based
     * authenticator This endpoint only functions for certificates issued by the controller. 3rd
     * party certificates are not handled. Allows an identity to extend its certificate's
     * expiration date by using its current and valid client certificate to submit a CSR. This CSR
     * may be passed in using a new private key, thus allowing private key rotation. The response
     * from this endpoint is a new client certificate which the client must be verified via the
     * /authenticators/{id}/extend-verify endpoint. After verification is completion any new
     * connections must be made with new certificate. Prior to verification the old client
     * certificate remains active.
     *
     * @param id The id of the requested resource (required)
     * @param extend (required)
     * @return CompletableFuture<IdentityExtendEnrollmentEnvelope>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture extendCurrentIdentityAuthenticator(
            String id, IdentityExtendEnrollmentRequest extend) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    extendCurrentIdentityAuthenticatorRequestBuilder(id, extend);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException(
                                                    "extendCurrentIdentityAuthenticator",
                                                    localVarResponse));
                                }
                                try {
                                    String responseBody = localVarResponse.body();
                                    return CompletableFuture.completedFuture(
                                            responseBody == null || responseBody.isBlank()
                                                    ? null
                                                    : memberVarObjectMapper.readValue(
                                                            responseBody,
                                                            new TypeReference<
                                                                    IdentityExtendEnrollmentEnvelope>() {}));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    /**
     * Allows the current identity to recieve a new certificate associated with a certificate based
     * authenticator This endpoint only functions for certificates issued by the controller. 3rd
     * party certificates are not handled. Allows an identity to extend its certificate's
     * expiration date by using its current and valid client certificate to submit a CSR. This CSR
     * may be passed in using a new private key, thus allowing private key rotation. The response
     * from this endpoint is a new client certificate which the client must be verified via the
     * /authenticators/{id}/extend-verify endpoint. After verification is completion any new
     * connections must be made with new certificate. Prior to verification the old client
     * certificate remains active.
     *
     * @param id The id of the requested resource (required)
     * @param extend (required)
     * @return CompletableFuture<ApiResponse<IdentityExtendEnrollmentEnvelope>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture>
            extendCurrentIdentityAuthenticatorWithHttpInfo(
                    String id, IdentityExtendEnrollmentRequest extend) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    extendCurrentIdentityAuthenticatorRequestBuilder(id, extend);
            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(
                                                    "extendCurrentIdentityAuthenticator",
                                                    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<
                                                                            IdentityExtendEnrollmentEnvelope>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder extendCurrentIdentityAuthenticatorRequestBuilder(
            String id, IdentityExtendEnrollmentRequest extend) throws ApiException {
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'id' when calling"
                            + " extendCurrentIdentityAuthenticator");
        }
        // verify the required parameter 'extend' is set
        if (extend == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'extend' when calling"
                            + " extendCurrentIdentityAuthenticator");
        }

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/current-identity/authenticators/{id}/extend"
                        .replace("{id}", ApiClient.urlEncode(id.toString()));

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Content-Type", "application/json");
        localVarRequestBuilder.header("Accept", "application/json");

        try {
            byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(extend);
            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;
    }

    /**
     * Extend the life of a currently enrolled router's certificates Allows a router to extend
     * its certificates' expiration date by using its current and valid client certificate to
     * submit a CSR. This CSR may be passed in using a new private key, thus allowing private key
     * rotation or swapping. After completion any new connections must be made with certificates
     * returned from a 200 OK response. The previous client certificate is rendered invalid for use
     * with the controller even if it has not expired. This request must be made using the existing,
     * valid, client certificate.
     *
     * @param routerExtendEnrollmentRequest (required)
     * @return CompletableFuture<EnrollmentCertsEnvelope>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture extendRouterEnrollment(
            RouterExtendEnrollmentRequest routerExtendEnrollmentRequest) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    extendRouterEnrollmentRequestBuilder(routerExtendEnrollmentRequest);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException(
                                                    "extendRouterEnrollment", localVarResponse));
                                }
                                try {
                                    String responseBody = localVarResponse.body();
                                    return CompletableFuture.completedFuture(
                                            responseBody == null || responseBody.isBlank()
                                                    ? null
                                                    : memberVarObjectMapper.readValue(
                                                            responseBody,
                                                            new TypeReference<
                                                                    EnrollmentCertsEnvelope>() {}));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    /**
     * Extend the life of a currently enrolled router's certificates Allows a router to extend
     * its certificates' expiration date by using its current and valid client certificate to
     * submit a CSR. This CSR may be passed in using a new private key, thus allowing private key
     * rotation or swapping. After completion any new connections must be made with certificates
     * returned from a 200 OK response. The previous client certificate is rendered invalid for use
     * with the controller even if it has not expired. This request must be made using the existing,
     * valid, client certificate.
     *
     * @param routerExtendEnrollmentRequest (required)
     * @return CompletableFuture<ApiResponse<EnrollmentCertsEnvelope>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture>
            extendRouterEnrollmentWithHttpInfo(
                    RouterExtendEnrollmentRequest routerExtendEnrollmentRequest)
                    throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    extendRouterEnrollmentRequestBuilder(routerExtendEnrollmentRequest);
            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(
                                                    "extendRouterEnrollment", 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<
                                                                            EnrollmentCertsEnvelope>() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder extendRouterEnrollmentRequestBuilder(
            RouterExtendEnrollmentRequest routerExtendEnrollmentRequest) throws ApiException {
        // verify the required parameter 'routerExtendEnrollmentRequest' is set
        if (routerExtendEnrollmentRequest == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'routerExtendEnrollmentRequest' when calling"
                            + " extendRouterEnrollment");
        }

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll/extend/router";

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Content-Type", "application/json");
        localVarRequestBuilder.header("Accept", "application/json");

        try {
            byte[] localVarPostBody =
                    memberVarObjectMapper.writeValueAsBytes(routerExtendEnrollmentRequest);
            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;
    }

    /**
     * Allows the current identity to validate reciept of a new client certificate After submitting
     * a CSR for a new client certificate the resulting public certificate must be re-submitted to
     * this endpoint to verify receipt. After receipt, the new client certificate must be used for
     * new authentication requests.
     *
     * @param id The id of the requested resource (required)
     * @param extend (required)
     * @return CompletableFuture<Empty>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture extendVerifyCurrentIdentityAuthenticator(
            String id, IdentityExtendValidateEnrollmentRequest extend) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    extendVerifyCurrentIdentityAuthenticatorRequestBuilder(id, extend);
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException(
                                                    "extendVerifyCurrentIdentityAuthenticator",
                                                    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);
        }
    }

    /**
     * Allows the current identity to validate reciept of a new client certificate After submitting
     * a CSR for a new client certificate the resulting public certificate must be re-submitted to
     * this endpoint to verify receipt. After receipt, the new client certificate must be used for
     * new authentication requests.
     *
     * @param id The id of the requested resource (required)
     * @param extend (required)
     * @return CompletableFuture<ApiResponse<Empty>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture>
            extendVerifyCurrentIdentityAuthenticatorWithHttpInfo(
                    String id, IdentityExtendValidateEnrollmentRequest extend) throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder =
                    extendVerifyCurrentIdentityAuthenticatorRequestBuilder(id, extend);
            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(
                                                    "extendVerifyCurrentIdentityAuthenticator",
                                                    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 extendVerifyCurrentIdentityAuthenticatorRequestBuilder(
            String id, IdentityExtendValidateEnrollmentRequest extend) throws ApiException {
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'id' when calling"
                            + " extendVerifyCurrentIdentityAuthenticator");
        }
        // verify the required parameter 'extend' is set
        if (extend == null) {
            throw new ApiException(
                    400,
                    "Missing the required parameter 'extend' when calling"
                            + " extendVerifyCurrentIdentityAuthenticator");
        }

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath =
                "/current-identity/authenticators/{id}/extend-verify"
                        .replace("{id}", ApiClient.urlEncode(id.toString()));

        localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));

        localVarRequestBuilder.header("Content-Type", "application/json");
        localVarRequestBuilder.header("Accept", "application/json");

        try {
            byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(extend);
            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;
    }

    /**
     * List JSON Web Keys associated with enrollment Returns a list of JSON Web Keys (JWKS) that are
     * used for enrollment signing. The keys listed here are used to sign and co-sign enrollment
     * JWTs. They can be verified through a challenge endpoint, using the public keys from this
     * endpoint to verify the target machine has possession of the related private key.
     *
     * @return CompletableFuture<Jwks>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture getEnrollmentJwks() throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = getEnrollmentJwksRequestBuilder();
            return memberVarHttpClient
                    .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString())
                    .thenComposeAsync(
                            localVarResponse -> {
                                if (localVarResponse.statusCode() / 100 != 2) {
                                    return CompletableFuture.failedFuture(
                                            getApiException("getEnrollmentJwks", 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);
        }
    }

    /**
     * List JSON Web Keys associated with enrollment Returns a list of JSON Web Keys (JWKS) that are
     * used for enrollment signing. The keys listed here are used to sign and co-sign enrollment
     * JWTs. They can be verified through a challenge endpoint, using the public keys from this
     * endpoint to verify the target machine has possession of the related private key.
     *
     * @return CompletableFuture<ApiResponse<Jwks>>
     * @throws ApiException if fails to make API call
     */
    public CompletableFuture> getEnrollmentJwksWithHttpInfo()
            throws ApiException {
        try {
            HttpRequest.Builder localVarRequestBuilder = getEnrollmentJwksRequestBuilder();
            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("getEnrollmentJwks", 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() {})));
                                } catch (IOException e) {
                                    return CompletableFuture.failedFuture(new ApiException(e));
                                }
                            });
        } catch (ApiException e) {
            return CompletableFuture.failedFuture(e);
        }
    }

    private HttpRequest.Builder getEnrollmentJwksRequestBuilder() throws ApiException {

        HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

        String localVarPath = "/enroll/jwks";

        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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy