Search in sources :

Example 16 with AdvancedThrottlePolicyDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AdvancedThrottlePolicyDTO in project carbon-apimgt by wso2.

the class AdvancedThrottlePolicyMappingUtil method fromAdvancedPolicyToDTO.

/**
 * Converts a single Advanced Policy model into REST API DTO
 *
 * @param apiPolicy Advanced Policy model object
 * @return Converted Advanced policy REST API DTO object
 * @throws UnsupportedThrottleLimitTypeException
 * @throws UnsupportedThrottleConditionTypeException
 */
public static AdvancedThrottlePolicyDTO fromAdvancedPolicyToDTO(APIPolicy apiPolicy) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
    AdvancedThrottlePolicyDTO policyDTO = new AdvancedThrottlePolicyDTO();
    policyDTO = CommonThrottleMappingUtil.updateFieldsFromToPolicyToDTO(apiPolicy, policyDTO);
    List<ConditionalGroupDTO> groupDTOs = CommonThrottleMappingUtil.fromPipelineListToConditionalGroupDTOList(apiPolicy.getPipelines());
    policyDTO.setConditionalGroups(groupDTOs);
    policyDTO.setType(ADVANCED_THROTTLING_POLICY_TYPE);
    if (apiPolicy.getDefaultQuotaPolicy() != null) {
        policyDTO.setDefaultLimit(CommonThrottleMappingUtil.fromQuotaPolicyToDTO(apiPolicy.getDefaultQuotaPolicy()));
    }
    return policyDTO;
}
Also used : ConditionalGroupDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ConditionalGroupDTO) AdvancedThrottlePolicyDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AdvancedThrottlePolicyDTO)

Aggregations

APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)9 AdvancedThrottlePolicyDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.AdvancedThrottlePolicyDTO)8 APIPolicy (org.wso2.carbon.apimgt.api.model.policy.APIPolicy)4 Test (org.testng.annotations.Test)3 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)3 RequestCountLimit (org.wso2.carbon.apimgt.core.models.policy.RequestCountLimit)3 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 APIMgtAdminService (org.wso2.carbon.apimgt.core.api.APIMgtAdminService)2 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)2 APIMgtAdminServiceImpl (org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl)2 QuotaPolicy (org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy)2 PoliciesApiServiceImpl (org.wso2.carbon.apimgt.rest.api.admin.impl.PoliciesApiServiceImpl)2 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 PolicyNotFoundException (org.wso2.carbon.apimgt.api.PolicyNotFoundException)1