/*
 * Cloudera Manager API
 * <h1>Cloudera Manager API v57</h1>       <p>Introduced in Cloudera Manager 7.13.1</p>       <p><a href=\"http://www.cloudera.com/documentation.html\">Cloudera Product Documentation</a></p>
 *
 * OpenAPI spec version: 7.13.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.ApiImpalaCancelResponse;
import com.cloudera.api.swagger.model.ApiImpalaQueryAttributeList;
import com.cloudera.api.swagger.model.ApiImpalaQueryDetailsResponse;
import com.cloudera.api.swagger.model.ApiImpalaQueryResponse;

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

public class ImpalaQueriesResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for cancelImpalaQuery
     * @param clusterName  (required)
     * @param queryId The queryId to cancel (required)
     * @param serviceName The name of the service (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call cancelImpalaQueryCall(String clusterName, String queryId, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/impalaQueries/{queryId}/cancel"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "queryId" + "\\}", apiClient.escapeString(queryId.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = 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 okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.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, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call cancelImpalaQueryValidateBeforeCall(String clusterName, String queryId, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling cancelImpalaQuery(Async)");
        }
        // verify the required parameter 'queryId' is set
        if (queryId == null) {
            throw new ApiException("Missing the required parameter 'queryId' when calling cancelImpalaQuery(Async)");
        }
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling cancelImpalaQuery(Async)");
        }

        okhttp3.Call call = cancelImpalaQueryCall(clusterName, queryId, serviceName, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Cancels an Impala Query.
     * Cancels an Impala Query. &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param queryId The queryId to cancel (required)
     * @param serviceName The name of the service (required)
     * @return ApiImpalaCancelResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiImpalaCancelResponse cancelImpalaQuery(String clusterName, String queryId, String serviceName) throws ApiException {
        ApiResponse<ApiImpalaCancelResponse> resp = cancelImpalaQueryWithHttpInfo(clusterName, queryId, serviceName);
        return resp.getData();
    }

    /**
     * Cancels an Impala Query.
     * Cancels an Impala Query. &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param queryId The queryId to cancel (required)
     * @param serviceName The name of the service (required)
     * @return ApiResponse&lt;ApiImpalaCancelResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiImpalaCancelResponse> cancelImpalaQueryWithHttpInfo(String clusterName, String queryId, String serviceName) throws ApiException {
        okhttp3.Call call = cancelImpalaQueryValidateBeforeCall(clusterName, queryId, serviceName, null, null);
        Type localVarReturnType = new TypeToken<ApiImpalaCancelResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Cancels an Impala Query. (asynchronously)
     * Cancels an Impala Query. &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param queryId The queryId to cancel (required)
     * @param serviceName The name of the service (required)
     * @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 okhttp3.Call cancelImpalaQueryAsync(String clusterName, String queryId, String serviceName, final ApiCallback<ApiImpalaCancelResponse> 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);
                }
            };
        }

        okhttp3.Call call = cancelImpalaQueryValidateBeforeCall(clusterName, queryId, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiImpalaCancelResponse>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getImpalaQueries
     * @param clusterName  (required)
     * @param serviceName The name of the service (required)
     * @param filter A filter to apply to the queries. A basic filter tests the value of an attribute and looks something like &#x27;rowsFetched &#x3D; 1&#x27; or &#x27;user &#x3D; root&#x27;. Multiple basic filters can be combined into a complex expression using standard and / or boolean logic and parenthesis. An example of a complex filter is: &#x27;query_duration &gt; 5s and (user &#x3D; root or user &#x3D; myUserName)&#x27;. An example of expected full query string in requested URL is: &#x27;?filter&#x3D;(query_duration &gt; 5s and (user &#x3D; root or user &#x3D; myUserName))&#x27;. (optional)
     * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the &#x27;to&#x27; time). (optional)
     * @param limit The maximum number of queries to return. Queries will be returned in the following order: &lt;ul&gt; &lt;li&gt; All executing queries, ordered from longest to shortest running &lt;/li&gt; &lt;li&gt; All completed queries order by end time descending. &lt;/li&gt; &lt;/ul&gt; (optional, default to 100)
     * @param offset The offset to start returning queries from. This is useful for paging through lists of queries. Note that this has non-deterministic behavior if executing queries are included in the response because they can disappear from the list while paging. To exclude executing queries from the response and a &#x27;executing &#x3D; false&#x27; clause to your filter. (optional, default to 0)
     * @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 okhttp3.Call getImpalaQueriesCall(String clusterName, String serviceName, String filter, String from, java.math.BigDecimal limit, java.math.BigDecimal offset, String to, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/impalaQueries"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (filter != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("filter", filter));
        if (from != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("from", from));
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (offset != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("offset", offset));
        if (to != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("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 okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.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, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getImpalaQueriesValidateBeforeCall(String clusterName, String serviceName, String filter, String from, java.math.BigDecimal limit, java.math.BigDecimal offset, String to, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling getImpalaQueries(Async)");
        }
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getImpalaQueries(Async)");
        }

        okhttp3.Call call = getImpalaQueriesCall(clusterName, serviceName, filter, from, limit, offset, to, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Returns a list of queries that satisfy the filter.
     * Returns a list of queries that satisfy the filter &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName The name of the service (required)
     * @param filter A filter to apply to the queries. A basic filter tests the value of an attribute and looks something like &#x27;rowsFetched &#x3D; 1&#x27; or &#x27;user &#x3D; root&#x27;. Multiple basic filters can be combined into a complex expression using standard and / or boolean logic and parenthesis. An example of a complex filter is: &#x27;query_duration &gt; 5s and (user &#x3D; root or user &#x3D; myUserName)&#x27;. An example of expected full query string in requested URL is: &#x27;?filter&#x3D;(query_duration &gt; 5s and (user &#x3D; root or user &#x3D; myUserName))&#x27;. (optional)
     * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the &#x27;to&#x27; time). (optional)
     * @param limit The maximum number of queries to return. Queries will be returned in the following order: &lt;ul&gt; &lt;li&gt; All executing queries, ordered from longest to shortest running &lt;/li&gt; &lt;li&gt; All completed queries order by end time descending. &lt;/li&gt; &lt;/ul&gt; (optional, default to 100)
     * @param offset The offset to start returning queries from. This is useful for paging through lists of queries. Note that this has non-deterministic behavior if executing queries are included in the response because they can disappear from the list while paging. To exclude executing queries from the response and a &#x27;executing &#x3D; false&#x27; clause to your filter. (optional, default to 0)
     * @param to End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @return ApiImpalaQueryResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiImpalaQueryResponse getImpalaQueries(String clusterName, String serviceName, String filter, String from, java.math.BigDecimal limit, java.math.BigDecimal offset, String to) throws ApiException {
        ApiResponse<ApiImpalaQueryResponse> resp = getImpalaQueriesWithHttpInfo(clusterName, serviceName, filter, from, limit, offset, to);
        return resp.getData();
    }

    /**
     * Returns a list of queries that satisfy the filter.
     * Returns a list of queries that satisfy the filter &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName The name of the service (required)
     * @param filter A filter to apply to the queries. A basic filter tests the value of an attribute and looks something like &#x27;rowsFetched &#x3D; 1&#x27; or &#x27;user &#x3D; root&#x27;. Multiple basic filters can be combined into a complex expression using standard and / or boolean logic and parenthesis. An example of a complex filter is: &#x27;query_duration &gt; 5s and (user &#x3D; root or user &#x3D; myUserName)&#x27;. An example of expected full query string in requested URL is: &#x27;?filter&#x3D;(query_duration &gt; 5s and (user &#x3D; root or user &#x3D; myUserName))&#x27;. (optional)
     * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the &#x27;to&#x27; time). (optional)
     * @param limit The maximum number of queries to return. Queries will be returned in the following order: &lt;ul&gt; &lt;li&gt; All executing queries, ordered from longest to shortest running &lt;/li&gt; &lt;li&gt; All completed queries order by end time descending. &lt;/li&gt; &lt;/ul&gt; (optional, default to 100)
     * @param offset The offset to start returning queries from. This is useful for paging through lists of queries. Note that this has non-deterministic behavior if executing queries are included in the response because they can disappear from the list while paging. To exclude executing queries from the response and a &#x27;executing &#x3D; false&#x27; clause to your filter. (optional, default to 0)
     * @param to End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @return ApiResponse&lt;ApiImpalaQueryResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiImpalaQueryResponse> getImpalaQueriesWithHttpInfo(String clusterName, String serviceName, String filter, String from, java.math.BigDecimal limit, java.math.BigDecimal offset, String to) throws ApiException {
        okhttp3.Call call = getImpalaQueriesValidateBeforeCall(clusterName, serviceName, filter, from, limit, offset, to, null, null);
        Type localVarReturnType = new TypeToken<ApiImpalaQueryResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns a list of queries that satisfy the filter. (asynchronously)
     * Returns a list of queries that satisfy the filter &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName The name of the service (required)
     * @param filter A filter to apply to the queries. A basic filter tests the value of an attribute and looks something like &#x27;rowsFetched &#x3D; 1&#x27; or &#x27;user &#x3D; root&#x27;. Multiple basic filters can be combined into a complex expression using standard and / or boolean logic and parenthesis. An example of a complex filter is: &#x27;query_duration &gt; 5s and (user &#x3D; root or user &#x3D; myUserName)&#x27;. An example of expected full query string in requested URL is: &#x27;?filter&#x3D;(query_duration &gt; 5s and (user &#x3D; root or user &#x3D; myUserName))&#x27;. (optional)
     * @param from Start of the period to query in ISO 8601 format (defaults to 5 minutes before the &#x27;to&#x27; time). (optional)
     * @param limit The maximum number of queries to return. Queries will be returned in the following order: &lt;ul&gt; &lt;li&gt; All executing queries, ordered from longest to shortest running &lt;/li&gt; &lt;li&gt; All completed queries order by end time descending. &lt;/li&gt; &lt;/ul&gt; (optional, default to 100)
     * @param offset The offset to start returning queries from. This is useful for paging through lists of queries. Note that this has non-deterministic behavior if executing queries are included in the response because they can disappear from the list while paging. To exclude executing queries from the response and a &#x27;executing &#x3D; false&#x27; clause to your filter. (optional, default to 0)
     * @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 okhttp3.Call getImpalaQueriesAsync(String clusterName, String serviceName, String filter, String from, java.math.BigDecimal limit, java.math.BigDecimal offset, String to, final ApiCallback<ApiImpalaQueryResponse> 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);
                }
            };
        }

        okhttp3.Call call = getImpalaQueriesValidateBeforeCall(clusterName, serviceName, filter, from, limit, offset, to, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiImpalaQueryResponse>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getImpalaQueryAttributes
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call getImpalaQueryAttributesCall(String clusterName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/impalaQueries/attributes"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = 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 okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.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, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getImpalaQueryAttributesValidateBeforeCall(String clusterName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling getImpalaQueryAttributes(Async)");
        }
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getImpalaQueryAttributes(Async)");
        }

        okhttp3.Call call = getImpalaQueryAttributesCall(clusterName, serviceName, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Returns the list of all attributes that the Service Monitor can associate with Impala queries.
     * Returns the list of all attributes that the Service Monitor can associate with Impala queries. &lt;p&gt; Examples of attributes include the user who issued the query and the number of HDFS bytes read by the query. &lt;p&gt; These attributes can be used to search for specific Impala queries through the getImpalaQueries API. For example the &#x27;user&#x27; attribute could be used in the search &#x27;user &#x3D; root&#x27;. If the attribute is numeric it can also be used as a metric in a tsquery (ie, &#x27;select hdfs_bytes_read from IMPALA_QUERIES&#x27;). &lt;p&gt; Note that this response is identical for all Impala services. &lt;p&gt; Available since API v6.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @return ApiImpalaQueryAttributeList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiImpalaQueryAttributeList getImpalaQueryAttributes(String clusterName, String serviceName) throws ApiException {
        ApiResponse<ApiImpalaQueryAttributeList> resp = getImpalaQueryAttributesWithHttpInfo(clusterName, serviceName);
        return resp.getData();
    }

    /**
     * Returns the list of all attributes that the Service Monitor can associate with Impala queries.
     * Returns the list of all attributes that the Service Monitor can associate with Impala queries. &lt;p&gt; Examples of attributes include the user who issued the query and the number of HDFS bytes read by the query. &lt;p&gt; These attributes can be used to search for specific Impala queries through the getImpalaQueries API. For example the &#x27;user&#x27; attribute could be used in the search &#x27;user &#x3D; root&#x27;. If the attribute is numeric it can also be used as a metric in a tsquery (ie, &#x27;select hdfs_bytes_read from IMPALA_QUERIES&#x27;). &lt;p&gt; Note that this response is identical for all Impala services. &lt;p&gt; Available since API v6.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;ApiImpalaQueryAttributeList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiImpalaQueryAttributeList> getImpalaQueryAttributesWithHttpInfo(String clusterName, String serviceName) throws ApiException {
        okhttp3.Call call = getImpalaQueryAttributesValidateBeforeCall(clusterName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<ApiImpalaQueryAttributeList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the list of all attributes that the Service Monitor can associate with Impala queries. (asynchronously)
     * Returns the list of all attributes that the Service Monitor can associate with Impala queries. &lt;p&gt; Examples of attributes include the user who issued the query and the number of HDFS bytes read by the query. &lt;p&gt; These attributes can be used to search for specific Impala queries through the getImpalaQueries API. For example the &#x27;user&#x27; attribute could be used in the search &#x27;user &#x3D; root&#x27;. If the attribute is numeric it can also be used as a metric in a tsquery (ie, &#x27;select hdfs_bytes_read from IMPALA_QUERIES&#x27;). &lt;p&gt; Note that this response is identical for all Impala services. &lt;p&gt; Available since API v6.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @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 okhttp3.Call getImpalaQueryAttributesAsync(String clusterName, String serviceName, final ApiCallback<ApiImpalaQueryAttributeList> 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);
                }
            };
        }

        okhttp3.Call call = getImpalaQueryAttributesValidateBeforeCall(clusterName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiImpalaQueryAttributeList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getQueryDetails
     * @param clusterName  (required)
     * @param queryId The queryId to get information about (required)
     * @param serviceName  (required)
     * @param format There are two valid format parameters: &lt;ul&gt; &lt;li&gt; &#x27;text&#x27;: this is a text based, human readable representation of the Impala runtime profile. &lt;/li&gt; &lt;li&gt; &#x27;thrift_encoded&#x27;: this a compact-thrift, base64 encoded representation of the Impala RuntimeProfile.thrift object. See the Impala documentation for more details. &lt;/li&gt; &lt;/ul&gt; (optional, default to text)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call getQueryDetailsCall(String clusterName, String queryId, String serviceName, String format, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/impalaQueries/{queryId}"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "queryId" + "\\}", apiClient.escapeString(queryId.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (format != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("format", format));

        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 okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.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, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getQueryDetailsValidateBeforeCall(String clusterName, String queryId, String serviceName, String format, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling getQueryDetails(Async)");
        }
        // verify the required parameter 'queryId' is set
        if (queryId == null) {
            throw new ApiException("Missing the required parameter 'queryId' when calling getQueryDetails(Async)");
        }
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getQueryDetails(Async)");
        }

        okhttp3.Call call = getQueryDetailsCall(clusterName, queryId, serviceName, format, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Returns details about the query.
     * Returns details about the query. Not all queries have details, check the detailsAvailable field from the getQueries response. &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param queryId The queryId to get information about (required)
     * @param serviceName  (required)
     * @param format There are two valid format parameters: &lt;ul&gt; &lt;li&gt; &#x27;text&#x27;: this is a text based, human readable representation of the Impala runtime profile. &lt;/li&gt; &lt;li&gt; &#x27;thrift_encoded&#x27;: this a compact-thrift, base64 encoded representation of the Impala RuntimeProfile.thrift object. See the Impala documentation for more details. &lt;/li&gt; &lt;/ul&gt; (optional, default to text)
     * @return ApiImpalaQueryDetailsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiImpalaQueryDetailsResponse getQueryDetails(String clusterName, String queryId, String serviceName, String format) throws ApiException {
        ApiResponse<ApiImpalaQueryDetailsResponse> resp = getQueryDetailsWithHttpInfo(clusterName, queryId, serviceName, format);
        return resp.getData();
    }

    /**
     * Returns details about the query.
     * Returns details about the query. Not all queries have details, check the detailsAvailable field from the getQueries response. &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param queryId The queryId to get information about (required)
     * @param serviceName  (required)
     * @param format There are two valid format parameters: &lt;ul&gt; &lt;li&gt; &#x27;text&#x27;: this is a text based, human readable representation of the Impala runtime profile. &lt;/li&gt; &lt;li&gt; &#x27;thrift_encoded&#x27;: this a compact-thrift, base64 encoded representation of the Impala RuntimeProfile.thrift object. See the Impala documentation for more details. &lt;/li&gt; &lt;/ul&gt; (optional, default to text)
     * @return ApiResponse&lt;ApiImpalaQueryDetailsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiImpalaQueryDetailsResponse> getQueryDetailsWithHttpInfo(String clusterName, String queryId, String serviceName, String format) throws ApiException {
        okhttp3.Call call = getQueryDetailsValidateBeforeCall(clusterName, queryId, serviceName, format, null, null);
        Type localVarReturnType = new TypeToken<ApiImpalaQueryDetailsResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns details about the query. (asynchronously)
     * Returns details about the query. Not all queries have details, check the detailsAvailable field from the getQueries response. &lt;p&gt; Available since API v4.
     * @param clusterName  (required)
     * @param queryId The queryId to get information about (required)
     * @param serviceName  (required)
     * @param format There are two valid format parameters: &lt;ul&gt; &lt;li&gt; &#x27;text&#x27;: this is a text based, human readable representation of the Impala runtime profile. &lt;/li&gt; &lt;li&gt; &#x27;thrift_encoded&#x27;: this a compact-thrift, base64 encoded representation of the Impala RuntimeProfile.thrift object. See the Impala documentation for more details. &lt;/li&gt; &lt;/ul&gt; (optional, default to text)
     * @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 okhttp3.Call getQueryDetailsAsync(String clusterName, String queryId, String serviceName, String format, final ApiCallback<ApiImpalaQueryDetailsResponse> 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);
                }
            };
        }

        okhttp3.Call call = getQueryDetailsValidateBeforeCall(clusterName, queryId, serviceName, format, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiImpalaQueryDetailsResponse>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
