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

com.dominodatalab.api.rest.ProjectManagementApi 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.DominoProjectManagementApiResponseMessage;
import com.dominodatalab.api.model.DominoProjectManagementWebErrorResponse;
import com.dominodatalab.api.model.DominoProjectManagementWebFilterProjectGoals;
import com.dominodatalab.api.model.DominoProjectManagementWebLinkJobToGoalRequest;
import com.dominodatalab.api.model.DominoProjectsApiProjectGoal;
import com.dominodatalab.api.model.Error;

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

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

  /**
   * Get project goals
   * 
   * @param projectId  (required)
   * @param dominoProjectManagementWebFilterProjectGoals JSON object with data to filter project goals (required)
   * @return List<DominoProjectsApiProjectGoal>
   * @throws ApiException if fails to make API call
   */
  public List getFilteredProjectGoals(String projectId, DominoProjectManagementWebFilterProjectGoals dominoProjectManagementWebFilterProjectGoals) throws ApiException {
    ApiResponse> localVarResponse = getFilteredProjectGoalsWithHttpInfo(projectId, dominoProjectManagementWebFilterProjectGoals);
    return localVarResponse.getData();
  }

  /**
   * Get project goals
   * 
   * @param projectId  (required)
   * @param dominoProjectManagementWebFilterProjectGoals JSON object with data to filter project goals (required)
   * @return ApiResponse<List<DominoProjectsApiProjectGoal>>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse> getFilteredProjectGoalsWithHttpInfo(String projectId, DominoProjectManagementWebFilterProjectGoals dominoProjectManagementWebFilterProjectGoals) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getFilteredProjectGoalsRequestBuilder(projectId, dominoProjectManagementWebFilterProjectGoals);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("getFilteredProjectGoals", 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 getFilteredProjectGoalsRequestBuilder(String projectId, DominoProjectManagementWebFilterProjectGoals dominoProjectManagementWebFilterProjectGoals) throws ApiException {
    // verify the required parameter 'projectId' is set
    if (projectId == null) {
      throw new ApiException(400, "Missing the required parameter 'projectId' when calling getFilteredProjectGoals");
    }
    // verify the required parameter 'dominoProjectManagementWebFilterProjectGoals' is set
    if (dominoProjectManagementWebFilterProjectGoals == null) {
      throw new ApiException(400, "Missing the required parameter 'dominoProjectManagementWebFilterProjectGoals' when calling getFilteredProjectGoals");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/projectManagement/{projectId}/goals"
        .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(dominoProjectManagementWebFilterProjectGoals);
      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;
  }
  /**
   * Get project goals
   * 
   * @param projectId  (required)
   * @return List<DominoProjectsApiProjectGoal>
   * @throws ApiException if fails to make API call
   */
  public List getProjectGoals(String projectId) throws ApiException {
    ApiResponse> localVarResponse = getProjectGoalsWithHttpInfo(projectId);
    return localVarResponse.getData();
  }

  /**
   * Get project goals
   * 
   * @param projectId  (required)
   * @return ApiResponse<List<DominoProjectsApiProjectGoal>>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse> getProjectGoalsWithHttpInfo(String projectId) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getProjectGoalsRequestBuilder(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("getProjectGoals", 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 getProjectGoalsRequestBuilder(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 getProjectGoals");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/projectManagement/{projectId}/goals"
        .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;
  }
  /**
   * Link job to goal
   * 
   * @param jobId  (required)
   * @param dominoProjectManagementWebLinkJobToGoalRequest JSON object with information for linking goal to a job (required)
   * @return DominoProjectManagementApiResponseMessage
   * @throws ApiException if fails to make API call
   */
  public DominoProjectManagementApiResponseMessage linkJobToGoal(String jobId, DominoProjectManagementWebLinkJobToGoalRequest dominoProjectManagementWebLinkJobToGoalRequest) throws ApiException {
    ApiResponse localVarResponse = linkJobToGoalWithHttpInfo(jobId, dominoProjectManagementWebLinkJobToGoalRequest);
    return localVarResponse.getData();
  }

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

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/projectManagement/{jobId}/linkJobToGoal"
        .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(dominoProjectManagementWebLinkJobToGoalRequest);
      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