/*
 * WSO2 API Manager - Governance
 * This document specifies a **RESTful API** for WSO2 **API Manager** - Governance. 
 *
 * The version of the OpenAPI document: v1.1
 * Contact: architecture@wso2.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package org.wso2.am.integration.clients.governance.api;

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

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import org.wso2.am.integration.clients.governance.api.dto.APIMGovernancePolicyDTO;
import org.wso2.am.integration.clients.governance.api.dto.APIMGovernancePolicyListDTO;
import org.wso2.am.integration.clients.governance.api.dto.ErrorDTO;

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

public class GovernancePoliciesApi {
    private ApiClient localVarApiClient;

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

    public GovernancePoliciesApi(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return localVarApiClient;
    }

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

    /**
     * Build call for createGovernancePolicy
     * @param apIMGovernancePolicyDTO JSON object containing the details of the new governance policy. (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> OK. Governance policy created successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createGovernancePolicyCall(APIMGovernancePolicyDTO apIMGovernancePolicyDTO, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = apIMGovernancePolicyDTO;

        // create path and map variables
        String localVarPath = "/policies";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();
        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

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

        String[] localVarAuthNames = new String[] { "OAuth2Security" };
        return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call createGovernancePolicyValidateBeforeCall(APIMGovernancePolicyDTO apIMGovernancePolicyDTO, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'apIMGovernancePolicyDTO' is set
        if (apIMGovernancePolicyDTO == null) {
            throw new ApiException("Missing the required parameter 'apIMGovernancePolicyDTO' when calling createGovernancePolicy(Async)");
        }
        

        okhttp3.Call localVarCall = createGovernancePolicyCall(apIMGovernancePolicyDTO, _callback);
        return localVarCall;

    }

    /**
     * Creates a new governance policy.
     * Creates a new governance policy for the user&#39;s organization.
     * @param apIMGovernancePolicyDTO JSON object containing the details of the new governance policy. (required)
     * @return APIMGovernancePolicyDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> OK. Governance policy created successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public APIMGovernancePolicyDTO createGovernancePolicy(APIMGovernancePolicyDTO apIMGovernancePolicyDTO) throws ApiException {
        ApiResponse<APIMGovernancePolicyDTO> localVarResp = createGovernancePolicyWithHttpInfo(apIMGovernancePolicyDTO);
        return localVarResp.getData();
    }

    /**
     * Creates a new governance policy.
     * Creates a new governance policy for the user&#39;s organization.
     * @param apIMGovernancePolicyDTO JSON object containing the details of the new governance policy. (required)
     * @return ApiResponse&lt;APIMGovernancePolicyDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> OK. Governance policy created successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<APIMGovernancePolicyDTO> createGovernancePolicyWithHttpInfo(APIMGovernancePolicyDTO apIMGovernancePolicyDTO) throws ApiException {
        okhttp3.Call localVarCall = createGovernancePolicyValidateBeforeCall(apIMGovernancePolicyDTO, null);
        Type localVarReturnType = new TypeToken<APIMGovernancePolicyDTO>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Creates a new governance policy. (asynchronously)
     * Creates a new governance policy for the user&#39;s organization.
     * @param apIMGovernancePolicyDTO JSON object containing the details of the new governance policy. (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
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 201 </td><td> OK. Governance policy created successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createGovernancePolicyAsync(APIMGovernancePolicyDTO apIMGovernancePolicyDTO, final ApiCallback<APIMGovernancePolicyDTO> _callback) throws ApiException {

        okhttp3.Call localVarCall = createGovernancePolicyValidateBeforeCall(apIMGovernancePolicyDTO, _callback);
        Type localVarReturnType = new TypeToken<APIMGovernancePolicyDTO>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for deleteGovernancePolicy
     * @param policyId **UUID** of the Policy.  (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> OK. Governance policy deleted successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteGovernancePolicyCall(String policyId, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/policies/{policyId}"
            .replaceAll("\\{" + "policyId" + "\\}", localVarApiClient.escapeString(policyId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();
        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

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

        String[] localVarAuthNames = new String[] { "OAuth2Security" };
        return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call deleteGovernancePolicyValidateBeforeCall(String policyId, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'policyId' is set
        if (policyId == null) {
            throw new ApiException("Missing the required parameter 'policyId' when calling deleteGovernancePolicy(Async)");
        }
        

        okhttp3.Call localVarCall = deleteGovernancePolicyCall(policyId, _callback);
        return localVarCall;

    }

    /**
     * Delete a specific governance policy
     * Deletes an existing governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (required)
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> OK. Governance policy deleted successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public void deleteGovernancePolicy(String policyId) throws ApiException {
        deleteGovernancePolicyWithHttpInfo(policyId);
    }

    /**
     * Delete a specific governance policy
     * Deletes an existing governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (required)
     * @return ApiResponse&lt;Void&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> OK. Governance policy deleted successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<Void> deleteGovernancePolicyWithHttpInfo(String policyId) throws ApiException {
        okhttp3.Call localVarCall = deleteGovernancePolicyValidateBeforeCall(policyId, null);
        return localVarApiClient.execute(localVarCall);
    }

    /**
     * Delete a specific governance policy (asynchronously)
     * Deletes an existing governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (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
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 204 </td><td> OK. Governance policy deleted successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call deleteGovernancePolicyAsync(String policyId, final ApiCallback<Void> _callback) throws ApiException {

        okhttp3.Call localVarCall = deleteGovernancePolicyValidateBeforeCall(policyId, _callback);
        localVarApiClient.executeAsync(localVarCall, _callback);
        return localVarCall;
    }
    /**
     * Build call for getGovernancePolicies
     * @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 query You can search for governance policies using following format.    - \&quot;query&#x3D;name:{NAME}\&quot; searches policies by name.   - \&quot;query&#x3D;state:{STATE} \&quot; searches policies by state.  You can also use multiple attributes to search for policies.   - \&quot;query&#x3D;name:{NAME} state:{STATE}\&quot; searches policies by name, state, and label.  Remember to use URL encoding if your client doesn&#39;t support it (e.g., curl).  (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Successful response with a list of governance policies. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getGovernancePoliciesCall(Integer limit, Integer offset, String query, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/policies";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        if (limit != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit));
        }

        if (offset != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("offset", offset));
        }

        if (query != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("query", query));
        }

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();
        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

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

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

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getGovernancePoliciesValidateBeforeCall(Integer limit, Integer offset, String query, final ApiCallback _callback) throws ApiException {
        

        okhttp3.Call localVarCall = getGovernancePoliciesCall(limit, offset, query, _callback);
        return localVarCall;

    }

    /**
     * Retrieves a list of all governance policies.
     * Retrieves a list of governance policies for the user&#39;s organization.
     * @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 query You can search for governance policies using following format.    - \&quot;query&#x3D;name:{NAME}\&quot; searches policies by name.   - \&quot;query&#x3D;state:{STATE} \&quot; searches policies by state.  You can also use multiple attributes to search for policies.   - \&quot;query&#x3D;name:{NAME} state:{STATE}\&quot; searches policies by name, state, and label.  Remember to use URL encoding if your client doesn&#39;t support it (e.g., curl).  (optional)
     * @return APIMGovernancePolicyListDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Successful response with a list of governance policies. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public APIMGovernancePolicyListDTO getGovernancePolicies(Integer limit, Integer offset, String query) throws ApiException {
        ApiResponse<APIMGovernancePolicyListDTO> localVarResp = getGovernancePoliciesWithHttpInfo(limit, offset, query);
        return localVarResp.getData();
    }

    /**
     * Retrieves a list of all governance policies.
     * Retrieves a list of governance policies for the user&#39;s organization.
     * @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 query You can search for governance policies using following format.    - \&quot;query&#x3D;name:{NAME}\&quot; searches policies by name.   - \&quot;query&#x3D;state:{STATE} \&quot; searches policies by state.  You can also use multiple attributes to search for policies.   - \&quot;query&#x3D;name:{NAME} state:{STATE}\&quot; searches policies by name, state, and label.  Remember to use URL encoding if your client doesn&#39;t support it (e.g., curl).  (optional)
     * @return ApiResponse&lt;APIMGovernancePolicyListDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Successful response with a list of governance policies. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<APIMGovernancePolicyListDTO> getGovernancePoliciesWithHttpInfo(Integer limit, Integer offset, String query) throws ApiException {
        okhttp3.Call localVarCall = getGovernancePoliciesValidateBeforeCall(limit, offset, query, null);
        Type localVarReturnType = new TypeToken<APIMGovernancePolicyListDTO>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Retrieves a list of all governance policies. (asynchronously)
     * Retrieves a list of governance policies for the user&#39;s organization.
     * @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 query You can search for governance policies using following format.    - \&quot;query&#x3D;name:{NAME}\&quot; searches policies by name.   - \&quot;query&#x3D;state:{STATE} \&quot; searches policies by state.  You can also use multiple attributes to search for policies.   - \&quot;query&#x3D;name:{NAME} state:{STATE}\&quot; searches policies by name, state, and label.  Remember to use URL encoding if your client doesn&#39;t support it (e.g., curl).  (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
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Successful response with a list of governance policies. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getGovernancePoliciesAsync(Integer limit, Integer offset, String query, final ApiCallback<APIMGovernancePolicyListDTO> _callback) throws ApiException {

        okhttp3.Call localVarCall = getGovernancePoliciesValidateBeforeCall(limit, offset, query, _callback);
        Type localVarReturnType = new TypeToken<APIMGovernancePolicyListDTO>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for getGovernancePolicyById
     * @param policyId **UUID** of the Policy.  (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Governance policy details retrieved successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getGovernancePolicyByIdCall(String policyId, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/policies/{policyId}"
            .replaceAll("\\{" + "policyId" + "\\}", localVarApiClient.escapeString(policyId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();
        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

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

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

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getGovernancePolicyByIdValidateBeforeCall(String policyId, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'policyId' is set
        if (policyId == null) {
            throw new ApiException("Missing the required parameter 'policyId' when calling getGovernancePolicyById(Async)");
        }
        

        okhttp3.Call localVarCall = getGovernancePolicyByIdCall(policyId, _callback);
        return localVarCall;

    }

    /**
     * Get a specific governance policy
     * Retrieves details of a specific governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (required)
     * @return APIMGovernancePolicyDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Governance policy details retrieved successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public APIMGovernancePolicyDTO getGovernancePolicyById(String policyId) throws ApiException {
        ApiResponse<APIMGovernancePolicyDTO> localVarResp = getGovernancePolicyByIdWithHttpInfo(policyId);
        return localVarResp.getData();
    }

    /**
     * Get a specific governance policy
     * Retrieves details of a specific governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (required)
     * @return ApiResponse&lt;APIMGovernancePolicyDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Governance policy details retrieved successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<APIMGovernancePolicyDTO> getGovernancePolicyByIdWithHttpInfo(String policyId) throws ApiException {
        okhttp3.Call localVarCall = getGovernancePolicyByIdValidateBeforeCall(policyId, null);
        Type localVarReturnType = new TypeToken<APIMGovernancePolicyDTO>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Get a specific governance policy (asynchronously)
     * Retrieves details of a specific governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (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
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Governance policy details retrieved successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getGovernancePolicyByIdAsync(String policyId, final ApiCallback<APIMGovernancePolicyDTO> _callback) throws ApiException {

        okhttp3.Call localVarCall = getGovernancePolicyByIdValidateBeforeCall(policyId, _callback);
        Type localVarReturnType = new TypeToken<APIMGovernancePolicyDTO>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for updateGovernancePolicyById
     * @param policyId **UUID** of the Policy.  (required)
     * @param apIMGovernancePolicyDTO JSON object containing the updated governance policy details. (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Governance policy updated successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call updateGovernancePolicyByIdCall(String policyId, APIMGovernancePolicyDTO apIMGovernancePolicyDTO, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = apIMGovernancePolicyDTO;

        // create path and map variables
        String localVarPath = "/policies/{policyId}"
            .replaceAll("\\{" + "policyId" + "\\}", localVarApiClient.escapeString(policyId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();
        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

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

        String[] localVarAuthNames = new String[] { "OAuth2Security" };
        return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call updateGovernancePolicyByIdValidateBeforeCall(String policyId, APIMGovernancePolicyDTO apIMGovernancePolicyDTO, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'policyId' is set
        if (policyId == null) {
            throw new ApiException("Missing the required parameter 'policyId' when calling updateGovernancePolicyById(Async)");
        }
        
        // verify the required parameter 'apIMGovernancePolicyDTO' is set
        if (apIMGovernancePolicyDTO == null) {
            throw new ApiException("Missing the required parameter 'apIMGovernancePolicyDTO' when calling updateGovernancePolicyById(Async)");
        }
        

        okhttp3.Call localVarCall = updateGovernancePolicyByIdCall(policyId, apIMGovernancePolicyDTO, _callback);
        return localVarCall;

    }

    /**
     * Update a specific governance policy
     * Updates the details of an existing governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (required)
     * @param apIMGovernancePolicyDTO JSON object containing the updated governance policy details. (required)
     * @return APIMGovernancePolicyDTO
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Governance policy updated successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public APIMGovernancePolicyDTO updateGovernancePolicyById(String policyId, APIMGovernancePolicyDTO apIMGovernancePolicyDTO) throws ApiException {
        ApiResponse<APIMGovernancePolicyDTO> localVarResp = updateGovernancePolicyByIdWithHttpInfo(policyId, apIMGovernancePolicyDTO);
        return localVarResp.getData();
    }

    /**
     * Update a specific governance policy
     * Updates the details of an existing governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (required)
     * @param apIMGovernancePolicyDTO JSON object containing the updated governance policy details. (required)
     * @return ApiResponse&lt;APIMGovernancePolicyDTO&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Governance policy updated successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<APIMGovernancePolicyDTO> updateGovernancePolicyByIdWithHttpInfo(String policyId, APIMGovernancePolicyDTO apIMGovernancePolicyDTO) throws ApiException {
        okhttp3.Call localVarCall = updateGovernancePolicyByIdValidateBeforeCall(policyId, apIMGovernancePolicyDTO, null);
        Type localVarReturnType = new TypeToken<APIMGovernancePolicyDTO>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Update a specific governance policy (asynchronously)
     * Updates the details of an existing governance policy identified by the policyId.
     * @param policyId **UUID** of the Policy.  (required)
     * @param apIMGovernancePolicyDTO JSON object containing the updated governance policy details. (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
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> OK. Governance policy updated successfully. </td><td>  -  </td></tr>
        <tr><td> 400 </td><td> Bad Request </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized </td><td>  -  </td></tr>
        <tr><td> 403 </td><td> Forbidden </td><td>  -  </td></tr>
        <tr><td> 500 </td><td> Internal Server Error </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call updateGovernancePolicyByIdAsync(String policyId, APIMGovernancePolicyDTO apIMGovernancePolicyDTO, final ApiCallback<APIMGovernancePolicyDTO> _callback) throws ApiException {

        okhttp3.Call localVarCall = updateGovernancePolicyByIdValidateBeforeCall(policyId, apIMGovernancePolicyDTO, _callback);
        Type localVarReturnType = new TypeToken<APIMGovernancePolicyDTO>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
}
