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

com.dominodatalab.pub.rest.HardwareTierApi 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 Public API
 * Domino Public API Endpoints
 *
 * The version of the OpenAPI document: 0.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.pub.rest;

import com.dominodatalab.pub.invoker.ApiClient;
import com.dominodatalab.pub.invoker.ApiException;
import com.dominodatalab.pub.invoker.ApiResponse;
import com.dominodatalab.pub.invoker.Pair;

import com.dominodatalab.pub.model.FailureEnvelopeV1;
import com.dominodatalab.pub.model.GetAIGatewayAuditData400Response;
import com.dominodatalab.pub.model.HardwareTierEnvelopeV1;
import com.dominodatalab.pub.model.HardwareTierV1;
import com.dominodatalab.pub.model.NewHardwareTierV1;
import com.dominodatalab.pub.model.PaginatedHardwareTierEnvelopeV1;

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:28.765500600-04:00[America/New_York]", comments = "Generator version: 7.8.0")
public class HardwareTierApi {
  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 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);
  }

  protected 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
   * Archive a hardware tier by Id. Required permissions: `ManageHardwareTiers`
   * @param hardwareTierId Id of hardwareTier to archive (required)
   * @return HardwareTierEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public HardwareTierEnvelopeV1 archiveHardwareTier(String hardwareTierId) throws ApiException {
    ApiResponse localVarResponse = archiveHardwareTierWithHttpInfo(hardwareTierId);
    return localVarResponse.getData();
  }

  /**
   * Archive a hardware tier
   * Archive a hardware tier by Id. Required permissions: `ManageHardwareTiers`
   * @param hardwareTierId Id of hardwareTier to archive (required)
   * @return ApiResponse<HardwareTierEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse archiveHardwareTierWithHttpInfo(String hardwareTierId) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = archiveHardwareTierRequestBuilder(hardwareTierId);
    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(),
          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 archiveHardwareTierRequestBuilder(String hardwareTierId) throws ApiException {
    // verify the required parameter 'hardwareTierId' is set
    if (hardwareTierId == null) {
      throw new ApiException(400, "Missing the required parameter 'hardwareTierId' when calling archiveHardwareTier");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/hardwaretiers/v1/hardwaretiers/{hardwareTierId}"
        .replace("{hardwareTierId}", ApiClient.urlEncode(hardwareTierId.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;
  }
  /**
   * Create a hardware tier
   * Create a hardware tier. Required permissions: `ManageHardwareTiers`
   * @param newHardwareTierV1 Hardware tier to create (required)
   * @return HardwareTierEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public HardwareTierEnvelopeV1 createHardwareTier(NewHardwareTierV1 newHardwareTierV1) throws ApiException {
    ApiResponse localVarResponse = createHardwareTierWithHttpInfo(newHardwareTierV1);
    return localVarResponse.getData();
  }

  /**
   * Create a hardware tier
   * Create a hardware tier. Required permissions: `ManageHardwareTiers`
   * @param newHardwareTierV1 Hardware tier to create (required)
   * @return ApiResponse<HardwareTierEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse createHardwareTierWithHttpInfo(NewHardwareTierV1 newHardwareTierV1) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = createHardwareTierRequestBuilder(newHardwareTierV1);
    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);
    }
  }

  protected HttpRequest.Builder createHardwareTierRequestBuilder(NewHardwareTierV1 newHardwareTierV1) throws ApiException {
    // verify the required parameter 'newHardwareTierV1' is set
    if (newHardwareTierV1 == null) {
      throw new ApiException(400, "Missing the required parameter 'newHardwareTierV1' when calling createHardwareTier");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/hardwaretiers/v1/hardwaretiers";

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(newHardwareTierV1);
      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
   * Get all hardware tiers. Required permissions: `ViewHardwareTiers`
   * @param offset How many hardware tiers from the start to skip. Defaults to 0. (optional)
   * @param limit How many hardware tiers to fetch. Defaults to 10. (optional)
   * @param includeArchived Whether to include archived hardware tiers. Defaults to false. (optional)
   * @return PaginatedHardwareTierEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public PaginatedHardwareTierEnvelopeV1 getAllHardwareTiers(Integer offset, Integer limit, Boolean includeArchived) throws ApiException {
    ApiResponse localVarResponse = getAllHardwareTiersWithHttpInfo(offset, limit, includeArchived);
    return localVarResponse.getData();
  }

  /**
   * Get all hardware tiers
   * Get all hardware tiers. Required permissions: `ViewHardwareTiers`
   * @param offset How many hardware tiers from the start to skip. Defaults to 0. (optional)
   * @param limit How many hardware tiers to fetch. Defaults to 10. (optional)
   * @param includeArchived Whether to include archived hardware tiers. Defaults to false. (optional)
   * @return ApiResponse<PaginatedHardwareTierEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getAllHardwareTiersWithHttpInfo(Integer offset, Integer limit, Boolean includeArchived) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getAllHardwareTiersRequestBuilder(offset, limit, includeArchived);
    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);
    }
  }

  protected HttpRequest.Builder getAllHardwareTiersRequestBuilder(Integer offset, Integer limit, Boolean includeArchived) throws ApiException {

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/hardwaretiers/v1/hardwaretiers";

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

    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 by Id
   * Get a hardware tier by Id. Required permissions: `ViewHardwareTiers`
   * @param hardwareTierId Id of hardwareTier to retrieve (required)
   * @return HardwareTierEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public HardwareTierEnvelopeV1 getHardwareTierById(String hardwareTierId) throws ApiException {
    ApiResponse localVarResponse = getHardwareTierByIdWithHttpInfo(hardwareTierId);
    return localVarResponse.getData();
  }

  /**
   * Get a hardware tier by Id
   * Get a hardware tier by Id. Required permissions: `ViewHardwareTiers`
   * @param hardwareTierId Id of hardwareTier to retrieve (required)
   * @return ApiResponse<HardwareTierEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getHardwareTierByIdWithHttpInfo(String hardwareTierId) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getHardwareTierByIdRequestBuilder(hardwareTierId);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("getHardwareTierById", 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 getHardwareTierByIdRequestBuilder(String hardwareTierId) throws ApiException {
    // verify the required parameter 'hardwareTierId' is set
    if (hardwareTierId == null) {
      throw new ApiException(400, "Missing the required parameter 'hardwareTierId' when calling getHardwareTierById");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/hardwaretiers/v1/hardwaretiers/{hardwareTierId}"
        .replace("{hardwareTierId}", ApiClient.urlEncode(hardwareTierId.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;
  }
  /**
   * Update a hardware tier
   * Update a hardware tier. Required permissions: `ManageHardwareTiers`
   * @param hardwareTierV1 Updated hardware tier (required)
   * @return HardwareTierEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public HardwareTierEnvelopeV1 updateHardwareTier(HardwareTierV1 hardwareTierV1) throws ApiException {
    ApiResponse localVarResponse = updateHardwareTierWithHttpInfo(hardwareTierV1);
    return localVarResponse.getData();
  }

  /**
   * Update a hardware tier
   * Update a hardware tier. Required permissions: `ManageHardwareTiers`
   * @param hardwareTierV1 Updated hardware tier (required)
   * @return ApiResponse<HardwareTierEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse updateHardwareTierWithHttpInfo(HardwareTierV1 hardwareTierV1) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = updateHardwareTierRequestBuilder(hardwareTierV1);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("updateHardwareTier", 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 updateHardwareTierRequestBuilder(HardwareTierV1 hardwareTierV1) throws ApiException {
    // verify the required parameter 'hardwareTierV1' is set
    if (hardwareTierV1 == null) {
      throw new ApiException(400, "Missing the required parameter 'hardwareTierV1' when calling updateHardwareTier");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/hardwaretiers/v1/hardwaretiers";

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

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

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