com.dominodatalab.pub.rest.AsyncPredictionsApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of domino-java-client Show documentation
Show all versions of domino-java-client Show documentation
Domino Data Lab API Client to connect to Domino web services using Java HTTP Client.
/*
* Domino Public API
* Domino Public API Endpoints
*
* The version of the OpenAPI document: 0.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.dominodatalab.pub.rest;
import com.dominodatalab.pub.invoker.ApiClient;
import com.dominodatalab.pub.invoker.ApiException;
import com.dominodatalab.pub.invoker.ApiResponse;
import com.dominodatalab.pub.invoker.Pair;
import com.dominodatalab.pub.model.AsyncPredictionEnvelopeV1;
import com.dominodatalab.pub.model.AsyncPredictionRequestEnvelopeV1;
import com.dominodatalab.pub.model.FailureEnvelopeV1;
import com.dominodatalab.pub.model.GetAIGatewayAuditData400Response;
import com.dominodatalab.pub.model.NewAsyncPredictionV1;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.http.HttpRequest;
import java.nio.channels.Channels;
import java.nio.channels.Pipe;
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.StringJoiner;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-10-04T16:37:28.765500600-04:00[America/New_York]", comments = "Generator version: 7.8.0")
public class AsyncPredictionsApi {
protected final HttpClient memberVarHttpClient;
protected final ObjectMapper memberVarObjectMapper;
protected final String memberVarBaseUri;
protected final Consumer memberVarInterceptor;
protected final Duration memberVarReadTimeout;
protected final Consumer> memberVarResponseInterceptor;
protected final Consumer> memberVarAsyncResponseInterceptor;
public AsyncPredictionsApi() {
this(new ApiClient());
}
public AsyncPredictionsApi(ApiClient apiClient) {
memberVarHttpClient = apiClient.getHttpClient();
memberVarObjectMapper = apiClient.getObjectMapper();
memberVarBaseUri = apiClient.getBaseUri();
memberVarInterceptor = apiClient.getRequestInterceptor();
memberVarReadTimeout = apiClient.getReadTimeout();
memberVarResponseInterceptor = apiClient.getResponseInterceptor();
memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor();
}
protected ApiException getApiException(String operationId, HttpResponse response) throws IOException {
String body = response.body() == null ? null : new String(response.body().readAllBytes());
String message = formatExceptionMessage(operationId, response.statusCode(), body);
return new ApiException(response.statusCode(), message, response.headers(), body);
}
protected String formatExceptionMessage(String operationId, int statusCode, String body) {
if (body == null || body.isEmpty()) {
body = "[no body]";
}
return operationId + " call failed with: " + statusCode + " - " + body;
}
/**
* Request a prediction from an Async model
* Request a prediction from an Async Model
* @param asyncModelId Id of Async Model (required)
* @param newAsyncPredictionV1 Information for new Async Prediction (required)
* @return AsyncPredictionRequestEnvelopeV1
* @throws ApiException if fails to make API call
*/
public AsyncPredictionRequestEnvelopeV1 requestAsyncPrediction(String asyncModelId, NewAsyncPredictionV1 newAsyncPredictionV1) throws ApiException {
ApiResponse localVarResponse = requestAsyncPredictionWithHttpInfo(asyncModelId, newAsyncPredictionV1);
return localVarResponse.getData();
}
/**
* Request a prediction from an Async model
* Request a prediction from an Async Model
* @param asyncModelId Id of Async Model (required)
* @param newAsyncPredictionV1 Information for new Async Prediction (required)
* @return ApiResponse<AsyncPredictionRequestEnvelopeV1>
* @throws ApiException if fails to make API call
*/
public ApiResponse requestAsyncPredictionWithHttpInfo(String asyncModelId, NewAsyncPredictionV1 newAsyncPredictionV1) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = requestAsyncPredictionRequestBuilder(asyncModelId, newAsyncPredictionV1);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("requestAsyncPrediction", localVarResponse);
}
return new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream
);
} finally {
}
} catch (IOException e) {
throw new ApiException(e);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
protected HttpRequest.Builder requestAsyncPredictionRequestBuilder(String asyncModelId, NewAsyncPredictionV1 newAsyncPredictionV1) throws ApiException {
// verify the required parameter 'asyncModelId' is set
if (asyncModelId == null) {
throw new ApiException(400, "Missing the required parameter 'asyncModelId' when calling requestAsyncPrediction");
}
// verify the required parameter 'newAsyncPredictionV1' is set
if (newAsyncPredictionV1 == null) {
throw new ApiException(400, "Missing the required parameter 'newAsyncPredictionV1' when calling requestAsyncPrediction");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/api/modelApis/async/v1/{asyncModelId}"
.replace("{asyncModelId}", ApiClient.urlEncode(asyncModelId.toString()));
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(newAsyncPredictionV1);
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;
}
/**
* Retrieve the result of an Async Model prediction
* Retrieve the result of an Async Model prediction
* @param asyncModelId Id of Async Model (required)
* @param asyncPredictionId Id of Async Prediction (required)
* @return AsyncPredictionEnvelopeV1
* @throws ApiException if fails to make API call
*/
public AsyncPredictionEnvelopeV1 retrieveAsyncPredictionResult(String asyncModelId, String asyncPredictionId) throws ApiException {
ApiResponse localVarResponse = retrieveAsyncPredictionResultWithHttpInfo(asyncModelId, asyncPredictionId);
return localVarResponse.getData();
}
/**
* Retrieve the result of an Async Model prediction
* Retrieve the result of an Async Model prediction
* @param asyncModelId Id of Async Model (required)
* @param asyncPredictionId Id of Async Prediction (required)
* @return ApiResponse<AsyncPredictionEnvelopeV1>
* @throws ApiException if fails to make API call
*/
public ApiResponse retrieveAsyncPredictionResultWithHttpInfo(String asyncModelId, String asyncPredictionId) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = retrieveAsyncPredictionResultRequestBuilder(asyncModelId, asyncPredictionId);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("retrieveAsyncPredictionResult", localVarResponse);
}
return new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream
);
} finally {
}
} catch (IOException e) {
throw new ApiException(e);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
protected HttpRequest.Builder retrieveAsyncPredictionResultRequestBuilder(String asyncModelId, String asyncPredictionId) throws ApiException {
// verify the required parameter 'asyncModelId' is set
if (asyncModelId == null) {
throw new ApiException(400, "Missing the required parameter 'asyncModelId' when calling retrieveAsyncPredictionResult");
}
// verify the required parameter 'asyncPredictionId' is set
if (asyncPredictionId == null) {
throw new ApiException(400, "Missing the required parameter 'asyncPredictionId' when calling retrieveAsyncPredictionResult");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/api/modelApis/async/v1/{asyncModelId}/{asyncPredictionId}"
.replace("{asyncModelId}", ApiClient.urlEncode(asyncModelId.toString()))
.replace("{asyncPredictionId}", ApiClient.urlEncode(asyncPredictionId.toString()));
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 - 2025 Weber Informatics LLC | Privacy Policy