/*
 * 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.ApiCommand;
import com.cloudera.api.swagger.model.ApiCommandList;
import com.cloudera.api.swagger.model.ApiCommandMetadataList;
import com.cloudera.api.swagger.model.ApiConfigList;
import com.cloudera.api.swagger.model.ApiEntityTag;
import com.cloudera.api.swagger.model.ApiImpalaRoleDiagnosticsArgs;
import com.cloudera.api.swagger.model.ApiMetricList;
import com.cloudera.api.swagger.model.ApiRole;
import com.cloudera.api.swagger.model.ApiRoleList;
import com.cloudera.api.swagger.model.ApiRoleNameList;
import java.io.File;

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

public class RolesResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for addTags
     * @param clusterName  (required)
     * @param roleName Name of the role (required)
     * @param serviceName  (required)
     * @param body List of tags to add to the role (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 addTagsCall(String clusterName, String roleName, String serviceName, List<ApiEntityTag> 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}/roles/{roleName}/tags"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call addTagsValidateBeforeCall(String clusterName, String roleName, String serviceName, List<ApiEntityTag> 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 addTags(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling addTags(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling addTags(Async)");
        }
        
        
        com.squareup.okhttp.Call call = addTagsCall(clusterName, roleName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Attach tags to the role.
     * Attach tags to the role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName Name of the role (required)
     * @param serviceName  (required)
     * @param body List of tags to add to the role (optional)
     * @return List&lt;ApiEntityTag&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public List<ApiEntityTag> addTags(String clusterName, String roleName, String serviceName, List<ApiEntityTag> body) throws ApiException {
        ApiResponse<List<ApiEntityTag>> resp = addTagsWithHttpInfo(clusterName, roleName, serviceName, body);
        return resp.getData();
    }

    /**
     * Attach tags to the role.
     * Attach tags to the role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName Name of the role (required)
     * @param serviceName  (required)
     * @param body List of tags to add to the role (optional)
     * @return ApiResponse&lt;List&lt;ApiEntityTag&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<List<ApiEntityTag>> addTagsWithHttpInfo(String clusterName, String roleName, String serviceName, List<ApiEntityTag> body) throws ApiException {
        com.squareup.okhttp.Call call = addTagsValidateBeforeCall(clusterName, roleName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<List<ApiEntityTag>>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Attach tags to the role. (asynchronously)
     * Attach tags to the role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName Name of the role (required)
     * @param serviceName  (required)
     * @param body List of tags to add to the role (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 addTagsAsync(String clusterName, String roleName, String serviceName, List<ApiEntityTag> body, final ApiCallback<List<ApiEntityTag>> 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 = addTagsValidateBeforeCall(clusterName, roleName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<List<ApiEntityTag>>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for bulkDeleteRoles
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body list of role names to be deleted (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 bulkDeleteRolesCall(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}/roles/bulkDelete"
            .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 bulkDeleteRolesValidateBeforeCall(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 bulkDeleteRoles(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling bulkDeleteRoles(Async)");
        }
        
        
        com.squareup.okhttp.Call call = bulkDeleteRolesCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Bulk delete roles in a particular service by name.
     * Bulk delete roles in a particular service by name. Fails if any role cannot be found.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body list of role names to be deleted (optional)
     * @return ApiRoleList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiRoleList bulkDeleteRoles(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        ApiResponse<ApiRoleList> resp = bulkDeleteRolesWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Bulk delete roles in a particular service by name.
     * Bulk delete roles in a particular service by name. Fails if any role cannot be found.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body list of role names to be deleted (optional)
     * @return ApiResponse&lt;ApiRoleList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiRoleList> bulkDeleteRolesWithHttpInfo(String clusterName, String serviceName, ApiRoleNameList body) throws ApiException {
        com.squareup.okhttp.Call call = bulkDeleteRolesValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiRoleList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Bulk delete roles in a particular service by name. (asynchronously)
     * Bulk delete roles in a particular service by name. Fails if any role cannot be found.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body list of role names to be deleted (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 bulkDeleteRolesAsync(String clusterName, String serviceName, ApiRoleNameList body, final ApiCallback<ApiRoleList> 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 = bulkDeleteRolesValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiRoleList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createRoles
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body Roles to create. (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 createRolesCall(String clusterName, String serviceName, ApiRoleList 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}/roles"
            .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 createRolesValidateBeforeCall(String clusterName, String serviceName, ApiRoleList 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 createRoles(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling createRoles(Async)");
        }
        
        
        com.squareup.okhttp.Call call = createRolesCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Create new roles in a given service.
     * Create new roles in a given service.  &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Service Type&lt;/th&gt; &lt;th&gt;Available Role Types&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH3)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH4)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, HTTPFS, FAILOVERCONTROLLER, GATEWAY, JOURNALNODE&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH5)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, HTTPFS, FAILOVERCONTROLLER, GATEWAY, JOURNALNODE, NFSGATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;td&gt;MAPREDUCE&lt;/td&gt; &lt;td&gt;JOBTRACKER, TASKTRACKER, GATEWAY, FAILOVERCONTROLLER,&lt;/td&gt; &lt;/tr&gt; &lt;td&gt;HBASE&lt;/td&gt; &lt;td&gt;MASTER, REGIONSERVER, GATEWAY, HBASETHRIFTSERVER, HBASERESTSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;YARN&lt;/td&gt; &lt;td&gt;RESOURCEMANAGER, NODEMANAGER, JOBHISTORY, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;OOZIE&lt;/td&gt; &lt;td&gt;OOZIE_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ZOOKEEPER&lt;/td&gt; &lt;td&gt;SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH3)&lt;/td&gt; &lt;td&gt;HUE_SERVER, BEESWAX_SERVER, KT_RENEWER, JOBSUBD&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH4)&lt;/td&gt; &lt;td&gt;HUE_SERVER, BEESWAX_SERVER, KT_RENEWER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH5)&lt;/td&gt; &lt;td&gt;HUE_SERVER, KT_RENEWER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH5 5.5+)&lt;/td&gt; &lt;td&gt;HUE_SERVER, KT_RENEWER, HUE_LOAD_BALANCER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;FLUME&lt;/td&gt; &lt;td&gt;AGENT&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;IMPALA (CDH4)&lt;/td&gt; &lt;td&gt;IMPALAD, STATESTORE, CATALOGSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;IMPALA (CDH5)&lt;/td&gt; &lt;td&gt;IMPALAD, STATESTORE, CATALOGSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HIVE&lt;/td&gt; &lt;td&gt;HIVESERVER2, HIVEMETASTORE, WEBHCAT, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SOLR&lt;/td&gt; &lt;td&gt;SOLR_SERVER, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SQOOP&lt;/td&gt; &lt;td&gt;SQOOP_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SQOOP_CLIENT&lt;/td&gt; &lt;td&gt;GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SENTRY&lt;/td&gt; &lt;td&gt;SENTRY_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ACCUMULO16&lt;/td&gt; &lt;td&gt;GARBAGE_COLLECTOR, GATEWAY, ACCUMULO16_MASTER, MONITOR, ACCUMULO16_TSERVER, TRACER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;KMS&lt;/td&gt; &lt;td&gt;KMS&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;KS_INDEXER&lt;/td&gt; &lt;td&gt;HBASE_INDEXER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SPARK_ON_YARN&lt;/td&gt; &lt;td&gt;GATEWAY, SPARK_YARN_HISTORY_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;  &lt;/table&gt;  When specifying roles to be created, the names provided for each role must not conflict with the names that CM auto-generates for roles. Specifically, names of the form \&quot;&lt;service name&gt;-&lt;role type&gt;-&lt;arbitrary value&gt;\&quot; cannot be used unless the &lt;arbitrary value&gt; is the same one CM would use. If CM detects such a conflict, the error message will indicate what &lt;arbitrary value&gt; is safe to use. Alternately, a differently formatted name should be used.  Since API v6: The role name can be left blank to allow CM to generate the name.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body Roles to create. (optional)
     * @return ApiRoleList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiRoleList createRoles(String clusterName, String serviceName, ApiRoleList body) throws ApiException {
        ApiResponse<ApiRoleList> resp = createRolesWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Create new roles in a given service.
     * Create new roles in a given service.  &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Service Type&lt;/th&gt; &lt;th&gt;Available Role Types&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH3)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH4)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, HTTPFS, FAILOVERCONTROLLER, GATEWAY, JOURNALNODE&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH5)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, HTTPFS, FAILOVERCONTROLLER, GATEWAY, JOURNALNODE, NFSGATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;td&gt;MAPREDUCE&lt;/td&gt; &lt;td&gt;JOBTRACKER, TASKTRACKER, GATEWAY, FAILOVERCONTROLLER,&lt;/td&gt; &lt;/tr&gt; &lt;td&gt;HBASE&lt;/td&gt; &lt;td&gt;MASTER, REGIONSERVER, GATEWAY, HBASETHRIFTSERVER, HBASERESTSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;YARN&lt;/td&gt; &lt;td&gt;RESOURCEMANAGER, NODEMANAGER, JOBHISTORY, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;OOZIE&lt;/td&gt; &lt;td&gt;OOZIE_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ZOOKEEPER&lt;/td&gt; &lt;td&gt;SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH3)&lt;/td&gt; &lt;td&gt;HUE_SERVER, BEESWAX_SERVER, KT_RENEWER, JOBSUBD&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH4)&lt;/td&gt; &lt;td&gt;HUE_SERVER, BEESWAX_SERVER, KT_RENEWER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH5)&lt;/td&gt; &lt;td&gt;HUE_SERVER, KT_RENEWER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH5 5.5+)&lt;/td&gt; &lt;td&gt;HUE_SERVER, KT_RENEWER, HUE_LOAD_BALANCER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;FLUME&lt;/td&gt; &lt;td&gt;AGENT&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;IMPALA (CDH4)&lt;/td&gt; &lt;td&gt;IMPALAD, STATESTORE, CATALOGSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;IMPALA (CDH5)&lt;/td&gt; &lt;td&gt;IMPALAD, STATESTORE, CATALOGSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HIVE&lt;/td&gt; &lt;td&gt;HIVESERVER2, HIVEMETASTORE, WEBHCAT, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SOLR&lt;/td&gt; &lt;td&gt;SOLR_SERVER, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SQOOP&lt;/td&gt; &lt;td&gt;SQOOP_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SQOOP_CLIENT&lt;/td&gt; &lt;td&gt;GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SENTRY&lt;/td&gt; &lt;td&gt;SENTRY_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ACCUMULO16&lt;/td&gt; &lt;td&gt;GARBAGE_COLLECTOR, GATEWAY, ACCUMULO16_MASTER, MONITOR, ACCUMULO16_TSERVER, TRACER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;KMS&lt;/td&gt; &lt;td&gt;KMS&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;KS_INDEXER&lt;/td&gt; &lt;td&gt;HBASE_INDEXER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SPARK_ON_YARN&lt;/td&gt; &lt;td&gt;GATEWAY, SPARK_YARN_HISTORY_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;  &lt;/table&gt;  When specifying roles to be created, the names provided for each role must not conflict with the names that CM auto-generates for roles. Specifically, names of the form \&quot;&lt;service name&gt;-&lt;role type&gt;-&lt;arbitrary value&gt;\&quot; cannot be used unless the &lt;arbitrary value&gt; is the same one CM would use. If CM detects such a conflict, the error message will indicate what &lt;arbitrary value&gt; is safe to use. Alternately, a differently formatted name should be used.  Since API v6: The role name can be left blank to allow CM to generate the name.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body Roles to create. (optional)
     * @return ApiResponse&lt;ApiRoleList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiRoleList> createRolesWithHttpInfo(String clusterName, String serviceName, ApiRoleList body) throws ApiException {
        com.squareup.okhttp.Call call = createRolesValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiRoleList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create new roles in a given service. (asynchronously)
     * Create new roles in a given service.  &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Service Type&lt;/th&gt; &lt;th&gt;Available Role Types&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH3)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH4)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, HTTPFS, FAILOVERCONTROLLER, GATEWAY, JOURNALNODE&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HDFS (CDH5)&lt;/td&gt; &lt;td&gt;NAMENODE, DATANODE, SECONDARYNAMENODE, BALANCER, HTTPFS, FAILOVERCONTROLLER, GATEWAY, JOURNALNODE, NFSGATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;td&gt;MAPREDUCE&lt;/td&gt; &lt;td&gt;JOBTRACKER, TASKTRACKER, GATEWAY, FAILOVERCONTROLLER,&lt;/td&gt; &lt;/tr&gt; &lt;td&gt;HBASE&lt;/td&gt; &lt;td&gt;MASTER, REGIONSERVER, GATEWAY, HBASETHRIFTSERVER, HBASERESTSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;YARN&lt;/td&gt; &lt;td&gt;RESOURCEMANAGER, NODEMANAGER, JOBHISTORY, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;OOZIE&lt;/td&gt; &lt;td&gt;OOZIE_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ZOOKEEPER&lt;/td&gt; &lt;td&gt;SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH3)&lt;/td&gt; &lt;td&gt;HUE_SERVER, BEESWAX_SERVER, KT_RENEWER, JOBSUBD&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH4)&lt;/td&gt; &lt;td&gt;HUE_SERVER, BEESWAX_SERVER, KT_RENEWER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH5)&lt;/td&gt; &lt;td&gt;HUE_SERVER, KT_RENEWER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HUE (CDH5 5.5+)&lt;/td&gt; &lt;td&gt;HUE_SERVER, KT_RENEWER, HUE_LOAD_BALANCER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;FLUME&lt;/td&gt; &lt;td&gt;AGENT&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;IMPALA (CDH4)&lt;/td&gt; &lt;td&gt;IMPALAD, STATESTORE, CATALOGSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;IMPALA (CDH5)&lt;/td&gt; &lt;td&gt;IMPALAD, STATESTORE, CATALOGSERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;HIVE&lt;/td&gt; &lt;td&gt;HIVESERVER2, HIVEMETASTORE, WEBHCAT, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SOLR&lt;/td&gt; &lt;td&gt;SOLR_SERVER, GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SQOOP&lt;/td&gt; &lt;td&gt;SQOOP_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SQOOP_CLIENT&lt;/td&gt; &lt;td&gt;GATEWAY&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SENTRY&lt;/td&gt; &lt;td&gt;SENTRY_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;ACCUMULO16&lt;/td&gt; &lt;td&gt;GARBAGE_COLLECTOR, GATEWAY, ACCUMULO16_MASTER, MONITOR, ACCUMULO16_TSERVER, TRACER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;KMS&lt;/td&gt; &lt;td&gt;KMS&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;KS_INDEXER&lt;/td&gt; &lt;td&gt;HBASE_INDEXER&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;SPARK_ON_YARN&lt;/td&gt; &lt;td&gt;GATEWAY, SPARK_YARN_HISTORY_SERVER&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;  &lt;/table&gt;  When specifying roles to be created, the names provided for each role must not conflict with the names that CM auto-generates for roles. Specifically, names of the form \&quot;&lt;service name&gt;-&lt;role type&gt;-&lt;arbitrary value&gt;\&quot; cannot be used unless the &lt;arbitrary value&gt; is the same one CM would use. If CM detects such a conflict, the error message will indicate what &lt;arbitrary value&gt; is safe to use. Alternately, a differently formatted name should be used.  Since API v6: The role name can be left blank to allow CM to generate the name.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body Roles to create. (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 createRolesAsync(String clusterName, String serviceName, ApiRoleList body, final ApiCallback<ApiRoleList> 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 = createRolesValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiRoleList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for deleteRole
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call deleteRoleCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 = {
            
        };
        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, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteRoleValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 deleteRole(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling deleteRole(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling deleteRole(Async)");
        }
        
        
        com.squareup.okhttp.Call call = deleteRoleCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Deletes a role from a given service.
     * Deletes a role from a given service.
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @return ApiRole
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiRole deleteRole(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<ApiRole> resp = deleteRoleWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Deletes a role from a given service.
     * Deletes a role from a given service.
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;ApiRole&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiRole> deleteRoleWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = deleteRoleValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<ApiRole>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Deletes a role from a given service. (asynchronously)
     * Deletes a role from a given service.
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call deleteRoleAsync(String clusterName, String roleName, String serviceName, final ApiCallback<ApiRole> 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 = deleteRoleValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiRole>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for deleteTags
     * @param clusterName  (required)
     * @param roleName Name of the role to remove tags from (required)
     * @param serviceName  (required)
     * @param body A list of tags to remove from the role (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 deleteTagsCall(String clusterName, String roleName, String serviceName, List<ApiEntityTag> 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}/roles/{roleName}/tags"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteTagsValidateBeforeCall(String clusterName, String roleName, String serviceName, List<ApiEntityTag> 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 deleteTags(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling deleteTags(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling deleteTags(Async)");
        }
        
        
        com.squareup.okhttp.Call call = deleteTagsCall(clusterName, roleName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Remove the tags associated with the role.
     * Remove the tags associated with the role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName Name of the role to remove tags from (required)
     * @param serviceName  (required)
     * @param body A list of tags to remove from the role (optional)
     * @return List&lt;ApiEntityTag&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public List<ApiEntityTag> deleteTags(String clusterName, String roleName, String serviceName, List<ApiEntityTag> body) throws ApiException {
        ApiResponse<List<ApiEntityTag>> resp = deleteTagsWithHttpInfo(clusterName, roleName, serviceName, body);
        return resp.getData();
    }

    /**
     * Remove the tags associated with the role.
     * Remove the tags associated with the role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName Name of the role to remove tags from (required)
     * @param serviceName  (required)
     * @param body A list of tags to remove from the role (optional)
     * @return ApiResponse&lt;List&lt;ApiEntityTag&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<List<ApiEntityTag>> deleteTagsWithHttpInfo(String clusterName, String roleName, String serviceName, List<ApiEntityTag> body) throws ApiException {
        com.squareup.okhttp.Call call = deleteTagsValidateBeforeCall(clusterName, roleName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<List<ApiEntityTag>>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Remove the tags associated with the role. (asynchronously)
     * Remove the tags associated with the role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName Name of the role to remove tags from (required)
     * @param serviceName  (required)
     * @param body A list of tags to remove from the role (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 deleteTagsAsync(String clusterName, String roleName, String serviceName, List<ApiEntityTag> body, final ApiCallback<List<ApiEntityTag>> 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 = deleteTagsValidateBeforeCall(clusterName, roleName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<List<ApiEntityTag>>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for enterMaintenanceMode
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call enterMaintenanceModeCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commands/enterMaintenanceMode"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 = {
            
        };
        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 enterMaintenanceModeValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 enterMaintenanceMode(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling enterMaintenanceMode(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling enterMaintenanceMode(Async)");
        }
        
        
        com.squareup.okhttp.Call call = enterMaintenanceModeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Put the role into maintenance mode.
     * Put the role into maintenance mode. This is a synchronous command. The result is known immediately upon return.  &lt;p&gt; Available since API v2. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand enterMaintenanceMode(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<ApiCommand> resp = enterMaintenanceModeWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Put the role into maintenance mode.
     * Put the role into maintenance mode. This is a synchronous command. The result is known immediately upon return.  &lt;p&gt; Available since API v2. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> enterMaintenanceModeWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = enterMaintenanceModeValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Put the role into maintenance mode. (asynchronously)
     * Put the role into maintenance mode. This is a synchronous command. The result is known immediately upon return.  &lt;p&gt; Available since API v2. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call enterMaintenanceModeAsync(String clusterName, String roleName, String serviceName, final ApiCallback<ApiCommand> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = enterMaintenanceModeValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for exitMaintenanceMode
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call exitMaintenanceModeCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commands/exitMaintenanceMode"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 = {
            
        };
        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 exitMaintenanceModeValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 exitMaintenanceMode(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling exitMaintenanceMode(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling exitMaintenanceMode(Async)");
        }
        
        
        com.squareup.okhttp.Call call = exitMaintenanceModeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Take the role out of maintenance mode.
     * Take the role out of maintenance mode. This is a synchronous command. The result is known immediately upon return.  &lt;p&gt; Available since API v2. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand exitMaintenanceMode(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<ApiCommand> resp = exitMaintenanceModeWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Take the role out of maintenance mode.
     * Take the role out of maintenance mode. This is a synchronous command. The result is known immediately upon return.  &lt;p&gt; Available since API v2. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> exitMaintenanceModeWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = exitMaintenanceModeValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Take the role out of maintenance mode. (asynchronously)
     * Take the role out of maintenance mode. This is a synchronous command. The result is known immediately upon return.  &lt;p&gt; Available since API v2. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call exitMaintenanceModeAsync(String clusterName, String roleName, String serviceName, final ApiCallback<ApiCommand> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = exitMaintenanceModeValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getFullLog
     * @param clusterName  (required)
     * @param roleName The role to fetch logs from. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getFullLogCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/full"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 = {
            "text/plain"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getFullLogValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 getFullLog(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling getFullLog(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getFullLog(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getFullLogCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieves the log file for the role&#39;s main process.
     * Retrieves the log file for the role&#39;s main process. &lt;p&gt; If the role is not started, this will be the log file associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch logs from. (required)
     * @param serviceName  (required)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String getFullLog(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<String> resp = getFullLogWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Retrieves the log file for the role&#39;s main process.
     * Retrieves the log file for the role&#39;s main process. &lt;p&gt; If the role is not started, this will be the log file associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch logs from. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;String&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<String> getFullLogWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = getFullLogValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieves the log file for the role&#39;s main process. (asynchronously)
     * Retrieves the log file for the role&#39;s main process. &lt;p&gt; If the role is not started, this will be the log file associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch logs from. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getFullLogAsync(String clusterName, String roleName, String serviceName, final ApiCallback<String> 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 = getFullLogValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getMetrics
     * @param clusterName  (required)
     * @param roleName The name of the role. (required)
     * @param serviceName  (required)
     * @param from Start of the period to query. (optional)
     * @param metrics Filter for which metrics to query. (optional)
     * @param to End of the period to query. (optional, default to now)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getMetricsCall(String clusterName, String roleName, String serviceName, String from, List<String> metrics, String to, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/metrics"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getMetricsValidateBeforeCall(String clusterName, String roleName, String serviceName, String from, List<String> metrics, String to, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling getMetrics(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling getMetrics(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getMetrics(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getMetricsCall(clusterName, roleName, serviceName, from, metrics, to, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

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

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

    /**
     * Fetch metric readings for a particular role. (asynchronously)
     * Fetch metric readings for a particular role. &lt;p&gt; By default, this call will look up all metrics available for the role. If only specific metrics are desired, use the &lt;i&gt;metrics&lt;/i&gt; parameter. &lt;p&gt; By default, the returned results correspond to a 5 minute window based on the provided end time (which defaults to the current server time). The &lt;i&gt;from&lt;/i&gt; and &lt;i&gt;to&lt;/i&gt; parameters can be used to control the window being queried. A maximum window of 3 hours is enforced. &lt;p&gt; When requesting a \&quot;full\&quot; view, aside from the extended properties of the returned metric data, the collection will also contain information about all metrics available for the role, even if no readings are available in the requested window.
     * @param clusterName  (required)
     * @param roleName The name of the role. (required)
     * @param serviceName  (required)
     * @param from Start of the period to query. (optional)
     * @param metrics Filter for which metrics to query. (optional)
     * @param to End of the period to query. (optional, default to now)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getMetricsAsync(String clusterName, String roleName, String serviceName, String from, List<String> metrics, String to, String view, final ApiCallback<ApiMetricList> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = getMetricsValidateBeforeCall(clusterName, roleName, serviceName, from, metrics, to, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiMetricList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getStacksLog
     * @param clusterName  (required)
     * @param roleName The role to fetch stacks logs from. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getStacksLogCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/stacks"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 = {
            "text/plain"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getStacksLogValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 getStacksLog(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling getStacksLog(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getStacksLog(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getStacksLogCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieves the stacks log file, if any, for the role&#39;s main process.
     * Retrieves the stacks log file, if any, for the role&#39;s main process. Note that not all roles support periodic stacks collection.  The log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stacks logs from. (required)
     * @param serviceName  (required)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String getStacksLog(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<String> resp = getStacksLogWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Retrieves the stacks log file, if any, for the role&#39;s main process.
     * Retrieves the stacks log file, if any, for the role&#39;s main process. Note that not all roles support periodic stacks collection.  The log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stacks logs from. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;String&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<String> getStacksLogWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = getStacksLogValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieves the stacks log file, if any, for the role&#39;s main process. (asynchronously)
     * Retrieves the stacks log file, if any, for the role&#39;s main process. Note that not all roles support periodic stacks collection.  The log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stacks logs from. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getStacksLogAsync(String clusterName, String roleName, String serviceName, final ApiCallback<String> 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 = getStacksLogValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getStacksLogsBundle
     * @param clusterName  (required)
     * @param roleName The role to fetch the stacks logs bundle from. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getStacksLogsBundleCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/stacksBundle"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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/octet-stream"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getStacksLogsBundleValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 getStacksLogsBundle(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling getStacksLogsBundle(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getStacksLogsBundle(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getStacksLogsBundleCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Download a zip-compressed archive of role stacks logs.
     * Download a zip-compressed archive of role stacks logs. Note that not all roles support periodic stacks collection.
     * @param clusterName  (required)
     * @param roleName The role to fetch the stacks logs bundle from. (required)
     * @param serviceName  (required)
     * @return File
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public File getStacksLogsBundle(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<File> resp = getStacksLogsBundleWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Download a zip-compressed archive of role stacks logs.
     * Download a zip-compressed archive of role stacks logs. Note that not all roles support periodic stacks collection.
     * @param clusterName  (required)
     * @param roleName The role to fetch the stacks logs bundle from. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;File&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<File> getStacksLogsBundleWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = getStacksLogsBundleValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<File>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Download a zip-compressed archive of role stacks logs. (asynchronously)
     * Download a zip-compressed archive of role stacks logs. Note that not all roles support periodic stacks collection.
     * @param clusterName  (required)
     * @param roleName The role to fetch the stacks logs bundle from. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getStacksLogsBundleAsync(String clusterName, String roleName, String serviceName, final ApiCallback<File> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = getStacksLogsBundleValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<File>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getStandardError
     * @param clusterName  (required)
     * @param roleName The role to fetch stderr from. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getStandardErrorCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/stderr"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 = {
            "text/plain"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getStandardErrorValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 getStandardError(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling getStandardError(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getStandardError(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getStandardErrorCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieves the role&#39;s standard error output.
     * Retrieves the role&#39;s standard error output. &lt;p&gt; If the role is not started, this will be the output associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stderr from. (required)
     * @param serviceName  (required)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String getStandardError(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<String> resp = getStandardErrorWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Retrieves the role&#39;s standard error output.
     * Retrieves the role&#39;s standard error output. &lt;p&gt; If the role is not started, this will be the output associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stderr from. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;String&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<String> getStandardErrorWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = getStandardErrorValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieves the role&#39;s standard error output. (asynchronously)
     * Retrieves the role&#39;s standard error output. &lt;p&gt; If the role is not started, this will be the output associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stderr from. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getStandardErrorAsync(String clusterName, String roleName, String serviceName, final ApiCallback<String> 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 = getStandardErrorValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getStandardOutput
     * @param clusterName  (required)
     * @param roleName The role to fetch stdout from. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call getStandardOutputCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/logs/stdout"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 = {
            "text/plain"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getStandardOutputValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 getStandardOutput(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling getStandardOutput(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling getStandardOutput(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getStandardOutputCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieves the role&#39;s standard output.
     * Retrieves the role&#39;s standard output. &lt;p&gt; If the role is not started, this will be the output associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stdout from. (required)
     * @param serviceName  (required)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String getStandardOutput(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<String> resp = getStandardOutputWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Retrieves the role&#39;s standard output.
     * Retrieves the role&#39;s standard output. &lt;p&gt; If the role is not started, this will be the output associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stdout from. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;String&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<String> getStandardOutputWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = getStandardOutputValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieves the role&#39;s standard output. (asynchronously)
     * Retrieves the role&#39;s standard output. &lt;p&gt; If the role is not started, this will be the output associated with the last time the role was run. &lt;p&gt; Log files are returned as plain text (type \&quot;text/plain\&quot;).
     * @param clusterName  (required)
     * @param roleName The role to fetch stdout from. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call getStandardOutputAsync(String clusterName, String roleName, String serviceName, final ApiCallback<String> 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 = getStandardOutputValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for impalaDiagnostics
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param body  (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 impalaDiagnosticsCall(String clusterName, String roleName, String serviceName, ApiImpalaRoleDiagnosticsArgs 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}/roles/{roleName}/commands/impalaDiagnostics"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 impalaDiagnosticsValidateBeforeCall(String clusterName, String roleName, String serviceName, ApiImpalaRoleDiagnosticsArgs 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 impalaDiagnostics(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling impalaDiagnostics(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling impalaDiagnostics(Async)");
        }
        
        
        com.squareup.okhttp.Call call = impalaDiagnosticsCall(clusterName, roleName, serviceName, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Collects diagnostics data for an Impala role.
     * Collects diagnostics data for an Impala role.  &lt;p&gt; Available since API v31. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param body  (optional)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand impalaDiagnostics(String clusterName, String roleName, String serviceName, ApiImpalaRoleDiagnosticsArgs body) throws ApiException {
        ApiResponse<ApiCommand> resp = impalaDiagnosticsWithHttpInfo(clusterName, roleName, serviceName, body);
        return resp.getData();
    }

    /**
     * Collects diagnostics data for an Impala role.
     * Collects diagnostics data for an Impala role.  &lt;p&gt; Available since API v31. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param body  (optional)
     * @return ApiResponse&lt;ApiCommand&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommand> impalaDiagnosticsWithHttpInfo(String clusterName, String roleName, String serviceName, ApiImpalaRoleDiagnosticsArgs body) throws ApiException {
        com.squareup.okhttp.Call call = impalaDiagnosticsValidateBeforeCall(clusterName, roleName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Collects diagnostics data for an Impala role. (asynchronously)
     * Collects diagnostics data for an Impala role.  &lt;p&gt; Available since API v31. &lt;/p&gt;
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param body  (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 impalaDiagnosticsAsync(String clusterName, String roleName, String serviceName, ApiImpalaRoleDiagnosticsArgs body, final ApiCallback<ApiCommand> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = impalaDiagnosticsValidateBeforeCall(clusterName, roleName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for listActiveCommands
     * @param clusterName  (required)
     * @param roleName The role to start. (required)
     * @param serviceName  (required)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call listActiveCommandsCall(String clusterName, String roleName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commands"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call listActiveCommandsValidateBeforeCall(String clusterName, String roleName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling listActiveCommands(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling listActiveCommands(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling listActiveCommands(Async)");
        }
        
        
        com.squareup.okhttp.Call call = listActiveCommandsCall(clusterName, roleName, serviceName, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * List active role commands.
     * List active role commands.
     * @param clusterName  (required)
     * @param roleName The role to start. (required)
     * @param serviceName  (required)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @return ApiCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommandList listActiveCommands(String clusterName, String roleName, String serviceName, String view) throws ApiException {
        ApiResponse<ApiCommandList> resp = listActiveCommandsWithHttpInfo(clusterName, roleName, serviceName, view);
        return resp.getData();
    }

    /**
     * List active role commands.
     * List active role commands.
     * @param clusterName  (required)
     * @param roleName The role to start. (required)
     * @param serviceName  (required)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @return ApiResponse&lt;ApiCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommandList> listActiveCommandsWithHttpInfo(String clusterName, String roleName, String serviceName, String view) throws ApiException {
        com.squareup.okhttp.Call call = listActiveCommandsValidateBeforeCall(clusterName, roleName, serviceName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * List active role commands. (asynchronously)
     * List active role commands.
     * @param clusterName  (required)
     * @param roleName The role to start. (required)
     * @param serviceName  (required)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call listActiveCommandsAsync(String clusterName, String roleName, String serviceName, String view, final ApiCallback<ApiCommandList> 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 = listActiveCommandsValidateBeforeCall(clusterName, roleName, serviceName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for listCommands
     * @param clusterName  (required)
     * @param roleName the role name. (required)
     * @param serviceName  (required)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call listCommandsCall(String clusterName, String roleName, String serviceName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/commandsByName"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.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 = {
            
        };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call listCommandsValidateBeforeCall(String clusterName, String roleName, String serviceName, 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 listCommands(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling listCommands(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling listCommands(Async)");
        }
        
        
        com.squareup.okhttp.Call call = listCommandsCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Lists all the commands that can be executed by name on the provided role.
     * Lists all the commands that can be executed by name on the provided role.
     * @param clusterName  (required)
     * @param roleName the role name. (required)
     * @param serviceName  (required)
     * @return ApiCommandMetadataList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommandMetadataList listCommands(String clusterName, String roleName, String serviceName) throws ApiException {
        ApiResponse<ApiCommandMetadataList> resp = listCommandsWithHttpInfo(clusterName, roleName, serviceName);
        return resp.getData();
    }

    /**
     * Lists all the commands that can be executed by name on the provided role.
     * Lists all the commands that can be executed by name on the provided role.
     * @param clusterName  (required)
     * @param roleName the role name. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;ApiCommandMetadataList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiCommandMetadataList> listCommandsWithHttpInfo(String clusterName, String roleName, String serviceName) throws ApiException {
        com.squareup.okhttp.Call call = listCommandsValidateBeforeCall(clusterName, roleName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<ApiCommandMetadataList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Lists all the commands that can be executed by name on the provided role. (asynchronously)
     * Lists all the commands that can be executed by name on the provided role.
     * @param clusterName  (required)
     * @param roleName the role name. (required)
     * @param serviceName  (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call listCommandsAsync(String clusterName, String roleName, String serviceName, final ApiCallback<ApiCommandMetadataList> 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 = listCommandsValidateBeforeCall(clusterName, roleName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommandMetadataList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readRole
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param view The view to materialize. Defaults to &#39;full&#39;. (optional, default to full)
     * @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 readRoleCall(String clusterName, String roleName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call readRoleValidateBeforeCall(String clusterName, String roleName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling readRole(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling readRole(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling readRole(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readRoleCall(clusterName, roleName, serviceName, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieves detailed information about a role.
     * Retrieves detailed information about a role.
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param view The view to materialize. Defaults to &#39;full&#39;. (optional, default to full)
     * @return ApiRole
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiRole readRole(String clusterName, String roleName, String serviceName, String view) throws ApiException {
        ApiResponse<ApiRole> resp = readRoleWithHttpInfo(clusterName, roleName, serviceName, view);
        return resp.getData();
    }

    /**
     * Retrieves detailed information about a role.
     * Retrieves detailed information about a role.
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param view The view to materialize. Defaults to &#39;full&#39;. (optional, default to full)
     * @return ApiResponse&lt;ApiRole&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiRole> readRoleWithHttpInfo(String clusterName, String roleName, String serviceName, String view) throws ApiException {
        com.squareup.okhttp.Call call = readRoleValidateBeforeCall(clusterName, roleName, serviceName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiRole>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieves detailed information about a role. (asynchronously)
     * Retrieves detailed information about a role.
     * @param clusterName  (required)
     * @param roleName The role name. (required)
     * @param serviceName  (required)
     * @param view The view to materialize. Defaults to &#39;full&#39;. (optional, default to full)
     * @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 readRoleAsync(String clusterName, String roleName, String serviceName, String view, final ApiCallback<ApiRole> 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 = readRoleValidateBeforeCall(clusterName, roleName, serviceName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiRole>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readRoleConfig
     * @param clusterName  (required)
     * @param roleName The role to look up. (required)
     * @param serviceName  (required)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call readRoleConfigCall(String clusterName, String roleName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/config"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call readRoleConfigValidateBeforeCall(String clusterName, String roleName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling readRoleConfig(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling readRoleConfig(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling readRoleConfig(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readRoleConfigCall(clusterName, roleName, serviceName, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Retrieves the configuration of a specific role.
     * Retrieves the configuration of a specific role. Note that the \&quot;full\&quot; view performs validation on the configuration, which could take a few seconds on a large cluster (around 500 nodes or more).
     * @param clusterName  (required)
     * @param roleName The role to look up. (required)
     * @param serviceName  (required)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @return ApiConfigList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiConfigList readRoleConfig(String clusterName, String roleName, String serviceName, String view) throws ApiException {
        ApiResponse<ApiConfigList> resp = readRoleConfigWithHttpInfo(clusterName, roleName, serviceName, view);
        return resp.getData();
    }

    /**
     * Retrieves the configuration of a specific role.
     * Retrieves the configuration of a specific role. Note that the \&quot;full\&quot; view performs validation on the configuration, which could take a few seconds on a large cluster (around 500 nodes or more).
     * @param clusterName  (required)
     * @param roleName The role to look up. (required)
     * @param serviceName  (required)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @return ApiResponse&lt;ApiConfigList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiConfigList> readRoleConfigWithHttpInfo(String clusterName, String roleName, String serviceName, String view) throws ApiException {
        com.squareup.okhttp.Call call = readRoleConfigValidateBeforeCall(clusterName, roleName, serviceName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiConfigList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieves the configuration of a specific role. (asynchronously)
     * Retrieves the configuration of a specific role. Note that the \&quot;full\&quot; view performs validation on the configuration, which could take a few seconds on a large cluster (around 500 nodes or more).
     * @param clusterName  (required)
     * @param roleName The role to look up. (required)
     * @param serviceName  (required)
     * @param view The view of the data to materialize, either \&quot;summary\&quot; or \&quot;full\&quot;. (optional, default to summary)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call readRoleConfigAsync(String clusterName, String roleName, String serviceName, String view, final ApiCallback<ApiConfigList> 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 = readRoleConfigValidateBeforeCall(clusterName, roleName, serviceName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiConfigList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readRoles
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param filter Optional query to filter the roles by. &lt;p&gt; The query specifies the intersection of a list of constraints, joined together with semicolons (without spaces). For example: hostname&#x3D;&#x3D;host1.abc.com;type&#x3D;&#x3D;DATANODE &lt;/p&gt;  Currently supports filtering by: &lt;ul&gt; &lt;li&gt;hostname: The hostname of the host the role is running on.&lt;/li&gt; &lt;li&gt;hostId: The unique identifier of the host the role is running on.&lt;/li&gt; &lt;li&gt;type: The role&#39;s type.&lt;/li&gt; &lt;/ul&gt; (optional, default to )
     * @param view DataView for getting roles. Defaults to &#39;summary&#39;. (optional, default to summary)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call readRolesCall(String clusterName, String serviceName, String filter, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call readRolesValidateBeforeCall(String clusterName, String serviceName, String filter, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'clusterName' is set
        if (clusterName == null) {
            throw new ApiException("Missing the required parameter 'clusterName' when calling readRoles(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling readRoles(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readRolesCall(clusterName, serviceName, filter, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Lists all roles of a given service.
     * Lists all roles of a given service.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param filter Optional query to filter the roles by. &lt;p&gt; The query specifies the intersection of a list of constraints, joined together with semicolons (without spaces). For example: hostname&#x3D;&#x3D;host1.abc.com;type&#x3D;&#x3D;DATANODE &lt;/p&gt;  Currently supports filtering by: &lt;ul&gt; &lt;li&gt;hostname: The hostname of the host the role is running on.&lt;/li&gt; &lt;li&gt;hostId: The unique identifier of the host the role is running on.&lt;/li&gt; &lt;li&gt;type: The role&#39;s type.&lt;/li&gt; &lt;/ul&gt; (optional, default to )
     * @param view DataView for getting roles. Defaults to &#39;summary&#39;. (optional, default to summary)
     * @return ApiRoleList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiRoleList readRoles(String clusterName, String serviceName, String filter, String view) throws ApiException {
        ApiResponse<ApiRoleList> resp = readRolesWithHttpInfo(clusterName, serviceName, filter, view);
        return resp.getData();
    }

    /**
     * Lists all roles of a given service.
     * Lists all roles of a given service.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param filter Optional query to filter the roles by. &lt;p&gt; The query specifies the intersection of a list of constraints, joined together with semicolons (without spaces). For example: hostname&#x3D;&#x3D;host1.abc.com;type&#x3D;&#x3D;DATANODE &lt;/p&gt;  Currently supports filtering by: &lt;ul&gt; &lt;li&gt;hostname: The hostname of the host the role is running on.&lt;/li&gt; &lt;li&gt;hostId: The unique identifier of the host the role is running on.&lt;/li&gt; &lt;li&gt;type: The role&#39;s type.&lt;/li&gt; &lt;/ul&gt; (optional, default to )
     * @param view DataView for getting roles. Defaults to &#39;summary&#39;. (optional, default to summary)
     * @return ApiResponse&lt;ApiRoleList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiRoleList> readRolesWithHttpInfo(String clusterName, String serviceName, String filter, String view) throws ApiException {
        com.squareup.okhttp.Call call = readRolesValidateBeforeCall(clusterName, serviceName, filter, view, null, null);
        Type localVarReturnType = new TypeToken<ApiRoleList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Lists all roles of a given service. (asynchronously)
     * Lists all roles of a given service.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param filter Optional query to filter the roles by. &lt;p&gt; The query specifies the intersection of a list of constraints, joined together with semicolons (without spaces). For example: hostname&#x3D;&#x3D;host1.abc.com;type&#x3D;&#x3D;DATANODE &lt;/p&gt;  Currently supports filtering by: &lt;ul&gt; &lt;li&gt;hostname: The hostname of the host the role is running on.&lt;/li&gt; &lt;li&gt;hostId: The unique identifier of the host the role is running on.&lt;/li&gt; &lt;li&gt;type: The role&#39;s type.&lt;/li&gt; &lt;/ul&gt; (optional, default to )
     * @param view DataView for getting roles. Defaults to &#39;summary&#39;. (optional, default to summary)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call readRolesAsync(String clusterName, String serviceName, String filter, String view, final ApiCallback<ApiRoleList> 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 = readRolesValidateBeforeCall(clusterName, serviceName, filter, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiRoleList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readTags
     * @param clusterName  (required)
     * @param roleName The name of the role (required)
     * @param serviceName  (required)
     * @param limit Number of tags (optional, default to 10)
     * @param offset Index of the first tag to retrieve (optional, default to 0)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public com.squareup.okhttp.Call readTagsCall(String clusterName, String roleName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/roles/{roleName}/tags"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

        String[] localVarAuthNames = new String[] { "basic" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call readTagsValidateBeforeCall(String clusterName, String roleName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset, 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 readTags(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling readTags(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling readTags(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readTagsCall(clusterName, roleName, serviceName, limit, offset, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Returns the tags associated with this role.
     * Returns the tags associated with this role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName The name of the role (required)
     * @param serviceName  (required)
     * @param limit Number of tags (optional, default to 10)
     * @param offset Index of the first tag to retrieve (optional, default to 0)
     * @return List&lt;ApiEntityTag&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public List<ApiEntityTag> readTags(String clusterName, String roleName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset) throws ApiException {
        ApiResponse<List<ApiEntityTag>> resp = readTagsWithHttpInfo(clusterName, roleName, serviceName, limit, offset);
        return resp.getData();
    }

    /**
     * Returns the tags associated with this role.
     * Returns the tags associated with this role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName The name of the role (required)
     * @param serviceName  (required)
     * @param limit Number of tags (optional, default to 10)
     * @param offset Index of the first tag to retrieve (optional, default to 0)
     * @return ApiResponse&lt;List&lt;ApiEntityTag&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<List<ApiEntityTag>> readTagsWithHttpInfo(String clusterName, String roleName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset) throws ApiException {
        com.squareup.okhttp.Call call = readTagsValidateBeforeCall(clusterName, roleName, serviceName, limit, offset, null, null);
        Type localVarReturnType = new TypeToken<List<ApiEntityTag>>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the tags associated with this role. (asynchronously)
     * Returns the tags associated with this role. Tag names beginning with the prefix _cldr_ (case insensitive) are reserved for internal use by Cloudera.
     * @param clusterName  (required)
     * @param roleName The name of the role (required)
     * @param serviceName  (required)
     * @param limit Number of tags (optional, default to 10)
     * @param offset Index of the first tag to retrieve (optional, default to 0)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call readTagsAsync(String clusterName, String roleName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset, final ApiCallback<List<ApiEntityTag>> 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 = readTagsValidateBeforeCall(clusterName, roleName, serviceName, limit, offset, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<List<ApiEntityTag>>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateRoleConfig
     * @param clusterName  (required)
     * @param roleName The role to modify. (required)
     * @param serviceName  (required)
     * @param message Optional message describing the changes. (optional)
     * @param body Configuration changes. (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 updateRoleConfigCall(String clusterName, String roleName, String serviceName, String message, ApiConfigList 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}/roles/{roleName}/config"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "roleName" + "\\}", apiClient.escapeString(roleName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

        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, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }
    
    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call updateRoleConfigValidateBeforeCall(String clusterName, String roleName, String serviceName, String message, ApiConfigList 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 updateRoleConfig(Async)");
        }
        
        // verify the required parameter 'roleName' is set
        if (roleName == null) {
            throw new ApiException("Missing the required parameter 'roleName' when calling updateRoleConfig(Async)");
        }
        
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling updateRoleConfig(Async)");
        }
        
        
        com.squareup.okhttp.Call call = updateRoleConfigCall(clusterName, roleName, serviceName, message, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Updates the role configuration with the given values.
     * Updates the role configuration with the given values. &lt;p&gt; If a value is set in the given configuration, it will be added to the role&#39;s configuration, replacing any existing entries. If a value is unset (its value is null), the existing configuration for the attribute will be erased, if any. &lt;p&gt; Attributes that are not listed in the input will maintain their current values in the configuration.
     * @param clusterName  (required)
     * @param roleName The role to modify. (required)
     * @param serviceName  (required)
     * @param message Optional message describing the changes. (optional)
     * @param body Configuration changes. (optional)
     * @return ApiConfigList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiConfigList updateRoleConfig(String clusterName, String roleName, String serviceName, String message, ApiConfigList body) throws ApiException {
        ApiResponse<ApiConfigList> resp = updateRoleConfigWithHttpInfo(clusterName, roleName, serviceName, message, body);
        return resp.getData();
    }

    /**
     * Updates the role configuration with the given values.
     * Updates the role configuration with the given values. &lt;p&gt; If a value is set in the given configuration, it will be added to the role&#39;s configuration, replacing any existing entries. If a value is unset (its value is null), the existing configuration for the attribute will be erased, if any. &lt;p&gt; Attributes that are not listed in the input will maintain their current values in the configuration.
     * @param clusterName  (required)
     * @param roleName The role to modify. (required)
     * @param serviceName  (required)
     * @param message Optional message describing the changes. (optional)
     * @param body Configuration changes. (optional)
     * @return ApiResponse&lt;ApiConfigList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiConfigList> updateRoleConfigWithHttpInfo(String clusterName, String roleName, String serviceName, String message, ApiConfigList body) throws ApiException {
        com.squareup.okhttp.Call call = updateRoleConfigValidateBeforeCall(clusterName, roleName, serviceName, message, body, null, null);
        Type localVarReturnType = new TypeToken<ApiConfigList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Updates the role configuration with the given values. (asynchronously)
     * Updates the role configuration with the given values. &lt;p&gt; If a value is set in the given configuration, it will be added to the role&#39;s configuration, replacing any existing entries. If a value is unset (its value is null), the existing configuration for the attribute will be erased, if any. &lt;p&gt; Attributes that are not listed in the input will maintain their current values in the configuration.
     * @param clusterName  (required)
     * @param roleName The role to modify. (required)
     * @param serviceName  (required)
     * @param message Optional message describing the changes. (optional)
     * @param body Configuration changes. (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 updateRoleConfigAsync(String clusterName, String roleName, String serviceName, String message, ApiConfigList body, final ApiCallback<ApiConfigList> 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 = updateRoleConfigValidateBeforeCall(clusterName, roleName, serviceName, message, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiConfigList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
