/*
 * NiFi Rest Api
 * The Rest Api provides programmatic access to command and control a NiFi instance in real time. Start and                                              stop processors, monitor queues, query provenance data, and more. Each endpoint below includes a description,                                             definitions of the expected input and output, potential response codes, and the authorizations required                                             to invoke each service.
 *
 * OpenAPI spec version: 1.5.0
 * Contact: [email protected]
 *
 * 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.github.hermannpencole.nifi.swagger.client;

import com.github.hermannpencole.nifi.swagger.ApiCallback;
import com.github.hermannpencole.nifi.swagger.ApiClient;
import com.github.hermannpencole.nifi.swagger.ApiException;
import com.github.hermannpencole.nifi.swagger.ApiResponse;
import com.github.hermannpencole.nifi.swagger.Configuration;
import com.github.hermannpencole.nifi.swagger.Pair;
import com.github.hermannpencole.nifi.swagger.ProgressRequestBody;
import com.github.hermannpencole.nifi.swagger.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import com.github.hermannpencole.nifi.swagger.client.model.DropRequestEntity;
import com.github.hermannpencole.nifi.swagger.client.model.FlowFileEntity;
import com.github.hermannpencole.nifi.swagger.client.model.ListingRequestEntity;
import com.github.hermannpencole.nifi.swagger.client.model.StreamingOutput;

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

public class FlowfileQueuesApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for createDropRequest
     * @param id The connection id. (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 createDropRequestCall(String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/flowfile-queues/{id}/drop-requests"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.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 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[] { "auth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call createDropRequestValidateBeforeCall(String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling createDropRequest(Async)");
        }
        

        com.squareup.okhttp.Call call = createDropRequestCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Creates a request to drop the contents of the queue in this connection.
     * 
     * @param id The connection id. (required)
     * @return DropRequestEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DropRequestEntity createDropRequest(String id) throws ApiException {
        ApiResponse<DropRequestEntity> resp = createDropRequestWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Creates a request to drop the contents of the queue in this connection.
     * 
     * @param id The connection id. (required)
     * @return ApiResponse&lt;DropRequestEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<DropRequestEntity> createDropRequestWithHttpInfo(String id) throws ApiException {
        com.squareup.okhttp.Call call = createDropRequestValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken<DropRequestEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Creates a request to drop the contents of the queue in this connection. (asynchronously)
     * 
     * @param id The connection id. (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 createDropRequestAsync(String id, final ApiCallback<DropRequestEntity> 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 = createDropRequestValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<DropRequestEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createFlowFileListing
     * @param id The connection id. (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 createFlowFileListingCall(String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/flowfile-queues/{id}/listing-requests"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.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 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[] { "auth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call createFlowFileListingValidateBeforeCall(String id, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling createFlowFileListing(Async)");
        }
        

        com.squareup.okhttp.Call call = createFlowFileListingCall(id, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Lists the contents of the queue in this connection.
     * 
     * @param id The connection id. (required)
     * @return ListingRequestEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ListingRequestEntity createFlowFileListing(String id) throws ApiException {
        ApiResponse<ListingRequestEntity> resp = createFlowFileListingWithHttpInfo(id);
        return resp.getData();
    }

    /**
     * Lists the contents of the queue in this connection.
     * 
     * @param id The connection id. (required)
     * @return ApiResponse&lt;ListingRequestEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ListingRequestEntity> createFlowFileListingWithHttpInfo(String id) throws ApiException {
        com.squareup.okhttp.Call call = createFlowFileListingValidateBeforeCall(id, null, null);
        Type localVarReturnType = new TypeToken<ListingRequestEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Lists the contents of the queue in this connection. (asynchronously)
     * 
     * @param id The connection id. (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 createFlowFileListingAsync(String id, final ApiCallback<ListingRequestEntity> 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 = createFlowFileListingValidateBeforeCall(id, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ListingRequestEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for deleteListingRequest
     * @param id The connection id. (required)
     * @param listingRequestId The listing request id. (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 deleteListingRequestCall(String id, String listingRequestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/flowfile-queues/{id}/listing-requests/{listing-request-id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()))
            .replaceAll("\\{" + "listing-request-id" + "\\}", apiClient.escapeString(listingRequestId.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 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[] { "auth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call deleteListingRequestValidateBeforeCall(String id, String listingRequestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling deleteListingRequest(Async)");
        }
        
        // verify the required parameter 'listingRequestId' is set
        if (listingRequestId == null) {
            throw new ApiException("Missing the required parameter 'listingRequestId' when calling deleteListingRequest(Async)");
        }
        

        com.squareup.okhttp.Call call = deleteListingRequestCall(id, listingRequestId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Cancels and/or removes a request to list the contents of this connection.
     * 
     * @param id The connection id. (required)
     * @param listingRequestId The listing request id. (required)
     * @return ListingRequestEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ListingRequestEntity deleteListingRequest(String id, String listingRequestId) throws ApiException {
        ApiResponse<ListingRequestEntity> resp = deleteListingRequestWithHttpInfo(id, listingRequestId);
        return resp.getData();
    }

    /**
     * Cancels and/or removes a request to list the contents of this connection.
     * 
     * @param id The connection id. (required)
     * @param listingRequestId The listing request id. (required)
     * @return ApiResponse&lt;ListingRequestEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ListingRequestEntity> deleteListingRequestWithHttpInfo(String id, String listingRequestId) throws ApiException {
        com.squareup.okhttp.Call call = deleteListingRequestValidateBeforeCall(id, listingRequestId, null, null);
        Type localVarReturnType = new TypeToken<ListingRequestEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Cancels and/or removes a request to list the contents of this connection. (asynchronously)
     * 
     * @param id The connection id. (required)
     * @param listingRequestId The listing request id. (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 deleteListingRequestAsync(String id, String listingRequestId, final ApiCallback<ListingRequestEntity> 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 = deleteListingRequestValidateBeforeCall(id, listingRequestId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ListingRequestEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for downloadFlowFileContent
     * @param id The connection id. (required)
     * @param flowfileUuid The flowfile uuid. (required)
     * @param clientId If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response. (optional)
     * @param clusterNodeId The id of the node where the content exists if clustered. (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 downloadFlowFileContentCall(String id, String flowfileUuid, String clientId, String clusterNodeId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/flowfile-queues/{id}/flowfiles/{flowfile-uuid}/content"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()))
            .replaceAll("\\{" + "flowfile-uuid" + "\\}", apiClient.escapeString(flowfileUuid.toString()));

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

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

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

        final String[] localVarAccepts = {
            "*/*"
        };
        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[] { "auth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call downloadFlowFileContentValidateBeforeCall(String id, String flowfileUuid, String clientId, String clusterNodeId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling downloadFlowFileContent(Async)");
        }
        
        // verify the required parameter 'flowfileUuid' is set
        if (flowfileUuid == null) {
            throw new ApiException("Missing the required parameter 'flowfileUuid' when calling downloadFlowFileContent(Async)");
        }
        

        com.squareup.okhttp.Call call = downloadFlowFileContentCall(id, flowfileUuid, clientId, clusterNodeId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Gets the content for a FlowFile in a Connection.
     * 
     * @param id The connection id. (required)
     * @param flowfileUuid The flowfile uuid. (required)
     * @param clientId If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response. (optional)
     * @param clusterNodeId The id of the node where the content exists if clustered. (optional)
     * @return StreamingOutput
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public StreamingOutput downloadFlowFileContent(String id, String flowfileUuid, String clientId, String clusterNodeId) throws ApiException {
        ApiResponse<StreamingOutput> resp = downloadFlowFileContentWithHttpInfo(id, flowfileUuid, clientId, clusterNodeId);
        return resp.getData();
    }

    /**
     * Gets the content for a FlowFile in a Connection.
     * 
     * @param id The connection id. (required)
     * @param flowfileUuid The flowfile uuid. (required)
     * @param clientId If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response. (optional)
     * @param clusterNodeId The id of the node where the content exists if clustered. (optional)
     * @return ApiResponse&lt;StreamingOutput&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<StreamingOutput> downloadFlowFileContentWithHttpInfo(String id, String flowfileUuid, String clientId, String clusterNodeId) throws ApiException {
        com.squareup.okhttp.Call call = downloadFlowFileContentValidateBeforeCall(id, flowfileUuid, clientId, clusterNodeId, null, null);
        Type localVarReturnType = new TypeToken<StreamingOutput>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Gets the content for a FlowFile in a Connection. (asynchronously)
     * 
     * @param id The connection id. (required)
     * @param flowfileUuid The flowfile uuid. (required)
     * @param clientId If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response. (optional)
     * @param clusterNodeId The id of the node where the content exists if clustered. (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 downloadFlowFileContentAsync(String id, String flowfileUuid, String clientId, String clusterNodeId, final ApiCallback<StreamingOutput> 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 = downloadFlowFileContentValidateBeforeCall(id, flowfileUuid, clientId, clusterNodeId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<StreamingOutput>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getDropRequest
     * @param id The connection id. (required)
     * @param dropRequestId The drop request id. (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 getDropRequestCall(String id, String dropRequestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/flowfile-queues/{id}/drop-requests/{drop-request-id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()))
            .replaceAll("\\{" + "drop-request-id" + "\\}", apiClient.escapeString(dropRequestId.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 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[] { "auth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getDropRequestValidateBeforeCall(String id, String dropRequestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getDropRequest(Async)");
        }
        
        // verify the required parameter 'dropRequestId' is set
        if (dropRequestId == null) {
            throw new ApiException("Missing the required parameter 'dropRequestId' when calling getDropRequest(Async)");
        }
        

        com.squareup.okhttp.Call call = getDropRequestCall(id, dropRequestId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Gets the current status of a drop request for the specified connection.
     * 
     * @param id The connection id. (required)
     * @param dropRequestId The drop request id. (required)
     * @return DropRequestEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DropRequestEntity getDropRequest(String id, String dropRequestId) throws ApiException {
        ApiResponse<DropRequestEntity> resp = getDropRequestWithHttpInfo(id, dropRequestId);
        return resp.getData();
    }

    /**
     * Gets the current status of a drop request for the specified connection.
     * 
     * @param id The connection id. (required)
     * @param dropRequestId The drop request id. (required)
     * @return ApiResponse&lt;DropRequestEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<DropRequestEntity> getDropRequestWithHttpInfo(String id, String dropRequestId) throws ApiException {
        com.squareup.okhttp.Call call = getDropRequestValidateBeforeCall(id, dropRequestId, null, null);
        Type localVarReturnType = new TypeToken<DropRequestEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Gets the current status of a drop request for the specified connection. (asynchronously)
     * 
     * @param id The connection id. (required)
     * @param dropRequestId The drop request id. (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 getDropRequestAsync(String id, String dropRequestId, final ApiCallback<DropRequestEntity> 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 = getDropRequestValidateBeforeCall(id, dropRequestId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<DropRequestEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getFlowFile
     * @param id The connection id. (required)
     * @param flowfileUuid The flowfile uuid. (required)
     * @param clusterNodeId The id of the node where the content exists if clustered. (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 getFlowFileCall(String id, String flowfileUuid, String clusterNodeId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/flowfile-queues/{id}/flowfiles/{flowfile-uuid}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()))
            .replaceAll("\\{" + "flowfile-uuid" + "\\}", apiClient.escapeString(flowfileUuid.toString()));

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

        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[] { "auth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getFlowFileValidateBeforeCall(String id, String flowfileUuid, String clusterNodeId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getFlowFile(Async)");
        }
        
        // verify the required parameter 'flowfileUuid' is set
        if (flowfileUuid == null) {
            throw new ApiException("Missing the required parameter 'flowfileUuid' when calling getFlowFile(Async)");
        }
        

        com.squareup.okhttp.Call call = getFlowFileCall(id, flowfileUuid, clusterNodeId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Gets a FlowFile from a Connection.
     * 
     * @param id The connection id. (required)
     * @param flowfileUuid The flowfile uuid. (required)
     * @param clusterNodeId The id of the node where the content exists if clustered. (optional)
     * @return FlowFileEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public FlowFileEntity getFlowFile(String id, String flowfileUuid, String clusterNodeId) throws ApiException {
        ApiResponse<FlowFileEntity> resp = getFlowFileWithHttpInfo(id, flowfileUuid, clusterNodeId);
        return resp.getData();
    }

    /**
     * Gets a FlowFile from a Connection.
     * 
     * @param id The connection id. (required)
     * @param flowfileUuid The flowfile uuid. (required)
     * @param clusterNodeId The id of the node where the content exists if clustered. (optional)
     * @return ApiResponse&lt;FlowFileEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<FlowFileEntity> getFlowFileWithHttpInfo(String id, String flowfileUuid, String clusterNodeId) throws ApiException {
        com.squareup.okhttp.Call call = getFlowFileValidateBeforeCall(id, flowfileUuid, clusterNodeId, null, null);
        Type localVarReturnType = new TypeToken<FlowFileEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Gets a FlowFile from a Connection. (asynchronously)
     * 
     * @param id The connection id. (required)
     * @param flowfileUuid The flowfile uuid. (required)
     * @param clusterNodeId The id of the node where the content exists if clustered. (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 getFlowFileAsync(String id, String flowfileUuid, String clusterNodeId, final ApiCallback<FlowFileEntity> 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 = getFlowFileValidateBeforeCall(id, flowfileUuid, clusterNodeId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<FlowFileEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for getListingRequest
     * @param id The connection id. (required)
     * @param listingRequestId The listing request id. (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 getListingRequestCall(String id, String listingRequestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/flowfile-queues/{id}/listing-requests/{listing-request-id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()))
            .replaceAll("\\{" + "listing-request-id" + "\\}", apiClient.escapeString(listingRequestId.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 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[] { "auth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call getListingRequestValidateBeforeCall(String id, String listingRequestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling getListingRequest(Async)");
        }
        
        // verify the required parameter 'listingRequestId' is set
        if (listingRequestId == null) {
            throw new ApiException("Missing the required parameter 'listingRequestId' when calling getListingRequest(Async)");
        }
        

        com.squareup.okhttp.Call call = getListingRequestCall(id, listingRequestId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Gets the current status of a listing request for the specified connection.
     * 
     * @param id The connection id. (required)
     * @param listingRequestId The listing request id. (required)
     * @return ListingRequestEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ListingRequestEntity getListingRequest(String id, String listingRequestId) throws ApiException {
        ApiResponse<ListingRequestEntity> resp = getListingRequestWithHttpInfo(id, listingRequestId);
        return resp.getData();
    }

    /**
     * Gets the current status of a listing request for the specified connection.
     * 
     * @param id The connection id. (required)
     * @param listingRequestId The listing request id. (required)
     * @return ApiResponse&lt;ListingRequestEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ListingRequestEntity> getListingRequestWithHttpInfo(String id, String listingRequestId) throws ApiException {
        com.squareup.okhttp.Call call = getListingRequestValidateBeforeCall(id, listingRequestId, null, null);
        Type localVarReturnType = new TypeToken<ListingRequestEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Gets the current status of a listing request for the specified connection. (asynchronously)
     * 
     * @param id The connection id. (required)
     * @param listingRequestId The listing request id. (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 getListingRequestAsync(String id, String listingRequestId, final ApiCallback<ListingRequestEntity> 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 = getListingRequestValidateBeforeCall(id, listingRequestId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ListingRequestEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for removeDropRequest
     * @param id The connection id. (required)
     * @param dropRequestId The drop request id. (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 removeDropRequestCall(String id, String dropRequestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/flowfile-queues/{id}/drop-requests/{drop-request-id}"
            .replaceAll("\\{" + "id" + "\\}", apiClient.escapeString(id.toString()))
            .replaceAll("\\{" + "drop-request-id" + "\\}", apiClient.escapeString(dropRequestId.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 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[] { "auth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call removeDropRequestValidateBeforeCall(String id, String dropRequestId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'id' is set
        if (id == null) {
            throw new ApiException("Missing the required parameter 'id' when calling removeDropRequest(Async)");
        }
        
        // verify the required parameter 'dropRequestId' is set
        if (dropRequestId == null) {
            throw new ApiException("Missing the required parameter 'dropRequestId' when calling removeDropRequest(Async)");
        }
        

        com.squareup.okhttp.Call call = removeDropRequestCall(id, dropRequestId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Cancels and/or removes a request to drop the contents of this connection.
     * 
     * @param id The connection id. (required)
     * @param dropRequestId The drop request id. (required)
     * @return DropRequestEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DropRequestEntity removeDropRequest(String id, String dropRequestId) throws ApiException {
        ApiResponse<DropRequestEntity> resp = removeDropRequestWithHttpInfo(id, dropRequestId);
        return resp.getData();
    }

    /**
     * Cancels and/or removes a request to drop the contents of this connection.
     * 
     * @param id The connection id. (required)
     * @param dropRequestId The drop request id. (required)
     * @return ApiResponse&lt;DropRequestEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<DropRequestEntity> removeDropRequestWithHttpInfo(String id, String dropRequestId) throws ApiException {
        com.squareup.okhttp.Call call = removeDropRequestValidateBeforeCall(id, dropRequestId, null, null);
        Type localVarReturnType = new TypeToken<DropRequestEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Cancels and/or removes a request to drop the contents of this connection. (asynchronously)
     * 
     * @param id The connection id. (required)
     * @param dropRequestId The drop request id. (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 removeDropRequestAsync(String id, String dropRequestId, final ApiCallback<DropRequestEntity> 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 = removeDropRequestValidateBeforeCall(id, dropRequestId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<DropRequestEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}