com.dominodatalab.api.rest.ScheduledJobsApi Maven / Gradle / Ivy
/*
* Domino Data Lab API v4
* This API is going to provide access to all the Domino functions available in the user interface. To authenticate your requests, include your API Key (which you can find on your account page) with the header X-Domino-Api-Key.
*
* The version of the OpenAPI document: 4.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.api.rest;
import com.dominodatalab.api.invoker.ApiClient;
import com.dominodatalab.api.invoker.ApiException;
import com.dominodatalab.api.invoker.ApiResponse;
import com.dominodatalab.api.invoker.Pair;
import com.dominodatalab.api.model.DominoApiErrorResponse;
import com.dominodatalab.api.model.DominoScheduledjobApiNewScheduledJobDto;
import com.dominodatalab.api.model.DominoScheduledjobApiScheduledJobDto;
import com.dominodatalab.api.model.DominoScheduledjobApiScheduledJobForRequestingUserDto;
import com.dominodatalab.api.model.DominoScheduledjobApiUpdatedScheduledJobDTO;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
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 = "2023-10-17T15:20:46.682098100-04:00[America/New_York]")
public class ScheduledJobsApi {
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 ScheduledJobsApi() {
this(new ApiClient());
}
public ScheduledJobsApi(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);
}
private String formatExceptionMessage(String operationId, int statusCode, String body) {
if (body == null || body.isEmpty()) {
body = "[no body]";
}
return operationId + " call failed with: " + statusCode + " - " + body;
}
/**
* creates a new scheduled job
*
* @param projectId Id of the project (required)
* @param dominoScheduledjobApiNewScheduledJobDto (required)
* @return DominoScheduledjobApiScheduledJobDto
* @throws ApiException if fails to make API call
*/
public DominoScheduledjobApiScheduledJobDto createScheduledJob(String projectId, DominoScheduledjobApiNewScheduledJobDto dominoScheduledjobApiNewScheduledJobDto) throws ApiException {
ApiResponse localVarResponse = createScheduledJobWithHttpInfo(projectId, dominoScheduledjobApiNewScheduledJobDto);
return localVarResponse.getData();
}
/**
* creates a new scheduled job
*
* @param projectId Id of the project (required)
* @param dominoScheduledjobApiNewScheduledJobDto (required)
* @return ApiResponse<DominoScheduledjobApiScheduledJobDto>
* @throws ApiException if fails to make API call
*/
public ApiResponse createScheduledJobWithHttpInfo(String projectId, DominoScheduledjobApiNewScheduledJobDto dominoScheduledjobApiNewScheduledJobDto) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = createScheduledJobRequestBuilder(projectId, dominoScheduledjobApiNewScheduledJobDto);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("createScheduledJob", 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);
}
}
private HttpRequest.Builder createScheduledJobRequestBuilder(String projectId, DominoScheduledjobApiNewScheduledJobDto dominoScheduledjobApiNewScheduledJobDto) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(400, "Missing the required parameter 'projectId' when calling createScheduledJob");
}
// verify the required parameter 'dominoScheduledjobApiNewScheduledJobDto' is set
if (dominoScheduledjobApiNewScheduledJobDto == null) {
throw new ApiException(400, "Missing the required parameter 'dominoScheduledjobApiNewScheduledJobDto' when calling createScheduledJob");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/projects/{projectId}/scheduledjobs"
.replace("{projectId}", ApiClient.urlEncode(projectId.toString()));
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(dominoScheduledjobApiNewScheduledJobDto);
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;
}
/**
* retrieves a scheduled job by Id
*
* @param projectId Id of the project (required)
* @param scheduledJobKey Id of the scheduled job to be retrieved (required)
* @return DominoScheduledjobApiScheduledJobDto
* @throws ApiException if fails to make API call
*/
public DominoScheduledjobApiScheduledJobDto getScheduledJob(String projectId, String scheduledJobKey) throws ApiException {
ApiResponse localVarResponse = getScheduledJobWithHttpInfo(projectId, scheduledJobKey);
return localVarResponse.getData();
}
/**
* retrieves a scheduled job by Id
*
* @param projectId Id of the project (required)
* @param scheduledJobKey Id of the scheduled job to be retrieved (required)
* @return ApiResponse<DominoScheduledjobApiScheduledJobDto>
* @throws ApiException if fails to make API call
*/
public ApiResponse getScheduledJobWithHttpInfo(String projectId, String scheduledJobKey) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = getScheduledJobRequestBuilder(projectId, scheduledJobKey);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("getScheduledJob", 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);
}
}
private HttpRequest.Builder getScheduledJobRequestBuilder(String projectId, String scheduledJobKey) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(400, "Missing the required parameter 'projectId' when calling getScheduledJob");
}
// verify the required parameter 'scheduledJobKey' is set
if (scheduledJobKey == null) {
throw new ApiException(400, "Missing the required parameter 'scheduledJobKey' when calling getScheduledJob");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/projects/{projectId}/scheduledjobs/{scheduledJobKey}"
.replace("{projectId}", ApiClient.urlEncode(projectId.toString()))
.replace("{scheduledJobKey}", ApiClient.urlEncode(scheduledJobKey.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;
}
/**
* retrieves list of scheduled job definitions for a given project
*
* @param projectId Id of the project (required)
* @return List<DominoScheduledjobApiScheduledJobDto>
* @throws ApiException if fails to make API call
*/
public List listScheduledJobs(String projectId) throws ApiException {
ApiResponse> localVarResponse = listScheduledJobsWithHttpInfo(projectId);
return localVarResponse.getData();
}
/**
* retrieves list of scheduled job definitions for a given project
*
* @param projectId Id of the project (required)
* @return ApiResponse<List<DominoScheduledjobApiScheduledJobDto>>
* @throws ApiException if fails to make API call
*/
public ApiResponse> listScheduledJobsWithHttpInfo(String projectId) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = listScheduledJobsRequestBuilder(projectId);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("listScheduledJobs", 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);
}
}
private HttpRequest.Builder listScheduledJobsRequestBuilder(String projectId) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(400, "Missing the required parameter 'projectId' when calling listScheduledJobs");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/projects/{projectId}/scheduledjobs"
.replace("{projectId}", ApiClient.urlEncode(projectId.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;
}
/**
* retrieves list of scheduled job definitions for a given project with metadata specific to requesting user
*
* @param projectId Id of the project (required)
* @return List<DominoScheduledjobApiScheduledJobForRequestingUserDto>
* @throws ApiException if fails to make API call
*/
public List listScheduledJobsForRequestingUser(String projectId) throws ApiException {
ApiResponse> localVarResponse = listScheduledJobsForRequestingUserWithHttpInfo(projectId);
return localVarResponse.getData();
}
/**
* retrieves list of scheduled job definitions for a given project with metadata specific to requesting user
*
* @param projectId Id of the project (required)
* @return ApiResponse<List<DominoScheduledjobApiScheduledJobForRequestingUserDto>>
* @throws ApiException if fails to make API call
*/
public ApiResponse> listScheduledJobsForRequestingUserWithHttpInfo(String projectId) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = listScheduledJobsForRequestingUserRequestBuilder(projectId);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("listScheduledJobsForRequestingUser", 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);
}
}
private HttpRequest.Builder listScheduledJobsForRequestingUserRequestBuilder(String projectId) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(400, "Missing the required parameter 'projectId' when calling listScheduledJobsForRequestingUser");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/projects/{projectId}/scheduledjobs/forRequestingUser"
.replace("{projectId}", ApiClient.urlEncode(projectId.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;
}
/**
* deletes a scheduled job
*
* @param projectId Id of the project (required)
* @param scheduledJobKey Id of the scheduled job to be deleted (required)
* @throws ApiException if fails to make API call
*/
public void unscheduleJob(String projectId, String scheduledJobKey) throws ApiException {
unscheduleJobWithHttpInfo(projectId, scheduledJobKey);
}
/**
* deletes a scheduled job
*
* @param projectId Id of the project (required)
* @param scheduledJobKey Id of the scheduled job to be deleted (required)
* @return ApiResponse<Void>
* @throws ApiException if fails to make API call
*/
public ApiResponse unscheduleJobWithHttpInfo(String projectId, String scheduledJobKey) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = unscheduleJobRequestBuilder(projectId, scheduledJobKey);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("unscheduleJob", 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);
}
}
private HttpRequest.Builder unscheduleJobRequestBuilder(String projectId, String scheduledJobKey) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(400, "Missing the required parameter 'projectId' when calling unscheduleJob");
}
// verify the required parameter 'scheduledJobKey' is set
if (scheduledJobKey == null) {
throw new ApiException(400, "Missing the required parameter 'scheduledJobKey' when calling unscheduleJob");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/projects/{projectId}/scheduledjobs/{scheduledJobKey}"
.replace("{projectId}", ApiClient.urlEncode(projectId.toString()))
.replace("{scheduledJobKey}", ApiClient.urlEncode(scheduledJobKey.toString()));
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Accept", "application/json");
localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody());
if (memberVarReadTimeout != null) {
localVarRequestBuilder.timeout(memberVarReadTimeout);
}
if (memberVarInterceptor != null) {
memberVarInterceptor.accept(localVarRequestBuilder);
}
return localVarRequestBuilder;
}
/**
* updates a scheduled job
*
* @param projectId Id of the project (required)
* @param scheduledJobKey Id of the scheduled job to be updated (required)
* @param dominoScheduledjobApiUpdatedScheduledJobDTO (required)
* @return DominoScheduledjobApiScheduledJobDto
* @throws ApiException if fails to make API call
*/
public DominoScheduledjobApiScheduledJobDto updateScheduledJob(String projectId, String scheduledJobKey, DominoScheduledjobApiUpdatedScheduledJobDTO dominoScheduledjobApiUpdatedScheduledJobDTO) throws ApiException {
ApiResponse localVarResponse = updateScheduledJobWithHttpInfo(projectId, scheduledJobKey, dominoScheduledjobApiUpdatedScheduledJobDTO);
return localVarResponse.getData();
}
/**
* updates a scheduled job
*
* @param projectId Id of the project (required)
* @param scheduledJobKey Id of the scheduled job to be updated (required)
* @param dominoScheduledjobApiUpdatedScheduledJobDTO (required)
* @return ApiResponse<DominoScheduledjobApiScheduledJobDto>
* @throws ApiException if fails to make API call
*/
public ApiResponse updateScheduledJobWithHttpInfo(String projectId, String scheduledJobKey, DominoScheduledjobApiUpdatedScheduledJobDTO dominoScheduledjobApiUpdatedScheduledJobDTO) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = updateScheduledJobRequestBuilder(projectId, scheduledJobKey, dominoScheduledjobApiUpdatedScheduledJobDTO);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("updateScheduledJob", 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);
}
}
private HttpRequest.Builder updateScheduledJobRequestBuilder(String projectId, String scheduledJobKey, DominoScheduledjobApiUpdatedScheduledJobDTO dominoScheduledjobApiUpdatedScheduledJobDTO) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(400, "Missing the required parameter 'projectId' when calling updateScheduledJob");
}
// verify the required parameter 'scheduledJobKey' is set
if (scheduledJobKey == null) {
throw new ApiException(400, "Missing the required parameter 'scheduledJobKey' when calling updateScheduledJob");
}
// verify the required parameter 'dominoScheduledjobApiUpdatedScheduledJobDTO' is set
if (dominoScheduledjobApiUpdatedScheduledJobDTO == null) {
throw new ApiException(400, "Missing the required parameter 'dominoScheduledjobApiUpdatedScheduledJobDTO' when calling updateScheduledJob");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/projects/{projectId}/scheduledjobs/{scheduledJobKey}"
.replace("{projectId}", ApiClient.urlEncode(projectId.toString()))
.replace("{scheduledJobKey}", ApiClient.urlEncode(scheduledJobKey.toString()));
localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
localVarRequestBuilder.header("Content-Type", "application/json");
localVarRequestBuilder.header("Accept", "application/json");
try {
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(dominoScheduledjobApiUpdatedScheduledJobDTO);
localVarRequestBuilder.method("PUT", 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