/*
 * 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.ApiAuditList;
import java.io.File;

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

public class AuditsResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for readAudits
     * @param endTime End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @param maxResults Maximum number of audits to return (optional, default to 100)
     * @param query The query to filter out audits in the system. It accepts querying the intersection of a list of constraints, joined together with semicolons (without spaces). For example: &lt;/p&gt; &lt;dl&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command.&lt;/dd&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus;username!&#x3D;foo&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command but excludes audits generated by foo username&lt;/dd&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus;source&#x3D;&#x3D;*oozie*&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command and source that contains the string &#x27;oozie&#x27;. &lt;/dd&gt; &lt;/dl&gt;  Following are valid selectors for the query (if applicable to the audit): &lt;table&gt; &lt;tr&gt; &lt;th&gt; Selector &lt;/th&gt; &lt;th&gt; Description &lt;/th&gt; &lt;th&gt; SCM &lt;/th&gt; &lt;th&gt; HDFS &lt;/th&gt; &lt;th&gt; HBase &lt;/th&gt; &lt;th&gt; Hive &lt;/th&gt; &lt;th&gt; Impala &lt;/th&gt; &lt;th&gt; Sentry &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; service &lt;/td&gt; &lt;td&gt; Cloudera Manager Service &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; operation &lt;/td&gt; &lt;td&gt; Operation name &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; username &lt;/td&gt; &lt;td&gt; User name &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; impersonator&lt;/td&gt; &lt;td&gt; Impersonator &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; ip_address &lt;/td&gt; &lt;td&gt; IP Address &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; allowed &lt;/td&gt; &lt;td&gt; Whether the request was allowed or denied &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; qualifier&lt;/td&gt; &lt;td&gt; Column qualifier &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; source &lt;/td&gt; &lt;td&gt; Source resource of the operation  &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; destination &lt;/td&gt; &lt;td&gt; Destination resource of the operation &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; hostIpAddress &lt;/td&gt; &lt;td&gt; Host IP Address &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; role &lt;/td&gt; &lt;td&gt; Cloudera Manager Role &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; family &lt;/td&gt; &lt;td&gt; Column family &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; database_name &lt;/td&gt; &lt;td&gt; Database name &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; table_name &lt;/td&gt; &lt;td&gt; Table name &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; object_type &lt;/td&gt; &lt;td&gt; Type of object being handled &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; operation_text &lt;/td&gt; &lt;td&gt; Command/query text &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt; The only supported operator is &lt;em&gt;\&quot;;\&quot;&lt;/em&gt; (Boolean AND). Boolean OR is not supported. &lt;p&gt; The supported comparators are &lt;em&gt;&#x3D;&#x3D;&lt;/em&gt; and &lt;em&gt;!&#x3D;&lt;/em&gt; Note that \&quot;LIKE\&quot; comparison is supported using the wild card syntax, for example &lt;em&gt;foo&#x3D;&#x3D;*value*&lt;/em&gt;. Asterisk is interpreted as a wild card character and must not be part of the value. (LIKE comparison queries are converted to standard SQL LIKE syntax, so any % (%25) character in a value that also contains a wild card will be interpreted as a wild card.) &lt;p/&gt; Available since API v8. A subset of these features is available since v4. (optional)
     * @param resultOffset Offset of audits to return (optional, default to 0)
     * @param startTime Start of the period to query in ISO 8601 format (defaults to 1 day ago relative to endTime). (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 okhttp3.Call readAuditsCall(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/audits";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (endTime != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("endTime", endTime));
        if (maxResults != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("maxResults", maxResults));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (resultOffset != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("resultOffset", resultOffset));
        if (startTime != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("startTime", startTime));

        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 readAuditsValidateBeforeCall(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {

        okhttp3.Call call = readAuditsCall(endTime, maxResults, query, resultOffset, startTime, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Fetch audit events from Cloudera Manager (CM) and CM managed services like HDFS, HBase, Impala, Hive, and Sentry.
     * Fetch audit events from Cloudera Manager (CM) and CM managed services like HDFS, HBase, Impala, Hive, and Sentry. &lt;p&gt; By default, this call will fetch the first 100 audit events (sorted from most recent to oldest) corresponding to a 1 day window based on provided end time (which defaults to the  current CM server time). The &lt;em&gt;startTime&lt;/em&gt; and &lt;em&gt;endTime&lt;/em&gt; parameters can be used to control the window being queried. &lt;p&gt; Audit events for CM managed services are only retrieved if Cloudera Navigator server is running.
     * @param endTime End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @param maxResults Maximum number of audits to return (optional, default to 100)
     * @param query The query to filter out audits in the system. It accepts querying the intersection of a list of constraints, joined together with semicolons (without spaces). For example: &lt;/p&gt; &lt;dl&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command.&lt;/dd&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus;username!&#x3D;foo&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command but excludes audits generated by foo username&lt;/dd&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus;source&#x3D;&#x3D;*oozie*&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command and source that contains the string &#x27;oozie&#x27;. &lt;/dd&gt; &lt;/dl&gt;  Following are valid selectors for the query (if applicable to the audit): &lt;table&gt; &lt;tr&gt; &lt;th&gt; Selector &lt;/th&gt; &lt;th&gt; Description &lt;/th&gt; &lt;th&gt; SCM &lt;/th&gt; &lt;th&gt; HDFS &lt;/th&gt; &lt;th&gt; HBase &lt;/th&gt; &lt;th&gt; Hive &lt;/th&gt; &lt;th&gt; Impala &lt;/th&gt; &lt;th&gt; Sentry &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; service &lt;/td&gt; &lt;td&gt; Cloudera Manager Service &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; operation &lt;/td&gt; &lt;td&gt; Operation name &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; username &lt;/td&gt; &lt;td&gt; User name &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; impersonator&lt;/td&gt; &lt;td&gt; Impersonator &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; ip_address &lt;/td&gt; &lt;td&gt; IP Address &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; allowed &lt;/td&gt; &lt;td&gt; Whether the request was allowed or denied &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; qualifier&lt;/td&gt; &lt;td&gt; Column qualifier &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; source &lt;/td&gt; &lt;td&gt; Source resource of the operation  &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; destination &lt;/td&gt; &lt;td&gt; Destination resource of the operation &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; hostIpAddress &lt;/td&gt; &lt;td&gt; Host IP Address &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; role &lt;/td&gt; &lt;td&gt; Cloudera Manager Role &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; family &lt;/td&gt; &lt;td&gt; Column family &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; database_name &lt;/td&gt; &lt;td&gt; Database name &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; table_name &lt;/td&gt; &lt;td&gt; Table name &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; object_type &lt;/td&gt; &lt;td&gt; Type of object being handled &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; operation_text &lt;/td&gt; &lt;td&gt; Command/query text &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt; The only supported operator is &lt;em&gt;\&quot;;\&quot;&lt;/em&gt; (Boolean AND). Boolean OR is not supported. &lt;p&gt; The supported comparators are &lt;em&gt;&#x3D;&#x3D;&lt;/em&gt; and &lt;em&gt;!&#x3D;&lt;/em&gt; Note that \&quot;LIKE\&quot; comparison is supported using the wild card syntax, for example &lt;em&gt;foo&#x3D;&#x3D;*value*&lt;/em&gt;. Asterisk is interpreted as a wild card character and must not be part of the value. (LIKE comparison queries are converted to standard SQL LIKE syntax, so any % (%25) character in a value that also contains a wild card will be interpreted as a wild card.) &lt;p/&gt; Available since API v8. A subset of these features is available since v4. (optional)
     * @param resultOffset Offset of audits to return (optional, default to 0)
     * @param startTime Start of the period to query in ISO 8601 format (defaults to 1 day ago relative to endTime). (optional)
     * @return ApiAuditList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiAuditList readAudits(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime) throws ApiException {
        ApiResponse<ApiAuditList> resp = readAuditsWithHttpInfo(endTime, maxResults, query, resultOffset, startTime);
        return resp.getData();
    }

    /**
     * Fetch audit events from Cloudera Manager (CM) and CM managed services like HDFS, HBase, Impala, Hive, and Sentry.
     * Fetch audit events from Cloudera Manager (CM) and CM managed services like HDFS, HBase, Impala, Hive, and Sentry. &lt;p&gt; By default, this call will fetch the first 100 audit events (sorted from most recent to oldest) corresponding to a 1 day window based on provided end time (which defaults to the  current CM server time). The &lt;em&gt;startTime&lt;/em&gt; and &lt;em&gt;endTime&lt;/em&gt; parameters can be used to control the window being queried. &lt;p&gt; Audit events for CM managed services are only retrieved if Cloudera Navigator server is running.
     * @param endTime End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @param maxResults Maximum number of audits to return (optional, default to 100)
     * @param query The query to filter out audits in the system. It accepts querying the intersection of a list of constraints, joined together with semicolons (without spaces). For example: &lt;/p&gt; &lt;dl&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command.&lt;/dd&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus;username!&#x3D;foo&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command but excludes audits generated by foo username&lt;/dd&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus;source&#x3D;&#x3D;*oozie*&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command and source that contains the string &#x27;oozie&#x27;. &lt;/dd&gt; &lt;/dl&gt;  Following are valid selectors for the query (if applicable to the audit): &lt;table&gt; &lt;tr&gt; &lt;th&gt; Selector &lt;/th&gt; &lt;th&gt; Description &lt;/th&gt; &lt;th&gt; SCM &lt;/th&gt; &lt;th&gt; HDFS &lt;/th&gt; &lt;th&gt; HBase &lt;/th&gt; &lt;th&gt; Hive &lt;/th&gt; &lt;th&gt; Impala &lt;/th&gt; &lt;th&gt; Sentry &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; service &lt;/td&gt; &lt;td&gt; Cloudera Manager Service &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; operation &lt;/td&gt; &lt;td&gt; Operation name &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; username &lt;/td&gt; &lt;td&gt; User name &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; impersonator&lt;/td&gt; &lt;td&gt; Impersonator &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; ip_address &lt;/td&gt; &lt;td&gt; IP Address &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; allowed &lt;/td&gt; &lt;td&gt; Whether the request was allowed or denied &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; qualifier&lt;/td&gt; &lt;td&gt; Column qualifier &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; source &lt;/td&gt; &lt;td&gt; Source resource of the operation  &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; destination &lt;/td&gt; &lt;td&gt; Destination resource of the operation &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; hostIpAddress &lt;/td&gt; &lt;td&gt; Host IP Address &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; role &lt;/td&gt; &lt;td&gt; Cloudera Manager Role &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; family &lt;/td&gt; &lt;td&gt; Column family &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; database_name &lt;/td&gt; &lt;td&gt; Database name &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; table_name &lt;/td&gt; &lt;td&gt; Table name &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; object_type &lt;/td&gt; &lt;td&gt; Type of object being handled &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; operation_text &lt;/td&gt; &lt;td&gt; Command/query text &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt; The only supported operator is &lt;em&gt;\&quot;;\&quot;&lt;/em&gt; (Boolean AND). Boolean OR is not supported. &lt;p&gt; The supported comparators are &lt;em&gt;&#x3D;&#x3D;&lt;/em&gt; and &lt;em&gt;!&#x3D;&lt;/em&gt; Note that \&quot;LIKE\&quot; comparison is supported using the wild card syntax, for example &lt;em&gt;foo&#x3D;&#x3D;*value*&lt;/em&gt;. Asterisk is interpreted as a wild card character and must not be part of the value. (LIKE comparison queries are converted to standard SQL LIKE syntax, so any % (%25) character in a value that also contains a wild card will be interpreted as a wild card.) &lt;p/&gt; Available since API v8. A subset of these features is available since v4. (optional)
     * @param resultOffset Offset of audits to return (optional, default to 0)
     * @param startTime Start of the period to query in ISO 8601 format (defaults to 1 day ago relative to endTime). (optional)
     * @return ApiResponse&lt;ApiAuditList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiAuditList> readAuditsWithHttpInfo(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime) throws ApiException {
        okhttp3.Call call = readAuditsValidateBeforeCall(endTime, maxResults, query, resultOffset, startTime, null, null);
        Type localVarReturnType = new TypeToken<ApiAuditList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Fetch audit events from Cloudera Manager (CM) and CM managed services like HDFS, HBase, Impala, Hive, and Sentry. (asynchronously)
     * Fetch audit events from Cloudera Manager (CM) and CM managed services like HDFS, HBase, Impala, Hive, and Sentry. &lt;p&gt; By default, this call will fetch the first 100 audit events (sorted from most recent to oldest) corresponding to a 1 day window based on provided end time (which defaults to the  current CM server time). The &lt;em&gt;startTime&lt;/em&gt; and &lt;em&gt;endTime&lt;/em&gt; parameters can be used to control the window being queried. &lt;p&gt; Audit events for CM managed services are only retrieved if Cloudera Navigator server is running.
     * @param endTime End of the period to query in ISO 8601 format (defaults to current time). (optional, default to now)
     * @param maxResults Maximum number of audits to return (optional, default to 100)
     * @param query The query to filter out audits in the system. It accepts querying the intersection of a list of constraints, joined together with semicolons (without spaces). For example: &lt;/p&gt; &lt;dl&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command.&lt;/dd&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus;username!&#x3D;foo&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command but excludes audits generated by foo username&lt;/dd&gt; &lt;dt&gt;command&#x3D;&#x3D;listStatus;source&#x3D;&#x3D;*oozie*&lt;/dt&gt; &lt;dd&gt;looks for audits with listStatus command and source that contains the string &#x27;oozie&#x27;. &lt;/dd&gt; &lt;/dl&gt;  Following are valid selectors for the query (if applicable to the audit): &lt;table&gt; &lt;tr&gt; &lt;th&gt; Selector &lt;/th&gt; &lt;th&gt; Description &lt;/th&gt; &lt;th&gt; SCM &lt;/th&gt; &lt;th&gt; HDFS &lt;/th&gt; &lt;th&gt; HBase &lt;/th&gt; &lt;th&gt; Hive &lt;/th&gt; &lt;th&gt; Impala &lt;/th&gt; &lt;th&gt; Sentry &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; service &lt;/td&gt; &lt;td&gt; Cloudera Manager Service &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; operation &lt;/td&gt; &lt;td&gt; Operation name &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; username &lt;/td&gt; &lt;td&gt; User name &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; impersonator&lt;/td&gt; &lt;td&gt; Impersonator &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; ip_address &lt;/td&gt; &lt;td&gt; IP Address &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; allowed &lt;/td&gt; &lt;td&gt; Whether the request was allowed or denied &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; qualifier&lt;/td&gt; &lt;td&gt; Column qualifier &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; source &lt;/td&gt; &lt;td&gt; Source resource of the operation  &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; destination &lt;/td&gt; &lt;td&gt; Destination resource of the operation &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; hostIpAddress &lt;/td&gt; &lt;td&gt; Host IP Address &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; role &lt;/td&gt; &lt;td&gt; Cloudera Manager Role &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; family &lt;/td&gt; &lt;td&gt; Column family &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; database_name &lt;/td&gt; &lt;td&gt; Database name &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; table_name &lt;/td&gt; &lt;td&gt; Table name &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; object_type &lt;/td&gt; &lt;td&gt; Type of object being handled &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; operation_text &lt;/td&gt; &lt;td&gt; Command/query text &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;td&gt; x &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt; The only supported operator is &lt;em&gt;\&quot;;\&quot;&lt;/em&gt; (Boolean AND). Boolean OR is not supported. &lt;p&gt; The supported comparators are &lt;em&gt;&#x3D;&#x3D;&lt;/em&gt; and &lt;em&gt;!&#x3D;&lt;/em&gt; Note that \&quot;LIKE\&quot; comparison is supported using the wild card syntax, for example &lt;em&gt;foo&#x3D;&#x3D;*value*&lt;/em&gt;. Asterisk is interpreted as a wild card character and must not be part of the value. (LIKE comparison queries are converted to standard SQL LIKE syntax, so any % (%25) character in a value that also contains a wild card will be interpreted as a wild card.) &lt;p/&gt; Available since API v8. A subset of these features is available since v4. (optional)
     * @param resultOffset Offset of audits to return (optional, default to 0)
     * @param startTime Start of the period to query in ISO 8601 format (defaults to 1 day ago relative to endTime). (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 okhttp3.Call readAuditsAsync(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime, final ApiCallback<ApiAuditList> 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 = readAuditsValidateBeforeCall(endTime, maxResults, query, resultOffset, startTime, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiAuditList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for streamAudits
     * @param endTime  (optional, default to now)
     * @param maxResults  (optional, default to 100)
     * @param query  (optional)
     * @param resultOffset  (optional, default to 0)
     * @param startTime  (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 okhttp3.Call streamAuditsCall(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/audits/stream";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (endTime != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("endTime", endTime));
        if (maxResults != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("maxResults", maxResults));
        if (query != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
        if (resultOffset != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("resultOffset", resultOffset));
        if (startTime != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("startTime", startTime));

        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 streamAuditsValidateBeforeCall(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {

        okhttp3.Call call = streamAuditsCall(endTime, maxResults, query, resultOffset, startTime, progressListener, progressRequestListener);
        return call;

    }

    /**
     * 
     * 
     * @param endTime  (optional, default to now)
     * @param maxResults  (optional, default to 100)
     * @param query  (optional)
     * @param resultOffset  (optional, default to 0)
     * @param startTime  (optional)
     * @return File
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public File streamAudits(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime) throws ApiException {
        ApiResponse<File> resp = streamAuditsWithHttpInfo(endTime, maxResults, query, resultOffset, startTime);
        return resp.getData();
    }

    /**
     * 
     * 
     * @param endTime  (optional, default to now)
     * @param maxResults  (optional, default to 100)
     * @param query  (optional)
     * @param resultOffset  (optional, default to 0)
     * @param startTime  (optional)
     * @return ApiResponse&lt;File&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<File> streamAuditsWithHttpInfo(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime) throws ApiException {
        okhttp3.Call call = streamAuditsValidateBeforeCall(endTime, maxResults, query, resultOffset, startTime, null, null);
        Type localVarReturnType = new TypeToken<File>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     *  (asynchronously)
     * 
     * @param endTime  (optional, default to now)
     * @param maxResults  (optional, default to 100)
     * @param query  (optional)
     * @param resultOffset  (optional, default to 0)
     * @param startTime  (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 okhttp3.Call streamAuditsAsync(String endTime, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String startTime, final ApiCallback<File> 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 = streamAuditsValidateBeforeCall(endTime, maxResults, query, resultOffset, startTime, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<File>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
