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

com.seeq.api.NotifierApi Maven / Gradle / Ivy

There is a newer version: 66.0.0-v202410141803
Show newest version
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.
    * 
    * @param accept API version (optional)
    * @return EmailerConfigurationOutputV1
    * @throws ApiException if fails to make API call
    */
    public EmailerConfigurationOutputV1 getConfiguration(String accept) throws ApiException {
        ApiClient.ApiResponse localVarResponse = getConfigurationWithHttpInfo(accept);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * Returns the configuration values that may be relevant for using the emailer service.
    * 
    * @param accept API version (optional)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getConfigurationWithHttpInfo(String accept) throws ApiException {
        Map localVarHeaderParams = new HashMap();
        return getConfigurationWithHeadersAndHttpInfo(accept, localVarHeaderParams);
        
    }

    /**
    * Returns the configuration values that may be relevant for using the emailer service.
    * 
    * @param accept API version (optional)
    * @param customHeaders a map with custom headers for the HTTP request (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getConfigurationWithHeadersAndHttpInfo(String accept, Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        if (accept != null) {
          localVarHeaderParams.put("Accept", apiClient.parameterToString(accept));
        }
        localVarHeaderParams.putAll(customHeaders);
        return getConfigurationInternal(localVarQueryParams, localVarHeaderParams);
    }
    
    private ApiClient.ApiResponse getConfigurationInternal(List queryParams, Map headerParams) throws ApiException {
        Object localVarPostBody = null;
        // create path and map variables
        String localVarPath = "/notify/configuration";

        // query params
        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" };

        long apiClientInvocationTime = System.currentTimeMillis();
        while(true) {
            try {
                GenericType localVarReturnType = new GenericType() {};
                return apiClient.invokeAPIWithHttpInfo(localVarPath, "GET", 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
    }
    /**
    * Sends an email.
    * 
    * @param accept API version (optional)
    * @param body  (required)
    * @return StatusMessage
    * @throws ApiException if fails to make API call
    */
    public StatusMessage sendEmail(String accept, SendEmailInputV1 body) throws ApiException {
        ApiClient.ApiResponse localVarResponse = sendEmailWithHttpInfo(accept, body);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * Sends an email.
    * 
    * @param accept API version (optional)
    * @param body  (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse sendEmailWithHttpInfo(String accept, SendEmailInputV1 body) throws ApiException {
        Map localVarHeaderParams = new HashMap();
        return sendEmailWithHeadersAndHttpInfo(accept, body, localVarHeaderParams);
        
    }

    /**
    * Sends an email.
    * 
    * @param accept API version (optional)
    * @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(String accept, SendEmailInputV1 body, Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        if (accept != null) {
          localVarHeaderParams.put("Accept", apiClient.parameterToString(accept));
        }
        localVarHeaderParams.putAll(customHeaders);
        return sendEmailInternal(body, localVarQueryParams, localVarHeaderParams);
    }
    
    private ApiClient.ApiResponse sendEmailInternal(SendEmailInputV1 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 sendEmail");
        }
        // create path and map variables
        String localVarPath = "/notify/send-email";

        // query params
        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" };

        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

    /**
    * 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 {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


        ApiClient.ApiResponse localVarResponse = getConfigurationInternal(localVarQueryParams, localVarHeaderParams);
        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 {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


        return getConfigurationInternal(localVarQueryParams, 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 {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


        localVarHeaderParams.putAll(customHeaders);
        return getConfigurationInternal(localVarQueryParams, localVarHeaderParams);
    }


    /**
    * Sends an email.
    *
    * @param body  (required)
    * @return StatusMessage
    * @throws ApiException if fails to make API call
    */
    public StatusMessage sendEmail(SendEmailInputV1 body) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


        ApiClient.ApiResponse localVarResponse = sendEmailInternal(body, localVarQueryParams, localVarHeaderParams);
        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 {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


        return sendEmailInternal(body, localVarQueryParams, 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 {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


        localVarHeaderParams.putAll(customHeaders);
        return sendEmailInternal(body, localVarQueryParams, localVarHeaderParams);
    }

// OVERLOADS END
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy