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

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

public class RoleCommandsResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for formatCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the NameNodes to format. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call formatCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsFormat"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call formatCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 formatCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling formatCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = formatCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Format HDFS NameNodes.
     * Format HDFS NameNodes. &lt;p&gt; Submit a format request to a list of NameNodes on a service. Note that trying to format a previously formatted NameNode will fail. &lt;p&gt; Note about high availability: when two NameNodes are working in an HA pair, only one of them should be formatted. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the NameNodes to format. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList formatCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = formatCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Format HDFS NameNodes.
     * Format HDFS NameNodes. &lt;p&gt; Submit a format request to a list of NameNodes on a service. Note that trying to format a previously formatted NameNode will fail. &lt;p&gt; Note about high availability: when two NameNodes are working in an HA pair, only one of them should be formatted. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the NameNodes to format. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> formatCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = formatCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Format HDFS NameNodes. (asynchronously)
     * Format HDFS NameNodes. &lt;p&gt; Submit a format request to a list of NameNodes on a service. Note that trying to format a previously formatted NameNode will fail. &lt;p&gt; Note about high availability: when two NameNodes are working in an HA pair, only one of them should be formatted. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the NameNodes to format. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call formatCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = formatCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for hdfsBootstrapStandByCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the stand-by NameNodes to bootstrap. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call hdfsBootstrapStandByCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsBootstrapStandBy"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call hdfsBootstrapStandByCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 hdfsBootstrapStandByCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling hdfsBootstrapStandByCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = hdfsBootstrapStandByCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Bootstrap HDFS stand-by NameNodes.
     * Bootstrap HDFS stand-by NameNodes. &lt;p&gt; Submit a request to synchronize HDFS NameNodes with their assigned HA partners. The command requires that the target NameNodes are part of existing HA pairs, which can be accomplished by setting the nameservice configuration parameter in the NameNode&#39;s configuration. &lt;p&gt; The HA partner must already be formatted and running for this command to run.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the stand-by NameNodes to bootstrap. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList hdfsBootstrapStandByCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = hdfsBootstrapStandByCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Bootstrap HDFS stand-by NameNodes.
     * Bootstrap HDFS stand-by NameNodes. &lt;p&gt; Submit a request to synchronize HDFS NameNodes with their assigned HA partners. The command requires that the target NameNodes are part of existing HA pairs, which can be accomplished by setting the nameservice configuration parameter in the NameNode&#39;s configuration. &lt;p&gt; The HA partner must already be formatted and running for this command to run.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the stand-by NameNodes to bootstrap. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> hdfsBootstrapStandByCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = hdfsBootstrapStandByCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Bootstrap HDFS stand-by NameNodes. (asynchronously)
     * Bootstrap HDFS stand-by NameNodes. &lt;p&gt; Submit a request to synchronize HDFS NameNodes with their assigned HA partners. The command requires that the target NameNodes are part of existing HA pairs, which can be accomplished by setting the nameservice configuration parameter in the NameNode&#39;s configuration. &lt;p&gt; The HA partner must already be formatted and running for this command to run.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the stand-by NameNodes to bootstrap. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call hdfsBootstrapStandByCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = hdfsBootstrapStandByCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for hdfsEnterSafemode
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to enter safemode. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call hdfsEnterSafemodeCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsEnterSafemode"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call hdfsEnterSafemodeValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 hdfsEnterSafemode(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling hdfsEnterSafemode(Async)");
        }
        
        
        com.squareup.okhttp.Call call = hdfsEnterSafemodeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Enter safemode for namenodes.
     * Enter safemode for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to enter safemode. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList hdfsEnterSafemode(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = hdfsEnterSafemodeWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Enter safemode for namenodes.
     * Enter safemode for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to enter safemode. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> hdfsEnterSafemodeWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = hdfsEnterSafemodeValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Enter safemode for namenodes. (asynchronously)
     * Enter safemode for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to enter safemode. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call hdfsEnterSafemodeAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = hdfsEnterSafemodeValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for hdfsFinalizeMetadataUpgrade
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to finalize the upgrade. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call hdfsFinalizeMetadataUpgradeCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsFinalizeMetadataUpgrade"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call hdfsFinalizeMetadataUpgradeValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 hdfsFinalizeMetadataUpgrade(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling hdfsFinalizeMetadataUpgrade(Async)");
        }
        
        
        com.squareup.okhttp.Call call = hdfsFinalizeMetadataUpgradeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Finalize HDFS NameNode metadata upgrade.
     * Finalize HDFS NameNode metadata upgrade. &lt;p/&gt; Available since API v3.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to finalize the upgrade. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList hdfsFinalizeMetadataUpgrade(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = hdfsFinalizeMetadataUpgradeWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Finalize HDFS NameNode metadata upgrade.
     * Finalize HDFS NameNode metadata upgrade. &lt;p/&gt; Available since API v3.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to finalize the upgrade. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> hdfsFinalizeMetadataUpgradeWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = hdfsFinalizeMetadataUpgradeValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Finalize HDFS NameNode metadata upgrade. (asynchronously)
     * Finalize HDFS NameNode metadata upgrade. &lt;p/&gt; Available since API v3.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to finalize the upgrade. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call hdfsFinalizeMetadataUpgradeAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = hdfsFinalizeMetadataUpgradeValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for hdfsInitializeAutoFailoverCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the controllers to initialize. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call hdfsInitializeAutoFailoverCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsInitializeAutoFailover"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call hdfsInitializeAutoFailoverCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 hdfsInitializeAutoFailoverCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling hdfsInitializeAutoFailoverCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = hdfsInitializeAutoFailoverCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Initialize HDFS HA failover controller metadata.
     * Initialize HDFS HA failover controller metadata. &lt;p&gt; The controllers being initialized must already exist and be properly configured. The command will make sure the needed data is initialized for the controller to work. &lt;p&gt; Only one controller per nameservice needs to be initialized.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the controllers to initialize. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList hdfsInitializeAutoFailoverCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = hdfsInitializeAutoFailoverCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Initialize HDFS HA failover controller metadata.
     * Initialize HDFS HA failover controller metadata. &lt;p&gt; The controllers being initialized must already exist and be properly configured. The command will make sure the needed data is initialized for the controller to work. &lt;p&gt; Only one controller per nameservice needs to be initialized.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the controllers to initialize. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> hdfsInitializeAutoFailoverCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = hdfsInitializeAutoFailoverCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Initialize HDFS HA failover controller metadata. (asynchronously)
     * Initialize HDFS HA failover controller metadata. &lt;p&gt; The controllers being initialized must already exist and be properly configured. The command will make sure the needed data is initialized for the controller to work. &lt;p&gt; Only one controller per nameservice needs to be initialized.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the controllers to initialize. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call hdfsInitializeAutoFailoverCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = hdfsInitializeAutoFailoverCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for hdfsInitializeSharedDirCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the NameNodes. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call hdfsInitializeSharedDirCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsInitializeSharedDir"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call hdfsInitializeSharedDirCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 hdfsInitializeSharedDirCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling hdfsInitializeSharedDirCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = hdfsInitializeSharedDirCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Initialize HDFS NameNodes&#39; shared edit directory.
     * Initialize HDFS NameNodes&#39; shared edit directory. &lt;p&gt; Shared edit directories are used when two HDFS NameNodes are operating as a high-availability pair. This command initializes the shared directory to include the necessary metadata. &lt;p&gt; The provided role names should reflect one of the NameNodes in the respective HA pair; the role must be stopped and its data directory must already have been formatted. The shared edits directory must be empty for this command to succeed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the NameNodes. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList hdfsInitializeSharedDirCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = hdfsInitializeSharedDirCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Initialize HDFS NameNodes&#39; shared edit directory.
     * Initialize HDFS NameNodes&#39; shared edit directory. &lt;p&gt; Shared edit directories are used when two HDFS NameNodes are operating as a high-availability pair. This command initializes the shared directory to include the necessary metadata. &lt;p&gt; The provided role names should reflect one of the NameNodes in the respective HA pair; the role must be stopped and its data directory must already have been formatted. The shared edits directory must be empty for this command to succeed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the NameNodes. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> hdfsInitializeSharedDirCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = hdfsInitializeSharedDirCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Initialize HDFS NameNodes&#39; shared edit directory. (asynchronously)
     * Initialize HDFS NameNodes&#39; shared edit directory. &lt;p&gt; Shared edit directories are used when two HDFS NameNodes are operating as a high-availability pair. This command initializes the shared directory to include the necessary metadata. &lt;p&gt; The provided role names should reflect one of the NameNodes in the respective HA pair; the role must be stopped and its data directory must already have been formatted. The shared edits directory must be empty for this command to succeed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the NameNodes. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call hdfsInitializeSharedDirCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = hdfsInitializeSharedDirCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for hdfsLeaveSafemode
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to leave safemode. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call hdfsLeaveSafemodeCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsLeaveSafemode"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call hdfsLeaveSafemodeValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 hdfsLeaveSafemode(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling hdfsLeaveSafemode(Async)");
        }
        
        
        com.squareup.okhttp.Call call = hdfsLeaveSafemodeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Leave safemode for namenodes.
     * Leave safemode for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to leave safemode. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList hdfsLeaveSafemode(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = hdfsLeaveSafemodeWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Leave safemode for namenodes.
     * Leave safemode for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to leave safemode. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> hdfsLeaveSafemodeWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = hdfsLeaveSafemodeValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Leave safemode for namenodes. (asynchronously)
     * Leave safemode for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to leave safemode. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call hdfsLeaveSafemodeAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = hdfsLeaveSafemodeValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for hdfsSaveNamespace
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to save namespace. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call hdfsSaveNamespaceCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hdfsSaveNamespace"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call hdfsSaveNamespaceValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 hdfsSaveNamespace(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling hdfsSaveNamespace(Async)");
        }
        
        
        com.squareup.okhttp.Call call = hdfsSaveNamespaceCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Save namespace for namenodes.
     * Save namespace for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to save namespace. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList hdfsSaveNamespace(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = hdfsSaveNamespaceWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Save namespace for namenodes.
     * Save namespace for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to save namespace. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> hdfsSaveNamespaceWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = hdfsSaveNamespaceValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Save namespace for namenodes. (asynchronously)
     * Save namespace for namenodes &lt;p/&gt; Available since API v4.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body NameNodes for which to save namespace. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call hdfsSaveNamespaceAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = hdfsSaveNamespaceValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for jmapDump
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jmap. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call jmapDumpCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/jmapDump"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call jmapDumpValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 jmapDump(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling jmapDump(Async)");
        }
        
        
        com.squareup.okhttp.Call call = jmapDumpCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Run the jmapDump diagnostic command.
     * Run the jmapDump diagnostic command. The command runs the jmap utility to capture a dump of the role&#39;s java heap. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jmap. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList jmapDump(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = jmapDumpWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Run the jmapDump diagnostic command.
     * Run the jmapDump diagnostic command. The command runs the jmap utility to capture a dump of the role&#39;s java heap. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jmap. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> jmapDumpWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = jmapDumpValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Run the jmapDump diagnostic command. (asynchronously)
     * Run the jmapDump diagnostic command. The command runs the jmap utility to capture a dump of the role&#39;s java heap. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jmap. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call jmapDumpAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = jmapDumpValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for jmapHisto
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jmap. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call jmapHistoCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/jmapHisto"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call jmapHistoValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 jmapHisto(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling jmapHisto(Async)");
        }
        
        
        com.squareup.okhttp.Call call = jmapHistoCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Run the jmapHisto diagnostic command.
     * Run the jmapHisto diagnostic command. The command runs the jmap utility to capture a histogram of the objects on the role&#39;s java heap. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jmap. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList jmapHisto(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = jmapHistoWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Run the jmapHisto diagnostic command.
     * Run the jmapHisto diagnostic command. The command runs the jmap utility to capture a histogram of the objects on the role&#39;s java heap. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jmap. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> jmapHistoWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = jmapHistoValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Run the jmapHisto diagnostic command. (asynchronously)
     * Run the jmapHisto diagnostic command. The command runs the jmap utility to capture a histogram of the objects on the role&#39;s java heap. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jmap. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call jmapHistoAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = jmapHistoValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for jstack
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jstack. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call jstackCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/jstack"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call jstackValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 jstack(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling jstack(Async)");
        }
        
        
        com.squareup.okhttp.Call call = jstackCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Run the jstack diagnostic command.
     * Run the jstack diagnostic command. The command runs the jstack utility to capture a role&#39;s java thread stacks. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jstack. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList jstack(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = jstackWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Run the jstack diagnostic command.
     * Run the jstack diagnostic command. The command runs the jstack utility to capture a role&#39;s java thread stacks. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jstack. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> jstackWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = jstackValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Run the jstack diagnostic command. (asynchronously)
     * Run the jstack diagnostic command. The command runs the jstack utility to capture a role&#39;s java thread stacks. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to jstack. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call jstackAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = jstackValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for lsof
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to lsof. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call lsofCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/lsof"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call lsofValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 lsof(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling lsof(Async)");
        }
        
        
        com.squareup.okhttp.Call call = lsofCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Run the lsof diagnostic command.
     * Run the lsof diagnostic command. This command runs the lsof utility to list a role&#39;s open files. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to lsof. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList lsof(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = lsofWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Run the lsof diagnostic command.
     * Run the lsof diagnostic command. This command runs the lsof utility to list a role&#39;s open files. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to lsof. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> lsofWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = lsofValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Run the lsof diagnostic command. (asynchronously)
     * Run the lsof diagnostic command. This command runs the lsof utility to list a role&#39;s open files. &lt;p/&gt; Available since API v8.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body the names of the roles to lsof. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call lsofAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = lsofValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for refreshCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call refreshCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/refresh"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call refreshCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 refreshCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling refreshCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = refreshCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Refresh a role&#39;s data.
     * Refresh a role&#39;s data. &lt;p&gt; For MapReduce services, this command should be executed on JobTracker roles. It refreshes the role&#39;s queue and node information. &lt;p&gt; For HDFS services, this command should be executed on NameNode or DataNode roles. For NameNodes, it refreshes the role&#39;s node list. For DataNodes, it refreshes the role&#39;s data directory list and other configuration. &lt;p&gt; For YARN services, this command should be executed on ResourceManager roles. It refreshes the role&#39;s queue and node information. &lt;p&gt; Available since API v1. DataNode data directories refresh available since API v10.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList refreshCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = refreshCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Refresh a role&#39;s data.
     * Refresh a role&#39;s data. &lt;p&gt; For MapReduce services, this command should be executed on JobTracker roles. It refreshes the role&#39;s queue and node information. &lt;p&gt; For HDFS services, this command should be executed on NameNode or DataNode roles. For NameNodes, it refreshes the role&#39;s node list. For DataNodes, it refreshes the role&#39;s data directory list and other configuration. &lt;p&gt; For YARN services, this command should be executed on ResourceManager roles. It refreshes the role&#39;s queue and node information. &lt;p&gt; Available since API v1. DataNode data directories refresh available since API v10.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> refreshCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = refreshCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Refresh a role&#39;s data. (asynchronously)
     * Refresh a role&#39;s data. &lt;p&gt; For MapReduce services, this command should be executed on JobTracker roles. It refreshes the role&#39;s queue and node information. &lt;p&gt; For HDFS services, this command should be executed on NameNode or DataNode roles. For NameNodes, it refreshes the role&#39;s node list. For DataNodes, it refreshes the role&#39;s data directory list and other configuration. &lt;p&gt; For YARN services, this command should be executed on ResourceManager roles. It refreshes the role&#39;s queue and node information. &lt;p&gt; Available since API v1. DataNode data directories refresh available since API v10.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call refreshCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = refreshCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for restartCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The name of the roles to restart. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call restartCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/restart"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call restartCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 restartCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling restartCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = restartCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Restart a set of role instances.
     * Restart a set of role instances &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The name of the roles to restart. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList restartCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = restartCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Restart a set of role instances.
     * Restart a set of role instances &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The name of the roles to restart. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> restartCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = restartCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Restart a set of role instances. (asynchronously)
     * Restart a set of role instances &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The name of the roles to restart. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call restartCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = restartCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for roleCommandByName
     * @param clusterName  (required)
     * @param commandName the name of command to execute. (required)
     * @param serviceName  (required)
     * @param body the roles to run this command on. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call roleCommandByNameCall(String clusterName, String commandName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/{commandName}"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "commandName" + "\\}", apiClient.escapeString(commandName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call roleCommandByNameValidateBeforeCall(String clusterName, String commandName, String serviceName, ApiRoleNameList body, 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 roleCommandByName(Async)");
        }
        
        // verify the required parameter 'commandName' is set
        if (commandName == null) {
            throw new ApiException("Missing the required parameter 'commandName' when calling roleCommandByName(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling roleCommandByName(Async)");
        }
        
        
        com.squareup.okhttp.Call call = roleCommandByNameCall(clusterName, commandName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Execute a role command by name.
     * Execute a role command by name. &lt;p/&gt; Available since API v6.
     * @param clusterName  (required)
     * @param commandName the name of command to execute. (required)
     * @param serviceName  (required)
     * @param body the roles to run this command on. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList roleCommandByName(String clusterName, String commandName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = roleCommandByNameWithHttpInfo(clusterName, commandName, serviceName, body);
        return resp.getData();
    }

    /**
     * Execute a role command by name.
     * Execute a role command by name. &lt;p/&gt; Available since API v6.
     * @param clusterName  (required)
     * @param commandName the name of command to execute. (required)
     * @param serviceName  (required)
     * @param body the roles to run this command on. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> roleCommandByNameWithHttpInfo(String clusterName, String commandName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = roleCommandByNameValidateBeforeCall(clusterName, commandName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Execute a role command by name. (asynchronously)
     * Execute a role command by name. &lt;p/&gt; Available since API v6.
     * @param clusterName  (required)
     * @param commandName the name of command to execute. (required)
     * @param serviceName  (required)
     * @param body the roles to run this command on. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call roleCommandByNameAsync(String clusterName, String commandName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = roleCommandByNameValidateBeforeCall(clusterName, commandName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for startCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles to start. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call startCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/start"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call startCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 startCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling startCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = startCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Start a set of role instances.
     * Start a set of role instances. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles to start. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList startCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = startCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Start a set of role instances.
     * Start a set of role instances. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles to start. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> startCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = startCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Start a set of role instances. (asynchronously)
     * Start a set of role instances. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles to start. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call startCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = startCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for stopCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The role type. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call stopCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/stop"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call stopCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 stopCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling stopCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = stopCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Stop a set of role instances.
     * Stop a set of role instances. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The role type. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList stopCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = stopCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Stop a set of role instances.
     * Stop a set of role instances. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The role type. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> stopCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = stopCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Stop a set of role instances. (asynchronously)
     * Stop a set of role instances. &lt;p&gt; Bulk command operations are not atomic, and may contain partial failures. The returned list will contain references to all successful commands, and a list of error messages identifying the roles on which the command failed.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The role type. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call stopCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = stopCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for syncHueDbCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the Hue server roles. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call syncHueDbCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/hueSyncDb"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call syncHueDbCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 syncHueDbCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling syncHueDbCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = syncHueDbCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Create / update the Hue database schema.
     * Create / update the Hue database schema. &lt;p&gt; This command is to be run whenever a new database has been specified or, as necessary, after an upgrade. &lt;p&gt; This request should be sent to Hue servers only.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the Hue server roles. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList syncHueDbCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = syncHueDbCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Create / update the Hue database schema.
     * Create / update the Hue database schema. &lt;p&gt; This command is to be run whenever a new database has been specified or, as necessary, after an upgrade. &lt;p&gt; This request should be sent to Hue servers only.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the Hue server roles. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> syncHueDbCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = syncHueDbCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create / update the Hue database schema. (asynchronously)
     * Create / update the Hue database schema. &lt;p&gt; This command is to be run whenever a new database has been specified or, as necessary, after an upgrade. &lt;p&gt; This request should be sent to Hue servers only.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the Hue server roles. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call syncHueDbCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = syncHueDbCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for zooKeeperCleanupCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call zooKeeperCleanupCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/zooKeeperCleanup"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call zooKeeperCleanupCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 zooKeeperCleanupCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling zooKeeperCleanupCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = zooKeeperCleanupCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Cleanup a list of ZooKeeper server roles.
     * Cleanup a list of ZooKeeper server roles. &lt;p&gt; This command removes snapshots and transaction log files kept by ZooKeeper for backup purposes. Refer to the ZooKeeper documentation for more details.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList zooKeeperCleanupCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = zooKeeperCleanupCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Cleanup a list of ZooKeeper server roles.
     * Cleanup a list of ZooKeeper server roles. &lt;p&gt; This command removes snapshots and transaction log files kept by ZooKeeper for backup purposes. Refer to the ZooKeeper documentation for more details.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> zooKeeperCleanupCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = zooKeeperCleanupCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Cleanup a list of ZooKeeper server roles. (asynchronously)
     * Cleanup a list of ZooKeeper server roles. &lt;p&gt; This command removes snapshots and transaction log files kept by ZooKeeper for backup purposes. Refer to the ZooKeeper documentation for more details.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call zooKeeperCleanupCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = zooKeeperCleanupCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for zooKeeperInitCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call zooKeeperInitCommandCall(String clusterName, String serviceName, ApiRoleNameList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roleCommands/zooKeeperInit"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

        final String[] localVarContentTypes = {
            "application/json"
        };
        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, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call zooKeeperInitCommandValidateBeforeCall(String clusterName, String serviceName, ApiRoleNameList body, 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 zooKeeperInitCommand(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling zooKeeperInitCommand(Async)");
        }
        
        
        com.squareup.okhttp.Call call = zooKeeperInitCommandCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Initialize a list of ZooKeeper server roles.
     * Initialize a list of ZooKeeper server roles. &lt;p&gt; This applies to ZooKeeper services from CDH4. Before ZooKeeper server roles can be used, they need to be initialized.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @return ApiBulkCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiBulkCommandList zooKeeperInitCommand(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiBulkCommandList> resp = zooKeeperInitCommandWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Initialize a list of ZooKeeper server roles.
     * Initialize a list of ZooKeeper server roles. &lt;p&gt; This applies to ZooKeeper services from CDH4. Before ZooKeeper server roles can be used, they need to be initialized.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @return ApiResponse&lt;ApiBulkCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiBulkCommandList> zooKeeperInitCommandWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = zooKeeperInitCommandValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Initialize a list of ZooKeeper server roles. (asynchronously)
     * Initialize a list of ZooKeeper server roles. &lt;p&gt; This applies to ZooKeeper services from CDH4. Before ZooKeeper server roles can be used, they need to be initialized.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body The names of the roles. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call zooKeeperInitCommandAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiBulkCommandList> 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 = zooKeeperInitCommandValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiBulkCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
