use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.QuotaPolicy in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method updateAPIPolicy.
/**
* Updated the given API policy
*
* @param apiPolicy {@link APIPolicy} instance to be updated
* @return updated {@link APIPolicy} instance
*/
public static APIPolicy updateAPIPolicy(APIPolicy apiPolicy) {
apiPolicy.setDisplayName(UPDATED_SAMPLE_API_POLICY);
apiPolicy.setDescription(UPDATED_SAMPLE_API_POLICY_DESCRIPTION);
QuotaPolicy defaultQuotaPolicy = new QuotaPolicy();
defaultQuotaPolicy.setType(PolicyConstants.BANDWIDTH_TYPE);
BandwidthLimit bandwidthLimit = new BandwidthLimit(TIME_UNIT_SECONDS, 1, 1000, "KB");
defaultQuotaPolicy.setLimit(bandwidthLimit);
apiPolicy.setDefaultQuotaPolicy(defaultQuotaPolicy);
apiPolicy.setPipelines(createDefaultPipelines());
apiPolicy.getPipelines().add(createNewIPRangePipeline());
return apiPolicy;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.QuotaPolicy in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createDefaultPolicy.
public static void createDefaultPolicy(PolicyDAO policyDAO) throws APIMgtDAOException {
QuotaPolicy quotaPolicy = new QuotaPolicy();
quotaPolicy.setType(REQUEST_COUNT_TYPE);
quotaPolicy.setLimit(new RequestCountLimit(SECONDS_TIMUNIT, 60, 1));
unlimitedApiPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addApiPolicy(unlimitedApiPolicy);
goldApiPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addApiPolicy(goldApiPolicy);
silverApiPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addApiPolicy(silverApiPolicy);
bronzeApiPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addApiPolicy(bronzeApiPolicy);
unlimitedSubscriptionPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addSubscriptionPolicy(unlimitedSubscriptionPolicy);
goldSubscriptionPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addSubscriptionPolicy(goldSubscriptionPolicy);
silverSubscriptionPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addSubscriptionPolicy(silverSubscriptionPolicy);
bronzeSubscriptionPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addSubscriptionPolicy(bronzeSubscriptionPolicy);
fiftyPerMinApplicationPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addApplicationPolicy(fiftyPerMinApplicationPolicy);
twentyPerMinApplicationPolicy.setDefaultQuotaPolicy(quotaPolicy);
policyDAO.addApplicationPolicy(twentyPerMinApplicationPolicy);
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.QuotaPolicy in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOToQuotaPolicy.
/**
* Converts a Throttle Limit DTO object into a Quota Policy object
*
* @param dto Throttle limit DTO object
* @return Derived Quota policy object from DTO
* @throws UnsupportedThrottleLimitTypeException - If error occurs
*/
public static QuotaPolicy fromDTOToQuotaPolicy(ThrottleLimitDTO dto) throws UnsupportedThrottleLimitTypeException {
QuotaPolicy quotaPolicy = new QuotaPolicy();
quotaPolicy.setLimit(fromDTOToLimit(dto));
quotaPolicy.setType(mapQuotaPolicyTypeFromDTOToModel(dto.getType()));
return quotaPolicy;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.QuotaPolicy in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createAPIPolicyWithRequestLimit.
public static APIPolicy createAPIPolicyWithRequestLimit(String name) {
APIPolicy apiPolicy = new APIPolicy(name);
apiPolicy.setDescription("testDescription");
QuotaPolicy quotaPolicy = new QuotaPolicy();
quotaPolicy.setType("requestCount");
RequestCountLimit requestCountLimit = new RequestCountLimit("s", 60, 10);
quotaPolicy.setLimit(requestCountLimit);
apiPolicy.setDefaultQuotaPolicy(quotaPolicy);
apiPolicy.setDisplayName("displayName");
return apiPolicy;
}
use of org.wso2.carbon.apimgt.throttle.policy.deployer.dto.QuotaPolicy in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createAPIPolicyWithBndwidthLimit.
public static APIPolicy createAPIPolicyWithBndwidthLimit(String name) {
APIPolicy apiPolicy = new APIPolicy(name);
apiPolicy.setDescription("testDescription");
QuotaPolicy quotaPolicy = new QuotaPolicy();
quotaPolicy.setType("bandwidth");
BandwidthLimit bandwidthLimit = new BandwidthLimit("s", 60, 10, "mb");
quotaPolicy.setLimit(bandwidthLimit);
apiPolicy.setDefaultQuotaPolicy(quotaPolicy);
apiPolicy.setDisplayName("displayName");
return apiPolicy;
}
Aggregations