com.seeq.api.ReportsApi Maven / Gradle / Ivy
package com.seeq.api;
import com.seeq.ApiException;
import com.seeq.ApiClient;
import com.seeq.Configuration;
import com.seeq.model.*;
import com.seeq.Pair;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.ProcessingException;
import java.io.File;
import com.seeq.model.ReportInputV1;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ReportsApi {
private ApiClient apiClient;
private long retryTimeout = 5_000; // Default of 5 seconds
public ReportsApi() {
this(Configuration.getDefaultApiClient());
}
public ReportsApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public void setRetryTimeout(long retryTimeout) {
this.retryTimeout = retryTimeout;
}
public long getRetryTimeout() {
return this.retryTimeout;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Generate report in the specified output format. Currently only pptx is supported.
*
* @param body ReportInput defining the report output format (required)
* @return File
* @throws ApiException if fails to make API call
*/
public File createReport(ReportInputV1 body) throws ApiException {
ApiClient.ApiResponse localVarResponse = createReportWithHttpInfo(body);
return localVarResponse != null ? localVarResponse.getData() : null;
}
/**
* Generate report in the specified output format. Currently only pptx is supported.
*
* @param body ReportInput defining the report output format (required)
* @throws ApiException if fails to make API call
*/
public ApiClient.ApiResponse createReportWithHttpInfo(ReportInputV1 body) throws ApiException {
Map localVarHeaderParams = new HashMap();
return createReportWithHeadersAndHttpInfo(body, localVarHeaderParams);
}
/**
* Generate report in the specified output format. Currently only pptx is supported.
*
* @param body ReportInput defining the report output format (required)
* @param customHeaders a map with custom headers for the HTTP request (required)
* @throws ApiException if fails to make API call
*/
public ApiClient.ApiResponse createReportWithHeadersAndHttpInfo(ReportInputV1 body, Map customHeaders) throws ApiException {
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
localVarHeaderParams.putAll(customHeaders);
return createReportInternal(body, localVarQueryParams, localVarHeaderParams);
}
private ApiClient.ApiResponse createReportInternal(ReportInputV1 body, List queryParams, Map headerParams) throws ApiException {
Object localVarPostBody = body;
// verify the required body parameter 'body' is set
if (body == null) {
throw new ApiException(400, "Missing the required body parameter 'body' when calling createReport");
}
// create path and map variables
String localVarPath = "/reports";
// query params
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.seeq.v1+json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
"application/vnd.seeq.v1+json"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "api_key" };
long apiClientInvocationTime = System.currentTimeMillis();
while(true) {
try {
GenericType localVarReturnType = new GenericType() {};
return apiClient.invokeAPIWithHttpInfo(localVarPath, "POST", queryParams, localVarPostBody, headerParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
// Possible exceptions:
// ===================
// * ResponseProcessingException - in case processing of a received HTTP response fails (e.g. in a filter or
// during conversion of the response entity data to an instance of a particular Java type).
// * ProcessingException - in case the request processing or subsequent I/O operation fails.
// * WebApplicationException - in case the response status code of the response returned by the server is not
// successful and the specified response type is not Response.
// * ApiException for exceptions wrapped by ApiClient. Most likely all WebApplicationException are wrapped
// in ApiException(s)
} catch (ApiException | ProcessingException e) {
if (e instanceof ProcessingException || e instanceof ApiException && ((ApiException) e).getCode() == 504) {
long elapsedTime = System.currentTimeMillis() - apiClientInvocationTime;
if (elapsedTime <= this.retryTimeout && this.retryTimeout != 0) {
continue;
}
}
throw e;
}
} // while
}
// OVERLOADS START
// OVERLOADS END
}