/*
 * WSO2 API Manager - Publisher API
 * This specifies a **RESTful API** for WSO2 **API Manager** - Publisher.  Please see [full swagger definition](https://raw.githubusercontent.com/wso2/carbon-apimgt/v6.0.4/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher/src/main/resources/publisher-api.yaml) of the API which is written using [swagger 2.0](http://swagger.io/) specification. 
 *
 * OpenAPI spec version: v1.0
 * Contact: architecture@wso2.com
 *
 * 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 org.wso2.am.integration.clients.publisher.api.v1;

import org.wso2.am.integration.clients.publisher.api.ApiCallback;
import org.wso2.am.integration.clients.publisher.api.ApiClient;
import org.wso2.am.integration.clients.publisher.api.ApiException;
import org.wso2.am.integration.clients.publisher.api.ApiResponse;
import org.wso2.am.integration.clients.publisher.api.Configuration;
import org.wso2.am.integration.clients.publisher.api.Pair;
import org.wso2.am.integration.clients.publisher.api.ProgressRequestBody;
import org.wso2.am.integration.clients.publisher.api.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import org.wso2.am.integration.clients.publisher.api.v1.dto.CertMetadataDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.CertificateInfoDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.CertificatesDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.ErrorDTO;
import java.io.File;

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

public class EndpointCertificatesApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

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

        // create path and map variables
        String localVarPath = "/endpoint-certificates/{alias}/content"
            .replaceAll("\\{" + "alias" + "\\}", apiClient.escapeString(alias.toString()));

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

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

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

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

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

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new 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[] { "OAuth2Security" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

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

        com.squareup.okhttp.Call call = endpointCertificatesAliasContentGetCall(alias, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Download a certificate.
     * This operation can be used to download a certificate which matches the given alias. 
     * @param alias  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void endpointCertificatesAliasContentGet(String alias) throws ApiException {
        endpointCertificatesAliasContentGetWithHttpInfo(alias);
    }

    /**
     * Download a certificate.
     * This operation can be used to download a certificate which matches the given alias. 
     * @param alias  (required)
     * @return ApiResponse&lt;Void&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<Void> endpointCertificatesAliasContentGetWithHttpInfo(String alias) throws ApiException {
        com.squareup.okhttp.Call call = endpointCertificatesAliasContentGetValidateBeforeCall(alias, null, null);
        return apiClient.execute(call);
    }

    /**
     * Download a certificate. (asynchronously)
     * This operation can be used to download a certificate which matches the given alias. 
     * @param alias  (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 endpointCertificatesAliasContentGetAsync(String alias, final ApiCallback<Void> 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 = endpointCertificatesAliasContentGetValidateBeforeCall(alias, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for endpointCertificatesAliasDelete
     * @param alias The alias of the certificate that should be deleted.  (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 endpointCertificatesAliasDeleteCall(String alias, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/endpoint-certificates/{alias}"
            .replaceAll("\\{" + "alias" + "\\}", apiClient.escapeString(alias.toString()));

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

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

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

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

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

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new 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[] { "OAuth2Security" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

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

        com.squareup.okhttp.Call call = endpointCertificatesAliasDeleteCall(alias, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Delete a certificate.
     * This operation can be used to delete an uploaded certificate. 
     * @param alias The alias of the certificate that should be deleted.  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void endpointCertificatesAliasDelete(String alias) throws ApiException {
        endpointCertificatesAliasDeleteWithHttpInfo(alias);
    }

    /**
     * Delete a certificate.
     * This operation can be used to delete an uploaded certificate. 
     * @param alias The alias of the certificate that should be deleted.  (required)
     * @return ApiResponse&lt;Void&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<Void> endpointCertificatesAliasDeleteWithHttpInfo(String alias) throws ApiException {
        com.squareup.okhttp.Call call = endpointCertificatesAliasDeleteValidateBeforeCall(alias, null, null);
        return apiClient.execute(call);
    }

    /**
     * Delete a certificate. (asynchronously)
     * This operation can be used to delete an uploaded certificate. 
     * @param alias The alias of the certificate that should be deleted.  (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 endpointCertificatesAliasDeleteAsync(String alias, final ApiCallback<Void> 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 = endpointCertificatesAliasDeleteValidateBeforeCall(alias, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for endpointCertificatesAliasGet
     * @param alias  (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 endpointCertificatesAliasGetCall(String alias, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/endpoint-certificates/{alias}"
            .replaceAll("\\{" + "alias" + "\\}", apiClient.escapeString(alias.toString()));

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

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

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

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

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

        if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new 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[] { "OAuth2Security" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

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

        com.squareup.okhttp.Call call = endpointCertificatesAliasGetCall(alias, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the certificate information.
     * This operation can be used to get the information about a certificate. 
     * @param alias  (required)
     * @return CertificateInfoDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public CertificateInfoDTO endpointCertificatesAliasGet(String alias) throws ApiException {
        ApiResponse<CertificateInfoDTO> resp = endpointCertificatesAliasGetWithHttpInfo(alias);
        return resp.getData();
    }

    /**
     * Get the certificate information.
     * This operation can be used to get the information about a certificate. 
     * @param alias  (required)
     * @return ApiResponse&lt;CertificateInfoDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<CertificateInfoDTO> endpointCertificatesAliasGetWithHttpInfo(String alias) throws ApiException {
        com.squareup.okhttp.Call call = endpointCertificatesAliasGetValidateBeforeCall(alias, null, null);
        Type localVarReturnType = new TypeToken<CertificateInfoDTO>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the certificate information. (asynchronously)
     * This operation can be used to get the information about a certificate. 
     * @param alias  (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 endpointCertificatesAliasGetAsync(String alias, final ApiCallback<CertificateInfoDTO> 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 = endpointCertificatesAliasGetValidateBeforeCall(alias, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<CertificateInfoDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for endpointCertificatesAliasPut
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (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 endpointCertificatesAliasPutCall(File certificate, String alias, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/endpoint-certificates/{alias}"
            .replaceAll("\\{" + "alias" + "\\}", apiClient.escapeString(alias.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>();
        if (certificate != null)
        localVarFormParams.put("certificate", certificate);

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

        final String[] localVarContentTypes = {
            "multipart/form-data"
        };
        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[] { "OAuth2Security" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

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

        com.squareup.okhttp.Call call = endpointCertificatesAliasPutCall(certificate, alias, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update a certificate.
     * This operation can be used to update an uploaded certificate. 
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (required)
     * @return CertMetadataDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public CertMetadataDTO endpointCertificatesAliasPut(File certificate, String alias) throws ApiException {
        ApiResponse<CertMetadataDTO> resp = endpointCertificatesAliasPutWithHttpInfo(certificate, alias);
        return resp.getData();
    }

    /**
     * Update a certificate.
     * This operation can be used to update an uploaded certificate. 
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (required)
     * @return ApiResponse&lt;CertMetadataDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<CertMetadataDTO> endpointCertificatesAliasPutWithHttpInfo(File certificate, String alias) throws ApiException {
        com.squareup.okhttp.Call call = endpointCertificatesAliasPutValidateBeforeCall(certificate, alias, null, null);
        Type localVarReturnType = new TypeToken<CertMetadataDTO>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Update a certificate. (asynchronously)
     * This operation can be used to update an uploaded certificate. 
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (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 endpointCertificatesAliasPutAsync(File certificate, String alias, final ApiCallback<CertMetadataDTO> 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 = endpointCertificatesAliasPutValidateBeforeCall(certificate, alias, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<CertMetadataDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for endpointCertificatesGet
     * @param limit Maximum size of resource array to return.  (optional, default to 25)
     * @param offset Starting point within the complete list of items qualified.  (optional, default to 0)
     * @param alias Alias for the certificate (optional)
     * @param endpoint Endpoint of which the certificate is uploaded (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 endpointCertificatesGetCall(Integer limit, Integer offset, String alias, String endpoint, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/endpoint-certificates";

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

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

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

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

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

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

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

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call endpointCertificatesGetValidateBeforeCall(Integer limit, Integer offset, String alias, String endpoint, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        

        com.squareup.okhttp.Call call = endpointCertificatesGetCall(limit, offset, alias, endpoint, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Retrieve/Search uploaded certificates.
     * This operation can be used to retrieve and search the uploaded certificates. 
     * @param limit Maximum size of resource array to return.  (optional, default to 25)
     * @param offset Starting point within the complete list of items qualified.  (optional, default to 0)
     * @param alias Alias for the certificate (optional)
     * @param endpoint Endpoint of which the certificate is uploaded (optional)
     * @return CertificatesDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public CertificatesDTO endpointCertificatesGet(Integer limit, Integer offset, String alias, String endpoint) throws ApiException {
        ApiResponse<CertificatesDTO> resp = endpointCertificatesGetWithHttpInfo(limit, offset, alias, endpoint);
        return resp.getData();
    }

    /**
     * Retrieve/Search uploaded certificates.
     * This operation can be used to retrieve and search the uploaded certificates. 
     * @param limit Maximum size of resource array to return.  (optional, default to 25)
     * @param offset Starting point within the complete list of items qualified.  (optional, default to 0)
     * @param alias Alias for the certificate (optional)
     * @param endpoint Endpoint of which the certificate is uploaded (optional)
     * @return ApiResponse&lt;CertificatesDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<CertificatesDTO> endpointCertificatesGetWithHttpInfo(Integer limit, Integer offset, String alias, String endpoint) throws ApiException {
        com.squareup.okhttp.Call call = endpointCertificatesGetValidateBeforeCall(limit, offset, alias, endpoint, null, null);
        Type localVarReturnType = new TypeToken<CertificatesDTO>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieve/Search uploaded certificates. (asynchronously)
     * This operation can be used to retrieve and search the uploaded certificates. 
     * @param limit Maximum size of resource array to return.  (optional, default to 25)
     * @param offset Starting point within the complete list of items qualified.  (optional, default to 0)
     * @param alias Alias for the certificate (optional)
     * @param endpoint Endpoint of which the certificate is uploaded (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 endpointCertificatesGetAsync(Integer limit, Integer offset, String alias, String endpoint, final ApiCallback<CertificatesDTO> 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 = endpointCertificatesGetValidateBeforeCall(limit, offset, alias, endpoint, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<CertificatesDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for endpointCertificatesPost
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (required)
     * @param endpoint Endpoint to which the certificate should be applied. (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 endpointCertificatesPostCall(File certificate, String alias, String endpoint, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/endpoint-certificates";

        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>();
        if (certificate != null)
        localVarFormParams.put("certificate", certificate);
        if (alias != null)
        localVarFormParams.put("alias", alias);
        if (endpoint != null)
        localVarFormParams.put("endpoint", endpoint);

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

        final String[] localVarContentTypes = {
            "multipart/form-data"
        };
        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[] { "OAuth2Security" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

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

        com.squareup.okhttp.Call call = endpointCertificatesPostCall(certificate, alias, endpoint, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Upload a new Certificate.
     * This operation can be used to upload a new certificate for an endpoint. 
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (required)
     * @param endpoint Endpoint to which the certificate should be applied. (required)
     * @return CertMetadataDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public CertMetadataDTO endpointCertificatesPost(File certificate, String alias, String endpoint) throws ApiException {
        ApiResponse<CertMetadataDTO> resp = endpointCertificatesPostWithHttpInfo(certificate, alias, endpoint);
        return resp.getData();
    }

    /**
     * Upload a new Certificate.
     * This operation can be used to upload a new certificate for an endpoint. 
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (required)
     * @param endpoint Endpoint to which the certificate should be applied. (required)
     * @return ApiResponse&lt;CertMetadataDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<CertMetadataDTO> endpointCertificatesPostWithHttpInfo(File certificate, String alias, String endpoint) throws ApiException {
        com.squareup.okhttp.Call call = endpointCertificatesPostValidateBeforeCall(certificate, alias, endpoint, null, null);
        Type localVarReturnType = new TypeToken<CertMetadataDTO>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Upload a new Certificate. (asynchronously)
     * This operation can be used to upload a new certificate for an endpoint. 
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (required)
     * @param endpoint Endpoint to which the certificate should be applied. (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 endpointCertificatesPostAsync(File certificate, String alias, String endpoint, final ApiCallback<CertMetadataDTO> 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 = endpointCertificatesPostValidateBeforeCall(certificate, alias, endpoint, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<CertMetadataDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
