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

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

public class ParcelResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for activateCommand
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call activateCommandCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/activate"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call activateCommandValidateBeforeCall(String clusterName, String product, String version, 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 activateCommand(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling activateCommand(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling activateCommand(Async)");
        }

        okhttp3.Call call = activateCommandCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * A synchronous command that activates the parcel on the cluster.
     * A synchronous command that activates the parcel on the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand activateCommand(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiCommand> resp = activateCommandWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * A synchronous command that activates the parcel on the cluster.
     * A synchronous command that activates the parcel on the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> activateCommandWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = activateCommandValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * A synchronous command that activates the parcel on the cluster. (asynchronously)
     * A synchronous command that activates the parcel on the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call activateCommandAsync(String clusterName, String product, String version, final ApiCallback<ApiCommand> 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 = activateCommandValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for cancelDistributionCommand
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call cancelDistributionCommandCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/cancelDistribution"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call cancelDistributionCommandValidateBeforeCall(String clusterName, String product, String version, 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 cancelDistributionCommand(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling cancelDistributionCommand(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling cancelDistributionCommand(Async)");
        }

        okhttp3.Call call = cancelDistributionCommandCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * A synchronous command that cancels the parcel distribution.
     * A synchronous command that cancels the parcel distribution. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand cancelDistributionCommand(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiCommand> resp = cancelDistributionCommandWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * A synchronous command that cancels the parcel distribution.
     * A synchronous command that cancels the parcel distribution. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> cancelDistributionCommandWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = cancelDistributionCommandValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * A synchronous command that cancels the parcel distribution. (asynchronously)
     * A synchronous command that cancels the parcel distribution. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call cancelDistributionCommandAsync(String clusterName, String product, String version, final ApiCallback<ApiCommand> 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 = cancelDistributionCommandValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for cancelDownloadCommand
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call cancelDownloadCommandCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/cancelDownload"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call cancelDownloadCommandValidateBeforeCall(String clusterName, String product, String version, 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 cancelDownloadCommand(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling cancelDownloadCommand(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling cancelDownloadCommand(Async)");
        }

        okhttp3.Call call = cancelDownloadCommandCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * A synchronous command that cancels the parcel download.
     * A synchronous command that cancels the parcel download. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand cancelDownloadCommand(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiCommand> resp = cancelDownloadCommandWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * A synchronous command that cancels the parcel download.
     * A synchronous command that cancels the parcel download. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> cancelDownloadCommandWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = cancelDownloadCommandValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * A synchronous command that cancels the parcel download. (asynchronously)
     * A synchronous command that cancels the parcel download. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call cancelDownloadCommandAsync(String clusterName, String product, String version, final ApiCallback<ApiCommand> 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 = cancelDownloadCommandValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for deactivateCommand
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call deactivateCommandCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/deactivate"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call deactivateCommandValidateBeforeCall(String clusterName, String product, String version, 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 deactivateCommand(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling deactivateCommand(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling deactivateCommand(Async)");
        }

        okhttp3.Call call = deactivateCommandCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * A synchronous command that deactivates the parcel on the cluster.
     * A synchronous command that deactivates the parcel on the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand deactivateCommand(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiCommand> resp = deactivateCommandWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * A synchronous command that deactivates the parcel on the cluster.
     * A synchronous command that deactivates the parcel on the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> deactivateCommandWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = deactivateCommandValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * A synchronous command that deactivates the parcel on the cluster. (asynchronously)
     * A synchronous command that deactivates the parcel on the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call deactivateCommandAsync(String clusterName, String product, String version, final ApiCallback<ApiCommand> 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 = deactivateCommandValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readParcel
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call readParcelCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call readParcelValidateBeforeCall(String clusterName, String product, String version, 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 readParcel(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling readParcel(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling readParcel(Async)");
        }

        okhttp3.Call call = readParcelCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Retrieves detailed information about a parcel.
     * Retrieves detailed information about a parcel.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiParcel
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiParcel readParcel(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiParcel> resp = readParcelWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * Retrieves detailed information about a parcel.
     * Retrieves detailed information about a parcel.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiParcel&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiParcel> readParcelWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = readParcelValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiParcel>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieves detailed information about a parcel. (asynchronously)
     * Retrieves detailed information about a parcel.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call readParcelAsync(String clusterName, String product, String version, final ApiCallback<ApiParcel> 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 = readParcelValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiParcel>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for removeDownloadCommand
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call removeDownloadCommandCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/removeDownload"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call removeDownloadCommandValidateBeforeCall(String clusterName, String product, String version, 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 removeDownloadCommand(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling removeDownloadCommand(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling removeDownloadCommand(Async)");
        }

        okhttp3.Call call = removeDownloadCommandCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * A synchronous command that removes the downloaded parcel.
     * A synchronous command that removes the downloaded parcel. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand removeDownloadCommand(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiCommand> resp = removeDownloadCommandWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * A synchronous command that removes the downloaded parcel.
     * A synchronous command that removes the downloaded parcel. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> removeDownloadCommandWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = removeDownloadCommandValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * A synchronous command that removes the downloaded parcel. (asynchronously)
     * A synchronous command that removes the downloaded parcel. &lt;p&gt; Since it is synchronous, the result is known immediately upon return.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call removeDownloadCommandAsync(String clusterName, String product, String version, final ApiCallback<ApiCommand> 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 = removeDownloadCommandValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for startDistributionCommand
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call startDistributionCommandCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/startDistribution"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call startDistributionCommandValidateBeforeCall(String clusterName, String product, String version, 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 startDistributionCommand(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling startDistributionCommand(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling startDistributionCommand(Async)");
        }

        okhttp3.Call call = startDistributionCommandCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * A synchronous command that starts the distribution of the parcel to the cluster.
     * A synchronous command that starts the distribution of the parcel to the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the distribution, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand startDistributionCommand(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiCommand> resp = startDistributionCommandWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * A synchronous command that starts the distribution of the parcel to the cluster.
     * A synchronous command that starts the distribution of the parcel to the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the distribution, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> startDistributionCommandWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = startDistributionCommandValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * A synchronous command that starts the distribution of the parcel to the cluster. (asynchronously)
     * A synchronous command that starts the distribution of the parcel to the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the distribution, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call startDistributionCommandAsync(String clusterName, String product, String version, final ApiCallback<ApiCommand> 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 = startDistributionCommandValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for startDownloadCommand
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call startDownloadCommandCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/startDownload"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call startDownloadCommandValidateBeforeCall(String clusterName, String product, String version, 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 startDownloadCommand(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling startDownloadCommand(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling startDownloadCommand(Async)");
        }

        okhttp3.Call call = startDownloadCommandCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * A synchronous command that starts the parcel download.
     * A synchronous command that starts the parcel download. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the download, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand startDownloadCommand(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiCommand> resp = startDownloadCommandWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * A synchronous command that starts the parcel download.
     * A synchronous command that starts the parcel download. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the download, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> startDownloadCommandWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = startDownloadCommandValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * A synchronous command that starts the parcel download. (asynchronously)
     * A synchronous command that starts the parcel download. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the download, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call startDownloadCommandAsync(String clusterName, String product, String version, final ApiCallback<ApiCommand> 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 = startDownloadCommandValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for startRemovalOfDistributionCommand
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call startRemovalOfDistributionCommandCall(String clusterName, String product, String version, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/parcels/products/{product}/versions/{version}/commands/startRemovalOfDistribution"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "product" + "\\}", apiClient.escapeString(product.toString()))
            .replaceAll("\\{" + "version" + "\\}", apiClient.escapeString(version.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call startRemovalOfDistributionCommandValidateBeforeCall(String clusterName, String product, String version, 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 startRemovalOfDistributionCommand(Async)");
        }
        // verify the required parameter 'product' is set
        if (product == null) {
            throw new ApiException("Missing the required parameter 'product' when calling startRemovalOfDistributionCommand(Async)");
        }
        // verify the required parameter 'version' is set
        if (version == null) {
            throw new ApiException("Missing the required parameter 'version' when calling startRemovalOfDistributionCommand(Async)");
        }

        okhttp3.Call call = startRemovalOfDistributionCommandCall(clusterName, product, version, progressListener, progressRequestListener);
        return call;

    }

    /**
     * A synchronous command that removes the distribution from the hosts in the cluster.
     * A synchronous command that removes the distribution from the hosts in the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the removal, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand startRemovalOfDistributionCommand(String clusterName, String product, String version) throws ApiException {
        ApiResponse<ApiCommand> resp = startRemovalOfDistributionCommandWithHttpInfo(clusterName, product, version);
        return resp.getData();
    }

    /**
     * A synchronous command that removes the distribution from the hosts in the cluster.
     * A synchronous command that removes the distribution from the hosts in the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the removal, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> startRemovalOfDistributionCommandWithHttpInfo(String clusterName, String product, String version) throws ApiException {
        okhttp3.Call call = startRemovalOfDistributionCommandValidateBeforeCall(clusterName, product, version, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * A synchronous command that removes the distribution from the hosts in the cluster. (asynchronously)
     * A synchronous command that removes the distribution from the hosts in the cluster. &lt;p&gt; Since it is synchronous, the result is known immediately upon return. In order to see the progress of the removal, a call to readParcel() needs to be made.
     * @param clusterName  (required)
     * @param product the product (required)
     * @param version the version (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call startRemovalOfDistributionCommandAsync(String clusterName, String product, String version, final ApiCallback<ApiCommand> 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 = startRemovalOfDistributionCommandValidateBeforeCall(clusterName, product, version, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
