/*
 * Cloudera Manager API
 * <h1>Cloudera Manager API v50</h1>       <p>Introduced in Cloudera Manager 7.8.1</p>       <p><a href=\"http://www.cloudera.com/documentation.html\">Cloudera Product Documentation</a></p>
 *
 * OpenAPI spec version: 7.8.1
 * 
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */


package com.cloudera.api.swagger;

import com.cloudera.api.swagger.client.ApiCallback;
import com.cloudera.api.swagger.client.ApiClient;
import com.cloudera.api.swagger.client.ApiException;
import com.cloudera.api.swagger.client.ApiResponse;
import com.cloudera.api.swagger.client.Configuration;
import com.cloudera.api.swagger.client.Pair;
import com.cloudera.api.swagger.client.ProgressRequestBody;
import com.cloudera.api.swagger.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.cloudera.api.swagger.model.ApiMetricSchemaList;
import com.cloudera.api.swagger.model.ApiTimeSeriesEntityAttributeList;
import com.cloudera.api.swagger.model.ApiTimeSeriesEntityTypeList;
import com.cloudera.api.swagger.model.ApiTimeSeriesRequest;
import com.cloudera.api.swagger.model.ApiTimeSeriesResponseList;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TimeSeriesResourceApi {
    private ApiClient apiClient;

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

    public TimeSeriesResourceApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * Build call for getEntityTypeAttributes
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getEntityTypeAttributesCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/timeseries/entityTypeAttributes";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getEntityTypeAttributesValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = getEntityTypeAttributesCall(progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieve all metric entity type attributes monitored by Cloudera Manager.
     * Retrieve all metric entity type attributes monitored by Cloudera Manager. &lt;p/&gt; Available since API v11.
     * @return ApiTimeSeriesEntityAttributeList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiTimeSeriesEntityAttributeList getEntityTypeAttributes() throws ApiException {
        ApiResponse<ApiTimeSeriesEntityAttributeList> resp = getEntityTypeAttributesWithHttpInfo();
        return resp.getData();
    }

    /**
     * Retrieve all metric entity type attributes monitored by Cloudera Manager.
     * Retrieve all metric entity type attributes monitored by Cloudera Manager. &lt;p/&gt; Available since API v11.
     * @return ApiResponse&lt;ApiTimeSeriesEntityAttributeList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiTimeSeriesEntityAttributeList> getEntityTypeAttributesWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getEntityTypeAttributesValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<ApiTimeSeriesEntityAttributeList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieve all metric entity type attributes monitored by Cloudera Manager. (asynchronously)
     * Retrieve all metric entity type attributes monitored by Cloudera Manager. &lt;p/&gt; Available since API v11.
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getEntityTypeAttributesAsync(final ApiCallback<ApiTimeSeriesEntityAttributeList> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = getEntityTypeAttributesValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiTimeSeriesEntityAttributeList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getEntityTypes
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getEntityTypesCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/timeseries/entityTypes";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getEntityTypesValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = getEntityTypesCall(progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieve all metric entity types monitored by Cloudera Manager.
     * Retrieve all metric entity types monitored by Cloudera Manager. It is guaranteed that parent types appear before their children. &lt;p/&gt; Available since API v11.
     * @return ApiTimeSeriesEntityTypeList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiTimeSeriesEntityTypeList getEntityTypes() throws ApiException {
        ApiResponse<ApiTimeSeriesEntityTypeList> resp = getEntityTypesWithHttpInfo();
        return resp.getData();
    }

    /**
     * Retrieve all metric entity types monitored by Cloudera Manager.
     * Retrieve all metric entity types monitored by Cloudera Manager. It is guaranteed that parent types appear before their children. &lt;p/&gt; Available since API v11.
     * @return ApiResponse&lt;ApiTimeSeriesEntityTypeList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiTimeSeriesEntityTypeList> getEntityTypesWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getEntityTypesValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<ApiTimeSeriesEntityTypeList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieve all metric entity types monitored by Cloudera Manager. (asynchronously)
     * Retrieve all metric entity types monitored by Cloudera Manager. It is guaranteed that parent types appear before their children. &lt;p/&gt; Available since API v11.
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getEntityTypesAsync(final ApiCallback<ApiTimeSeriesEntityTypeList> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = getEntityTypesValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiTimeSeriesEntityTypeList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMetricSchema
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMetricSchemaCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/timeseries/schema";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMetricSchemaValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = getMetricSchemaCall(progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieve schema for all metrics.
     * Retrieve schema for all metrics &lt;p/&gt; The schema is fixed for a product version. The schema may change for an API versions &lt;p/&gt; Available since API v4.
     * @return ApiMetricSchemaList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiMetricSchemaList getMetricSchema() throws ApiException {
        ApiResponse<ApiMetricSchemaList> resp = getMetricSchemaWithHttpInfo();
        return resp.getData();
    }

    /**
     * Retrieve schema for all metrics.
     * Retrieve schema for all metrics &lt;p/&gt; The schema is fixed for a product version. The schema may change for an API versions &lt;p/&gt; Available since API v4.
     * @return ApiResponse&lt;ApiMetricSchemaList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiMetricSchemaList> getMetricSchemaWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getMetricSchemaValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<ApiMetricSchemaList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieve schema for all metrics. (asynchronously)
     * Retrieve schema for all metrics &lt;p/&gt; The schema is fixed for a product version. The schema may change for an API versions &lt;p/&gt; Available since API v4.
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getMetricSchemaAsync(final ApiCallback<ApiMetricSchemaList> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = getMetricSchemaValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiMetricSchemaList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for queryTimeSeries
     * @param contentType to return the response in. The content types \&quot;application/json\&quot; and \&quot;text/csv\&quot; are supported. This defaults to \&quot;application/json\&quot;. If \&quot;text/csv\&quot; is specified then we return one row per time series data point, and we don&#39;t return any of the metadata. (optional, default to application/json)
     * @param desiredRollup Aggregate rollup level desired for the response data. Valid values are RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, and WEEKLY. Note that if the mustUseDesiredRollup parameter is not set, then the monitoring server can decide to return a different rollup level. (optional, default to RAW)
     * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the end of the period). (optional)
     * @param mustUseDesiredRollup If set then the tsquery will return data with the desired aggregate rollup level. (optional, default to false)
     * @param query Tsquery to run against the CM time-series data store. (optional)
     * @param to End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call queryTimeSeriesCall(String contentType, String desiredRollup, String from, Boolean mustUseDesiredRollup, String query, String to, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/timeseries";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        if (contentType != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "contentType", contentType));
        if (desiredRollup != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "desiredRollup", desiredRollup));
        if (from != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "from", from));
        if (mustUseDesiredRollup != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "mustUseDesiredRollup", mustUseDesiredRollup));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "query", query));
        if (to != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "to", to));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call queryTimeSeriesValidateBeforeCall(String contentType, String desiredRollup, String from, Boolean mustUseDesiredRollup, String query, String to, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = queryTimeSeriesCall(contentType, desiredRollup, from, mustUseDesiredRollup, query, to, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.  Please see the &lt;a href&#x3D;\&quot;https://docs.cloudera.com/r/cm_tsquery\&quot;&gt; tsquery language documentation&lt;/a&gt;. &lt;p/&gt; Available since API v6.
     * @param contentType to return the response in. The content types \&quot;application/json\&quot; and \&quot;text/csv\&quot; are supported. This defaults to \&quot;application/json\&quot;. If \&quot;text/csv\&quot; is specified then we return one row per time series data point, and we don&#39;t return any of the metadata. (optional, default to application/json)
     * @param desiredRollup Aggregate rollup level desired for the response data. Valid values are RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, and WEEKLY. Note that if the mustUseDesiredRollup parameter is not set, then the monitoring server can decide to return a different rollup level. (optional, default to RAW)
     * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the end of the period). (optional)
     * @param mustUseDesiredRollup If set then the tsquery will return data with the desired aggregate rollup level. (optional, default to false)
     * @param query Tsquery to run against the CM time-series data store. (optional)
     * @param to End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @return ApiTimeSeriesResponseList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiTimeSeriesResponseList queryTimeSeries(String contentType, String desiredRollup, String from, Boolean mustUseDesiredRollup, String query, String to) throws ApiException {
        ApiResponse<ApiTimeSeriesResponseList> resp = queryTimeSeriesWithHttpInfo(contentType, desiredRollup, from, mustUseDesiredRollup, query, to);
        return resp.getData();
    }

    /**
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.  Please see the &lt;a href&#x3D;\&quot;https://docs.cloudera.com/r/cm_tsquery\&quot;&gt; tsquery language documentation&lt;/a&gt;. &lt;p/&gt; Available since API v6.
     * @param contentType to return the response in. The content types \&quot;application/json\&quot; and \&quot;text/csv\&quot; are supported. This defaults to \&quot;application/json\&quot;. If \&quot;text/csv\&quot; is specified then we return one row per time series data point, and we don&#39;t return any of the metadata. (optional, default to application/json)
     * @param desiredRollup Aggregate rollup level desired for the response data. Valid values are RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, and WEEKLY. Note that if the mustUseDesiredRollup parameter is not set, then the monitoring server can decide to return a different rollup level. (optional, default to RAW)
     * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the end of the period). (optional)
     * @param mustUseDesiredRollup If set then the tsquery will return data with the desired aggregate rollup level. (optional, default to false)
     * @param query Tsquery to run against the CM time-series data store. (optional)
     * @param to End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @return ApiResponse&lt;ApiTimeSeriesResponseList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiTimeSeriesResponseList> queryTimeSeriesWithHttpInfo(String contentType, String desiredRollup, String from, Boolean mustUseDesiredRollup, String query, String to) throws ApiException {
        com.squareup.okhttp.Call call = queryTimeSeriesValidateBeforeCall(contentType, desiredRollup, from, mustUseDesiredRollup, query, to, null, null);
        Type localVarReturnType = new TypeToken<ApiTimeSeriesResponseList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery. (asynchronously)
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.  Please see the &lt;a href&#x3D;\&quot;https://docs.cloudera.com/r/cm_tsquery\&quot;&gt; tsquery language documentation&lt;/a&gt;. &lt;p/&gt; Available since API v6.
     * @param contentType to return the response in. The content types \&quot;application/json\&quot; and \&quot;text/csv\&quot; are supported. This defaults to \&quot;application/json\&quot;. If \&quot;text/csv\&quot; is specified then we return one row per time series data point, and we don&#39;t return any of the metadata. (optional, default to application/json)
     * @param desiredRollup Aggregate rollup level desired for the response data. Valid values are RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, and WEEKLY. Note that if the mustUseDesiredRollup parameter is not set, then the monitoring server can decide to return a different rollup level. (optional, default to RAW)
     * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the end of the period). (optional)
     * @param mustUseDesiredRollup If set then the tsquery will return data with the desired aggregate rollup level. (optional, default to false)
     * @param query Tsquery to run against the CM time-series data store. (optional)
     * @param to End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call queryTimeSeriesAsync(String contentType, String desiredRollup, String from, Boolean mustUseDesiredRollup, String query, String to, final ApiCallback<ApiTimeSeriesResponseList> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = queryTimeSeriesValidateBeforeCall(contentType, desiredRollup, from, mustUseDesiredRollup, query, to, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiTimeSeriesResponseList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for queryTimeSeries_0
     * @param body Request object containing information used when retrieving timeseries data. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call queryTimeSeries_0Call(ApiTimeSeriesRequest body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/timeseries";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call queryTimeSeries_0ValidateBeforeCall(ApiTimeSeriesRequest body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = queryTimeSeries_0Call(body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request.
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request. This method differs from queryTimeSeries() in v6 that this could accept query strings that are longer than HTTP GET request limit.  Available since API v11.
     * @param body Request object containing information used when retrieving timeseries data. (optional)
     * @return ApiTimeSeriesResponseList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiTimeSeriesResponseList queryTimeSeries_0(ApiTimeSeriesRequest body) throws ApiException {
        ApiResponse<ApiTimeSeriesResponseList> resp = queryTimeSeries_0WithHttpInfo(body);
        return resp.getData();
    }

    /**
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request.
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request. This method differs from queryTimeSeries() in v6 that this could accept query strings that are longer than HTTP GET request limit.  Available since API v11.
     * @param body Request object containing information used when retrieving timeseries data. (optional)
     * @return ApiResponse&lt;ApiTimeSeriesResponseList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiTimeSeriesResponseList> queryTimeSeries_0WithHttpInfo(ApiTimeSeriesRequest body) throws ApiException {
        com.squareup.okhttp.Call call = queryTimeSeries_0ValidateBeforeCall(body, null, null);
        Type localVarReturnType = new TypeToken<ApiTimeSeriesResponseList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request. (asynchronously)
     * Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request. This method differs from queryTimeSeries() in v6 that this could accept query strings that are longer than HTTP GET request limit.  Available since API v11.
     * @param body Request object containing information used when retrieving timeseries data. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call queryTimeSeries_0Async(ApiTimeSeriesRequest body, final ApiCallback<ApiTimeSeriesResponseList> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = queryTimeSeries_0ValidateBeforeCall(body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiTimeSeriesResponseList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
