/*
 * Cloudera Manager API
 * <h1>Cloudera Manager API v57</h1>       <p>Introduced in Cloudera Manager 7.13.1</p>       <p><a href=\"http://www.cloudera.com/documentation.html\">Cloudera Product Documentation</a></p>
 *
 * OpenAPI spec version: 7.13.1
 * 
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

package com.cloudera.api.swagger;

import com.cloudera.api.swagger.client.ApiCallback;
import com.cloudera.api.swagger.client.ApiClient;
import com.cloudera.api.swagger.client.ApiException;
import com.cloudera.api.swagger.client.ApiResponse;
import com.cloudera.api.swagger.client.Configuration;
import com.cloudera.api.swagger.client.Pair;
import com.cloudera.api.swagger.client.ProgressRequestBody;
import com.cloudera.api.swagger.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.cloudera.api.swagger.model.ApiCommand;
import com.cloudera.api.swagger.model.ApiHBaseSnapshot;
import com.cloudera.api.swagger.model.ApiSnapshotCommandList;
import com.cloudera.api.swagger.model.ApiSnapshotPolicy;
import com.cloudera.api.swagger.model.ApiSnapshotPolicyList;

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

public class SnapshotsResourceApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for createHBaseSnapshotFromRemote
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body  (optional)
     * @param bandwidthPerMap  (optional)
     * @param directCopy  (optional)
     * @param externalAccount  (optional)
     * @param numMappers  (optional)
     * @param runAsUser  (optional)
     * @param schedulerPoolName  (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 okhttp3.Call createHBaseSnapshotFromRemoteCall(String clusterName, String serviceName, ApiHBaseSnapshot body, java.math.BigDecimal bandwidthPerMap, Boolean directCopy, String externalAccount, java.math.BigDecimal numMappers, String runAsUser, String schedulerPoolName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/snapshots"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (bandwidthPerMap != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("bandwidthPerMap", bandwidthPerMap));
        if (directCopy != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("directCopy", directCopy));
        if (externalAccount != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("externalAccount", externalAccount));
        if (numMappers != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("numMappers", numMappers));
        if (runAsUser != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("runAsUser", runAsUser));
        if (schedulerPoolName != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("schedulerPoolName", schedulerPoolName));

        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 okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

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

    @SuppressWarnings("rawtypes")
    private okhttp3.Call createHBaseSnapshotFromRemoteValidateBeforeCall(String clusterName, String serviceName, ApiHBaseSnapshot body, java.math.BigDecimal bandwidthPerMap, Boolean directCopy, String externalAccount, java.math.BigDecimal numMappers, String runAsUser, String schedulerPoolName, 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 createHBaseSnapshotFromRemote(Async)");
        }
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling createHBaseSnapshotFromRemote(Async)");
        }

        okhttp3.Call call = createHBaseSnapshotFromRemoteCall(clusterName, serviceName, body, bandwidthPerMap, directCopy, externalAccount, numMappers, runAsUser, schedulerPoolName, progressListener, progressRequestListener);
        return call;

    }

    /**
     * 
     * 
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body  (optional)
     * @param bandwidthPerMap  (optional)
     * @param directCopy  (optional)
     * @param externalAccount  (optional)
     * @param numMappers  (optional)
     * @param runAsUser  (optional)
     * @param schedulerPoolName  (optional)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand createHBaseSnapshotFromRemote(String clusterName, String serviceName, ApiHBaseSnapshot body, java.math.BigDecimal bandwidthPerMap, Boolean directCopy, String externalAccount, java.math.BigDecimal numMappers, String runAsUser, String schedulerPoolName) throws ApiException {
        ApiResponse<ApiCommand> resp = createHBaseSnapshotFromRemoteWithHttpInfo(clusterName, serviceName, body, bandwidthPerMap, directCopy, externalAccount, numMappers, runAsUser, schedulerPoolName);
        return resp.getData();
    }

    /**
     * 
     * 
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body  (optional)
     * @param bandwidthPerMap  (optional)
     * @param directCopy  (optional)
     * @param externalAccount  (optional)
     * @param numMappers  (optional)
     * @param runAsUser  (optional)
     * @param schedulerPoolName  (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> createHBaseSnapshotFromRemoteWithHttpInfo(String clusterName, String serviceName, ApiHBaseSnapshot body, java.math.BigDecimal bandwidthPerMap, Boolean directCopy, String externalAccount, java.math.BigDecimal numMappers, String runAsUser, String schedulerPoolName) throws ApiException {
        okhttp3.Call call = createHBaseSnapshotFromRemoteValidateBeforeCall(clusterName, serviceName, body, bandwidthPerMap, directCopy, externalAccount, numMappers, runAsUser, schedulerPoolName, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     *  (asynchronously)
     * 
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body  (optional)
     * @param bandwidthPerMap  (optional)
     * @param directCopy  (optional)
     * @param externalAccount  (optional)
     * @param numMappers  (optional)
     * @param runAsUser  (optional)
     * @param schedulerPoolName  (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 okhttp3.Call createHBaseSnapshotFromRemoteAsync(String clusterName, String serviceName, ApiHBaseSnapshot body, java.math.BigDecimal bandwidthPerMap, Boolean directCopy, String externalAccount, java.math.BigDecimal numMappers, String runAsUser, String schedulerPoolName, final ApiCallback<ApiCommand> callback) throws ApiException {

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

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

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

        okhttp3.Call call = createHBaseSnapshotFromRemoteValidateBeforeCall(clusterName, serviceName, body, bandwidthPerMap, directCopy, externalAccount, numMappers, runAsUser, schedulerPoolName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createPolicies
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body List of the snapshot policies 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 okhttp3.Call createPoliciesCall(String clusterName, String serviceName, ApiSnapshotPolicyList 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}/snapshots/policies"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

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

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

        okhttp3.Call call = createPoliciesCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Creates one or more snapshot policies.
     * Creates one or more snapshot policies.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body List of the snapshot policies to create. (optional)
     * @return ApiSnapshotPolicyList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiSnapshotPolicyList createPolicies(String clusterName, String serviceName, ApiSnapshotPolicyList body) throws ApiException {
        ApiResponse<ApiSnapshotPolicyList> resp = createPoliciesWithHttpInfo(clusterName, serviceName, body);
        return resp.getData();
    }

    /**
     * Creates one or more snapshot policies.
     * Creates one or more snapshot policies.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body List of the snapshot policies to create. (optional)
     * @return ApiResponse&lt;ApiSnapshotPolicyList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiSnapshotPolicyList> createPoliciesWithHttpInfo(String clusterName, String serviceName, ApiSnapshotPolicyList body) throws ApiException {
        okhttp3.Call call = createPoliciesValidateBeforeCall(clusterName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicyList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Creates one or more snapshot policies. (asynchronously)
     * Creates one or more snapshot policies.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param body List of the snapshot policies 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 okhttp3.Call createPoliciesAsync(String clusterName, String serviceName, ApiSnapshotPolicyList body, final ApiCallback<ApiSnapshotPolicyList> callback) throws ApiException {

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

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

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

        okhttp3.Call call = createPoliciesValidateBeforeCall(clusterName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicyList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for deletePolicy
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (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 okhttp3.Call deletePolicyCall(String clusterName, String policyName, 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}/snapshots/policies/{policyName}"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "policyName" + "\\}", apiClient.escapeString(policyName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

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

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

        okhttp3.Call call = deletePolicyCall(clusterName, policyName, serviceName, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Deletes an existing snapshot policy.
     * Deletes an existing snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @return ApiSnapshotPolicy
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiSnapshotPolicy deletePolicy(String clusterName, String policyName, String serviceName) throws ApiException {
        ApiResponse<ApiSnapshotPolicy> resp = deletePolicyWithHttpInfo(clusterName, policyName, serviceName);
        return resp.getData();
    }

    /**
     * Deletes an existing snapshot policy.
     * Deletes an existing snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @return ApiResponse&lt;ApiSnapshotPolicy&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiSnapshotPolicy> deletePolicyWithHttpInfo(String clusterName, String policyName, String serviceName) throws ApiException {
        okhttp3.Call call = deletePolicyValidateBeforeCall(clusterName, policyName, serviceName, null, null);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicy>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Deletes an existing snapshot policy. (asynchronously)
     * Deletes an existing snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (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 okhttp3.Call deletePolicyAsync(String clusterName, String policyName, String serviceName, final ApiCallback<ApiSnapshotPolicy> callback) throws ApiException {

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

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

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

        okhttp3.Call call = deletePolicyValidateBeforeCall(clusterName, policyName, serviceName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicy>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for listHBaseSnapshotsCommand
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param storage Location from where the snapshots should be fetched. (optional)
     * @param storageLocation Location of remote snapshots, if other than the local storage should be used. (optional)
     * @param tableName Table for which to list snapshots. If null is provided, it will list all snapshots for all tables. (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 okhttp3.Call listHBaseSnapshotsCommandCall(String clusterName, String serviceName, String storage, String storageLocation, String tableName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/snapshots/listHBaseSnapshotsCommand"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (storage != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("storage", storage));
        if (storageLocation != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("storageLocation", storageLocation));
        if (tableName != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("tableName", tableName));

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

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

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

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

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

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

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

        okhttp3.Call call = listHBaseSnapshotsCommandCall(clusterName, serviceName, storage, storageLocation, tableName, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Starts a command that lists the available HBase snapshots from S3 or local HBase service.
     * Starts a command that lists the available HBase snapshots from S3 or local HBase service. If a table name is provided, it will list the snapshots for that table only, otherwise it will list all available snapshots.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param storage Location from where the snapshots should be fetched. (optional)
     * @param storageLocation Location of remote snapshots, if other than the local storage should be used. (optional)
     * @param tableName Table for which to list snapshots. If null is provided, it will list all snapshots for all tables. (optional)
     * @return ApiCommand
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiCommand listHBaseSnapshotsCommand(String clusterName, String serviceName, String storage, String storageLocation, String tableName) throws ApiException {
        ApiResponse<ApiCommand> resp = listHBaseSnapshotsCommandWithHttpInfo(clusterName, serviceName, storage, storageLocation, tableName);
        return resp.getData();
    }

    /**
     * Starts a command that lists the available HBase snapshots from S3 or local HBase service.
     * Starts a command that lists the available HBase snapshots from S3 or local HBase service. If a table name is provided, it will list the snapshots for that table only, otherwise it will list all available snapshots.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param storage Location from where the snapshots should be fetched. (optional)
     * @param storageLocation Location of remote snapshots, if other than the local storage should be used. (optional)
     * @param tableName Table for which to list snapshots. If null is provided, it will list all snapshots for all tables. (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> listHBaseSnapshotsCommandWithHttpInfo(String clusterName, String serviceName, String storage, String storageLocation, String tableName) throws ApiException {
        okhttp3.Call call = listHBaseSnapshotsCommandValidateBeforeCall(clusterName, serviceName, storage, storageLocation, tableName, null, null);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Starts a command that lists the available HBase snapshots from S3 or local HBase service. (asynchronously)
     * Starts a command that lists the available HBase snapshots from S3 or local HBase service. If a table name is provided, it will list the snapshots for that table only, otherwise it will list all available snapshots.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param storage Location from where the snapshots should be fetched. (optional)
     * @param storageLocation Location of remote snapshots, if other than the local storage should be used. (optional)
     * @param tableName Table for which to list snapshots. If null is provided, it will list all snapshots for all tables. (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 okhttp3.Call listHBaseSnapshotsCommandAsync(String clusterName, String serviceName, String storage, String storageLocation, String tableName, final ApiCallback<ApiCommand> callback) throws ApiException {

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

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

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

        okhttp3.Call call = listHBaseSnapshotsCommandValidateBeforeCall(clusterName, serviceName, storage, storageLocation, tableName, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiCommand>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readHistory
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param limit Maximum number of commands to retrieve. (optional, default to 20)
     * @param offset Index of first command to retrieve. (optional, default to 0)
     * @param view The view to materialize. (optional, default to summary)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call readHistoryCall(String clusterName, String policyName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset, 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}/snapshots/policies/{policyName}/history"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "policyName" + "\\}", apiClient.escapeString(policyName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (limit != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
        if (offset != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("offset", offset));
        if (view != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("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 okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

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

    @SuppressWarnings("rawtypes")
    private okhttp3.Call readHistoryValidateBeforeCall(String clusterName, String policyName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset, 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 readHistory(Async)");
        }
        // verify the required parameter 'policyName' is set
        if (policyName == null) {
            throw new ApiException("Missing the required parameter 'policyName' when calling readHistory(Async)");
        }
        // verify the required parameter 'serviceName' is set
        if (serviceName == null) {
            throw new ApiException("Missing the required parameter 'serviceName' when calling readHistory(Async)");
        }

        okhttp3.Call call = readHistoryCall(clusterName, policyName, serviceName, limit, offset, view, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Returns a list of commands triggered by a snapshot policy.
     * Returns a list of commands triggered by a snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param limit Maximum number of commands to retrieve. (optional, default to 20)
     * @param offset Index of first command to retrieve. (optional, default to 0)
     * @param view The view to materialize. (optional, default to summary)
     * @return ApiSnapshotCommandList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiSnapshotCommandList readHistory(String clusterName, String policyName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset, String view) throws ApiException {
        ApiResponse<ApiSnapshotCommandList> resp = readHistoryWithHttpInfo(clusterName, policyName, serviceName, limit, offset, view);
        return resp.getData();
    }

    /**
     * Returns a list of commands triggered by a snapshot policy.
     * Returns a list of commands triggered by a snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param limit Maximum number of commands to retrieve. (optional, default to 20)
     * @param offset Index of first command to retrieve. (optional, default to 0)
     * @param view The view to materialize. (optional, default to summary)
     * @return ApiResponse&lt;ApiSnapshotCommandList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiSnapshotCommandList> readHistoryWithHttpInfo(String clusterName, String policyName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset, String view) throws ApiException {
        okhttp3.Call call = readHistoryValidateBeforeCall(clusterName, policyName, serviceName, limit, offset, view, null, null);
        Type localVarReturnType = new TypeToken<ApiSnapshotCommandList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns a list of commands triggered by a snapshot policy. (asynchronously)
     * Returns a list of commands triggered by a snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param limit Maximum number of commands to retrieve. (optional, default to 20)
     * @param offset Index of first command to retrieve. (optional, default to 0)
     * @param view The view to materialize. (optional, default to summary)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call readHistoryAsync(String clusterName, String policyName, String serviceName, java.math.BigDecimal limit, java.math.BigDecimal offset, String view, final ApiCallback<ApiSnapshotCommandList> callback) throws ApiException {

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

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

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

        okhttp3.Call call = readHistoryValidateBeforeCall(clusterName, policyName, serviceName, limit, offset, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiSnapshotCommandList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readPolicies
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param view The view to materialize. (optional, default to summary)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call readPoliciesCall(String clusterName, String serviceName, String view, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/clusters/{clusterName}/services/{serviceName}/snapshots/policies"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (view != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("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 okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

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

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

        okhttp3.Call call = readPoliciesCall(clusterName, serviceName, view, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Returns information for all snapshot policies.
     * Returns information for all snapshot policies.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param view The view to materialize. (optional, default to summary)
     * @return ApiSnapshotPolicyList
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiSnapshotPolicyList readPolicies(String clusterName, String serviceName, String view) throws ApiException {
        ApiResponse<ApiSnapshotPolicyList> resp = readPoliciesWithHttpInfo(clusterName, serviceName, view);
        return resp.getData();
    }

    /**
     * Returns information for all snapshot policies.
     * Returns information for all snapshot policies.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param view The view to materialize. (optional, default to summary)
     * @return ApiResponse&lt;ApiSnapshotPolicyList&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiSnapshotPolicyList> readPoliciesWithHttpInfo(String clusterName, String serviceName, String view) throws ApiException {
        okhttp3.Call call = readPoliciesValidateBeforeCall(clusterName, serviceName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicyList>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns information for all snapshot policies. (asynchronously)
     * Returns information for all snapshot policies.
     * @param clusterName  (required)
     * @param serviceName  (required)
     * @param view The view to materialize. (optional, default to summary)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call readPoliciesAsync(String clusterName, String serviceName, String view, final ApiCallback<ApiSnapshotPolicyList> callback) throws ApiException {

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

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

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

        okhttp3.Call call = readPoliciesValidateBeforeCall(clusterName, serviceName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicyList>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for readPolicy
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param view The view to materialize. (optional, default to summary)
     * @param progressListener Progress listener
     * @param progressRequestListener Progress request listener
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     */
    public okhttp3.Call readPolicyCall(String clusterName, String policyName, 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}/snapshots/policies/{policyName}"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "policyName" + "\\}", apiClient.escapeString(policyName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (view != null)
        localVarQueryParams.addAll(apiClient.parameterToPair("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 okhttp3.Interceptor() {
                @Override
                public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException {
                    okhttp3.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

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

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

        okhttp3.Call call = readPolicyCall(clusterName, policyName, serviceName, view, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Returns information for a specific snapshot policy.
     * Returns information for a specific snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param view The view to materialize. (optional, default to summary)
     * @return ApiSnapshotPolicy
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiSnapshotPolicy readPolicy(String clusterName, String policyName, String serviceName, String view) throws ApiException {
        ApiResponse<ApiSnapshotPolicy> resp = readPolicyWithHttpInfo(clusterName, policyName, serviceName, view);
        return resp.getData();
    }

    /**
     * Returns information for a specific snapshot policy.
     * Returns information for a specific snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param view The view to materialize. (optional, default to summary)
     * @return ApiResponse&lt;ApiSnapshotPolicy&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiSnapshotPolicy> readPolicyWithHttpInfo(String clusterName, String policyName, String serviceName, String view) throws ApiException {
        okhttp3.Call call = readPolicyValidateBeforeCall(clusterName, policyName, serviceName, view, null, null);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicy>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns information for a specific snapshot policy. (asynchronously)
     * Returns information for a specific snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param view The view to materialize. (optional, default to summary)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public okhttp3.Call readPolicyAsync(String clusterName, String policyName, String serviceName, String view, final ApiCallback<ApiSnapshotPolicy> callback) throws ApiException {

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

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

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

        okhttp3.Call call = readPolicyValidateBeforeCall(clusterName, policyName, serviceName, view, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicy>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for updatePolicy
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param body Modified policy. (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 okhttp3.Call updatePolicyCall(String clusterName, String policyName, String serviceName, ApiSnapshotPolicy 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}/snapshots/policies/{policyName}"
            .replaceAll("\\{" + "clusterName" + "\\}", apiClient.escapeString(clusterName.toString()))
            .replaceAll("\\{" + "policyName" + "\\}", apiClient.escapeString(policyName.toString()))
            .replaceAll("\\{" + "serviceName" + "\\}", apiClient.escapeString(serviceName.toString()));

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

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

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

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

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

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

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

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

        okhttp3.Call call = updatePolicyCall(clusterName, policyName, serviceName, body, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Updates an existing snapshot policy.
     * Updates an existing snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param body Modified policy. (optional)
     * @return ApiSnapshotPolicy
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiSnapshotPolicy updatePolicy(String clusterName, String policyName, String serviceName, ApiSnapshotPolicy body) throws ApiException {
        ApiResponse<ApiSnapshotPolicy> resp = updatePolicyWithHttpInfo(clusterName, policyName, serviceName, body);
        return resp.getData();
    }

    /**
     * Updates an existing snapshot policy.
     * Updates an existing snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param body Modified policy. (optional)
     * @return ApiResponse&lt;ApiSnapshotPolicy&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ApiSnapshotPolicy> updatePolicyWithHttpInfo(String clusterName, String policyName, String serviceName, ApiSnapshotPolicy body) throws ApiException {
        okhttp3.Call call = updatePolicyValidateBeforeCall(clusterName, policyName, serviceName, body, null, null);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicy>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Updates an existing snapshot policy. (asynchronously)
     * Updates an existing snapshot policy.
     * @param clusterName  (required)
     * @param policyName Name of an existing snapshot policy. (required)
     * @param serviceName  (required)
     * @param body Modified policy. (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 okhttp3.Call updatePolicyAsync(String clusterName, String policyName, String serviceName, ApiSnapshotPolicy body, final ApiCallback<ApiSnapshotPolicy> callback) throws ApiException {

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

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

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

        okhttp3.Call call = updatePolicyValidateBeforeCall(clusterName, policyName, serviceName, body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ApiSnapshotPolicy>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
