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

com.dominodatalab.api.rest.JobsApi Maven / Gradle / Ivy

Go to download

Domino Data Lab API Client to connect to Domino web services using Java HTTP Client.

There is a newer version: 6.0.1.0
Show newest version
/*
 * Domino Data Lab API v4
 * This API provides access to select Domino functions available in Domino's non-public API. 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.DominoJobsInterfaceJob;
import com.dominodatalab.api.model.DominoJobsWebJobRestartOperationRequest;
import com.dominodatalab.api.model.DominoJobsWebJobStopOperationRequest;
import com.dominodatalab.api.model.DominoJobsWebStartJobRequest;
import com.dominodatalab.api.model.DominoJobsWebUpdateJobName;
import com.dominodatalab.api.model.Error;
import com.dominodatalab.api.model.RestartJob409Response;

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:26.309454-04:00[America/New_York]", comments = "Generator version: 7.8.0")
public class JobsApi {
  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 JobsApi() {
    this(new ApiClient());
  }

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

  /**
   * Gets a job
   * 
   * @param jobId  (required)
   * @return DominoJobsInterfaceJob
   * @throws ApiException if fails to make API call
   */
  public DominoJobsInterfaceJob getJob(String jobId) throws ApiException {
    ApiResponse localVarResponse = getJobWithHttpInfo(jobId);
    return localVarResponse.getData();
  }

  /**
   * Gets a job
   * 
   * @param jobId  (required)
   * @return ApiResponse<DominoJobsInterfaceJob>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getJobWithHttpInfo(String jobId) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getJobRequestBuilder(jobId);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("getJob", 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 getJobRequestBuilder(String jobId) throws ApiException {
    // verify the required parameter 'jobId' is set
    if (jobId == null) {
      throw new ApiException(400, "Missing the required parameter 'jobId' when calling getJob");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/jobs/{jobId}"
        .replace("{jobId}", ApiClient.urlEncode(jobId.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;
  }
  /**
   * Restart a Job
   * 
   * @param dominoJobsWebJobRestartOperationRequest JSON object with information for restarting the Job (required)
   * @return DominoJobsInterfaceJob
   * @throws ApiException if fails to make API call
   */
  public DominoJobsInterfaceJob restartJob(DominoJobsWebJobRestartOperationRequest dominoJobsWebJobRestartOperationRequest) throws ApiException {
    ApiResponse localVarResponse = restartJobWithHttpInfo(dominoJobsWebJobRestartOperationRequest);
    return localVarResponse.getData();
  }

  /**
   * Restart a Job
   * 
   * @param dominoJobsWebJobRestartOperationRequest JSON object with information for restarting the Job (required)
   * @return ApiResponse<DominoJobsInterfaceJob>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse restartJobWithHttpInfo(DominoJobsWebJobRestartOperationRequest dominoJobsWebJobRestartOperationRequest) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = restartJobRequestBuilder(dominoJobsWebJobRestartOperationRequest);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("restartJob", 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 restartJobRequestBuilder(DominoJobsWebJobRestartOperationRequest dominoJobsWebJobRestartOperationRequest) throws ApiException {
    // verify the required parameter 'dominoJobsWebJobRestartOperationRequest' is set
    if (dominoJobsWebJobRestartOperationRequest == null) {
      throw new ApiException(400, "Missing the required parameter 'dominoJobsWebJobRestartOperationRequest' when calling restartJob");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/jobs/restart";

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(dominoJobsWebJobRestartOperationRequest);
      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;
  }
  /**
   * Starts a new Job
   * 
   * @param dominoJobsWebStartJobRequest JSON object with information for starting the Job (optional)
   * @return DominoJobsInterfaceJob
   * @throws ApiException if fails to make API call
   */
  public DominoJobsInterfaceJob startJob(DominoJobsWebStartJobRequest dominoJobsWebStartJobRequest) throws ApiException {
    ApiResponse localVarResponse = startJobWithHttpInfo(dominoJobsWebStartJobRequest);
    return localVarResponse.getData();
  }

  /**
   * Starts a new Job
   * 
   * @param dominoJobsWebStartJobRequest JSON object with information for starting the Job (optional)
   * @return ApiResponse<DominoJobsInterfaceJob>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse startJobWithHttpInfo(DominoJobsWebStartJobRequest dominoJobsWebStartJobRequest) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = startJobRequestBuilder(dominoJobsWebStartJobRequest);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("startJob", 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 startJobRequestBuilder(DominoJobsWebStartJobRequest dominoJobsWebStartJobRequest) throws ApiException {

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/jobs/start";

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(dominoJobsWebStartJobRequest);
      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;
  }
  /**
   * Stop a Job
   * 
   * @param dominoJobsWebJobStopOperationRequest JSON object with information for stopping the Job (required)
   * @return DominoJobsInterfaceJob
   * @throws ApiException if fails to make API call
   */
  public DominoJobsInterfaceJob stopJob(DominoJobsWebJobStopOperationRequest dominoJobsWebJobStopOperationRequest) throws ApiException {
    ApiResponse localVarResponse = stopJobWithHttpInfo(dominoJobsWebJobStopOperationRequest);
    return localVarResponse.getData();
  }

  /**
   * Stop a Job
   * 
   * @param dominoJobsWebJobStopOperationRequest JSON object with information for stopping the Job (required)
   * @return ApiResponse<DominoJobsInterfaceJob>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse stopJobWithHttpInfo(DominoJobsWebJobStopOperationRequest dominoJobsWebJobStopOperationRequest) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = stopJobRequestBuilder(dominoJobsWebJobStopOperationRequest);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("stopJob", 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 stopJobRequestBuilder(DominoJobsWebJobStopOperationRequest dominoJobsWebJobStopOperationRequest) throws ApiException {
    // verify the required parameter 'dominoJobsWebJobStopOperationRequest' is set
    if (dominoJobsWebJobStopOperationRequest == null) {
      throw new ApiException(400, "Missing the required parameter 'dominoJobsWebJobStopOperationRequest' when calling stopJob");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/jobs/stop";

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(dominoJobsWebJobStopOperationRequest);
      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;
  }
  /**
   * Update name for job
   * 
   * @param jobId  (required)
   * @param dominoJobsWebUpdateJobName JSON object with information for new name (required)
   * @return DominoJobsInterfaceJob
   * @throws ApiException if fails to make API call
   */
  public DominoJobsInterfaceJob updateJob(String jobId, DominoJobsWebUpdateJobName dominoJobsWebUpdateJobName) throws ApiException {
    ApiResponse localVarResponse = updateJobWithHttpInfo(jobId, dominoJobsWebUpdateJobName);
    return localVarResponse.getData();
  }

  /**
   * Update name for job
   * 
   * @param jobId  (required)
   * @param dominoJobsWebUpdateJobName JSON object with information for new name (required)
   * @return ApiResponse<DominoJobsInterfaceJob>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse updateJobWithHttpInfo(String jobId, DominoJobsWebUpdateJobName dominoJobsWebUpdateJobName) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = updateJobRequestBuilder(jobId, dominoJobsWebUpdateJobName);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("updateJob", 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 updateJobRequestBuilder(String jobId, DominoJobsWebUpdateJobName dominoJobsWebUpdateJobName) throws ApiException {
    // verify the required parameter 'jobId' is set
    if (jobId == null) {
      throw new ApiException(400, "Missing the required parameter 'jobId' when calling updateJob");
    }
    // verify the required parameter 'dominoJobsWebUpdateJobName' is set
    if (dominoJobsWebUpdateJobName == null) {
      throw new ApiException(400, "Missing the required parameter 'dominoJobsWebUpdateJobName' when calling updateJob");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/jobs/{jobId}/name"
        .replace("{jobId}", ApiClient.urlEncode(jobId.toString()));

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

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

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