Search in sources :

Example 1 with BandwidthLimit

use of org.wso2.carbon.apimgt.core.models.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;
}
Also used : SubscriptionPolicy(org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy) QuotaPolicy(org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy) BandwidthLimit(org.wso2.carbon.apimgt.core.models.policy.BandwidthLimit)

Example 2 with BandwidthLimit

use of org.wso2.carbon.apimgt.core.models.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;
}
Also used : QuotaPolicy(org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy) BandwidthLimit(org.wso2.carbon.apimgt.core.models.policy.BandwidthLimit)

Example 3 with BandwidthLimit

use of org.wso2.carbon.apimgt.core.models.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;
}
Also used : QuotaPolicy(org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy) BandwidthLimit(org.wso2.carbon.apimgt.core.models.policy.BandwidthLimit)

Example 4 with BandwidthLimit

use of org.wso2.carbon.apimgt.core.models.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;
}
Also used : ThrottleLimitDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.ThrottleLimitDTO) BandwidthLimitDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.BandwidthLimitDTO)

Example 5 with BandwidthLimit

use of org.wso2.carbon.apimgt.core.models.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;
}
Also used : ApplicationPolicy(org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy) QuotaPolicy(org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy) BandwidthLimit(org.wso2.carbon.apimgt.core.models.policy.BandwidthLimit)

Aggregations

BandwidthLimit (org.wso2.carbon.apimgt.core.models.policy.BandwidthLimit)18 QuotaPolicy (org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy)15 RequestCountLimit (org.wso2.carbon.apimgt.core.models.policy.RequestCountLimit)7 ArrayList (java.util.ArrayList)4 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)4 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)4 Test (org.testng.annotations.Test)3 Condition (org.wso2.carbon.apimgt.core.models.policy.Condition)3 HeaderCondition (org.wso2.carbon.apimgt.core.models.policy.HeaderCondition)3 IPCondition (org.wso2.carbon.apimgt.core.models.policy.IPCondition)3 JWTClaimsCondition (org.wso2.carbon.apimgt.core.models.policy.JWTClaimsCondition)3 Pipeline (org.wso2.carbon.apimgt.core.models.policy.Pipeline)3 QueryParameterCondition (org.wso2.carbon.apimgt.core.models.policy.QueryParameterCondition)3 Limit (org.wso2.carbon.apimgt.core.models.policy.Limit)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Iterator (java.util.Iterator)1 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)1 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)1 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)1