use of org.wso2.carbon.apimgt.api.model.policy.BandwidthLimit in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createSubscriptionPolicyWithBandwithLimit.
public static SubscriptionPolicy createSubscriptionPolicyWithBandwithLimit() {
SubscriptionPolicy subscriptionPolicy = new SubscriptionPolicy("SubPolicyBandwith");
subscriptionPolicy.setUuid(UUID.randomUUID().toString());
subscriptionPolicy.setDisplayName(SAMPLE_SUBSCRIPTION_POLICY);
subscriptionPolicy.setDescription(SAMPLE_SUBSCRIPTION_POLICY_DESCRIPTION);
subscriptionPolicy.setCustomAttributes(SAMPLE_CUSTOM_ATTRIBUTE.getBytes());
QuotaPolicy defaultQuotaPolicy = new QuotaPolicy();
defaultQuotaPolicy.setType(PolicyConstants.BANDWIDTH_TYPE);
BandwidthLimit bandwidthLimit = new BandwidthLimit(TIME_UNIT_SECONDS, 1, 1000, "KB");
defaultQuotaPolicy.setLimit(bandwidthLimit);
subscriptionPolicy.setDefaultQuotaPolicy(defaultQuotaPolicy);
subscriptionPolicy.setBillingPlan(BUSINESS_PLAN_FREE);
subscriptionPolicy.setRateLimitCount(100);
subscriptionPolicy.setRateLimitTimeUnit("s");
subscriptionPolicy.setStopOnQuotaReach(true);
return subscriptionPolicy;
}
use of org.wso2.carbon.apimgt.api.model.policy.BandwidthLimit in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method updateApplicationPolicy.
public static ApplicationPolicy updateApplicationPolicy(ApplicationPolicy applicationPolicy) {
applicationPolicy.setDisplayName(UPDATED_SAMPLE_APP_POLICY);
applicationPolicy.setDescription(UPDATED_SAMPLE_APP_POLICY_DESCRIPTION);
QuotaPolicy defaultQuotaPolicy = new QuotaPolicy();
defaultQuotaPolicy.setType(PolicyConstants.BANDWIDTH_TYPE);
BandwidthLimit bandwidthLimit = new BandwidthLimit(TIME_UNIT_SECONDS, 10, 1000, "KB");
defaultQuotaPolicy.setLimit(bandwidthLimit);
applicationPolicy.setDefaultQuotaPolicy(defaultQuotaPolicy);
return applicationPolicy;
}
use of org.wso2.carbon.apimgt.api.model.policy.BandwidthLimit in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method updateSubscriptionPolicy.
public static SubscriptionPolicy updateSubscriptionPolicy(SubscriptionPolicy subscriptionPolicy) {
subscriptionPolicy.setDisplayName(UPDATED_SAMPLE_SUBSCRIPTION_POLICY);
subscriptionPolicy.setDescription(UPDATED_SAMPLE_SUBSCRIPTION_POLICY_DESCRIPTION);
QuotaPolicy defaultQuotaPolicy = new QuotaPolicy();
defaultQuotaPolicy.setType(PolicyConstants.BANDWIDTH_TYPE);
BandwidthLimit bandwidthLimit = new BandwidthLimit(TIME_UNIT_SECONDS, 1, 1000, "KB");
defaultQuotaPolicy.setLimit(bandwidthLimit);
subscriptionPolicy.setDefaultQuotaPolicy(defaultQuotaPolicy);
return subscriptionPolicy;
}
use of org.wso2.carbon.apimgt.api.model.policy.BandwidthLimit in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromBandwidthLimitToDTO.
/**
* Converts a Bandwidth Limit model object into a Bandwidth Limit DTO object
*
* @param bandwidthLimit Bandwidth Limit model object
* @return Bandwidth Limit DTO object derived from model
*/
public static ThrottleLimitDTO fromBandwidthLimitToDTO(BandwidthLimit bandwidthLimit) {
// done
ThrottleLimitDTO dto = new ThrottleLimitDTO();
dto = updateFieldsFromLimitToDTO(bandwidthLimit, dto);
dto.setType(PolicyConstants.BANDWIDTH_LIMIT_TYPE);
dto.setBandwidthLimit(new BandwidthLimitDTO());
dto.getBandwidthLimit().setDataAmount(bandwidthLimit.getDataAmount());
dto.getBandwidthLimit().setDataUnit(bandwidthLimit.getDataUnit());
return dto;
}
use of org.wso2.carbon.apimgt.api.model.policy.BandwidthLimit in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createApplicationPolicyWithBndwidthLimit.
public static ApplicationPolicy createApplicationPolicyWithBndwidthLimit(String name) {
ApplicationPolicy applicationPolicy = new ApplicationPolicy(name);
applicationPolicy.setDescription("testDescription");
QuotaPolicy quotaPolicy = new QuotaPolicy();
quotaPolicy.setType("bandwidth");
BandwidthLimit bandwidthLimit = new BandwidthLimit("s", 60, 10, "mb");
quotaPolicy.setLimit(bandwidthLimit);
applicationPolicy.setDefaultQuotaPolicy(quotaPolicy);
applicationPolicy.setDisplayName("displayName");
return applicationPolicy;
}
Aggregations