Search in sources :

Example 16 with UnsupportedThrottleConditionTypeException

use of org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException in project carbon-apimgt by wso2.

the class AdvancedThrottlePolicyMappingUtil method fromAPIPolicyArrayToListDTO.

/**
 * Converts an array of Advanced Policy objects into a List DTO
 *
 * @param apiPolicies Array of Advanced Policies
 * @return A List DTO of converted Advanced Policies
 * @throws UnsupportedThrottleLimitTypeException
 * @throws UnsupportedThrottleConditionTypeException
 */
public static AdvancedThrottlePolicyListDTO fromAPIPolicyArrayToListDTO(APIPolicy[] apiPolicies) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
    AdvancedThrottlePolicyListDTO listDTO = new AdvancedThrottlePolicyListDTO();
    List<AdvancedThrottlePolicyInfoDTO> advancedPolicyDTOs = new ArrayList<>();
    if (apiPolicies != null) {
        for (APIPolicy apiPolicy : apiPolicies) {
            advancedPolicyDTOs.add(fromAdvancedPolicyToInfoDTO(apiPolicy));
        }
    }
    listDTO.setList(advancedPolicyDTOs);
    listDTO.setCount(advancedPolicyDTOs.size());
    return listDTO;
}
Also used : AdvancedThrottlePolicyListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AdvancedThrottlePolicyListDTO) ArrayList(java.util.ArrayList) AdvancedThrottlePolicyInfoDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AdvancedThrottlePolicyInfoDTO) APIPolicy(org.wso2.carbon.apimgt.api.model.policy.APIPolicy)

Example 17 with UnsupportedThrottleConditionTypeException

use of org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException 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)

Example 18 with UnsupportedThrottleConditionTypeException

use of org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException in project carbon-apimgt by wso2.

the class CommonThrottleMappingUtil method fromPipelineToConditionalGroupDTO.

/**
 * Converts a single Pipeline object into a Conditional Group DTO object
 *
 * @param pipeline Pipeline object
 * @return Derived DTO object from Pipeline object
 * @throws UnsupportedThrottleLimitTypeException
 * @throws UnsupportedThrottleConditionTypeException
 */
public static ConditionalGroupDTO fromPipelineToConditionalGroupDTO(Pipeline pipeline) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
    ConditionalGroupDTO groupDTO = new ConditionalGroupDTO();
    groupDTO.setDescription(pipeline.getDescription());
    groupDTO.setLimit(fromQuotaPolicyToDTO(pipeline.getQuotaPolicy()));
    List<ThrottleConditionDTO> conditionDTOList = fromConditionListToDTOList(pipeline.getConditions());
    groupDTO.setConditions(conditionDTOList);
    return groupDTO;
}
Also used : ConditionalGroupDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ConditionalGroupDTO) ThrottleConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ThrottleConditionDTO)

Aggregations

ArrayList (java.util.ArrayList)4 HeaderCondition (org.wso2.carbon.apimgt.api.model.policy.HeaderCondition)3 IPCondition (org.wso2.carbon.apimgt.api.model.policy.IPCondition)3 JWTClaimsCondition (org.wso2.carbon.apimgt.api.model.policy.JWTClaimsCondition)3 QueryParameterCondition (org.wso2.carbon.apimgt.api.model.policy.QueryParameterCondition)3 AdvancedThrottlePolicyDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.AdvancedThrottlePolicyDTO)3 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ThrottleConditionDTO)3 UnsupportedThrottleConditionTypeException (org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException)2 APIPolicy (org.wso2.carbon.apimgt.api.model.policy.APIPolicy)2 Condition (org.wso2.carbon.apimgt.api.model.policy.Condition)2 Pipeline (org.wso2.carbon.apimgt.api.model.policy.Pipeline)2 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)2 IPCondition (org.wso2.carbon.apimgt.core.models.policy.IPCondition)2 Pipeline (org.wso2.carbon.apimgt.core.models.policy.Pipeline)2 ApplicationThrottlePolicyDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ApplicationThrottlePolicyDTO)2 ConditionalGroupDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ConditionalGroupDTO)2 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)2 AdvancedThrottlePolicyInfoDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AdvancedThrottlePolicyInfoDTO)2 ConditionalGroupDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ConditionalGroupDTO)2 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)1