/*
 * 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.ApiEvent;
import com.cloudera.api.swagger.model.ApiEventQueryResult;

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

public class EventsResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for readEvent
     * @param eventId The UUID of the event to read (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 com.squareup.okhttp.Call readEventCall(String eventId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/events/{eventId}"
            .replaceAll("\\{" + "eventId" + "\\}", apiClient.escapeString(eventId.toString()));

        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 readEventValidateBeforeCall(String eventId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'eventId' is set
        if (eventId == null) {
            throw new ApiException("Missing the required parameter 'eventId' when calling readEvent(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readEventCall(eventId, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Returns a specific event in the system.
     * Returns a specific event in the system
     * @param eventId The UUID of the event to read (required)
     * @return ApiEvent
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiEvent readEvent(String eventId) throws ApiException {
        ApiResponse<ApiEvent> resp = readEventWithHttpInfo(eventId);
        return resp.getData();
    }

    /**
     * Returns a specific event in the system.
     * Returns a specific event in the system
     * @param eventId The UUID of the event to read (required)
     * @return ApiResponse&lt;ApiEvent&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiEvent> readEventWithHttpInfo(String eventId) throws ApiException {
        com.squareup.okhttp.Call call = readEventValidateBeforeCall(eventId, null, null);
        Type localVarReturnType = new TypeToken<ApiEvent>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns a specific event in the system. (asynchronously)
     * Returns a specific event in the system
     * @param eventId The UUID of the event to read (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 com.squareup.okhttp.Call readEventAsync(String eventId, final ApiCallback<ApiEvent> 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 = readEventValidateBeforeCall(eventId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiEvent>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readEvents
     * @param maxResults The maximum number of events to return. (optional, default to 100)
     * @param query The query to perform to find events 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;alert&#x3D;&#x3D;true&lt;/dt&gt; &lt;dd&gt;looks for alerts.&lt;/dd&gt; &lt;dt&gt;alert&#x3D;&#x3D;true;attributes.host!&#x3D;flaky.mysite.com&lt;/dt&gt; &lt;dd&gt;looks for alerts, but exclude those with the host attribute of \&quot;flaky.mysite.com\&quot;.&lt;/dd&gt; &lt;dt&gt;category&#x3D;&#x3D;log_event;attributes.log_level&#x3D;&#x3D;ERROR&lt;/dt&gt; &lt;dd&gt;looks for error log events. Event attribute matching is case sensitive.&lt;/dd&gt; &lt;dt&gt;attributes.service&#x3D;&#x3D;hbase1;content&#x3D;&#x3D;hlog&lt;/dt&gt; &lt;dd&gt;looks for any events from the \&quot;hbase1\&quot; service that mention \&quot;hlog\&quot;.&lt;/dd&gt; &lt;dt&gt;attributes.service&#x3D;&#x3D;hbase1;content!&#x3D;hlog&lt;/dt&gt; &lt;dd&gt;looks for any events from the \&quot;hbase1\&quot; service that do not mention \&quot;hlog\&quot;.&lt;br/&gt; A query must not contain only negative constraints (&lt;em&gt;!&#x3D;&lt;/em&gt;). It returns empty results because there is nothing to perform exclusion on.&lt;/dd&gt; &lt;dt&gt;attributes.role_type&#x3D;&#x3D;NAMENODE;severity&#x3D;&#x3D;critical important&lt;/dt&gt; &lt;dd&gt;looks for any important or critical events related to all NameNodes.&lt;/dd&gt; &lt;dt&gt;severity&#x3D;&#x3D;critical;timeReceived&#x3D;ge&#x3D;2012-05-04T00:00;timeReceived&#x3D;lt&#x3D;2012-05-04T00:10&lt;/dt&gt; &lt;dd&gt;looks for critical events received between the given 10 minute range. &lt;br/&gt; When polling for events, use &lt;em&gt;timeReceived&lt;/em&gt; instead of &lt;em&gt;timeOccurred&lt;/em&gt; because events arrive out of order.&lt;/dd&gt; &lt;/dl&gt;  You may query any fields present in the ApiEvent object. You can also query by event attribute values using the &lt;em&gt;attributes.*&lt;/em&gt; syntax. Values for date time fields (e.g. &lt;em&gt;timeOccurred&lt;/em&gt;, &lt;em&gt;timeReceived&lt;/em&gt;) should be ISO8601 timestamps. &lt;p&gt; The other valid comparators are &lt;em&gt;&#x3D;lt&#x3D;&lt;/em&gt;, &lt;em&gt;&#x3D;le&#x3D;&lt;/em&gt;, &lt;em&gt;&#x3D;ge&#x3D;&lt;/em&gt;, and &lt;em&gt;&#x3D;gt&#x3D;&lt;/em&gt;. They stand for \&quot;&amp;lt;\&quot;, \&quot;&amp;lt;&#x3D;\&quot;, \&quot;&amp;gt;&#x3D;\&quot;, \&quot;&amp;gt;\&quot; respectively. These comparators are only applicable for date time fields. (optional)
     * @param resultOffset Specified the offset of events to return. (optional, default to 0)
     * @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 readEventsCall(java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/events";

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

        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 readEventsValidateBeforeCall(java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = readEventsCall(maxResults, query, resultOffset, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Allows you to query events in the system.
     * Allows you to query events in the system.
     * @param maxResults The maximum number of events to return. (optional, default to 100)
     * @param query The query to perform to find events 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;alert&#x3D;&#x3D;true&lt;/dt&gt; &lt;dd&gt;looks for alerts.&lt;/dd&gt; &lt;dt&gt;alert&#x3D;&#x3D;true;attributes.host!&#x3D;flaky.mysite.com&lt;/dt&gt; &lt;dd&gt;looks for alerts, but exclude those with the host attribute of \&quot;flaky.mysite.com\&quot;.&lt;/dd&gt; &lt;dt&gt;category&#x3D;&#x3D;log_event;attributes.log_level&#x3D;&#x3D;ERROR&lt;/dt&gt; &lt;dd&gt;looks for error log events. Event attribute matching is case sensitive.&lt;/dd&gt; &lt;dt&gt;attributes.service&#x3D;&#x3D;hbase1;content&#x3D;&#x3D;hlog&lt;/dt&gt; &lt;dd&gt;looks for any events from the \&quot;hbase1\&quot; service that mention \&quot;hlog\&quot;.&lt;/dd&gt; &lt;dt&gt;attributes.service&#x3D;&#x3D;hbase1;content!&#x3D;hlog&lt;/dt&gt; &lt;dd&gt;looks for any events from the \&quot;hbase1\&quot; service that do not mention \&quot;hlog\&quot;.&lt;br/&gt; A query must not contain only negative constraints (&lt;em&gt;!&#x3D;&lt;/em&gt;). It returns empty results because there is nothing to perform exclusion on.&lt;/dd&gt; &lt;dt&gt;attributes.role_type&#x3D;&#x3D;NAMENODE;severity&#x3D;&#x3D;critical important&lt;/dt&gt; &lt;dd&gt;looks for any important or critical events related to all NameNodes.&lt;/dd&gt; &lt;dt&gt;severity&#x3D;&#x3D;critical;timeReceived&#x3D;ge&#x3D;2012-05-04T00:00;timeReceived&#x3D;lt&#x3D;2012-05-04T00:10&lt;/dt&gt; &lt;dd&gt;looks for critical events received between the given 10 minute range. &lt;br/&gt; When polling for events, use &lt;em&gt;timeReceived&lt;/em&gt; instead of &lt;em&gt;timeOccurred&lt;/em&gt; because events arrive out of order.&lt;/dd&gt; &lt;/dl&gt;  You may query any fields present in the ApiEvent object. You can also query by event attribute values using the &lt;em&gt;attributes.*&lt;/em&gt; syntax. Values for date time fields (e.g. &lt;em&gt;timeOccurred&lt;/em&gt;, &lt;em&gt;timeReceived&lt;/em&gt;) should be ISO8601 timestamps. &lt;p&gt; The other valid comparators are &lt;em&gt;&#x3D;lt&#x3D;&lt;/em&gt;, &lt;em&gt;&#x3D;le&#x3D;&lt;/em&gt;, &lt;em&gt;&#x3D;ge&#x3D;&lt;/em&gt;, and &lt;em&gt;&#x3D;gt&#x3D;&lt;/em&gt;. They stand for \&quot;&amp;lt;\&quot;, \&quot;&amp;lt;&#x3D;\&quot;, \&quot;&amp;gt;&#x3D;\&quot;, \&quot;&amp;gt;\&quot; respectively. These comparators are only applicable for date time fields. (optional)
     * @param resultOffset Specified the offset of events to return. (optional, default to 0)
     * @return ApiEventQueryResult
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiEventQueryResult readEvents(java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset) throws ApiException {
        ApiResponse<ApiEventQueryResult> resp = readEventsWithHttpInfo(maxResults, query, resultOffset);
        return resp.getData();
    }

    /**
     * Allows you to query events in the system.
     * Allows you to query events in the system.
     * @param maxResults The maximum number of events to return. (optional, default to 100)
     * @param query The query to perform to find events 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;alert&#x3D;&#x3D;true&lt;/dt&gt; &lt;dd&gt;looks for alerts.&lt;/dd&gt; &lt;dt&gt;alert&#x3D;&#x3D;true;attributes.host!&#x3D;flaky.mysite.com&lt;/dt&gt; &lt;dd&gt;looks for alerts, but exclude those with the host attribute of \&quot;flaky.mysite.com\&quot;.&lt;/dd&gt; &lt;dt&gt;category&#x3D;&#x3D;log_event;attributes.log_level&#x3D;&#x3D;ERROR&lt;/dt&gt; &lt;dd&gt;looks for error log events. Event attribute matching is case sensitive.&lt;/dd&gt; &lt;dt&gt;attributes.service&#x3D;&#x3D;hbase1;content&#x3D;&#x3D;hlog&lt;/dt&gt; &lt;dd&gt;looks for any events from the \&quot;hbase1\&quot; service that mention \&quot;hlog\&quot;.&lt;/dd&gt; &lt;dt&gt;attributes.service&#x3D;&#x3D;hbase1;content!&#x3D;hlog&lt;/dt&gt; &lt;dd&gt;looks for any events from the \&quot;hbase1\&quot; service that do not mention \&quot;hlog\&quot;.&lt;br/&gt; A query must not contain only negative constraints (&lt;em&gt;!&#x3D;&lt;/em&gt;). It returns empty results because there is nothing to perform exclusion on.&lt;/dd&gt; &lt;dt&gt;attributes.role_type&#x3D;&#x3D;NAMENODE;severity&#x3D;&#x3D;critical important&lt;/dt&gt; &lt;dd&gt;looks for any important or critical events related to all NameNodes.&lt;/dd&gt; &lt;dt&gt;severity&#x3D;&#x3D;critical;timeReceived&#x3D;ge&#x3D;2012-05-04T00:00;timeReceived&#x3D;lt&#x3D;2012-05-04T00:10&lt;/dt&gt; &lt;dd&gt;looks for critical events received between the given 10 minute range. &lt;br/&gt; When polling for events, use &lt;em&gt;timeReceived&lt;/em&gt; instead of &lt;em&gt;timeOccurred&lt;/em&gt; because events arrive out of order.&lt;/dd&gt; &lt;/dl&gt;  You may query any fields present in the ApiEvent object. You can also query by event attribute values using the &lt;em&gt;attributes.*&lt;/em&gt; syntax. Values for date time fields (e.g. &lt;em&gt;timeOccurred&lt;/em&gt;, &lt;em&gt;timeReceived&lt;/em&gt;) should be ISO8601 timestamps. &lt;p&gt; The other valid comparators are &lt;em&gt;&#x3D;lt&#x3D;&lt;/em&gt;, &lt;em&gt;&#x3D;le&#x3D;&lt;/em&gt;, &lt;em&gt;&#x3D;ge&#x3D;&lt;/em&gt;, and &lt;em&gt;&#x3D;gt&#x3D;&lt;/em&gt;. They stand for \&quot;&amp;lt;\&quot;, \&quot;&amp;lt;&#x3D;\&quot;, \&quot;&amp;gt;&#x3D;\&quot;, \&quot;&amp;gt;\&quot; respectively. These comparators are only applicable for date time fields. (optional)
     * @param resultOffset Specified the offset of events to return. (optional, default to 0)
     * @return ApiResponse&lt;ApiEventQueryResult&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiEventQueryResult> readEventsWithHttpInfo(java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset) throws ApiException {
        com.squareup.okhttp.Call call = readEventsValidateBeforeCall(maxResults, query, resultOffset, null, null);
        Type localVarReturnType = new TypeToken<ApiEventQueryResult>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Allows you to query events in the system. (asynchronously)
     * Allows you to query events in the system.
     * @param maxResults The maximum number of events to return. (optional, default to 100)
     * @param query The query to perform to find events 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;alert&#x3D;&#x3D;true&lt;/dt&gt; &lt;dd&gt;looks for alerts.&lt;/dd&gt; &lt;dt&gt;alert&#x3D;&#x3D;true;attributes.host!&#x3D;flaky.mysite.com&lt;/dt&gt; &lt;dd&gt;looks for alerts, but exclude those with the host attribute of \&quot;flaky.mysite.com\&quot;.&lt;/dd&gt; &lt;dt&gt;category&#x3D;&#x3D;log_event;attributes.log_level&#x3D;&#x3D;ERROR&lt;/dt&gt; &lt;dd&gt;looks for error log events. Event attribute matching is case sensitive.&lt;/dd&gt; &lt;dt&gt;attributes.service&#x3D;&#x3D;hbase1;content&#x3D;&#x3D;hlog&lt;/dt&gt; &lt;dd&gt;looks for any events from the \&quot;hbase1\&quot; service that mention \&quot;hlog\&quot;.&lt;/dd&gt; &lt;dt&gt;attributes.service&#x3D;&#x3D;hbase1;content!&#x3D;hlog&lt;/dt&gt; &lt;dd&gt;looks for any events from the \&quot;hbase1\&quot; service that do not mention \&quot;hlog\&quot;.&lt;br/&gt; A query must not contain only negative constraints (&lt;em&gt;!&#x3D;&lt;/em&gt;). It returns empty results because there is nothing to perform exclusion on.&lt;/dd&gt; &lt;dt&gt;attributes.role_type&#x3D;&#x3D;NAMENODE;severity&#x3D;&#x3D;critical important&lt;/dt&gt; &lt;dd&gt;looks for any important or critical events related to all NameNodes.&lt;/dd&gt; &lt;dt&gt;severity&#x3D;&#x3D;critical;timeReceived&#x3D;ge&#x3D;2012-05-04T00:00;timeReceived&#x3D;lt&#x3D;2012-05-04T00:10&lt;/dt&gt; &lt;dd&gt;looks for critical events received between the given 10 minute range. &lt;br/&gt; When polling for events, use &lt;em&gt;timeReceived&lt;/em&gt; instead of &lt;em&gt;timeOccurred&lt;/em&gt; because events arrive out of order.&lt;/dd&gt; &lt;/dl&gt;  You may query any fields present in the ApiEvent object. You can also query by event attribute values using the &lt;em&gt;attributes.*&lt;/em&gt; syntax. Values for date time fields (e.g. &lt;em&gt;timeOccurred&lt;/em&gt;, &lt;em&gt;timeReceived&lt;/em&gt;) should be ISO8601 timestamps. &lt;p&gt; The other valid comparators are &lt;em&gt;&#x3D;lt&#x3D;&lt;/em&gt;, &lt;em&gt;&#x3D;le&#x3D;&lt;/em&gt;, &lt;em&gt;&#x3D;ge&#x3D;&lt;/em&gt;, and &lt;em&gt;&#x3D;gt&#x3D;&lt;/em&gt;. They stand for \&quot;&amp;lt;\&quot;, \&quot;&amp;lt;&#x3D;\&quot;, \&quot;&amp;gt;&#x3D;\&quot;, \&quot;&amp;gt;\&quot; respectively. These comparators are only applicable for date time fields. (optional)
     * @param resultOffset Specified the offset of events to return. (optional, default to 0)
     * @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 readEventsAsync(java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, final ApiCallback<ApiEventQueryResult> 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 = readEventsValidateBeforeCall(maxResults, query, resultOffset, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiEventQueryResult>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
