Search in sources :

Example 1 with ThrottleConditionDTO

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

the class CommonThrottleMappingUtil method fromDTOToIPCondition.

/**
 * Converts a IP Condition DTO object into a model object
 *
 * @param dto IP Condition DTO object
 * @return IP Condition model object derived from DTO
 */
public static IPCondition fromDTOToIPCondition(ThrottleConditionDTO dto) throws UnsupportedThrottleConditionTypeException {
    String ipConditionType = mapIPConditionTypeFromDTOToModel(dto.getIpCondition().getIpConditionType());
    IPCondition ipCondition = new IPCondition(ipConditionType);
    ipCondition = updateFieldsFromDTOToCondition(dto, ipCondition);
    ipCondition.setSpecificIP(dto.getIpCondition().getSpecificIP());
    ipCondition.setStartingIP(dto.getIpCondition().getStartingIP());
    ipCondition.setEndingIP(dto.getIpCondition().getEndingIP());
    return ipCondition;
}
Also used : IPCondition(org.wso2.carbon.apimgt.core.models.policy.IPCondition)

Example 2 with ThrottleConditionDTO

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

the class CommonThrottleMappingUtil method fromQueryParameterConditionToDTO.

/**
 * Converts a Query Parameter Condition model object into a DTO
 *
 * @param condition Query Parameter Condition model object
 * @return DTO object that was derived from Query Parameter Condition model object
 */
public static ThrottleConditionDTO fromQueryParameterConditionToDTO(QueryParameterCondition condition) {
    ThrottleConditionDTO throttleConditionDTO = new ThrottleConditionDTO();
    throttleConditionDTO.setType(PolicyConstants.QUERY_PARAMS_CONDITION_TYPE);
    throttleConditionDTO.setQueryParameterCondition(new QueryParameterConditionDTO());
    throttleConditionDTO = updateFieldsFromConditionToDTO(condition, throttleConditionDTO);
    throttleConditionDTO.getQueryParameterCondition().setParameterName(condition.getParameter());
    throttleConditionDTO.getQueryParameterCondition().setParameterValue(condition.getValue());
    return throttleConditionDTO;
}
Also used : QueryParameterConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.QueryParameterConditionDTO) ThrottleConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)

Example 3 with ThrottleConditionDTO

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

the class CommonThrottleMappingUtil method fromDTOToQueryParameterCondition.

/**
 * Converts a Query Parameter Condition DTO object into a model object
 *
 * @param dto Query Parameter Condition DTO object
 * @return Query Parameter Condition model object derived from Query Parameter Condition DTO
 */
public static QueryParameterCondition fromDTOToQueryParameterCondition(ThrottleConditionDTO dto) {
    QueryParameterCondition queryParameterCondition = new QueryParameterCondition();
    queryParameterCondition = updateFieldsFromDTOToCondition(dto, queryParameterCondition);
    queryParameterCondition.setParameter(dto.getQueryParameterCondition().getParameterName());
    queryParameterCondition.setValue(dto.getQueryParameterCondition().getParameterValue());
    return queryParameterCondition;
}
Also used : QueryParameterCondition(org.wso2.carbon.apimgt.core.models.policy.QueryParameterCondition)

Example 4 with ThrottleConditionDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ThrottleConditionDTO 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 - If error occurs
 * @throws UnsupportedThrottleConditionTypeException - If error occurs
 */
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.dto.ConditionalGroupDTO) ThrottleConditionDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)

Example 5 with ThrottleConditionDTO

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

the class CommonThrottleMappingUtil method fromDTOToHeaderCondition.

/**
 * Converts a Header Condition DTO object into a model object
 *
 * @param dto Header Condition DTO object
 * @return Header Condition model object derived from Header Condition DTO
 */
public static HeaderCondition fromDTOToHeaderCondition(ThrottleConditionDTO dto) {
    HeaderCondition headerCondition = new HeaderCondition();
    headerCondition = updateFieldsFromDTOToCondition(dto, headerCondition);
    headerCondition.setHeader(dto.getHeaderCondition().getHeaderName());
    headerCondition.setValue(dto.getHeaderCondition().getHeaderValue());
    return headerCondition;
}
Also used : HeaderCondition(org.wso2.carbon.apimgt.core.models.policy.HeaderCondition)

Aggregations

Test (org.testng.annotations.Test)5 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleConditionDTO)5 IPCondition (org.wso2.carbon.apimgt.core.models.policy.IPCondition)3 ThrottleConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ThrottleConditionDTO)3 UnsupportedThrottleConditionTypeException (org.wso2.carbon.apimgt.api.UnsupportedThrottleConditionTypeException)2 HeaderCondition (org.wso2.carbon.apimgt.api.model.policy.HeaderCondition)2 IPCondition (org.wso2.carbon.apimgt.api.model.policy.IPCondition)2 JWTClaimsCondition (org.wso2.carbon.apimgt.api.model.policy.JWTClaimsCondition)2 QueryParameterCondition (org.wso2.carbon.apimgt.api.model.policy.QueryParameterCondition)2 HeaderCondition (org.wso2.carbon.apimgt.core.models.policy.HeaderCondition)2 JWTClaimsCondition (org.wso2.carbon.apimgt.core.models.policy.JWTClaimsCondition)2 QueryParameterCondition (org.wso2.carbon.apimgt.core.models.policy.QueryParameterCondition)2 ArrayList (java.util.ArrayList)1 Condition (org.wso2.carbon.apimgt.api.model.policy.Condition)1 ConditionalGroupDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.ConditionalGroupDTO)1 HeaderConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.HeaderConditionDTO)1 IPConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.IPConditionDTO)1 JWTClaimsConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.JWTClaimsConditionDTO)1 QueryParameterConditionDTO (org.wso2.carbon.apimgt.rest.api.admin.dto.QueryParameterConditionDTO)1 ConditionalGroupDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.ConditionalGroupDTO)1