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

com.dominodatalab.api.rest.HardwareTierApi 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.DominoHardwaretierApiHardwareTierDto;
import com.dominodatalab.api.model.DominoHardwaretierApiHardwareTierEnvelope;
import com.dominodatalab.api.model.DominoHardwaretierApiHardwareTierIdentifier;
import com.dominodatalab.api.model.DominoHardwaretierApiHardwareTierWithCapacityDto;
import com.dominodatalab.api.model.DominoHardwaretierApiNewHardwareTierDto;

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

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

  /**
   * Archive a hardware tier
   * 
   * @param dominoHardwaretierApiHardwareTierIdentifier  (required)
   * @throws ApiException if fails to make API call
   */
  public void archiveHardwareTier(DominoHardwaretierApiHardwareTierIdentifier dominoHardwaretierApiHardwareTierIdentifier) throws ApiException {
    archiveHardwareTierWithHttpInfo(dominoHardwaretierApiHardwareTierIdentifier);
  }

  /**
   * Archive a hardware tier
   * 
   * @param dominoHardwaretierApiHardwareTierIdentifier  (required)
   * @return ApiResponse<Void>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse archiveHardwareTierWithHttpInfo(DominoHardwaretierApiHardwareTierIdentifier dominoHardwaretierApiHardwareTierIdentifier) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = archiveHardwareTierRequestBuilder(dominoHardwaretierApiHardwareTierIdentifier);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("archiveHardwareTier", 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 archiveHardwareTierRequestBuilder(DominoHardwaretierApiHardwareTierIdentifier dominoHardwaretierApiHardwareTierIdentifier) throws ApiException {
    // verify the required parameter 'dominoHardwaretierApiHardwareTierIdentifier' is set
    if (dominoHardwaretierApiHardwareTierIdentifier == null) {
      throw new ApiException(400, "Missing the required parameter 'dominoHardwaretierApiHardwareTierIdentifier' when calling archiveHardwareTier");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/hardwareTier/archive";

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(dominoHardwaretierApiHardwareTierIdentifier);
      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;
  }
  /**
   * Create a hardware tier
   * 
   * @param dominoHardwaretierApiNewHardwareTierDto  (required)
   * @return DominoHardwaretierApiHardwareTierDto
   * @throws ApiException if fails to make API call
   */
  public DominoHardwaretierApiHardwareTierDto createHardwareTier(DominoHardwaretierApiNewHardwareTierDto dominoHardwaretierApiNewHardwareTierDto) throws ApiException {
    ApiResponse localVarResponse = createHardwareTierWithHttpInfo(dominoHardwaretierApiNewHardwareTierDto);
    return localVarResponse.getData();
  }

  /**
   * Create a hardware tier
   * 
   * @param dominoHardwaretierApiNewHardwareTierDto  (required)
   * @return ApiResponse<DominoHardwaretierApiHardwareTierDto>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse createHardwareTierWithHttpInfo(DominoHardwaretierApiNewHardwareTierDto dominoHardwaretierApiNewHardwareTierDto) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = createHardwareTierRequestBuilder(dominoHardwaretierApiNewHardwareTierDto);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("createHardwareTier", 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 createHardwareTierRequestBuilder(DominoHardwaretierApiNewHardwareTierDto dominoHardwaretierApiNewHardwareTierDto) throws ApiException {
    // verify the required parameter 'dominoHardwaretierApiNewHardwareTierDto' is set
    if (dominoHardwaretierApiNewHardwareTierDto == null) {
      throw new ApiException(400, "Missing the required parameter 'dominoHardwaretierApiNewHardwareTierDto' when calling createHardwareTier");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/hardwareTier";

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(dominoHardwaretierApiNewHardwareTierDto);
      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 all hardware tiers
   * 
   * @param showArchived If show_archived is true, then hardware tiers that are archived also will be shown. (optional)
   * @return DominoHardwaretierApiHardwareTierEnvelope
   * @throws ApiException if fails to make API call
   */
  public DominoHardwaretierApiHardwareTierEnvelope getAllHardwareTiers(Boolean showArchived) throws ApiException {
    ApiResponse localVarResponse = getAllHardwareTiersWithHttpInfo(showArchived);
    return localVarResponse.getData();
  }

  /**
   * Get all hardware tiers
   * 
   * @param showArchived If show_archived is true, then hardware tiers that are archived also will be shown. (optional)
   * @return ApiResponse<DominoHardwaretierApiHardwareTierEnvelope>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getAllHardwareTiersWithHttpInfo(Boolean showArchived) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getAllHardwareTiersRequestBuilder(showArchived);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("getAllHardwareTiers", 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 getAllHardwareTiersRequestBuilder(Boolean showArchived) throws ApiException {

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/hardwareTier";

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

    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;
  }
  /**
   * Get a hardware tier
   * 
   * @param hardwareTierId  (required)
   * @param projectId  (optional)
   * @return DominoHardwaretierApiHardwareTierDto
   * @throws ApiException if fails to make API call
   */
  public DominoHardwaretierApiHardwareTierDto getHardwareTier(String hardwareTierId, String projectId) throws ApiException {
    ApiResponse localVarResponse = getHardwareTierWithHttpInfo(hardwareTierId, projectId);
    return localVarResponse.getData();
  }

  /**
   * Get a hardware tier
   * 
   * @param hardwareTierId  (required)
   * @param projectId  (optional)
   * @return ApiResponse<DominoHardwaretierApiHardwareTierDto>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getHardwareTierWithHttpInfo(String hardwareTierId, String projectId) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getHardwareTierRequestBuilder(hardwareTierId, 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("getHardwareTier", 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 getHardwareTierRequestBuilder(String hardwareTierId, String projectId) throws ApiException {
    // verify the required parameter 'hardwareTierId' is set
    if (hardwareTierId == null) {
      throw new ApiException(400, "Missing the required parameter 'hardwareTierId' when calling getHardwareTier");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/hardwareTier/{hardwareTierId}"
        .replace("{hardwareTierId}", ApiClient.urlEncode(hardwareTierId.toString()));

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

    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;
  }
  /**
   * Get a hardware tier with capacity
   * 
   * @param hardwareTierId  (required)
   * @param projectId  (optional)
   * @return DominoHardwaretierApiHardwareTierWithCapacityDto
   * @throws ApiException if fails to make API call
   */
  public DominoHardwaretierApiHardwareTierWithCapacityDto getHardwareTierWithCapacity(String hardwareTierId, String projectId) throws ApiException {
    ApiResponse localVarResponse = getHardwareTierWithCapacityWithHttpInfo(hardwareTierId, projectId);
    return localVarResponse.getData();
  }

  /**
   * Get a hardware tier with capacity
   * 
   * @param hardwareTierId  (required)
   * @param projectId  (optional)
   * @return ApiResponse<DominoHardwaretierApiHardwareTierWithCapacityDto>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getHardwareTierWithCapacityWithHttpInfo(String hardwareTierId, String projectId) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getHardwareTierWithCapacityRequestBuilder(hardwareTierId, 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("getHardwareTierWithCapacity", 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 getHardwareTierWithCapacityRequestBuilder(String hardwareTierId, String projectId) throws ApiException {
    // verify the required parameter 'hardwareTierId' is set
    if (hardwareTierId == null) {
      throw new ApiException(400, "Missing the required parameter 'hardwareTierId' when calling getHardwareTierWithCapacity");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/hardwareTier/withCapacity/{hardwareTierId}"
        .replace("{hardwareTierId}", ApiClient.urlEncode(hardwareTierId.toString()));

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

    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;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy