com.dominodatalab.pub.rest.CustomMetricsApi 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.FailureEnvelopeV1;
import com.dominodatalab.pub.model.GetAIGatewayAuditData400Response;
import com.dominodatalab.pub.model.MetricAlertRequestV1;
import com.dominodatalab.pub.model.MetricValuesEnvelopeV1;
import com.dominodatalab.pub.model.NewMetricValuesEnvelopeV1;
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 CustomMetricsApi {
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 CustomMetricsApi() {
this(new ApiClient());
}
public CustomMetricsApi(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;
}
/**
* Log metric values
* Log metric values. Required Permissions: `RegisterMonitoringDataset`
* @param newMetricValuesEnvelopeV1 List of metric values to log (required)
* @throws ApiException if fails to make API call
*/
public void logMetricValues(NewMetricValuesEnvelopeV1 newMetricValuesEnvelopeV1) throws ApiException {
logMetricValuesWithHttpInfo(newMetricValuesEnvelopeV1);
}
/**
* Log metric values
* Log metric values. Required Permissions: `RegisterMonitoringDataset`
* @param newMetricValuesEnvelopeV1 List of metric values to log (required)
* @return ApiResponse<Void>
* @throws ApiException if fails to make API call
*/
public ApiResponse logMetricValuesWithHttpInfo(NewMetricValuesEnvelopeV1 newMetricValuesEnvelopeV1) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = logMetricValuesRequestBuilder(newMetricValuesEnvelopeV1);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("logMetricValues", localVarResponse);
}
return new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
} finally {
// Drain the InputStream
while (localVarResponse.body().read() != -1) {
// Ignore
}
localVarResponse.body().close();
}
} catch (IOException e) {
throw new ApiException(e);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
protected HttpRequest.Builder logMetricValuesRequestBuilder(NewMetricValuesEnvelopeV1 newMetricValuesEnvelopeV1) throws ApiException {
// verify the required parameter 'newMetricValuesEnvelopeV1' is set
if (newMetricValuesEnvelopeV1 == null) {
throw new ApiException(400, "Missing the required parameter 'newMetricValuesEnvelopeV1' when calling logMetricValues");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/api/metricValues/v1";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(newMetricValuesEnvelopeV1);
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 metric values
* Retrieve metric values. Required Permissions: `UpdateMonitoringSettings`
* @param modelMonitoringId ID of the monitored model (required)
* @param metric Name of the metric to retrieve (required)
* @param startingReferenceTimestampInclusive Timestamp to filter metrics by referenceTimestamp >= startingReferenceTimestampInclusive. Timestamp should follow the RFC3339 format with timezone e.g. 2013-07-01T17:55:13-07:00 (required)
* @param endingReferenceTimestampInclusive Timestamp to filter metrics by referenceTimestamp <= endingReferenceTimestampInclusive. Timestamp should follow the RFC3339 format with timezone e.g. 2013-07-01T17:55:13-07:00 (required)
* @return MetricValuesEnvelopeV1
* @throws ApiException if fails to make API call
*/
public MetricValuesEnvelopeV1 retrieveMetricValues(String modelMonitoringId, String metric, String startingReferenceTimestampInclusive, String endingReferenceTimestampInclusive) throws ApiException {
ApiResponse localVarResponse = retrieveMetricValuesWithHttpInfo(modelMonitoringId, metric, startingReferenceTimestampInclusive, endingReferenceTimestampInclusive);
return localVarResponse.getData();
}
/**
* Retrieve metric values
* Retrieve metric values. Required Permissions: `UpdateMonitoringSettings`
* @param modelMonitoringId ID of the monitored model (required)
* @param metric Name of the metric to retrieve (required)
* @param startingReferenceTimestampInclusive Timestamp to filter metrics by referenceTimestamp >= startingReferenceTimestampInclusive. Timestamp should follow the RFC3339 format with timezone e.g. 2013-07-01T17:55:13-07:00 (required)
* @param endingReferenceTimestampInclusive Timestamp to filter metrics by referenceTimestamp <= endingReferenceTimestampInclusive. Timestamp should follow the RFC3339 format with timezone e.g. 2013-07-01T17:55:13-07:00 (required)
* @return ApiResponse<MetricValuesEnvelopeV1>
* @throws ApiException if fails to make API call
*/
public ApiResponse retrieveMetricValuesWithHttpInfo(String modelMonitoringId, String metric, String startingReferenceTimestampInclusive, String endingReferenceTimestampInclusive) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = retrieveMetricValuesRequestBuilder(modelMonitoringId, metric, startingReferenceTimestampInclusive, endingReferenceTimestampInclusive);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("retrieveMetricValues", 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 retrieveMetricValuesRequestBuilder(String modelMonitoringId, String metric, String startingReferenceTimestampInclusive, String endingReferenceTimestampInclusive) throws ApiException {
// verify the required parameter 'modelMonitoringId' is set
if (modelMonitoringId == null) {
throw new ApiException(400, "Missing the required parameter 'modelMonitoringId' when calling retrieveMetricValues");
}
// verify the required parameter 'metric' is set
if (metric == null) {
throw new ApiException(400, "Missing the required parameter 'metric' when calling retrieveMetricValues");
}
// verify the required parameter 'startingReferenceTimestampInclusive' is set
if (startingReferenceTimestampInclusive == null) {
throw new ApiException(400, "Missing the required parameter 'startingReferenceTimestampInclusive' when calling retrieveMetricValues");
}
// verify the required parameter 'endingReferenceTimestampInclusive' is set
if (endingReferenceTimestampInclusive == null) {
throw new ApiException(400, "Missing the required parameter 'endingReferenceTimestampInclusive' when calling retrieveMetricValues");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/api/metricValues/v1/{modelMonitoringId}/{metric}"
.replace("{modelMonitoringId}", ApiClient.urlEncode(modelMonitoringId.toString()))
.replace("{metric}", ApiClient.urlEncode(metric.toString()));
List localVarQueryParams = new ArrayList<>();
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
localVarQueryParameterBaseName = "startingReferenceTimestampInclusive";
localVarQueryParams.addAll(ApiClient.parameterToPairs("startingReferenceTimestampInclusive", startingReferenceTimestampInclusive));
localVarQueryParameterBaseName = "endingReferenceTimestampInclusive";
localVarQueryParams.addAll(ApiClient.parameterToPairs("endingReferenceTimestampInclusive", endingReferenceTimestampInclusive));
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/json");
localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* Send a metric alert
* Send a metric out of range alert for a monitored model. Required Permissions: `ViewMonitoringResults`
* @param metricAlertRequestV1 Details about the metric alert to send (required)
* @throws ApiException if fails to make API call
*/
public void sendMetricAlert(MetricAlertRequestV1 metricAlertRequestV1) throws ApiException {
sendMetricAlertWithHttpInfo(metricAlertRequestV1);
}
/**
* Send a metric alert
* Send a metric out of range alert for a monitored model. Required Permissions: `ViewMonitoringResults`
* @param metricAlertRequestV1 Details about the metric alert to send (required)
* @return ApiResponse<Void>
* @throws ApiException if fails to make API call
*/
public ApiResponse sendMetricAlertWithHttpInfo(MetricAlertRequestV1 metricAlertRequestV1) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = sendMetricAlertRequestBuilder(metricAlertRequestV1);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("sendMetricAlert", localVarResponse);
}
return new ApiResponse(
localVarResponse.statusCode(),
localVarResponse.headers().map(),
null
);
} finally {
// Drain the InputStream
while (localVarResponse.body().read() != -1) {
// Ignore
}
localVarResponse.body().close();
}
} catch (IOException e) {
throw new ApiException(e);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ApiException(e);
}
}
protected HttpRequest.Builder sendMetricAlertRequestBuilder(MetricAlertRequestV1 metricAlertRequestV1) throws ApiException {
// verify the required parameter 'metricAlertRequestV1' is set
if (metricAlertRequestV1 == null) {
throw new ApiException(400, "Missing the required parameter 'metricAlertRequestV1' when calling sendMetricAlert");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/api/metricAlerts/v1";
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(metricAlertRequestV1);
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;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy