/*
 * 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.ApiCommandMetadataList;
import com.cloudera.api.swagger.model.ApiConfigList;
import com.cloudera.api.swagger.model.ApiExternalAccount;
import com.cloudera.api.swagger.model.ApiExternalAccountCategoryList;
import com.cloudera.api.swagger.model.ApiExternalAccountList;
import com.cloudera.api.swagger.model.ApiExternalAccountTypeList;

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

public class ExternalAccountsResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for createAccount
     * @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 createAccountCall(ApiExternalAccount body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/create";

        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 createAccountValidateBeforeCall(ApiExternalAccount body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = createAccountCall(body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Create a new external account.
     * Create a new external account. Account names and display names must be unique, i.e. they must not share names or display names with an existing account. Server generates an account ID for the requested account.
     * @param body  (optional)
     * @return ApiExternalAccount
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiExternalAccount createAccount(ApiExternalAccount body) throws ApiException {
        ApiResponse<ApiExternalAccount> resp = createAccountWithHttpInfo(body);
        return resp.getData();
    }

    /**
     * Create a new external account.
     * Create a new external account. Account names and display names must be unique, i.e. they must not share names or display names with an existing account. Server generates an account ID for the requested account.
     * @param body  (optional)
     * @return ApiResponse&lt;ApiExternalAccount&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiExternalAccount> createAccountWithHttpInfo(ApiExternalAccount body) throws ApiException {
        com.squareup.okhttp.Call call = createAccountValidateBeforeCall(body, null, null);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create a new external account. (asynchronously)
     * Create a new external account. Account names and display names must be unique, i.e. they must not share names or display names with an existing account. Server generates an account ID for the requested account.
     * @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 createAccountAsync(ApiExternalAccount body, final ApiCallback<ApiExternalAccount> 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 = createAccountValidateBeforeCall(body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for deleteAccount
     * @param name  (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 deleteAccountCall(String name, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/delete/{name}"
            .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.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 deleteAccountValidateBeforeCall(String name, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'name' is set
        if (name == null) {
            throw new ApiException("Missing the required parameter 'name' when calling deleteAccount(Async)");
        }
        
        
        com.squareup.okhttp.Call call = deleteAccountCall(name, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Delete an external account, specifying its name.
     * Delete an external account, specifying its name.
     * @param name  (required)
     * @return ApiExternalAccount
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiExternalAccount deleteAccount(String name) throws ApiException {
        ApiResponse<ApiExternalAccount> resp = deleteAccountWithHttpInfo(name);
        return resp.getData();
    }

    /**
     * Delete an external account, specifying its name.
     * Delete an external account, specifying its name.
     * @param name  (required)
     * @return ApiResponse&lt;ApiExternalAccount&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiExternalAccount> deleteAccountWithHttpInfo(String name) throws ApiException {
        com.squareup.okhttp.Call call = deleteAccountValidateBeforeCall(name, null, null);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Delete an external account, specifying its name. (asynchronously)
     * Delete an external account, specifying its name.
     * @param name  (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 deleteAccountAsync(String name, final ApiCallback<ApiExternalAccount> 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 = deleteAccountValidateBeforeCall(name, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for externalAccountCommandByName
     * @param commandName The command name. (required)
     * @param name The external account name. (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 externalAccountCommandByNameCall(String commandName, String name, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/account/{name}/commands/{commandName}"
            .replaceAll("\\{" + "commandName" + "\\}", apiClient.escapeString(commandName.toString()))
            .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.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 externalAccountCommandByNameValidateBeforeCall(String commandName, String name, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'commandName' is set
        if (commandName == null) {
            throw new ApiException("Missing the required parameter 'commandName' when calling externalAccountCommandByName(Async)");
        }
        
        // verify the required parameter 'name' is set
        if (name == null) {
            throw new ApiException("Missing the required parameter 'name' when calling externalAccountCommandByName(Async)");
        }
        
        
        com.squareup.okhttp.Call call = externalAccountCommandByNameCall(commandName, name, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Executes a command on the external account specified by name.
     * Executes a command on the external account specified by name. &lt;p&gt; Available since API v16.
     * @param commandName The command name. (required)
     * @param name The external account name. (required)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand externalAccountCommandByName(String commandName, String name) throws ApiException {
        ApiResponse<ApiCommand> resp = externalAccountCommandByNameWithHttpInfo(commandName, name);
        return resp.getData();
    }

    /**
     * Executes a command on the external account specified by name.
     * Executes a command on the external account specified by name. &lt;p&gt; Available since API v16.
     * @param commandName The command name. (required)
     * @param name The external account name. (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> externalAccountCommandByNameWithHttpInfo(String commandName, String name) throws ApiException {
        com.squareup.okhttp.Call call = externalAccountCommandByNameValidateBeforeCall(commandName, name, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Executes a command on the external account specified by name. (asynchronously)
     * Executes a command on the external account specified by name. &lt;p&gt; Available since API v16.
     * @param commandName The command name. (required)
     * @param name The external account name. (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 externalAccountCommandByNameAsync(String commandName, String name, 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 = externalAccountCommandByNameValidateBeforeCall(commandName, name, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSupportedCategories
     * @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 getSupportedCategoriesCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/supportedCategories";

        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 getSupportedCategoriesValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = getSupportedCategoriesCall(progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * List of external account categories supported by this Cloudera Manager.
     * List of external account categories supported by this Cloudera Manager.
     * @return ApiExternalAccountCategoryList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiExternalAccountCategoryList getSupportedCategories() throws ApiException {
        ApiResponse<ApiExternalAccountCategoryList> resp = getSupportedCategoriesWithHttpInfo();
        return resp.getData();
    }

    /**
     * List of external account categories supported by this Cloudera Manager.
     * List of external account categories supported by this Cloudera Manager.
     * @return ApiResponse&lt;ApiExternalAccountCategoryList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiExternalAccountCategoryList> getSupportedCategoriesWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = getSupportedCategoriesValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<ApiExternalAccountCategoryList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * List of external account categories supported by this Cloudera Manager. (asynchronously)
     * List of external account categories supported by this Cloudera Manager.
     * @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 getSupportedCategoriesAsync(final ApiCallback<ApiExternalAccountCategoryList> 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 = getSupportedCategoriesValidateBeforeCall(progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiExternalAccountCategoryList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getSupportedTypes
     * @param categoryName  (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 getSupportedTypesCall(String categoryName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/supportedTypes/{categoryName}"
            .replaceAll("\\{" + "categoryName" + "\\}", apiClient.escapeString(categoryName.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 getSupportedTypesValidateBeforeCall(String categoryName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'categoryName' is set
        if (categoryName == null) {
            throw new ApiException("Missing the required parameter 'categoryName' when calling getSupportedTypes(Async)");
        }
        
        
        com.squareup.okhttp.Call call = getSupportedTypesCall(categoryName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * List of external account types supported by this Cloudera Manager by category.
     * List of external account types supported by this Cloudera Manager by category.
     * @param categoryName  (required)
     * @return ApiExternalAccountTypeList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiExternalAccountTypeList getSupportedTypes(String categoryName) throws ApiException {
        ApiResponse<ApiExternalAccountTypeList> resp = getSupportedTypesWithHttpInfo(categoryName);
        return resp.getData();
    }

    /**
     * List of external account types supported by this Cloudera Manager by category.
     * List of external account types supported by this Cloudera Manager by category.
     * @param categoryName  (required)
     * @return ApiResponse&lt;ApiExternalAccountTypeList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiExternalAccountTypeList> getSupportedTypesWithHttpInfo(String categoryName) throws ApiException {
        com.squareup.okhttp.Call call = getSupportedTypesValidateBeforeCall(categoryName, null, null);
        Type localVarReturnType = new TypeToken<ApiExternalAccountTypeList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * List of external account types supported by this Cloudera Manager by category. (asynchronously)
     * List of external account types supported by this Cloudera Manager by category.
     * @param categoryName  (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 getSupportedTypesAsync(String categoryName, final ApiCallback<ApiExternalAccountTypeList> 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 = getSupportedTypesValidateBeforeCall(categoryName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiExternalAccountTypeList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for listExternalAccountCommands
     * @param typeName The external account type name (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 listExternalAccountCommandsCall(String typeName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/typeInfo/{typeName}/commandsByName"
            .replaceAll("\\{" + "typeName" + "\\}", apiClient.escapeString(typeName.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 listExternalAccountCommandsValidateBeforeCall(String typeName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'typeName' is set
        if (typeName == null) {
            throw new ApiException("Missing the required parameter 'typeName' when calling listExternalAccountCommands(Async)");
        }
        
        
        com.squareup.okhttp.Call call = listExternalAccountCommandsCall(typeName, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Lists all the commands that can be executed by name on the provided external account type.
     * Lists all the commands that can be executed by name on the provided external account type. &lt;p&gt; Available since API v16.
     * @param typeName The external account type name (required)
     * @return ApiCommandMetadataList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommandMetadataList listExternalAccountCommands(String typeName) throws ApiException {
        ApiResponse<ApiCommandMetadataList> resp = listExternalAccountCommandsWithHttpInfo(typeName);
        return resp.getData();
    }

    /**
     * Lists all the commands that can be executed by name on the provided external account type.
     * Lists all the commands that can be executed by name on the provided external account type. &lt;p&gt; Available since API v16.
     * @param typeName The external account type name (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> listExternalAccountCommandsWithHttpInfo(String typeName) throws ApiException {
        com.squareup.okhttp.Call call = listExternalAccountCommandsValidateBeforeCall(typeName, 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 external account type. (asynchronously)
     * Lists all the commands that can be executed by name on the provided external account type. &lt;p&gt; Available since API v16.
     * @param typeName The external account type name (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 listExternalAccountCommandsAsync(String typeName, 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 = listExternalAccountCommandsValidateBeforeCall(typeName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommandMetadataList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readAccount
     * @param name  (required)
     * @param view  (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 readAccountCall(String name, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/account/{name}"
            .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.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 readAccountValidateBeforeCall(String name, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'name' is set
        if (name == null) {
            throw new ApiException("Missing the required parameter 'name' when calling readAccount(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readAccountCall(name, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Get a single external account by account name.
     * Get a single external account by account name.
     * @param name  (required)
     * @param view  (optional)
     * @return ApiExternalAccount
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiExternalAccount readAccount(String name, String view) throws ApiException {
        ApiResponse<ApiExternalAccount> resp = readAccountWithHttpInfo(name, view);
        return resp.getData();
    }

    /**
     * Get a single external account by account name.
     * Get a single external account by account name.
     * @param name  (required)
     * @param view  (optional)
     * @return ApiResponse&lt;ApiExternalAccount&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiExternalAccount> readAccountWithHttpInfo(String name, String view) throws ApiException {
        com.squareup.okhttp.Call call = readAccountValidateBeforeCall(name, view, null, null);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a single external account by account name. (asynchronously)
     * Get a single external account by account name.
     * @param name  (required)
     * @param view  (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 readAccountAsync(String name, String view, final ApiCallback<ApiExternalAccount> 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 = readAccountValidateBeforeCall(name, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readAccountByDisplayName
     * @param displayName  (required)
     * @param view  (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 readAccountByDisplayNameCall(String displayName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/accountByDisplayName/{displayName}"
            .replaceAll("\\{" + "displayName" + "\\}", apiClient.escapeString(displayName.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 readAccountByDisplayNameValidateBeforeCall(String displayName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'displayName' is set
        if (displayName == null) {
            throw new ApiException("Missing the required parameter 'displayName' when calling readAccountByDisplayName(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readAccountByDisplayNameCall(displayName, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Get a single external account by display name.
     * Get a single external account by display name.
     * @param displayName  (required)
     * @param view  (optional)
     * @return ApiExternalAccount
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiExternalAccount readAccountByDisplayName(String displayName, String view) throws ApiException {
        ApiResponse<ApiExternalAccount> resp = readAccountByDisplayNameWithHttpInfo(displayName, view);
        return resp.getData();
    }

    /**
     * Get a single external account by display name.
     * Get a single external account by display name.
     * @param displayName  (required)
     * @param view  (optional)
     * @return ApiResponse&lt;ApiExternalAccount&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiExternalAccount> readAccountByDisplayNameWithHttpInfo(String displayName, String view) throws ApiException {
        com.squareup.okhttp.Call call = readAccountByDisplayNameValidateBeforeCall(displayName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a single external account by display name. (asynchronously)
     * Get a single external account by display name.
     * @param displayName  (required)
     * @param view  (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 readAccountByDisplayNameAsync(String displayName, String view, final ApiCallback<ApiExternalAccount> 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 = readAccountByDisplayNameValidateBeforeCall(displayName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readAccounts
     * @param typeName  (required)
     * @param view  (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 readAccountsCall(String typeName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/type/{typeName}"
            .replaceAll("\\{" + "typeName" + "\\}", apiClient.escapeString(typeName.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 readAccountsValidateBeforeCall(String typeName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'typeName' is set
        if (typeName == null) {
            throw new ApiException("Missing the required parameter 'typeName' when calling readAccounts(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readAccountsCall(typeName, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Get a list of external accounts for a specific account type.
     * Get a list of external accounts for a specific account type.
     * @param typeName  (required)
     * @param view  (optional)
     * @return ApiExternalAccountList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiExternalAccountList readAccounts(String typeName, String view) throws ApiException {
        ApiResponse<ApiExternalAccountList> resp = readAccountsWithHttpInfo(typeName, view);
        return resp.getData();
    }

    /**
     * Get a list of external accounts for a specific account type.
     * Get a list of external accounts for a specific account type.
     * @param typeName  (required)
     * @param view  (optional)
     * @return ApiResponse&lt;ApiExternalAccountList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiExternalAccountList> readAccountsWithHttpInfo(String typeName, String view) throws ApiException {
        com.squareup.okhttp.Call call = readAccountsValidateBeforeCall(typeName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiExternalAccountList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a list of external accounts for a specific account type. (asynchronously)
     * Get a list of external accounts for a specific account type.
     * @param typeName  (required)
     * @param view  (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 readAccountsAsync(String typeName, String view, final ApiCallback<ApiExternalAccountList> 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 = readAccountsValidateBeforeCall(typeName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiExternalAccountList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readConfig
     * @param name The external account name (required)
     * @param view The view 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 readConfigCall(String name, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/account/{name}/config"
            .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.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 readConfigValidateBeforeCall(String name, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'name' is set
        if (name == null) {
            throw new ApiException("Missing the required parameter 'name' when calling readConfig(Async)");
        }
        
        
        com.squareup.okhttp.Call call = readConfigCall(name, view, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Get configs of external account for the given account name.
     * Get configs of external account for the given account name.
     * @param name The external account name (required)
     * @param view The view 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 readConfig(String name, String view) throws ApiException {
        ApiResponse<ApiConfigList> resp = readConfigWithHttpInfo(name, view);
        return resp.getData();
    }

    /**
     * Get configs of external account for the given account name.
     * Get configs of external account for the given account name.
     * @param name The external account name (required)
     * @param view The view 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> readConfigWithHttpInfo(String name, String view) throws ApiException {
        com.squareup.okhttp.Call call = readConfigValidateBeforeCall(name, view, null, null);
        Type localVarReturnType = new TypeToken<ApiConfigList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get configs of external account for the given account name. (asynchronously)
     * Get configs of external account for the given account name.
     * @param name The external account name (required)
     * @param view The view 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 readConfigAsync(String name, 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 = readConfigValidateBeforeCall(name, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiConfigList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateAccount
     * @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 updateAccountCall(ApiExternalAccount body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/update";

        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 updateAccountValidateBeforeCall(ApiExternalAccount body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        
        com.squareup.okhttp.Call call = updateAccountCall(body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Update an external account.
     * Update an external account.
     * @param body  (optional)
     * @return ApiExternalAccount
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiExternalAccount updateAccount(ApiExternalAccount body) throws ApiException {
        ApiResponse<ApiExternalAccount> resp = updateAccountWithHttpInfo(body);
        return resp.getData();
    }

    /**
     * Update an external account.
     * Update an external account.
     * @param body  (optional)
     * @return ApiResponse&lt;ApiExternalAccount&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiExternalAccount> updateAccountWithHttpInfo(ApiExternalAccount body) throws ApiException {
        com.squareup.okhttp.Call call = updateAccountValidateBeforeCall(body, null, null);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Update an external account. (asynchronously)
     * Update an external account.
     * @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 updateAccountAsync(ApiExternalAccount body, final ApiCallback<ApiExternalAccount> 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 = updateAccountValidateBeforeCall(body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiExternalAccount>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updateConfig
     * @param name The external account name (required)
     * @param message Optional message describing the changes. (optional)
     * @param body Settings to update. (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 updateConfigCall(String name, String message, ApiConfigList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;
        
        // create path and map variables
        String localVarPath = "/externalAccounts/account/{name}/config"
            .replaceAll("\\{" + "name" + "\\}", apiClient.escapeString(name.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 updateConfigValidateBeforeCall(String name, String message, ApiConfigList body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'name' is set
        if (name == null) {
            throw new ApiException("Missing the required parameter 'name' when calling updateConfig(Async)");
        }
        
        
        com.squareup.okhttp.Call call = updateConfigCall(name, message, body, progressListener, progressRequestListener);
        return call;

        
        
        
        
    }

    /**
     * Upadate configs of external account for the given account name.
     * Upadate configs of external account for the given account name.
     * @param name The external account name (required)
     * @param message Optional message describing the changes. (optional)
     * @param body Settings to update. (optional)
     * @return ApiConfigList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiConfigList updateConfig(String name, String message, ApiConfigList body) throws ApiException {
        ApiResponse<ApiConfigList> resp = updateConfigWithHttpInfo(name, message, body);
        return resp.getData();
    }

    /**
     * Upadate configs of external account for the given account name.
     * Upadate configs of external account for the given account name.
     * @param name The external account name (required)
     * @param message Optional message describing the changes. (optional)
     * @param body Settings to update. (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> updateConfigWithHttpInfo(String name, String message, ApiConfigList body) throws ApiException {
        com.squareup.okhttp.Call call = updateConfigValidateBeforeCall(name, message, body, null, null);
        Type localVarReturnType = new TypeToken<ApiConfigList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Upadate configs of external account for the given account name. (asynchronously)
     * Upadate configs of external account for the given account name.
     * @param name The external account name (required)
     * @param message Optional message describing the changes. (optional)
     * @param body Settings to update. (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 updateConfigAsync(String name, 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 = updateConfigValidateBeforeCall(name, message, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiConfigList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
