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

com.dominodatalab.api.rest.DataMountApi 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.DominoDatamountApiDataMountDto;
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 DataMountApi {
  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 DataMountApi() {
    this(new ApiClient());
  }

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

  /**
   * Add project to data mounts
   * 
   * @param projectId project id to add to data mounts (required)
   * @param datamountIds data mount id's to add to the project (required)
   * @return List<DominoDatamountApiDataMountDto>
   * @throws ApiException if fails to make API call
   */
  public List addProject(String projectId, List datamountIds) throws ApiException {
    ApiResponse> localVarResponse = addProjectWithHttpInfo(projectId, datamountIds);
    return localVarResponse.getData();
  }

  /**
   * Add project to data mounts
   * 
   * @param projectId project id to add to data mounts (required)
   * @param datamountIds data mount id's to add to the project (required)
   * @return ApiResponse<List<DominoDatamountApiDataMountDto>>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse> addProjectWithHttpInfo(String projectId, List datamountIds) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = addProjectRequestBuilder(projectId, datamountIds);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("addProject", 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 addProjectRequestBuilder(String projectId, List datamountIds) throws ApiException {
    // verify the required parameter 'projectId' is set
    if (projectId == null) {
      throw new ApiException(400, "Missing the required parameter 'projectId' when calling addProject");
    }
    // verify the required parameter 'datamountIds' is set
    if (datamountIds == null) {
      throw new ApiException(400, "Missing the required parameter 'datamountIds' when calling addProject");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/datamount/projects/{projectId}"
        .replace("{projectId}", ApiClient.urlEncode(projectId.toString()));

    List localVarQueryParams = new ArrayList<>();
    StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
    String localVarQueryParameterBaseName;
    localVarQueryParameterBaseName = "datamountIds";
    localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "datamountIds", datamountIds));

    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("POST", HttpRequest.BodyPublishers.noBody());
    if (memberVarReadTimeout != null) {
      localVarRequestBuilder.timeout(memberVarReadTimeout);
    }
    if (memberVarInterceptor != null) {
      memberVarInterceptor.accept(localVarRequestBuilder);
    }
    return localVarRequestBuilder;
  }
  /**
   * Find data mounts by project
   * 
   * @param projectId project id (required)
   * @return List<DominoDatamountApiDataMountDto>
   * @throws ApiException if fails to make API call
   */
  public List findDataMountsByProject(String projectId) throws ApiException {
    ApiResponse> localVarResponse = findDataMountsByProjectWithHttpInfo(projectId);
    return localVarResponse.getData();
  }

  /**
   * Find data mounts by project
   * 
   * @param projectId project id (required)
   * @return ApiResponse<List<DominoDatamountApiDataMountDto>>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse> findDataMountsByProjectWithHttpInfo(String projectId) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = findDataMountsByProjectRequestBuilder(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("findDataMountsByProject", 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 findDataMountsByProjectRequestBuilder(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 findDataMountsByProject");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/datamount/projects/{projectId}"
        .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;
  }
  /**
   * Remove project
   * 
   * @param projectId Project id to remove from data mount (required)
   * @param datamountId data mount id from which to remove the project (required)
   * @return DominoDatamountApiDataMountDto
   * @throws ApiException if fails to make API call
   */
  public DominoDatamountApiDataMountDto removeProject(String projectId, String datamountId) throws ApiException {
    ApiResponse localVarResponse = removeProjectWithHttpInfo(projectId, datamountId);
    return localVarResponse.getData();
  }

  /**
   * Remove project
   * 
   * @param projectId Project id to remove from data mount (required)
   * @param datamountId data mount id from which to remove the project (required)
   * @return ApiResponse<DominoDatamountApiDataMountDto>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse removeProjectWithHttpInfo(String projectId, String datamountId) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = removeProjectRequestBuilder(projectId, datamountId);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("removeProject", 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 removeProjectRequestBuilder(String projectId, String datamountId) throws ApiException {
    // verify the required parameter 'projectId' is set
    if (projectId == null) {
      throw new ApiException(400, "Missing the required parameter 'projectId' when calling removeProject");
    }
    // verify the required parameter 'datamountId' is set
    if (datamountId == null) {
      throw new ApiException(400, "Missing the required parameter 'datamountId' when calling removeProject");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/datamount/projects/{projectId}"
        .replace("{projectId}", ApiClient.urlEncode(projectId.toString()));

    List localVarQueryParams = new ArrayList<>();
    StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
    String localVarQueryParameterBaseName;
    localVarQueryParameterBaseName = "datamountId";
    localVarQueryParams.addAll(ApiClient.parameterToPairs("datamountId", datamountId));

    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("DELETE", HttpRequest.BodyPublishers.noBody());
    if (memberVarReadTimeout != null) {
      localVarRequestBuilder.timeout(memberVarReadTimeout);
    }
    if (memberVarInterceptor != null) {
      memberVarInterceptor.accept(localVarRequestBuilder);
    }
    return localVarRequestBuilder;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy