/*
 * 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.StreamingOutput;
import com.github.hermannpencole.nifi.swagger.client.model.TransactionResultEntity;

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

public class DataTransferApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for commitInputPortTransaction
     * @param responseCode The response code. Available values are BAD_CHECKSUM(19), CONFIRM_TRANSACTION(12) or CANCEL_TRANSACTION(15). (required)
     * @param portId The input port id. (required)
     * @param transactionId The transaction 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 commitInputPortTransactionCall(Integer responseCode, String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/data-transfer/input-ports/{portId}/transactions/{transactionId}"
            .replaceAll("\\{" + "portId" + "\\}", apiClient.escapeString(portId.toString()))
            .replaceAll("\\{" + "transactionId" + "\\}", apiClient.escapeString(transactionId.toString()));

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

        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/octet-stream"
        };
        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 commitInputPortTransactionValidateBeforeCall(Integer responseCode, String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'responseCode' is set
        if (responseCode == null) {
            throw new ApiException("Missing the required parameter 'responseCode' when calling commitInputPortTransaction(Async)");
        }
        
        // verify the required parameter 'portId' is set
        if (portId == null) {
            throw new ApiException("Missing the required parameter 'portId' when calling commitInputPortTransaction(Async)");
        }
        
        // verify the required parameter 'transactionId' is set
        if (transactionId == null) {
            throw new ApiException("Missing the required parameter 'transactionId' when calling commitInputPortTransaction(Async)");
        }
        

        com.squareup.okhttp.Call call = commitInputPortTransactionCall(responseCode, portId, transactionId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Commit or cancel the specified transaction
     * 
     * @param responseCode The response code. Available values are BAD_CHECKSUM(19), CONFIRM_TRANSACTION(12) or CANCEL_TRANSACTION(15). (required)
     * @param portId The input port id. (required)
     * @param transactionId The transaction id. (required)
     * @return TransactionResultEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransactionResultEntity commitInputPortTransaction(Integer responseCode, String portId, String transactionId) throws ApiException {
        ApiResponse<TransactionResultEntity> resp = commitInputPortTransactionWithHttpInfo(responseCode, portId, transactionId);
        return resp.getData();
    }

    /**
     * Commit or cancel the specified transaction
     * 
     * @param responseCode The response code. Available values are BAD_CHECKSUM(19), CONFIRM_TRANSACTION(12) or CANCEL_TRANSACTION(15). (required)
     * @param portId The input port id. (required)
     * @param transactionId The transaction id. (required)
     * @return ApiResponse&lt;TransactionResultEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TransactionResultEntity> commitInputPortTransactionWithHttpInfo(Integer responseCode, String portId, String transactionId) throws ApiException {
        com.squareup.okhttp.Call call = commitInputPortTransactionValidateBeforeCall(responseCode, portId, transactionId, null, null);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Commit or cancel the specified transaction (asynchronously)
     * 
     * @param responseCode The response code. Available values are BAD_CHECKSUM(19), CONFIRM_TRANSACTION(12) or CANCEL_TRANSACTION(15). (required)
     * @param portId The input port id. (required)
     * @param transactionId The transaction 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 commitInputPortTransactionAsync(Integer responseCode, String portId, String transactionId, final ApiCallback<TransactionResultEntity> 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 = commitInputPortTransactionValidateBeforeCall(responseCode, portId, transactionId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for commitOutputPortTransaction
     * @param responseCode The response code. Available values are CONFIRM_TRANSACTION(12) or CANCEL_TRANSACTION(15). (required)
     * @param checksum A checksum calculated at client side using CRC32 to check flow file content integrity. It must match with the value calculated at server side. (required)
     * @param portId The output port id. (required)
     * @param transactionId The transaction 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 commitOutputPortTransactionCall(Integer responseCode, String checksum, String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/data-transfer/output-ports/{portId}/transactions/{transactionId}"
            .replaceAll("\\{" + "portId" + "\\}", apiClient.escapeString(portId.toString()))
            .replaceAll("\\{" + "transactionId" + "\\}", apiClient.escapeString(transactionId.toString()));

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

        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/octet-stream"
        };
        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 commitOutputPortTransactionValidateBeforeCall(Integer responseCode, String checksum, String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'responseCode' is set
        if (responseCode == null) {
            throw new ApiException("Missing the required parameter 'responseCode' when calling commitOutputPortTransaction(Async)");
        }
        
        // verify the required parameter 'checksum' is set
        if (checksum == null) {
            throw new ApiException("Missing the required parameter 'checksum' when calling commitOutputPortTransaction(Async)");
        }
        
        // verify the required parameter 'portId' is set
        if (portId == null) {
            throw new ApiException("Missing the required parameter 'portId' when calling commitOutputPortTransaction(Async)");
        }
        
        // verify the required parameter 'transactionId' is set
        if (transactionId == null) {
            throw new ApiException("Missing the required parameter 'transactionId' when calling commitOutputPortTransaction(Async)");
        }
        

        com.squareup.okhttp.Call call = commitOutputPortTransactionCall(responseCode, checksum, portId, transactionId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Commit or cancel the specified transaction
     * 
     * @param responseCode The response code. Available values are CONFIRM_TRANSACTION(12) or CANCEL_TRANSACTION(15). (required)
     * @param checksum A checksum calculated at client side using CRC32 to check flow file content integrity. It must match with the value calculated at server side. (required)
     * @param portId The output port id. (required)
     * @param transactionId The transaction id. (required)
     * @return TransactionResultEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransactionResultEntity commitOutputPortTransaction(Integer responseCode, String checksum, String portId, String transactionId) throws ApiException {
        ApiResponse<TransactionResultEntity> resp = commitOutputPortTransactionWithHttpInfo(responseCode, checksum, portId, transactionId);
        return resp.getData();
    }

    /**
     * Commit or cancel the specified transaction
     * 
     * @param responseCode The response code. Available values are CONFIRM_TRANSACTION(12) or CANCEL_TRANSACTION(15). (required)
     * @param checksum A checksum calculated at client side using CRC32 to check flow file content integrity. It must match with the value calculated at server side. (required)
     * @param portId The output port id. (required)
     * @param transactionId The transaction id. (required)
     * @return ApiResponse&lt;TransactionResultEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TransactionResultEntity> commitOutputPortTransactionWithHttpInfo(Integer responseCode, String checksum, String portId, String transactionId) throws ApiException {
        com.squareup.okhttp.Call call = commitOutputPortTransactionValidateBeforeCall(responseCode, checksum, portId, transactionId, null, null);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Commit or cancel the specified transaction (asynchronously)
     * 
     * @param responseCode The response code. Available values are CONFIRM_TRANSACTION(12) or CANCEL_TRANSACTION(15). (required)
     * @param checksum A checksum calculated at client side using CRC32 to check flow file content integrity. It must match with the value calculated at server side. (required)
     * @param portId The output port id. (required)
     * @param transactionId The transaction 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 commitOutputPortTransactionAsync(Integer responseCode, String checksum, String portId, String transactionId, final ApiCallback<TransactionResultEntity> 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 = commitOutputPortTransactionValidateBeforeCall(responseCode, checksum, portId, transactionId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for createPortTransaction
     * @param portType The port type. (required)
     * @param portId  (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 createPortTransactionCall(String portType, String portId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/data-transfer/{portType}/{portId}/transactions"
            .replaceAll("\\{" + "portType" + "\\}", apiClient.escapeString(portType.toString()))
            .replaceAll("\\{" + "portId" + "\\}", apiClient.escapeString(portId.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 createPortTransactionValidateBeforeCall(String portType, String portId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'portType' is set
        if (portType == null) {
            throw new ApiException("Missing the required parameter 'portType' when calling createPortTransaction(Async)");
        }
        
        // verify the required parameter 'portId' is set
        if (portId == null) {
            throw new ApiException("Missing the required parameter 'portId' when calling createPortTransaction(Async)");
        }
        

        com.squareup.okhttp.Call call = createPortTransactionCall(portType, portId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Create a transaction to the specified output port or input port
     * 
     * @param portType The port type. (required)
     * @param portId  (required)
     * @return TransactionResultEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransactionResultEntity createPortTransaction(String portType, String portId) throws ApiException {
        ApiResponse<TransactionResultEntity> resp = createPortTransactionWithHttpInfo(portType, portId);
        return resp.getData();
    }

    /**
     * Create a transaction to the specified output port or input port
     * 
     * @param portType The port type. (required)
     * @param portId  (required)
     * @return ApiResponse&lt;TransactionResultEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TransactionResultEntity> createPortTransactionWithHttpInfo(String portType, String portId) throws ApiException {
        com.squareup.okhttp.Call call = createPortTransactionValidateBeforeCall(portType, portId, null, null);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create a transaction to the specified output port or input port (asynchronously)
     * 
     * @param portType The port type. (required)
     * @param portId  (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 createPortTransactionAsync(String portType, String portId, final ApiCallback<TransactionResultEntity> 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 = createPortTransactionValidateBeforeCall(portType, portId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for extendInputPortTransactionTTL
     * @param portId  (required)
     * @param transactionId  (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 extendInputPortTransactionTTLCall(String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/data-transfer/input-ports/{portId}/transactions/{transactionId}"
            .replaceAll("\\{" + "portId" + "\\}", apiClient.escapeString(portId.toString()))
            .replaceAll("\\{" + "transactionId" + "\\}", apiClient.escapeString(transactionId.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, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

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

        com.squareup.okhttp.Call call = extendInputPortTransactionTTLCall(portId, transactionId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Extend transaction TTL
     * 
     * @param portId  (required)
     * @param transactionId  (required)
     * @return TransactionResultEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransactionResultEntity extendInputPortTransactionTTL(String portId, String transactionId) throws ApiException {
        ApiResponse<TransactionResultEntity> resp = extendInputPortTransactionTTLWithHttpInfo(portId, transactionId);
        return resp.getData();
    }

    /**
     * Extend transaction TTL
     * 
     * @param portId  (required)
     * @param transactionId  (required)
     * @return ApiResponse&lt;TransactionResultEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TransactionResultEntity> extendInputPortTransactionTTLWithHttpInfo(String portId, String transactionId) throws ApiException {
        com.squareup.okhttp.Call call = extendInputPortTransactionTTLValidateBeforeCall(portId, transactionId, null, null);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Extend transaction TTL (asynchronously)
     * 
     * @param portId  (required)
     * @param transactionId  (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 extendInputPortTransactionTTLAsync(String portId, String transactionId, final ApiCallback<TransactionResultEntity> 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 = extendInputPortTransactionTTLValidateBeforeCall(portId, transactionId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for extendOutputPortTransactionTTL
     * @param portId  (required)
     * @param transactionId  (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 extendOutputPortTransactionTTLCall(String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/data-transfer/output-ports/{portId}/transactions/{transactionId}"
            .replaceAll("\\{" + "portId" + "\\}", apiClient.escapeString(portId.toString()))
            .replaceAll("\\{" + "transactionId" + "\\}", apiClient.escapeString(transactionId.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, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

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

        com.squareup.okhttp.Call call = extendOutputPortTransactionTTLCall(portId, transactionId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Extend transaction TTL
     * 
     * @param portId  (required)
     * @param transactionId  (required)
     * @return TransactionResultEntity
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TransactionResultEntity extendOutputPortTransactionTTL(String portId, String transactionId) throws ApiException {
        ApiResponse<TransactionResultEntity> resp = extendOutputPortTransactionTTLWithHttpInfo(portId, transactionId);
        return resp.getData();
    }

    /**
     * Extend transaction TTL
     * 
     * @param portId  (required)
     * @param transactionId  (required)
     * @return ApiResponse&lt;TransactionResultEntity&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TransactionResultEntity> extendOutputPortTransactionTTLWithHttpInfo(String portId, String transactionId) throws ApiException {
        com.squareup.okhttp.Call call = extendOutputPortTransactionTTLValidateBeforeCall(portId, transactionId, null, null);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Extend transaction TTL (asynchronously)
     * 
     * @param portId  (required)
     * @param transactionId  (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 extendOutputPortTransactionTTLAsync(String portId, String transactionId, final ApiCallback<TransactionResultEntity> 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 = extendOutputPortTransactionTTLValidateBeforeCall(portId, transactionId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TransactionResultEntity>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for receiveFlowFiles
     * @param portId The input port id. (required)
     * @param transactionId  (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 receiveFlowFilesCall(String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/data-transfer/input-ports/{portId}/transactions/{transactionId}/flow-files"
            .replaceAll("\\{" + "portId" + "\\}", apiClient.escapeString(portId.toString()))
            .replaceAll("\\{" + "transactionId" + "\\}", apiClient.escapeString(transactionId.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 = {
            "text/plain"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = {
            "application/octet-stream"
        };
        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 receiveFlowFilesValidateBeforeCall(String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'portId' is set
        if (portId == null) {
            throw new ApiException("Missing the required parameter 'portId' when calling receiveFlowFiles(Async)");
        }
        
        // verify the required parameter 'transactionId' is set
        if (transactionId == null) {
            throw new ApiException("Missing the required parameter 'transactionId' when calling receiveFlowFiles(Async)");
        }
        

        com.squareup.okhttp.Call call = receiveFlowFilesCall(portId, transactionId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Transfer flow files to the input port
     * 
     * @param portId The input port id. (required)
     * @param transactionId  (required)
     * @return String
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public String receiveFlowFiles(String portId, String transactionId) throws ApiException {
        ApiResponse<String> resp = receiveFlowFilesWithHttpInfo(portId, transactionId);
        return resp.getData();
    }

    /**
     * Transfer flow files to the input port
     * 
     * @param portId The input port id. (required)
     * @param transactionId  (required)
     * @return ApiResponse&lt;String&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<String> receiveFlowFilesWithHttpInfo(String portId, String transactionId) throws ApiException {
        com.squareup.okhttp.Call call = receiveFlowFilesValidateBeforeCall(portId, transactionId, null, null);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Transfer flow files to the input port (asynchronously)
     * 
     * @param portId The input port id. (required)
     * @param transactionId  (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 receiveFlowFilesAsync(String portId, String transactionId, final ApiCallback<String> callback) throws ApiException {

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

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

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

        com.squareup.okhttp.Call call = receiveFlowFilesValidateBeforeCall(portId, transactionId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<String>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for transferFlowFiles
     * @param portId The output port id. (required)
     * @param transactionId  (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 transferFlowFilesCall(String portId, String transactionId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/data-transfer/output-ports/{portId}/transactions/{transactionId}/flow-files"
            .replaceAll("\\{" + "portId" + "\\}", apiClient.escapeString(portId.toString()))
            .replaceAll("\\{" + "transactionId" + "\\}", apiClient.escapeString(transactionId.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/octet-stream"
        };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

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

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

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

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

        com.squareup.okhttp.Call call = transferFlowFilesCall(portId, transactionId, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Transfer flow files from the output port
     * 
     * @param portId The output port id. (required)
     * @param transactionId  (required)
     * @return StreamingOutput
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public StreamingOutput transferFlowFiles(String portId, String transactionId) throws ApiException {
        ApiResponse<StreamingOutput> resp = transferFlowFilesWithHttpInfo(portId, transactionId);
        return resp.getData();
    }

    /**
     * Transfer flow files from the output port
     * 
     * @param portId The output port id. (required)
     * @param transactionId  (required)
     * @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> transferFlowFilesWithHttpInfo(String portId, String transactionId) throws ApiException {
        com.squareup.okhttp.Call call = transferFlowFilesValidateBeforeCall(portId, transactionId, null, null);
        Type localVarReturnType = new TypeToken<StreamingOutput>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Transfer flow files from the output port (asynchronously)
     * 
     * @param portId The output port id. (required)
     * @param transactionId  (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 transferFlowFilesAsync(String portId, String transactionId, 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 = transferFlowFilesValidateBeforeCall(portId, transactionId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<StreamingOutput>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}