/*
 * 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.1
 * 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.CertificateInfoDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.ClientCertMetadataDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.ClientCertificatesDTO;
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 ClientCertificatesApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

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

        // create path and map variables
        String localVarPath = "/apis/{apiId}/client-certificates/{alias}/content"
            .replaceAll("\\{" + "apiId" + "\\}", apiClient.escapeString(apiId.toString()))
            .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 apisApiIdClientCertificatesAliasContentGetValidateBeforeCall(String apiId, String alias, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'apiId' is set
        if (apiId == null) {
            throw new ApiException("Missing the required parameter 'apiId' when calling apisApiIdClientCertificatesAliasContentGet(Async)");
        }
        
        // verify the required parameter 'alias' is set
        if (alias == null) {
            throw new ApiException("Missing the required parameter 'alias' when calling apisApiIdClientCertificatesAliasContentGet(Async)");
        }
        

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

    }

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

    /**
     * Download a certificate.
     * This operation can be used to download a certificate which matches the given alias. 
     * @param apiId The api identifier (required)
     * @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> apisApiIdClientCertificatesAliasContentGetWithHttpInfo(String apiId, String alias) throws ApiException {
        com.squareup.okhttp.Call call = apisApiIdClientCertificatesAliasContentGetValidateBeforeCall(apiId, 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 apiId The api identifier (required)
     * @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 apisApiIdClientCertificatesAliasContentGetAsync(String apiId, 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 = apisApiIdClientCertificatesAliasContentGetValidateBeforeCall(apiId, alias, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for apisApiIdClientCertificatesAliasDelete
     * @param alias The alias of the certificate that should be deleted.  (required)
     * @param apiId The api identifier (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 apisApiIdClientCertificatesAliasDeleteCall(String alias, String apiId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/apis/{apiId}/client-certificates/{alias}"
            .replaceAll("\\{" + "alias" + "\\}", apiClient.escapeString(alias.toString()))
            .replaceAll("\\{" + "apiId" + "\\}", apiClient.escapeString(apiId.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 apisApiIdClientCertificatesAliasDeleteValidateBeforeCall(String alias, String apiId, 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 apisApiIdClientCertificatesAliasDelete(Async)");
        }
        
        // verify the required parameter 'apiId' is set
        if (apiId == null) {
            throw new ApiException("Missing the required parameter 'apiId' when calling apisApiIdClientCertificatesAliasDelete(Async)");
        }
        

        com.squareup.okhttp.Call call = apisApiIdClientCertificatesAliasDeleteCall(alias, apiId, 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)
     * @param apiId The api identifier (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public void apisApiIdClientCertificatesAliasDelete(String alias, String apiId) throws ApiException {
        apisApiIdClientCertificatesAliasDeleteWithHttpInfo(alias, apiId);
    }

    /**
     * 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)
     * @param apiId The api identifier (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> apisApiIdClientCertificatesAliasDeleteWithHttpInfo(String alias, String apiId) throws ApiException {
        com.squareup.okhttp.Call call = apisApiIdClientCertificatesAliasDeleteValidateBeforeCall(alias, apiId, 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 apiId The api identifier (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 apisApiIdClientCertificatesAliasDeleteAsync(String alias, String apiId, 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 = apisApiIdClientCertificatesAliasDeleteValidateBeforeCall(alias, apiId, progressListener, progressRequestListener);
        apiClient.executeAsync(call, callback);
        return call;
    }
    /**
     * Build call for apisApiIdClientCertificatesAliasGet
     * @param alias  (required)
     * @param apiId The api identifier (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 apisApiIdClientCertificatesAliasGetCall(String alias, String apiId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/apis/{apiId}/client-certificates/{alias}"
            .replaceAll("\\{" + "alias" + "\\}", apiClient.escapeString(alias.toString()))
            .replaceAll("\\{" + "apiId" + "\\}", apiClient.escapeString(apiId.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 apisApiIdClientCertificatesAliasGetValidateBeforeCall(String alias, String apiId, 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 apisApiIdClientCertificatesAliasGet(Async)");
        }
        
        // verify the required parameter 'apiId' is set
        if (apiId == null) {
            throw new ApiException("Missing the required parameter 'apiId' when calling apisApiIdClientCertificatesAliasGet(Async)");
        }
        

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

    }

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

    /**
     * Get the certificate information.
     * This operation can be used to get the information about a certificate. 
     * @param alias  (required)
     * @param apiId The api identifier (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> apisApiIdClientCertificatesAliasGetWithHttpInfo(String alias, String apiId) throws ApiException {
        com.squareup.okhttp.Call call = apisApiIdClientCertificatesAliasGetValidateBeforeCall(alias, apiId, 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 apiId The api identifier (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 apisApiIdClientCertificatesAliasGetAsync(String alias, String apiId, 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 = apisApiIdClientCertificatesAliasGetValidateBeforeCall(alias, apiId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<CertificateInfoDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for apisApiIdClientCertificatesAliasPut
     * @param alias Alias for the certificate (required)
     * @param apiId The api identifier (required)
     * @param certificate The certificate that needs to be uploaded. (optional)
     * @param tier The tier of the certificate (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 apisApiIdClientCertificatesAliasPutCall(String alias, String apiId, File certificate, String tier, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        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 apisApiIdClientCertificatesAliasPutValidateBeforeCall(String alias, String apiId, File certificate, String tier, 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 apisApiIdClientCertificatesAliasPut(Async)");
        }
        
        // verify the required parameter 'apiId' is set
        if (apiId == null) {
            throw new ApiException("Missing the required parameter 'apiId' when calling apisApiIdClientCertificatesAliasPut(Async)");
        }
        

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

    }

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

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

    /**
     * Update a certificate. (asynchronously)
     * This operation can be used to update an uploaded certificate. 
     * @param alias Alias for the certificate (required)
     * @param apiId The api identifier (required)
     * @param certificate The certificate that needs to be uploaded. (optional)
     * @param tier The tier of the certificate (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 apisApiIdClientCertificatesAliasPutAsync(String alias, String apiId, File certificate, String tier, final ApiCallback<ClientCertMetadataDTO> 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 = apisApiIdClientCertificatesAliasPutValidateBeforeCall(alias, apiId, certificate, tier, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ClientCertMetadataDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for apisApiIdClientCertificatesGet
     * @param apiId UUID of the API (required)
     * @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 client certificate (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 apisApiIdClientCertificatesGetCall(String apiId, Integer limit, Integer offset, String alias, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

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

        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 apisApiIdClientCertificatesGetValidateBeforeCall(String apiId, Integer limit, Integer offset, String alias, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        
        // verify the required parameter 'apiId' is set
        if (apiId == null) {
            throw new ApiException("Missing the required parameter 'apiId' when calling apisApiIdClientCertificatesGet(Async)");
        }
        

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

    }

    /**
     * Retrieve/ Search uploaded Client Certificates.
     * This operation can be used to retrieve and search the uploaded client certificates. 
     * @param apiId UUID of the API (required)
     * @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 client certificate (optional)
     * @return ClientCertificatesDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ClientCertificatesDTO apisApiIdClientCertificatesGet(String apiId, Integer limit, Integer offset, String alias) throws ApiException {
        ApiResponse<ClientCertificatesDTO> resp = apisApiIdClientCertificatesGetWithHttpInfo(apiId, limit, offset, alias);
        return resp.getData();
    }

    /**
     * Retrieve/ Search uploaded Client Certificates.
     * This operation can be used to retrieve and search the uploaded client certificates. 
     * @param apiId UUID of the API (required)
     * @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 client certificate (optional)
     * @return ApiResponse&lt;ClientCertificatesDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ClientCertificatesDTO> apisApiIdClientCertificatesGetWithHttpInfo(String apiId, Integer limit, Integer offset, String alias) throws ApiException {
        com.squareup.okhttp.Call call = apisApiIdClientCertificatesGetValidateBeforeCall(apiId, limit, offset, alias, null, null);
        Type localVarReturnType = new TypeToken<ClientCertificatesDTO>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Retrieve/ Search uploaded Client Certificates. (asynchronously)
     * This operation can be used to retrieve and search the uploaded client certificates. 
     * @param apiId UUID of the API (required)
     * @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 client certificate (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 apisApiIdClientCertificatesGetAsync(String apiId, Integer limit, Integer offset, String alias, final ApiCallback<ClientCertificatesDTO> 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 = apisApiIdClientCertificatesGetValidateBeforeCall(apiId, limit, offset, alias, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ClientCertificatesDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for apisApiIdClientCertificatesPost
     * @param certificate The certificate that needs to be uploaded. (required)
     * @param alias Alias for the certificate (required)
     * @param apiId apiId to which the certificate should be applied. (required)
     * @param tier apiId 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 apisApiIdClientCertificatesPostCall(File certificate, String alias, String apiId, String tier, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        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 apisApiIdClientCertificatesPostValidateBeforeCall(File certificate, String alias, String apiId, String tier, 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 apisApiIdClientCertificatesPost(Async)");
        }
        
        // verify the required parameter 'alias' is set
        if (alias == null) {
            throw new ApiException("Missing the required parameter 'alias' when calling apisApiIdClientCertificatesPost(Async)");
        }
        
        // verify the required parameter 'apiId' is set
        if (apiId == null) {
            throw new ApiException("Missing the required parameter 'apiId' when calling apisApiIdClientCertificatesPost(Async)");
        }
        
        // verify the required parameter 'tier' is set
        if (tier == null) {
            throw new ApiException("Missing the required parameter 'tier' when calling apisApiIdClientCertificatesPost(Async)");
        }
        

        com.squareup.okhttp.Call call = apisApiIdClientCertificatesPostCall(certificate, alias, apiId, tier, 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 apiId apiId to which the certificate should be applied. (required)
     * @param tier apiId to which the certificate should be applied. (required)
     * @return ClientCertMetadataDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ClientCertMetadataDTO apisApiIdClientCertificatesPost(File certificate, String alias, String apiId, String tier) throws ApiException {
        ApiResponse<ClientCertMetadataDTO> resp = apisApiIdClientCertificatesPostWithHttpInfo(certificate, alias, apiId, tier);
        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 apiId apiId to which the certificate should be applied. (required)
     * @param tier apiId to which the certificate should be applied. (required)
     * @return ApiResponse&lt;ClientCertMetadataDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ClientCertMetadataDTO> apisApiIdClientCertificatesPostWithHttpInfo(File certificate, String alias, String apiId, String tier) throws ApiException {
        com.squareup.okhttp.Call call = apisApiIdClientCertificatesPostValidateBeforeCall(certificate, alias, apiId, tier, null, null);
        Type localVarReturnType = new TypeToken<ClientCertMetadataDTO>(){}.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 apiId apiId to which the certificate should be applied. (required)
     * @param tier apiId 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 apisApiIdClientCertificatesPostAsync(File certificate, String alias, String apiId, String tier, final ApiCallback<ClientCertMetadataDTO> 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 = apisApiIdClientCertificatesPostValidateBeforeCall(certificate, alias, apiId, tier, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ClientCertMetadataDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
