/*
 * 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.ApiActivity;
import com.cloudera.api.swagger.model.ApiActivityList;
import com.cloudera.api.swagger.model.ApiMetricList;

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

public class ActivitiesResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for getMetrics
     * @param activityId The name of the activity. (required)
     * @param clusterName The name of the cluster. (required)
     * @param serviceName The name of the service. (required)
     * @param from Start of the period to query. (optional)
     * @param metrics Filter for which metrics to query. (optional)
     * @param to End of the period to query. (optional, default to now)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @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 getMetricsCall(String activityId, String clusterName, String serviceName, String from, List<String> metrics, String to, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/activities/{activityId}/metrics"
            .replaceAll("\\{" + "activityId" + "\\}", apiClient.escapeString(activityId.toString()))
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        if (from != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "from", from));
        if (metrics != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "metrics", metrics));
        if (to != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "to", to));
        if (view != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "view", view));

        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 getMetricsValidateBeforeCall(String activityId, String clusterName, String serviceName, String from, List<String> metrics, String to, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'activityId' is set
        if (activityId == null) {
            throw new ApiException("Missing the required parameter 'activityId' when calling getMetrics(Async)");
        }
        
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling getMetrics(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getMetrics(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getMetricsCall(activityId, clusterName, serviceName, from, metrics, to, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Fetch metric readings for a particular activity.
     * Fetch metric readings for a particular activity. &lt;p&gt; By default, this call will look up all metrics available for the activity. If only specific metrics are desired, use the &lt;i&gt;metrics&lt;/i&gt; parameter. &lt;p&gt; By default, the returned results correspond to a 5 minute window based on the provided end time (which defaults to the current server time). The &lt;i&gt;from&lt;/i&gt; and &lt;i&gt;to&lt;/i&gt; parameters can be used to control the window being queried. A maximum window of 3 hours is enforced. &lt;p&gt; When requesting a \&quot;full\&quot; view, aside from the extended properties of the returned metric data, the collection will also contain information about all metrics available for the activity, even if no readings are available in the requested window.
     * @param activityId The name of the activity. (required)
     * @param clusterName The name of the cluster. (required)
     * @param serviceName The name of the service. (required)
     * @param from Start of the period to query. (optional)
     * @param metrics Filter for which metrics to query. (optional)
     * @param to End of the period to query. (optional, default to now)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @return ApiMetricList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiMetricList getMetrics(String activityId, String clusterName, String serviceName, String from, List<String> metrics, String to, String view) throws ApiException {
        ApiResponse<ApiMetricList> resp = getMetricsWithHttpInfo(activityId, clusterName, serviceName, from, metrics, to, view);
        return resp.getData();
    }

    /**
     * Fetch metric readings for a particular activity.
     * Fetch metric readings for a particular activity. &lt;p&gt; By default, this call will look up all metrics available for the activity. If only specific metrics are desired, use the &lt;i&gt;metrics&lt;/i&gt; parameter. &lt;p&gt; By default, the returned results correspond to a 5 minute window based on the provided end time (which defaults to the current server time). The &lt;i&gt;from&lt;/i&gt; and &lt;i&gt;to&lt;/i&gt; parameters can be used to control the window being queried. A maximum window of 3 hours is enforced. &lt;p&gt; When requesting a \&quot;full\&quot; view, aside from the extended properties of the returned metric data, the collection will also contain information about all metrics available for the activity, even if no readings are available in the requested window.
     * @param activityId The name of the activity. (required)
     * @param clusterName The name of the cluster. (required)
     * @param serviceName The name of the service. (required)
     * @param from Start of the period to query. (optional)
     * @param metrics Filter for which metrics to query. (optional)
     * @param to End of the period to query. (optional, default to now)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @return ApiResponse&lt;ApiMetricList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiMetricList> getMetricsWithHttpInfo(String activityId, String clusterName, String serviceName, String from, List<String> metrics, String to, String view) throws ApiException {
        com.squareup.okhttp.Call call = getMetricsValidateBeforeCall(activityId, clusterName, serviceName, from, metrics, to, view, null, null);
        Type localVarReturnType = new TypeToken<ApiMetricList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Fetch metric readings for a particular activity. (asynchronously)
     * Fetch metric readings for a particular activity. &lt;p&gt; By default, this call will look up all metrics available for the activity. If only specific metrics are desired, use the &lt;i&gt;metrics&lt;/i&gt; parameter. &lt;p&gt; By default, the returned results correspond to a 5 minute window based on the provided end time (which defaults to the current server time). The &lt;i&gt;from&lt;/i&gt; and &lt;i&gt;to&lt;/i&gt; parameters can be used to control the window being queried. A maximum window of 3 hours is enforced. &lt;p&gt; When requesting a \&quot;full\&quot; view, aside from the extended properties of the returned metric data, the collection will also contain information about all metrics available for the activity, even if no readings are available in the requested window.
     * @param activityId The name of the activity. (required)
     * @param clusterName The name of the cluster. (required)
     * @param serviceName The name of the service. (required)
     * @param from Start of the period to query. (optional)
     * @param metrics Filter for which metrics to query. (optional)
     * @param to End of the period to query. (optional, default to now)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @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 getMetricsAsync(String activityId, String clusterName, String serviceName, String from, List<String> metrics, String to, String view, final ApiCallback<ApiMetricList> 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 = getMetricsValidateBeforeCall(activityId, clusterName, serviceName, from, metrics, to, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiMetricList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readActivities
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param maxResults The maximum number of activities to return. (optional, default to 100)
     * @param query The query to perform to find activities in the system. By default, this call returns top level (i.e. root) activities that have currently started. &lt;p&gt; The query specifies the intersection of a list of constraints, joined together with semicolons (without spaces). For example: &lt;/p&gt; &lt;dl&gt; &lt;dt&gt;status&#x3D;&#x3D;started;parent&#x3D;&#x3D;&lt;/dt&gt; &lt;dd&gt;looks for running root activities. This is also the default query.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;failed;finishTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for failed activities after the given date time.&lt;/dd&gt; &lt;dt&gt;name&#x3D;&#x3D;Pi Estimator;startTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for activities started after the given date time, with the name of \&quot;Pi Estimator\&quot;.&lt;/dd&gt; &lt;dt&gt;startTime&#x3D;lt&#x3D;2012-01-02T00:00:00.000Z;finishTime&#x3D;ge&#x3D;2012-01-01T00:00:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for activities that are active on 2012 New Year&#39;s Day. Note that they may start before or finish after that day.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;failed;parent&#x3D;&#x3D;000014-20120425161321-oozie-joe&lt;/dt&gt; &lt;dd&gt;looks for failed child activities of the given parent activity id.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;started;metrics.cpu_user&#x3D;gt&#x3D;10&lt;/dt&gt; &lt;dd&gt;looks for started activities that are using more than 10 cores per second.&lt;/dd&gt; &lt;dt&gt;type&#x3D;&#x3D;hive;metrics.user&#x3D;&#x3D;bc;finishTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for all hive queries submitted by user bc after the given date time.&lt;/dd&gt; &lt;/dl&gt;  You may query any fields present in the ApiActivity object. You can also query by activity metric values using the &lt;em&gt;metrics.*&lt;/em&gt; syntax. Values for date time fields should be ISO8601 timestamps. &lt;p&gt; The valid comparators are &lt;em&gt;&#x3D;&#x3D;&lt;/em&gt;, &lt;em&gt;!&#x3D;&lt;/em&gt;, &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;&#x3D;&#x3D;\&quot;, \&quot;!&#x3D;\&quot;, \&quot;&amp;lt;\&quot;, \&quot;&amp;lt;&#x3D;\&quot;, \&quot;&amp;gt;&#x3D;\&quot;, \&quot;&amp;gt;\&quot; respectively. (optional, default to status==started;parent==)
     * @param resultOffset Specified the offset of activities to return. (optional, default to 0)
     * @param view The view of the activities to materialize (optional, default to summary)
     * @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 readActivitiesCall(String clusterName, String serviceName, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/activities"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        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));
        if (view != null)
        localVarQueryParams.addAll(apiClient.parameterToPairs("", "view", view));

        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 readActivitiesValidateBeforeCall(String clusterName, String serviceName, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String view, 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 readActivities(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling readActivities(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readActivitiesCall(clusterName, serviceName, maxResults, query, resultOffset, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Read all activities in the system.
     * Read all activities in the system
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param maxResults The maximum number of activities to return. (optional, default to 100)
     * @param query The query to perform to find activities in the system. By default, this call returns top level (i.e. root) activities that have currently started. &lt;p&gt; The query specifies the intersection of a list of constraints, joined together with semicolons (without spaces). For example: &lt;/p&gt; &lt;dl&gt; &lt;dt&gt;status&#x3D;&#x3D;started;parent&#x3D;&#x3D;&lt;/dt&gt; &lt;dd&gt;looks for running root activities. This is also the default query.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;failed;finishTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for failed activities after the given date time.&lt;/dd&gt; &lt;dt&gt;name&#x3D;&#x3D;Pi Estimator;startTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for activities started after the given date time, with the name of \&quot;Pi Estimator\&quot;.&lt;/dd&gt; &lt;dt&gt;startTime&#x3D;lt&#x3D;2012-01-02T00:00:00.000Z;finishTime&#x3D;ge&#x3D;2012-01-01T00:00:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for activities that are active on 2012 New Year&#39;s Day. Note that they may start before or finish after that day.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;failed;parent&#x3D;&#x3D;000014-20120425161321-oozie-joe&lt;/dt&gt; &lt;dd&gt;looks for failed child activities of the given parent activity id.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;started;metrics.cpu_user&#x3D;gt&#x3D;10&lt;/dt&gt; &lt;dd&gt;looks for started activities that are using more than 10 cores per second.&lt;/dd&gt; &lt;dt&gt;type&#x3D;&#x3D;hive;metrics.user&#x3D;&#x3D;bc;finishTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for all hive queries submitted by user bc after the given date time.&lt;/dd&gt; &lt;/dl&gt;  You may query any fields present in the ApiActivity object. You can also query by activity metric values using the &lt;em&gt;metrics.*&lt;/em&gt; syntax. Values for date time fields should be ISO8601 timestamps. &lt;p&gt; The valid comparators are &lt;em&gt;&#x3D;&#x3D;&lt;/em&gt;, &lt;em&gt;!&#x3D;&lt;/em&gt;, &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;&#x3D;&#x3D;\&quot;, \&quot;!&#x3D;\&quot;, \&quot;&amp;lt;\&quot;, \&quot;&amp;lt;&#x3D;\&quot;, \&quot;&amp;gt;&#x3D;\&quot;, \&quot;&amp;gt;\&quot; respectively. (optional, default to status==started;parent==)
     * @param resultOffset Specified the offset of activities to return. (optional, default to 0)
     * @param view The view of the activities to materialize (optional, default to summary)
     * @return ApiActivityList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiActivityList readActivities(String clusterName, String serviceName, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String view) throws ApiException {
        ApiResponse<ApiActivityList> resp = readActivitiesWithHttpInfo(clusterName, serviceName, maxResults, query, resultOffset, view);
        return resp.getData();
    }

    /**
     * Read all activities in the system.
     * Read all activities in the system
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param maxResults The maximum number of activities to return. (optional, default to 100)
     * @param query The query to perform to find activities in the system. By default, this call returns top level (i.e. root) activities that have currently started. &lt;p&gt; The query specifies the intersection of a list of constraints, joined together with semicolons (without spaces). For example: &lt;/p&gt; &lt;dl&gt; &lt;dt&gt;status&#x3D;&#x3D;started;parent&#x3D;&#x3D;&lt;/dt&gt; &lt;dd&gt;looks for running root activities. This is also the default query.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;failed;finishTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for failed activities after the given date time.&lt;/dd&gt; &lt;dt&gt;name&#x3D;&#x3D;Pi Estimator;startTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for activities started after the given date time, with the name of \&quot;Pi Estimator\&quot;.&lt;/dd&gt; &lt;dt&gt;startTime&#x3D;lt&#x3D;2012-01-02T00:00:00.000Z;finishTime&#x3D;ge&#x3D;2012-01-01T00:00:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for activities that are active on 2012 New Year&#39;s Day. Note that they may start before or finish after that day.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;failed;parent&#x3D;&#x3D;000014-20120425161321-oozie-joe&lt;/dt&gt; &lt;dd&gt;looks for failed child activities of the given parent activity id.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;started;metrics.cpu_user&#x3D;gt&#x3D;10&lt;/dt&gt; &lt;dd&gt;looks for started activities that are using more than 10 cores per second.&lt;/dd&gt; &lt;dt&gt;type&#x3D;&#x3D;hive;metrics.user&#x3D;&#x3D;bc;finishTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for all hive queries submitted by user bc after the given date time.&lt;/dd&gt; &lt;/dl&gt;  You may query any fields present in the ApiActivity object. You can also query by activity metric values using the &lt;em&gt;metrics.*&lt;/em&gt; syntax. Values for date time fields should be ISO8601 timestamps. &lt;p&gt; The valid comparators are &lt;em&gt;&#x3D;&#x3D;&lt;/em&gt;, &lt;em&gt;!&#x3D;&lt;/em&gt;, &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;&#x3D;&#x3D;\&quot;, \&quot;!&#x3D;\&quot;, \&quot;&amp;lt;\&quot;, \&quot;&amp;lt;&#x3D;\&quot;, \&quot;&amp;gt;&#x3D;\&quot;, \&quot;&amp;gt;\&quot; respectively. (optional, default to status==started;parent==)
     * @param resultOffset Specified the offset of activities to return. (optional, default to 0)
     * @param view The view of the activities to materialize (optional, default to summary)
     * @return ApiResponse&lt;ApiActivityList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiActivityList> readActivitiesWithHttpInfo(String clusterName, String serviceName, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String view) throws ApiException {
        com.squareup.okhttp.Call call = readActivitiesValidateBeforeCall(clusterName, serviceName, maxResults, query, resultOffset, view, null, null);
        Type localVarReturnType = new TypeToken<ApiActivityList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Read all activities in the system. (asynchronously)
     * Read all activities in the system
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param maxResults The maximum number of activities to return. (optional, default to 100)
     * @param query The query to perform to find activities in the system. By default, this call returns top level (i.e. root) activities that have currently started. &lt;p&gt; The query specifies the intersection of a list of constraints, joined together with semicolons (without spaces). For example: &lt;/p&gt; &lt;dl&gt; &lt;dt&gt;status&#x3D;&#x3D;started;parent&#x3D;&#x3D;&lt;/dt&gt; &lt;dd&gt;looks for running root activities. This is also the default query.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;failed;finishTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for failed activities after the given date time.&lt;/dd&gt; &lt;dt&gt;name&#x3D;&#x3D;Pi Estimator;startTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for activities started after the given date time, with the name of \&quot;Pi Estimator\&quot;.&lt;/dd&gt; &lt;dt&gt;startTime&#x3D;lt&#x3D;2012-01-02T00:00:00.000Z;finishTime&#x3D;ge&#x3D;2012-01-01T00:00:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for activities that are active on 2012 New Year&#39;s Day. Note that they may start before or finish after that day.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;failed;parent&#x3D;&#x3D;000014-20120425161321-oozie-joe&lt;/dt&gt; &lt;dd&gt;looks for failed child activities of the given parent activity id.&lt;/dd&gt; &lt;dt&gt;status&#x3D;&#x3D;started;metrics.cpu_user&#x3D;gt&#x3D;10&lt;/dt&gt; &lt;dd&gt;looks for started activities that are using more than 10 cores per second.&lt;/dd&gt; &lt;dt&gt;type&#x3D;&#x3D;hive;metrics.user&#x3D;&#x3D;bc;finishTime&#x3D;gt&#x3D;2012-04-01T20:30:00.000Z&lt;/dt&gt; &lt;dd&gt;looks for all hive queries submitted by user bc after the given date time.&lt;/dd&gt; &lt;/dl&gt;  You may query any fields present in the ApiActivity object. You can also query by activity metric values using the &lt;em&gt;metrics.*&lt;/em&gt; syntax. Values for date time fields should be ISO8601 timestamps. &lt;p&gt; The valid comparators are &lt;em&gt;&#x3D;&#x3D;&lt;/em&gt;, &lt;em&gt;!&#x3D;&lt;/em&gt;, &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;&#x3D;&#x3D;\&quot;, \&quot;!&#x3D;\&quot;, \&quot;&amp;lt;\&quot;, \&quot;&amp;lt;&#x3D;\&quot;, \&quot;&amp;gt;&#x3D;\&quot;, \&quot;&amp;gt;\&quot; respectively. (optional, default to status==started;parent==)
     * @param resultOffset Specified the offset of activities to return. (optional, default to 0)
     * @param view The view of the activities to materialize (optional, default to summary)
     * @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 readActivitiesAsync(String clusterName, String serviceName, java.math.BigDecimal maxResults, String query, java.math.BigDecimal resultOffset, String view, final ApiCallback<ApiActivityList> 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 = readActivitiesValidateBeforeCall(clusterName, serviceName, maxResults, query, resultOffset, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiActivityList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readActivity
     * @param activityId The id of the activity to retrieve (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param view The view of the activity to materialize (optional, default to summary)
     * @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 readActivityCall(String activityId, String clusterName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/activities/{activityId}"
            .replaceAll("\\{" + "activityId" + "\\}", apiClient.escapeString(activityId.toString()))
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

        
        
        
        
    }

    /**
     * Returns a specific activity in the system.
     * Returns a specific activity in the system
     * @param activityId The id of the activity to retrieve (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param view The view of the activity to materialize (optional, default to summary)
     * @return ApiActivity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiActivity readActivity(String activityId, String clusterName, String serviceName, String view) throws ApiException {
        ApiResponse<ApiActivity> resp = readActivityWithHttpInfo(activityId, clusterName, serviceName, view);
        return resp.getData();
    }

    /**
     * Returns a specific activity in the system.
     * Returns a specific activity in the system
     * @param activityId The id of the activity to retrieve (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param view The view of the activity to materialize (optional, default to summary)
     * @return ApiResponse&lt;ApiActivity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiActivity> readActivityWithHttpInfo(String activityId, String clusterName, String serviceName, String view) throws ApiException {
        com.squareup.okhttp.Call call = readActivityValidateBeforeCall(activityId, clusterName, serviceName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiActivity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns a specific activity in the system. (asynchronously)
     * Returns a specific activity in the system
     * @param activityId The id of the activity to retrieve (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param view The view of the activity to materialize (optional, default to summary)
     * @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 readActivityAsync(String activityId, String clusterName, String serviceName, String view, final ApiCallback<ApiActivity> 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 = readActivityValidateBeforeCall(activityId, clusterName, serviceName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiActivity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readChildActivities
     * @param activityId The id of the activity (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param maxResults The maximum number of activities to return. (optional, default to 100)
     * @param resultOffset Specified the offset of activities to return. (optional, default to 0)
     * @param view The view of the children to materialize (optional, default to summary)
     * @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 readChildActivitiesCall(String activityId, String clusterName, String serviceName, java.math.BigDecimal maxResults, java.math.BigDecimal resultOffset, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/activities/{activityId}/children"
            .replaceAll("\\{" + "activityId" + "\\}", apiClient.escapeString(activityId.toString()))
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

        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 readChildActivitiesValidateBeforeCall(String activityId, String clusterName, String serviceName, java.math.BigDecimal maxResults, java.math.BigDecimal resultOffset, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'activityId' is set
        if (activityId == null) {
            throw new ApiException("Missing the required parameter 'activityId' when calling readChildActivities(Async)");
        }
        
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling readChildActivities(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling readChildActivities(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readChildActivitiesCall(activityId, clusterName, serviceName, maxResults, resultOffset, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Returns the child activities.
     * Returns the child activities
     * @param activityId The id of the activity (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param maxResults The maximum number of activities to return. (optional, default to 100)
     * @param resultOffset Specified the offset of activities to return. (optional, default to 0)
     * @param view The view of the children to materialize (optional, default to summary)
     * @return ApiActivityList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiActivityList readChildActivities(String activityId, String clusterName, String serviceName, java.math.BigDecimal maxResults, java.math.BigDecimal resultOffset, String view) throws ApiException {
        ApiResponse<ApiActivityList> resp = readChildActivitiesWithHttpInfo(activityId, clusterName, serviceName, maxResults, resultOffset, view);
        return resp.getData();
    }

    /**
     * Returns the child activities.
     * Returns the child activities
     * @param activityId The id of the activity (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param maxResults The maximum number of activities to return. (optional, default to 100)
     * @param resultOffset Specified the offset of activities to return. (optional, default to 0)
     * @param view The view of the children to materialize (optional, default to summary)
     * @return ApiResponse&lt;ApiActivityList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiActivityList> readChildActivitiesWithHttpInfo(String activityId, String clusterName, String serviceName, java.math.BigDecimal maxResults, java.math.BigDecimal resultOffset, String view) throws ApiException {
        com.squareup.okhttp.Call call = readChildActivitiesValidateBeforeCall(activityId, clusterName, serviceName, maxResults, resultOffset, view, null, null);
        Type localVarReturnType = new TypeToken<ApiActivityList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the child activities. (asynchronously)
     * Returns the child activities
     * @param activityId The id of the activity (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param maxResults The maximum number of activities to return. (optional, default to 100)
     * @param resultOffset Specified the offset of activities to return. (optional, default to 0)
     * @param view The view of the children to materialize (optional, default to summary)
     * @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 readChildActivitiesAsync(String activityId, String clusterName, String serviceName, java.math.BigDecimal maxResults, java.math.BigDecimal resultOffset, String view, final ApiCallback<ApiActivityList> 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 = readChildActivitiesValidateBeforeCall(activityId, clusterName, serviceName, maxResults, resultOffset, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiActivityList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readSimilarActivities
     * @param activityId The id of the activity (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param view The view of the activities to materialize (optional, default to summary)
     * @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 readSimilarActivitiesCall(String activityId, String clusterName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/activities/{activityId}/similar"
            .replaceAll("\\{" + "activityId" + "\\}", apiClient.escapeString(activityId.toString()))
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

        
        
        
        
    }

    /**
     * Returns a list of similar activities.
     * Returns a list of similar activities
     * @param activityId The id of the activity (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param view The view of the activities to materialize (optional, default to summary)
     * @return ApiActivityList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiActivityList readSimilarActivities(String activityId, String clusterName, String serviceName, String view) throws ApiException {
        ApiResponse<ApiActivityList> resp = readSimilarActivitiesWithHttpInfo(activityId, clusterName, serviceName, view);
        return resp.getData();
    }

    /**
     * Returns a list of similar activities.
     * Returns a list of similar activities
     * @param activityId The id of the activity (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param view The view of the activities to materialize (optional, default to summary)
     * @return ApiResponse&lt;ApiActivityList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiActivityList> readSimilarActivitiesWithHttpInfo(String activityId, String clusterName, String serviceName, String view) throws ApiException {
        com.squareup.okhttp.Call call = readSimilarActivitiesValidateBeforeCall(activityId, clusterName, serviceName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiActivityList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns a list of similar activities. (asynchronously)
     * Returns a list of similar activities
     * @param activityId The id of the activity (required)
     * @param clusterName The name of the cluster (required)
     * @param serviceName The name of the service (required)
     * @param view The view of the activities to materialize (optional, default to summary)
     * @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 readSimilarActivitiesAsync(String activityId, String clusterName, String serviceName, String view, final ApiCallback<ApiActivityList> 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 = readSimilarActivitiesValidateBeforeCall(activityId, clusterName, serviceName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiActivityList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
