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

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

There is a newer version: 66.0.0-v202407310200
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.GetMetricsOutputV1;
import com.seeq.model.StatusMessageBase;
import com.seeq.model.ThresholdMetricInputV1;
import com.seeq.model.ThresholdMetricOutputV1;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MetricsApi {
    private ApiClient apiClient;
    private long retryTimeout = 5_000; // Default of 5 seconds

    public MetricsApi() {
        this(Configuration.getDefaultApiClient());
    }

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

    /**
    * Archive a metric
    * 
    * @param id The Seeq ID for the metric (required)
    * @return StatusMessageBase
    * @throws ApiException if fails to make API call
    */
    public StatusMessageBase archiveMetric(String id) throws ApiException {
        ApiClient.ApiResponse localVarResponse = archiveMetricWithHttpInfo(id);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * Archive a metric
    * 
    * @param id The Seeq ID for the metric (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse archiveMetricWithHttpInfo(String id) throws ApiException {
        Map localVarHeaderParams = new HashMap();
        return archiveMetricWithHeadersAndHttpInfo(id, localVarHeaderParams);
        
    }

    /**
    * Archive a metric
    * 
    * @param id The Seeq ID for the metric (required)
    * @param customHeaders a map with custom headers for the HTTP request (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse archiveMetricWithHeadersAndHttpInfo(String id, Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
                localVarHeaderParams.putAll(customHeaders);
        return archiveMetricInternal(id, localVarQueryParams, localVarHeaderParams);
    }
    
    private ApiClient.ApiResponse archiveMetricInternal(String id, List queryParams, Map headerParams) throws ApiException {
        Object localVarPostBody = null;
        // verify the required path parameter 'id' is set
        if (id == null) {
            throw new ApiException(400, "Missing the required path parameter 'id' when calling archiveMetric");
        }
        // create path and map variables
        String localVarPath = "/metrics/{id}"
          .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        // 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, "DELETE", 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
    }
    /**
    * Create a metric that defines thresholds
    * 
    * @param body  (required)
    * @return ThresholdMetricOutputV1
    * @throws ApiException if fails to make API call
    */
    public ThresholdMetricOutputV1 createThresholdMetric(ThresholdMetricInputV1 body) throws ApiException {
        ApiClient.ApiResponse localVarResponse = createThresholdMetricWithHttpInfo(body);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * Create a metric that defines thresholds
    * 
    * @param body  (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse createThresholdMetricWithHttpInfo(ThresholdMetricInputV1 body) throws ApiException {
        Map localVarHeaderParams = new HashMap();
        return createThresholdMetricWithHeadersAndHttpInfo(body, localVarHeaderParams);
        
    }

    /**
    * Create a metric that defines thresholds
    * 
    * @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 createThresholdMetricWithHeadersAndHttpInfo(ThresholdMetricInputV1 body, Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
                localVarHeaderParams.putAll(customHeaders);
        return createThresholdMetricInternal(body, localVarQueryParams, localVarHeaderParams);
    }
    
    private ApiClient.ApiResponse createThresholdMetricInternal(ThresholdMetricInputV1 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 createThresholdMetric");
        }
        // create path and map variables
        String localVarPath = "/metrics/thresholds";

        // 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
    }
    /**
    * Get metric
    * 
    * @param id The Seeq ID for the metric (required)
    * @return ThresholdMetricOutputV1
    * @throws ApiException if fails to make API call
    */
    public ThresholdMetricOutputV1 getMetric(String id) throws ApiException {
        ApiClient.ApiResponse localVarResponse = getMetricWithHttpInfo(id);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * Get metric
    * 
    * @param id The Seeq ID for the metric (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getMetricWithHttpInfo(String id) throws ApiException {
        Map localVarHeaderParams = new HashMap();
        return getMetricWithHeadersAndHttpInfo(id, localVarHeaderParams);
        
    }

    /**
    * Get metric
    * 
    * @param id The Seeq ID for the metric (required)
    * @param customHeaders a map with custom headers for the HTTP request (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getMetricWithHeadersAndHttpInfo(String id, Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
                localVarHeaderParams.putAll(customHeaders);
        return getMetricInternal(id, localVarQueryParams, localVarHeaderParams);
    }
    
    private ApiClient.ApiResponse getMetricInternal(String id, List queryParams, Map headerParams) throws ApiException {
        Object localVarPostBody = null;
        // verify the required path parameter 'id' is set
        if (id == null) {
            throw new ApiException(400, "Missing the required path parameter 'id' when calling getMetric");
        }
        // create path and map variables
        String localVarPath = "/metrics/{id}"
          .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        // 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
    }
    /**
    * List metrics
    * 
    * @param offset The pagination offset, the index of the first metric that will be returned in this page of results (optional, default to 0)
    * @param limit The pagination limit, the total number of metrics that will be returned in this page of results (optional, default to 40)
    * @return GetMetricsOutputV1
    * @throws ApiException if fails to make API call
    */
    public GetMetricsOutputV1 getMetrics(Integer offset, Integer limit) throws ApiException {
        ApiClient.ApiResponse localVarResponse = getMetricsWithHttpInfo(offset, limit);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * List metrics
    * 
    * @param offset The pagination offset, the index of the first metric that will be returned in this page of results (optional, default to 0)
    * @param limit The pagination limit, the total number of metrics that will be returned in this page of results (optional, default to 40)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getMetricsWithHttpInfo(Integer offset, Integer limit) throws ApiException {
        Map localVarHeaderParams = new HashMap();
        return getMetricsWithHeadersAndHttpInfo(offset, limit, localVarHeaderParams);
        
    }

    /**
    * List metrics
    * 
    * @param offset The pagination offset, the index of the first metric that will be returned in this page of results (optional, default to 0)
    * @param limit The pagination limit, the total number of metrics that will be returned in this page of results (optional, default to 40)
    * @param customHeaders a map with custom headers for the HTTP request (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getMetricsWithHeadersAndHttpInfo(Integer offset, Integer limit, Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit));
                localVarHeaderParams.putAll(customHeaders);
        return getMetricsInternal(localVarQueryParams, localVarHeaderParams);
    }
    
    private ApiClient.ApiResponse getMetricsInternal(List queryParams, Map headerParams) throws ApiException {
        Object localVarPostBody = null;
        // create path and map variables
        String localVarPath = "/metrics";

        // 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
    }
    /**
    * Updates a metric that defines thresholds
    * 
    * @param id The Seeq ID for the metric (required)
    * @param body  (required)
    * @return ThresholdMetricOutputV1
    * @throws ApiException if fails to make API call
    */
    public ThresholdMetricOutputV1 putThresholdMetric(String id, ThresholdMetricInputV1 body) throws ApiException {
        ApiClient.ApiResponse localVarResponse = putThresholdMetricWithHttpInfo(id, body);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * Updates a metric that defines thresholds
    * 
    * @param id The Seeq ID for the metric (required)
    * @param body  (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse putThresholdMetricWithHttpInfo(String id, ThresholdMetricInputV1 body) throws ApiException {
        Map localVarHeaderParams = new HashMap();
        return putThresholdMetricWithHeadersAndHttpInfo(id, body, localVarHeaderParams);
        
    }

    /**
    * Updates a metric that defines thresholds
    * 
    * @param id The Seeq ID for the metric (required)
    * @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 putThresholdMetricWithHeadersAndHttpInfo(String id, ThresholdMetricInputV1 body, Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();
                localVarHeaderParams.putAll(customHeaders);
        return putThresholdMetricInternal(id, body, localVarQueryParams, localVarHeaderParams);
    }
    
    private ApiClient.ApiResponse putThresholdMetricInternal(String id, ThresholdMetricInputV1 body, List queryParams, Map headerParams) throws ApiException {
        Object localVarPostBody = body;
        // verify the required path parameter 'id' is set
        if (id == null) {
            throw new ApiException(400, "Missing the required path parameter 'id' when calling putThresholdMetric");
        }
        // verify the required body parameter 'body' is set
        if (body == null) {
            throw new ApiException(400, "Missing the required body parameter 'body' when calling putThresholdMetric");
        }
        // create path and map variables
        String localVarPath = "/metrics/thresholds/{id}"
          .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()));

        // 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

    /**
    * List metrics
    *
    * @param offset The pagination offset, the index of the first metric that will be returned in this page of results (optional)
    * @return GetMetricsOutputV1
    * @throws ApiException if fails to make API call
    */
    public GetMetricsOutputV1 getMetrics(Integer offset) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();

        localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));

        ApiClient.ApiResponse localVarResponse = getMetricsInternal(localVarQueryParams, localVarHeaderParams);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }

    /**
    * List metrics
    * @param offset The pagination offset, the index of the first metric that will be returned in this page of results (optional)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getMetricsWithHttpInfo(Integer offset) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();

        localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));

        return getMetricsInternal(localVarQueryParams, localVarHeaderParams);
    }

    /**
    * List metrics
    *
    * @param offset The pagination offset, the index of the first metric that will be returned in this page of results (optional)
    * @param customHeaders a map with custom headers for the HTTP request (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getMetricsWithHeadersAndHttpInfo(Integer offset, Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();

        localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));

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


    /**
    * List metrics
    *
    *
    * @return GetMetricsOutputV1
    * @throws ApiException if fails to make API call
    */
    public GetMetricsOutputV1 getMetrics() throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


        ApiClient.ApiResponse localVarResponse = getMetricsInternal(localVarQueryParams, localVarHeaderParams);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }

    /**
    * List metrics
    *
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getMetricsWithHttpInfo() throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


        return getMetricsInternal(localVarQueryParams, localVarHeaderParams);
    }

    /**
    * List metrics
    *
    *
    * @param customHeaders a map with custom headers for the HTTP request (required)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getMetricsWithHeadersAndHttpInfo(Map customHeaders) throws ApiException {
        List localVarQueryParams = new ArrayList();
        Map localVarHeaderParams = new HashMap();


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

// OVERLOADS END
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy