com.seeq.api.NotifierApi 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 com.seeq.model.EmailerConfigurationOutputV1;
import com.seeq.model.SendEmailInputV1;
import com.seeq.model.StatusMessage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NotifierApi {
private ApiClient apiClient;
private long retryTimeout = 5_000; // Default of 5 seconds
public NotifierApi() {
this(Configuration.getDefaultApiClient());
}
public NotifierApi(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;
}
/**
* Returns the configuration values that may be relevant for using the emailer service.
*
* @return EmailerConfigurationOutputV1
* @throws ApiException if fails to make API call
*/
public EmailerConfigurationOutputV1 getConfiguration() throws ApiException {
ApiClient.ApiResponse localVarResponse = getConfigurationWithHttpInfo();
return localVarResponse != null ? localVarResponse.getData() : null;
}
/**
* Returns the configuration values that may be relevant for using the emailer service.
*
* @throws ApiException if fails to make API call
*/
public ApiClient.ApiResponse getConfigurationWithHttpInfo() throws ApiException {
Map localVarHeaderParams = new HashMap();
return getConfigurationWithHeadersAndHttpInfo(localVarHeaderParams);
}
/**
* Returns the configuration values that may be relevant for using the emailer service.
*
* @param customHeaders a map with custom headers for the HTTP request (required)
* @throws ApiException if fails to make API call
*/
public ApiClient.ApiResponse getConfigurationWithHeadersAndHttpInfo(Map customHeaders) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/notify/configuration";
// query params
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"application/vnd.seeq.v1+json"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "api_key" };
localVarHeaderParams.putAll(customHeaders);
long apiClientInvocationTime = System.currentTimeMillis();
while(true) {
try {
GenericType localVarReturnType = new GenericType() {};
return apiClient.invokeAPIWithHttpInfo(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, 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
}
/**
* Sends an email.
*
* @param body (required)
* @return StatusMessage
* @throws ApiException if fails to make API call
*/
public StatusMessage sendEmail(SendEmailInputV1 body) throws ApiException {
ApiClient.ApiResponse localVarResponse = sendEmailWithHttpInfo(body);
return localVarResponse != null ? localVarResponse.getData() : null;
}
/**
* Sends an email.
*
* @param body (required)
* @throws ApiException if fails to make API call
*/
public ApiClient.ApiResponse sendEmailWithHttpInfo(SendEmailInputV1 body) throws ApiException {
Map localVarHeaderParams = new HashMap();
return sendEmailWithHeadersAndHttpInfo(body, localVarHeaderParams);
}
/**
* Sends an email.
*
* @param body (required)
* @param customHeaders a map with custom headers for the HTTP request (required)
* @throws ApiException if fails to make API call
*/
public ApiClient.ApiResponse sendEmailWithHeadersAndHttpInfo(SendEmailInputV1 body, Map customHeaders) throws ApiException {
Object localVarPostBody = body;
// verify the required parameter 'body' is set
if (body == null) {
throw new ApiException(400, "Missing the required parameter 'body' when calling sendEmail");
}
// create path and map variables
String localVarPath = "/notify/send-email";
// query params
List localVarQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarFormParams = new HashMap();
final String[] localVarAccepts = {
"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" };
localVarHeaderParams.putAll(customHeaders);
long apiClientInvocationTime = System.currentTimeMillis();
while(true) {
try {
GenericType localVarReturnType = new GenericType() {};
return apiClient.invokeAPIWithHttpInfo(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, 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
}
}