com.dominodatalab.pub.rest.ProjectsFilesApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of domino-java-client Show documentation
Show all versions of domino-java-client Show documentation
Domino Data Lab API Client to connect to Domino web services using Java HTTP Client.
/*
* 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.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 ProjectsFilesApi {
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 ProjectsFilesApi() {
this(new ApiClient());
}
public ProjectsFilesApi(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;
}
/**
* Returns the contents of a file
* Return the raw contents of a file in a project at given commit.
* @param projectId Id of the project to return files for (required)
* @param commitId Id of a commit in the project repository to list files from (required)
* @param path Path in the project's repository to the file. It must be url-encoded and is case-sensitive. (required)
* @return java.io.InputStream
* @throws ApiException if fails to make API call
*/
public java.io.InputStream getProjectFileContents(String projectId, String commitId, String path) throws ApiException {
ApiResponse localVarResponse = getProjectFileContentsWithHttpInfo(projectId, commitId, path);
return localVarResponse.getData();
}
/**
* Returns the contents of a file
* Return the raw contents of a file in a project at given commit.
* @param projectId Id of the project to return files for (required)
* @param commitId Id of a commit in the project repository to list files from (required)
* @param path Path in the project's repository to the file. It must be url-encoded and is case-sensitive. (required)
* @return ApiResponse<java.io.InputStream>
* @throws ApiException if fails to make API call
*/
public ApiResponse getProjectFileContentsWithHttpInfo(String projectId, String commitId, String path) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = getProjectFileContentsRequestBuilder(projectId, commitId, path);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("getProjectFileContents", 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 getProjectFileContentsRequestBuilder(String projectId, String commitId, String path) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(400, "Missing the required parameter 'projectId' when calling getProjectFileContents");
}
// verify the required parameter 'commitId' is set
if (commitId == null) {
throw new ApiException(400, "Missing the required parameter 'commitId' when calling getProjectFileContents");
}
// verify the required parameter 'path' is set
if (path == null) {
throw new ApiException(400, "Missing the required parameter 'path' when calling getProjectFileContents");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/api/projects/v1/projects/{projectId}/files/{commitId}/{path}/content"
.replace("{projectId}", ApiClient.urlEncode(projectId.toString()))
.replace("{commitId}", ApiClient.urlEncode(commitId.toString()))
.replace("{path}", ApiClient.urlEncode(path.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;
}
/**
* Returns the contents of a file (deprecated, use v1 endpoint instead)
* Return the raw contents of a file in a project at given commit.
* @param projectId Id of the project to return files for (required)
* @param commitId Id of a commit in the project repository to list files from (required)
* @param path Path in the project's repository to the file. It must be url-encoded and is case-sensitive. (required)
* @return java.io.InputStream
* @throws ApiException if fails to make API call
*/
public java.io.InputStream getProjectFileContentsDeprecated(String projectId, String commitId, String path) throws ApiException {
ApiResponse localVarResponse = getProjectFileContentsDeprecatedWithHttpInfo(projectId, commitId, path);
return localVarResponse.getData();
}
/**
* Returns the contents of a file (deprecated, use v1 endpoint instead)
* Return the raw contents of a file in a project at given commit.
* @param projectId Id of the project to return files for (required)
* @param commitId Id of a commit in the project repository to list files from (required)
* @param path Path in the project's repository to the file. It must be url-encoded and is case-sensitive. (required)
* @return ApiResponse<java.io.InputStream>
* @throws ApiException if fails to make API call
*/
public ApiResponse getProjectFileContentsDeprecatedWithHttpInfo(String projectId, String commitId, String path) throws ApiException {
HttpRequest.Builder localVarRequestBuilder = getProjectFileContentsDeprecatedRequestBuilder(projectId, commitId, path);
try {
HttpResponse localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (memberVarResponseInterceptor != null) {
memberVarResponseInterceptor.accept(localVarResponse);
}
try {
if (localVarResponse.statusCode()/ 100 != 2) {
throw getApiException("getProjectFileContentsDeprecated", 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 getProjectFileContentsDeprecatedRequestBuilder(String projectId, String commitId, String path) throws ApiException {
// verify the required parameter 'projectId' is set
if (projectId == null) {
throw new ApiException(400, "Missing the required parameter 'projectId' when calling getProjectFileContentsDeprecated");
}
// verify the required parameter 'commitId' is set
if (commitId == null) {
throw new ApiException(400, "Missing the required parameter 'commitId' when calling getProjectFileContentsDeprecated");
}
// verify the required parameter 'path' is set
if (path == null) {
throw new ApiException(400, "Missing the required parameter 'path' when calling getProjectFileContentsDeprecated");
}
HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
String localVarPath = "/api/projects/beta/projects/{projectId}/files/{commitId}/{path}/content"
.replace("{projectId}", ApiClient.urlEncode(projectId.toString()))
.replace("{commitId}", ApiClient.urlEncode(commitId.toString()))
.replace("{path}", ApiClient.urlEncode(path.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;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy