use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.RequestCountLimit in project carbon-apimgt by wso2.
the class APIUtilTierTest method generateAppPolicies.
private ApplicationPolicy[] generateAppPolicies(String[] policyNames) {
List<ApplicationPolicy> policyList = new ArrayList<ApplicationPolicy>();
for (String policyName : policyNames) {
ApplicationPolicy policy = new ApplicationPolicy(policyName);
QuotaPolicy quotaPolicy = new QuotaPolicy();
RequestCountLimit countLimit = new RequestCountLimit();
countLimit.setRequestCount(123);
quotaPolicy.setLimit(countLimit);
policy.setDefaultQuotaPolicy(quotaPolicy);
policy.setDescription(policyName);
policyList.add(policy);
}
ApplicationPolicy[] array = {};
return policyList.toArray(array);
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.RequestCountLimit in project carbon-apimgt by wso2.
the class SubscriptionValidationDataUtil method getThrottleLimitDTO.
/**
* Converts a quota policy object of a policy into a Throttle Limit DTO object.
*
* @param policy policy model object
* @return Throttle Limit DTO
*/
private static ThrottleLimitDTO getThrottleLimitDTO(Policy policy) {
QuotaPolicy quotaPolicy = policy.getQuotaPolicy();
ThrottleLimitDTO defaultLimit = new ThrottleLimitDTO();
defaultLimit.setQuotaType(quotaPolicy.getType());
if (PolicyConstants.REQUEST_COUNT_TYPE.equals(quotaPolicy.getType())) {
RequestCountLimit requestCountLimit = (RequestCountLimit) quotaPolicy.getLimit();
defaultLimit.setRequestCount(fromRequestCountLimitToDTO(requestCountLimit));
} else if (PolicyConstants.BANDWIDTH_TYPE.equals(quotaPolicy.getType())) {
BandwidthLimit bandwidthLimit = (BandwidthLimit) quotaPolicy.getLimit();
defaultLimit.setBandwidth(fromBandwidthLimitToDTO(bandwidthLimit));
} else if (PolicyConstants.EVENT_COUNT_TYPE.equals(quotaPolicy.getType())) {
EventCountLimit eventCountLimit = (EventCountLimit) quotaPolicy.getLimit();
defaultLimit.setEventCount(fromEventCountLimitToDTO(eventCountLimit));
}
return defaultLimit;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.RequestCountLimit in project carbon-apimgt by wso2.
the class SubscriptionValidationDataUtil method fromRequestCountLimitToDTO.
/**
* Converts a Request Count Limit model object into a Request Count Limit DTO object.
*
* @param requestCountLimit Request Count Limit model object
* @return Request Count DTO object derived from model
*/
private static RequestCountLimitDTO fromRequestCountLimitToDTO(RequestCountLimit requestCountLimit) {
RequestCountLimitDTO dto = new RequestCountLimitDTO();
dto.setTimeUnit(requestCountLimit.getTimeUnit());
dto.setUnitTime(requestCountLimit.getUnitTime());
dto.setRequestCount(requestCountLimit.getRequestCount());
return dto;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.RequestCountLimit in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromRequestCountLimitToDTO.
/**
* Converts a Request Count Limit model object into a Request Count Limit DTO object
*
* @param requestCountLimit Request Count Limit model object
* @return Request Count DTO object derived from model
*/
public static RequestCountLimitDTO fromRequestCountLimitToDTO(RequestCountLimit requestCountLimit) {
// done
RequestCountLimitDTO dto = new RequestCountLimitDTO();
dto.setTimeUnit(requestCountLimit.getTimeUnit());
dto.setUnitTime(requestCountLimit.getUnitTime());
dto.setRequestCount(requestCountLimit.getRequestCount());
return dto;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.RequestCountLimit in project carbon-apimgt by wso2.
the class TestUtil method getPolicySubLevel.
/**
* Generate a dummy Subscription Policy object
*
* @return an Subscription Policy
*/
public static SubscriptionPolicy getPolicySubLevel() {
SubscriptionPolicy subscriptionPolicy = new SubscriptionPolicy();
subscriptionPolicy.setId(1);
subscriptionPolicy.setTenantId(-1234);
subscriptionPolicy.setTenantDomain("carbon.super");
subscriptionPolicy.setName("policy1");
subscriptionPolicy.setQuotaType("requestCount");
QuotaPolicy defaultLimit = new QuotaPolicy();
defaultLimit.setQuotaType("requestCount");
RequestCountLimit requestCountLimit = new RequestCountLimit();
requestCountLimit.setRequestCount(1);
requestCountLimit.setTimeUnit("min");
requestCountLimit.setUnitTime(1);
defaultLimit.setRequestCount(requestCountLimit);
subscriptionPolicy.setDefaultLimit(defaultLimit);
subscriptionPolicy.setGraphQLMaxComplexity(0);
subscriptionPolicy.setGraphQLMaxDepth(0);
subscriptionPolicy.setRateLimitCount(0);
subscriptionPolicy.setRateLimitTimeUnit(null);
subscriptionPolicy.setStopOnQuotaReach(true);
subscriptionPolicy.setSubscriberCount(0);
return subscriptionPolicy;
}
Aggregations