/*
 * 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.ErrorDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.ResourcePolicyInfoDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.ResourcePolicyListDTO;

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

public class ApiResourcePoliciesApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Build call for apisApiIdResourcePoliciesGet
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param sequenceType sequence type of the resource policy resource definition (required)
     * @param resourcePath Resource path of the resource policy definition (optional)
     * @param verb HTTP verb of the resource path of the resource policy definition (optional)
     * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.  (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 apisApiIdResourcePoliciesGetCall(String apiId, String sequenceType, String resourcePath, String verb, String ifNoneMatch, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

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

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        if (ifNoneMatch != null)
        localVarHeaderParams.put("If-None-Match", apiClient.parameterToString(ifNoneMatch));

        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 apisApiIdResourcePoliciesGetValidateBeforeCall(String apiId, String sequenceType, String resourcePath, String verb, String ifNoneMatch, 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 apisApiIdResourcePoliciesGet(Async)");
        }
        
        // verify the required parameter 'sequenceType' is set
        if (sequenceType == null) {
            throw new ApiException("Missing the required parameter 'sequenceType' when calling apisApiIdResourcePoliciesGet(Async)");
        }
        

        com.squareup.okhttp.Call call = apisApiIdResourcePoliciesGetCall(apiId, sequenceType, resourcePath, verb, ifNoneMatch, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the resource policy (inflow/outflow) definitions
     * This operation can be used to retrieve conversion policy resource definitions of an API. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param sequenceType sequence type of the resource policy resource definition (required)
     * @param resourcePath Resource path of the resource policy definition (optional)
     * @param verb HTTP verb of the resource path of the resource policy definition (optional)
     * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.  (optional)
     * @return ResourcePolicyListDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourcePolicyListDTO apisApiIdResourcePoliciesGet(String apiId, String sequenceType, String resourcePath, String verb, String ifNoneMatch) throws ApiException {
        ApiResponse<ResourcePolicyListDTO> resp = apisApiIdResourcePoliciesGetWithHttpInfo(apiId, sequenceType, resourcePath, verb, ifNoneMatch);
        return resp.getData();
    }

    /**
     * Get the resource policy (inflow/outflow) definitions
     * This operation can be used to retrieve conversion policy resource definitions of an API. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param sequenceType sequence type of the resource policy resource definition (required)
     * @param resourcePath Resource path of the resource policy definition (optional)
     * @param verb HTTP verb of the resource path of the resource policy definition (optional)
     * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.  (optional)
     * @return ApiResponse&lt;ResourcePolicyListDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ResourcePolicyListDTO> apisApiIdResourcePoliciesGetWithHttpInfo(String apiId, String sequenceType, String resourcePath, String verb, String ifNoneMatch) throws ApiException {
        com.squareup.okhttp.Call call = apisApiIdResourcePoliciesGetValidateBeforeCall(apiId, sequenceType, resourcePath, verb, ifNoneMatch, null, null);
        Type localVarReturnType = new TypeToken<ResourcePolicyListDTO>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the resource policy (inflow/outflow) definitions (asynchronously)
     * This operation can be used to retrieve conversion policy resource definitions of an API. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param sequenceType sequence type of the resource policy resource definition (required)
     * @param resourcePath Resource path of the resource policy definition (optional)
     * @param verb HTTP verb of the resource path of the resource policy definition (optional)
     * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.  (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 apisApiIdResourcePoliciesGetAsync(String apiId, String sequenceType, String resourcePath, String verb, String ifNoneMatch, final ApiCallback<ResourcePolicyListDTO> 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 = apisApiIdResourcePoliciesGetValidateBeforeCall(apiId, sequenceType, resourcePath, verb, ifNoneMatch, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ResourcePolicyListDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for apisApiIdResourcePoliciesResourcePolicyIdGet
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param resourcePolicyId registry resource Id  (required)
     * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.  (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 apisApiIdResourcePoliciesResourcePolicyIdGetCall(String apiId, String resourcePolicyId, String ifNoneMatch, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

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

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        if (ifNoneMatch != null)
        localVarHeaderParams.put("If-None-Match", apiClient.parameterToString(ifNoneMatch));

        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 apisApiIdResourcePoliciesResourcePolicyIdGetValidateBeforeCall(String apiId, String resourcePolicyId, String ifNoneMatch, 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 apisApiIdResourcePoliciesResourcePolicyIdGet(Async)");
        }
        
        // verify the required parameter 'resourcePolicyId' is set
        if (resourcePolicyId == null) {
            throw new ApiException("Missing the required parameter 'resourcePolicyId' when calling apisApiIdResourcePoliciesResourcePolicyIdGet(Async)");
        }
        

        com.squareup.okhttp.Call call = apisApiIdResourcePoliciesResourcePolicyIdGetCall(apiId, resourcePolicyId, ifNoneMatch, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Get the resource policy (inflow/outflow) definition for a given resource identifier.
     * This operation can be used to retrieve conversion policy resource definitions of an API given the resource identifier. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param resourcePolicyId registry resource Id  (required)
     * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.  (optional)
     * @return ResourcePolicyInfoDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourcePolicyInfoDTO apisApiIdResourcePoliciesResourcePolicyIdGet(String apiId, String resourcePolicyId, String ifNoneMatch) throws ApiException {
        ApiResponse<ResourcePolicyInfoDTO> resp = apisApiIdResourcePoliciesResourcePolicyIdGetWithHttpInfo(apiId, resourcePolicyId, ifNoneMatch);
        return resp.getData();
    }

    /**
     * Get the resource policy (inflow/outflow) definition for a given resource identifier.
     * This operation can be used to retrieve conversion policy resource definitions of an API given the resource identifier. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param resourcePolicyId registry resource Id  (required)
     * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.  (optional)
     * @return ApiResponse&lt;ResourcePolicyInfoDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ResourcePolicyInfoDTO> apisApiIdResourcePoliciesResourcePolicyIdGetWithHttpInfo(String apiId, String resourcePolicyId, String ifNoneMatch) throws ApiException {
        com.squareup.okhttp.Call call = apisApiIdResourcePoliciesResourcePolicyIdGetValidateBeforeCall(apiId, resourcePolicyId, ifNoneMatch, null, null);
        Type localVarReturnType = new TypeToken<ResourcePolicyInfoDTO>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get the resource policy (inflow/outflow) definition for a given resource identifier. (asynchronously)
     * This operation can be used to retrieve conversion policy resource definitions of an API given the resource identifier. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param resourcePolicyId registry resource Id  (required)
     * @param ifNoneMatch Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource.  (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 apisApiIdResourcePoliciesResourcePolicyIdGetAsync(String apiId, String resourcePolicyId, String ifNoneMatch, final ApiCallback<ResourcePolicyInfoDTO> 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 = apisApiIdResourcePoliciesResourcePolicyIdGetValidateBeforeCall(apiId, resourcePolicyId, ifNoneMatch, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ResourcePolicyInfoDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
    /**
     * Build call for apisApiIdResourcePoliciesResourcePolicyIdPut
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param resourcePolicyId registry resource Id  (required)
     * @param body Content of the resource policy definition that needs to be updated (required)
     * @param ifMatch Validator for conditional requests; based on ETag.  (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 apisApiIdResourcePoliciesResourcePolicyIdPutCall(String apiId, String resourcePolicyId, ResourcePolicyInfoDTO body, String ifMatch, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;

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

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

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        if (ifMatch != null)
        localVarHeaderParams.put("If-Match", apiClient.parameterToString(ifMatch));

        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, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    @SuppressWarnings("rawtypes")
    private com.squareup.okhttp.Call apisApiIdResourcePoliciesResourcePolicyIdPutValidateBeforeCall(String apiId, String resourcePolicyId, ResourcePolicyInfoDTO body, String ifMatch, 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 apisApiIdResourcePoliciesResourcePolicyIdPut(Async)");
        }
        
        // verify the required parameter 'resourcePolicyId' is set
        if (resourcePolicyId == null) {
            throw new ApiException("Missing the required parameter 'resourcePolicyId' when calling apisApiIdResourcePoliciesResourcePolicyIdPut(Async)");
        }
        
        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling apisApiIdResourcePoliciesResourcePolicyIdPut(Async)");
        }
        

        com.squareup.okhttp.Call call = apisApiIdResourcePoliciesResourcePolicyIdPutCall(apiId, resourcePolicyId, body, ifMatch, progressListener, progressRequestListener);
        return call;

    }

    /**
     * Update the resource policy(inflow/outflow) definition for the given resource identifier
     * This operation can be used to update the resource policy(inflow/outflow) definition for the given resource identifier of an existing API. resource policy definition to be updated is passed as a body parameter &#x60;content&#x60;. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param resourcePolicyId registry resource Id  (required)
     * @param body Content of the resource policy definition that needs to be updated (required)
     * @param ifMatch Validator for conditional requests; based on ETag.  (optional)
     * @return ResourcePolicyInfoDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ResourcePolicyInfoDTO apisApiIdResourcePoliciesResourcePolicyIdPut(String apiId, String resourcePolicyId, ResourcePolicyInfoDTO body, String ifMatch) throws ApiException {
        ApiResponse<ResourcePolicyInfoDTO> resp = apisApiIdResourcePoliciesResourcePolicyIdPutWithHttpInfo(apiId, resourcePolicyId, body, ifMatch);
        return resp.getData();
    }

    /**
     * Update the resource policy(inflow/outflow) definition for the given resource identifier
     * This operation can be used to update the resource policy(inflow/outflow) definition for the given resource identifier of an existing API. resource policy definition to be updated is passed as a body parameter &#x60;content&#x60;. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param resourcePolicyId registry resource Id  (required)
     * @param body Content of the resource policy definition that needs to be updated (required)
     * @param ifMatch Validator for conditional requests; based on ETag.  (optional)
     * @return ApiResponse&lt;ResourcePolicyInfoDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<ResourcePolicyInfoDTO> apisApiIdResourcePoliciesResourcePolicyIdPutWithHttpInfo(String apiId, String resourcePolicyId, ResourcePolicyInfoDTO body, String ifMatch) throws ApiException {
        com.squareup.okhttp.Call call = apisApiIdResourcePoliciesResourcePolicyIdPutValidateBeforeCall(apiId, resourcePolicyId, body, ifMatch, null, null);
        Type localVarReturnType = new TypeToken<ResourcePolicyInfoDTO>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Update the resource policy(inflow/outflow) definition for the given resource identifier (asynchronously)
     * This operation can be used to update the resource policy(inflow/outflow) definition for the given resource identifier of an existing API. resource policy definition to be updated is passed as a body parameter &#x60;content&#x60;. 
     * @param apiId **API ID** consisting of the **UUID** of the API.  (required)
     * @param resourcePolicyId registry resource Id  (required)
     * @param body Content of the resource policy definition that needs to be updated (required)
     * @param ifMatch Validator for conditional requests; based on ETag.  (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 apisApiIdResourcePoliciesResourcePolicyIdPutAsync(String apiId, String resourcePolicyId, ResourcePolicyInfoDTO body, String ifMatch, final ApiCallback<ResourcePolicyInfoDTO> 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 = apisApiIdResourcePoliciesResourcePolicyIdPutValidateBeforeCall(apiId, resourcePolicyId, body, ifMatch, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<ResourcePolicyInfoDTO>(){}.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}
