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

com.dominodatalab.pub.rest.AiGatewayApi 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.AIGatewayAuditDataV1;
import com.dominodatalab.pub.model.AIGatewayEnvelopeV1;
import com.dominodatalab.pub.model.EndpointEnvelopeV1;
import com.dominodatalab.pub.model.EndpointPermissionsDtoV1;
import com.dominodatalab.pub.model.FailureEnvelopeV1;
import com.dominodatalab.pub.model.GetAIGatewayAuditData400Response;
import com.dominodatalab.pub.model.NewEndpointV1;
import java.time.OffsetDateTime;
import com.dominodatalab.pub.model.UpdatedEndpointPermissionsV1;
import com.dominodatalab.pub.model.UpdatedEndpointV1;

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

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

  /**
   * Create a new endpoint
   * Create a new a endpoint
   * @param newEndpointV1 Details of the new endpoint to create (required)
   * @return EndpointEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public EndpointEnvelopeV1 createGatewayEndpoint(NewEndpointV1 newEndpointV1) throws ApiException {
    ApiResponse localVarResponse = createGatewayEndpointWithHttpInfo(newEndpointV1);
    return localVarResponse.getData();
  }

  /**
   * Create a new endpoint
   * Create a new a endpoint
   * @param newEndpointV1 Details of the new endpoint to create (required)
   * @return ApiResponse<EndpointEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse createGatewayEndpointWithHttpInfo(NewEndpointV1 newEndpointV1) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = createGatewayEndpointRequestBuilder(newEndpointV1);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("createGatewayEndpoint", 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 createGatewayEndpointRequestBuilder(NewEndpointV1 newEndpointV1) throws ApiException {
    // verify the required parameter 'newEndpointV1' is set
    if (newEndpointV1 == null) {
      throw new ApiException(400, "Missing the required parameter 'newEndpointV1' when calling createGatewayEndpoint");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/aigateway/v1/endpoints";

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(newEndpointV1);
      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;
  }
  /**
   * Delete a endpoint by name
   * Delete a endpoint by name
   * @param endpointName Name of the endpoint to delete (required)
   * @throws ApiException if fails to make API call
   */
  public void deleteGatewayEndpointByName(String endpointName) throws ApiException {
    deleteGatewayEndpointByNameWithHttpInfo(endpointName);
  }

  /**
   * Delete a endpoint by name
   * Delete a endpoint by name
   * @param endpointName Name of the endpoint to delete (required)
   * @return ApiResponse<Void>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse deleteGatewayEndpointByNameWithHttpInfo(String endpointName) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = deleteGatewayEndpointByNameRequestBuilder(endpointName);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("deleteGatewayEndpointByName", 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);
    }
  }

  protected HttpRequest.Builder deleteGatewayEndpointByNameRequestBuilder(String endpointName) throws ApiException {
    // verify the required parameter 'endpointName' is set
    if (endpointName == null) {
      throw new ApiException(400, "Missing the required parameter 'endpointName' when calling deleteGatewayEndpointByName");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/aigateway/v1/endpoints/{endpointName}"
        .replace("{endpointName}", ApiClient.urlEncode(endpointName.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;
  }
  /**
   * Get AI Gateway Audit Data
   * Gets AI Gateway audit data given filter input parameters
   * @param endpointIds Endpoint IDs to query audit data for (optional
   * @param endpointNames Endpoint names to query audit data for (optional
   * @param startTime Start time (iso8601) (optional)
   * @param endTime End time (iso8601) (optional)
   * @return List<AIGatewayAuditDataV1>
   * @throws ApiException if fails to make API call
   */
  public List getAIGatewayAuditData(List endpointIds, List endpointNames, OffsetDateTime startTime, OffsetDateTime endTime) throws ApiException {
    ApiResponse> localVarResponse = getAIGatewayAuditDataWithHttpInfo(endpointIds, endpointNames, startTime, endTime);
    return localVarResponse.getData();
  }

  /**
   * Get AI Gateway Audit Data
   * Gets AI Gateway audit data given filter input parameters
   * @param endpointIds Endpoint IDs to query audit data for (optional
   * @param endpointNames Endpoint names to query audit data for (optional
   * @param startTime Start time (iso8601) (optional)
   * @param endTime End time (iso8601) (optional)
   * @return ApiResponse<List<AIGatewayAuditDataV1>>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse> getAIGatewayAuditDataWithHttpInfo(List endpointIds, List endpointNames, OffsetDateTime startTime, OffsetDateTime endTime) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getAIGatewayAuditDataRequestBuilder(endpointIds, endpointNames, startTime, endTime);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("getAIGatewayAuditData", 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 getAIGatewayAuditDataRequestBuilder(List endpointIds, List endpointNames, OffsetDateTime startTime, OffsetDateTime endTime) throws ApiException {

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/aigateway/v1/audit";

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

    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 all active Gateway LLMs accessible by the user
   * Get all active Gateway LLMs accessible by the user
   * @param offset How many Endpoints from the start to skip. Defaults to 0. (optional)
   * @param limit Max number of Endpoints to fetch. Defaults to fetching all. (optional)
   * @param sortByField The field by which to sort the list of returned endpoints. Defaults to creation date (optional)
   * @param shouldSortAscending Boolean whether to sort Endpoints ascending or descending. Defaults to false (descending). (optional)
   * @param searchFilter Search string by which to filter the list of returned endpoints (optional)
   * @return AIGatewayEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public AIGatewayEnvelopeV1 getAllGatewayEndpoints(Integer offset, Integer limit, String sortByField, Boolean shouldSortAscending, String searchFilter) throws ApiException {
    ApiResponse localVarResponse = getAllGatewayEndpointsWithHttpInfo(offset, limit, sortByField, shouldSortAscending, searchFilter);
    return localVarResponse.getData();
  }

  /**
   * Get all active Gateway LLMs accessible by the user
   * Get all active Gateway LLMs accessible by the user
   * @param offset How many Endpoints from the start to skip. Defaults to 0. (optional)
   * @param limit Max number of Endpoints to fetch. Defaults to fetching all. (optional)
   * @param sortByField The field by which to sort the list of returned endpoints. Defaults to creation date (optional)
   * @param shouldSortAscending Boolean whether to sort Endpoints ascending or descending. Defaults to false (descending). (optional)
   * @param searchFilter Search string by which to filter the list of returned endpoints (optional)
   * @return ApiResponse<AIGatewayEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getAllGatewayEndpointsWithHttpInfo(Integer offset, Integer limit, String sortByField, Boolean shouldSortAscending, String searchFilter) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getAllGatewayEndpointsRequestBuilder(offset, limit, sortByField, shouldSortAscending, searchFilter);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("getAllGatewayEndpoints", 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 getAllGatewayEndpointsRequestBuilder(Integer offset, Integer limit, String sortByField, Boolean shouldSortAscending, String searchFilter) throws ApiException {

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/aigateway/v1/endpoints";

    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 = "sortByField";
    localVarQueryParams.addAll(ApiClient.parameterToPairs("sortByField", sortByField));
    localVarQueryParameterBaseName = "shouldSortAscending";
    localVarQueryParams.addAll(ApiClient.parameterToPairs("shouldSortAscending", shouldSortAscending));
    localVarQueryParameterBaseName = "searchFilter";
    localVarQueryParams.addAll(ApiClient.parameterToPairs("searchFilter", searchFilter));

    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 endpoint by name
   * Get a endpoint by name (returns endpoint if user has access and endpoint is active)
   * @param endpointName Name of the endpoint to get (required)
   * @param numInputTokens Number of input tokens sent to the endpoint (optional)
   * @return EndpointEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public EndpointEnvelopeV1 getGatewayEndpointByName(String endpointName, String numInputTokens) throws ApiException {
    ApiResponse localVarResponse = getGatewayEndpointByNameWithHttpInfo(endpointName, numInputTokens);
    return localVarResponse.getData();
  }

  /**
   * Get a endpoint by name
   * Get a endpoint by name (returns endpoint if user has access and endpoint is active)
   * @param endpointName Name of the endpoint to get (required)
   * @param numInputTokens Number of input tokens sent to the endpoint (optional)
   * @return ApiResponse<EndpointEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getGatewayEndpointByNameWithHttpInfo(String endpointName, String numInputTokens) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getGatewayEndpointByNameRequestBuilder(endpointName, numInputTokens);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("getGatewayEndpointByName", 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 getGatewayEndpointByNameRequestBuilder(String endpointName, String numInputTokens) throws ApiException {
    // verify the required parameter 'endpointName' is set
    if (endpointName == null) {
      throw new ApiException(400, "Missing the required parameter 'endpointName' when calling getGatewayEndpointByName");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/aigateway/v1/endpoints/{endpointName}"
        .replace("{endpointName}", ApiClient.urlEncode(endpointName.toString()));

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

    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 permissions for a endpoint by name
   * Get permissions for a endpoint by name
   * @param endpointName Name of the endpoint to get permissions for (required)
   * @return EndpointPermissionsDtoV1
   * @throws ApiException if fails to make API call
   */
  public EndpointPermissionsDtoV1 getGatewayEndpointPermissionsByName(String endpointName) throws ApiException {
    ApiResponse localVarResponse = getGatewayEndpointPermissionsByNameWithHttpInfo(endpointName);
    return localVarResponse.getData();
  }

  /**
   * Get permissions for a endpoint by name
   * Get permissions for a endpoint by name
   * @param endpointName Name of the endpoint to get permissions for (required)
   * @return ApiResponse<EndpointPermissionsDtoV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse getGatewayEndpointPermissionsByNameWithHttpInfo(String endpointName) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = getGatewayEndpointPermissionsByNameRequestBuilder(endpointName);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("getGatewayEndpointPermissionsByName", 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 getGatewayEndpointPermissionsByNameRequestBuilder(String endpointName) throws ApiException {
    // verify the required parameter 'endpointName' is set
    if (endpointName == null) {
      throw new ApiException(400, "Missing the required parameter 'endpointName' when calling getGatewayEndpointPermissionsByName");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/aigateway/v1/endpoints/{endpointName}/permissions"
        .replace("{endpointName}", ApiClient.urlEncode(endpointName.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 endpoint by name
   * Update a endpoint by name (change endpoint name, endpoint type, model name, model provider, or model config)
   * @param endpointName Name of the endpoint to update details for (required)
   * @param updatedEndpointV1 Updated endpoint details (required)
   * @return EndpointEnvelopeV1
   * @throws ApiException if fails to make API call
   */
  public EndpointEnvelopeV1 updateGatewayEndpointByName(String endpointName, UpdatedEndpointV1 updatedEndpointV1) throws ApiException {
    ApiResponse localVarResponse = updateGatewayEndpointByNameWithHttpInfo(endpointName, updatedEndpointV1);
    return localVarResponse.getData();
  }

  /**
   * Update a endpoint by name
   * Update a endpoint by name (change endpoint name, endpoint type, model name, model provider, or model config)
   * @param endpointName Name of the endpoint to update details for (required)
   * @param updatedEndpointV1 Updated endpoint details (required)
   * @return ApiResponse<EndpointEnvelopeV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse updateGatewayEndpointByNameWithHttpInfo(String endpointName, UpdatedEndpointV1 updatedEndpointV1) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = updateGatewayEndpointByNameRequestBuilder(endpointName, updatedEndpointV1);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("updateGatewayEndpointByName", 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 updateGatewayEndpointByNameRequestBuilder(String endpointName, UpdatedEndpointV1 updatedEndpointV1) throws ApiException {
    // verify the required parameter 'endpointName' is set
    if (endpointName == null) {
      throw new ApiException(400, "Missing the required parameter 'endpointName' when calling updateGatewayEndpointByName");
    }
    // verify the required parameter 'updatedEndpointV1' is set
    if (updatedEndpointV1 == null) {
      throw new ApiException(400, "Missing the required parameter 'updatedEndpointV1' when calling updateGatewayEndpointByName");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/aigateway/v1/endpoints/{endpointName}"
        .replace("{endpointName}", ApiClient.urlEncode(endpointName.toString()));

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(updatedEndpointV1);
      localVarRequestBuilder.method("PATCH", 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 permissions for a endpoint by name
   * Update permissions for a endpoint by name (add or remove user IDs, or change isEveryoneAllowed)
   * @param endpointName Name of the endpoint to update permissions for (required)
   * @param updatedEndpointPermissionsV1 Updated endpoint permissions (required)
   * @return EndpointPermissionsDtoV1
   * @throws ApiException if fails to make API call
   */
  public EndpointPermissionsDtoV1 updateGatewayEndpointPermissionsByName(String endpointName, UpdatedEndpointPermissionsV1 updatedEndpointPermissionsV1) throws ApiException {
    ApiResponse localVarResponse = updateGatewayEndpointPermissionsByNameWithHttpInfo(endpointName, updatedEndpointPermissionsV1);
    return localVarResponse.getData();
  }

  /**
   * Update permissions for a endpoint by name
   * Update permissions for a endpoint by name (add or remove user IDs, or change isEveryoneAllowed)
   * @param endpointName Name of the endpoint to update permissions for (required)
   * @param updatedEndpointPermissionsV1 Updated endpoint permissions (required)
   * @return ApiResponse<EndpointPermissionsDtoV1>
   * @throws ApiException if fails to make API call
   */
  public ApiResponse updateGatewayEndpointPermissionsByNameWithHttpInfo(String endpointName, UpdatedEndpointPermissionsV1 updatedEndpointPermissionsV1) throws ApiException {
    HttpRequest.Builder localVarRequestBuilder = updateGatewayEndpointPermissionsByNameRequestBuilder(endpointName, updatedEndpointPermissionsV1);
    try {
      HttpResponse localVarResponse = memberVarHttpClient.send(
          localVarRequestBuilder.build(),
          HttpResponse.BodyHandlers.ofInputStream());
      if (memberVarResponseInterceptor != null) {
        memberVarResponseInterceptor.accept(localVarResponse);
      }
      try {
        if (localVarResponse.statusCode()/ 100 != 2) {
          throw getApiException("updateGatewayEndpointPermissionsByName", 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 updateGatewayEndpointPermissionsByNameRequestBuilder(String endpointName, UpdatedEndpointPermissionsV1 updatedEndpointPermissionsV1) throws ApiException {
    // verify the required parameter 'endpointName' is set
    if (endpointName == null) {
      throw new ApiException(400, "Missing the required parameter 'endpointName' when calling updateGatewayEndpointPermissionsByName");
    }
    // verify the required parameter 'updatedEndpointPermissionsV1' is set
    if (updatedEndpointPermissionsV1 == null) {
      throw new ApiException(400, "Missing the required parameter 'updatedEndpointPermissionsV1' when calling updateGatewayEndpointPermissionsByName");
    }

    HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();

    String localVarPath = "/api/aigateway/v1/endpoints/{endpointName}/permissions"
        .replace("{endpointName}", ApiClient.urlEncode(endpointName.toString()));

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

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

    try {
      byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(updatedEndpointPermissionsV1);
      localVarRequestBuilder.method("PATCH", 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