Skip to content

Commit

Permalink
Add minor changes
Browse files Browse the repository at this point in the history
Remove extra spaces
Fix publisher REST APIs for fetching subscription policies
  • Loading branch information
SavinduDimal committed Sep 2, 2024
1 parent 318e504 commit 7ef4d05
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* under the License.
*/


package org.wso2.carbon.apimgt.api.model.policy;

public class AIQuotaLimit extends Limit {
Expand Down Expand Up @@ -63,5 +62,4 @@ public String toString() {
+ ", requestTokenCount=" + requestTokenCount + ", responseTokenCount=" + responseTokenCount
+ ", toString()=" + super.toString() + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Map;

public class SubscriptionPolicy extends Policy {

private int rateLimitCount;
private String rateLimitTimeUnit;
private int subscriberCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ public class ThrottlePolicyConstants {

public static final String COLUMN_RESPONSE_TOKEN_COUNT = "RESPONSE_TOKEN_COUNT";

public static final String COLUMN_TOKEN_UNIT_TIME = "TOKEN_UNIT_TIME";

public static final String COLUMN_TOKEN_TIME_UNIT = "TOKEN_TIME_UNIT";

public static final String COLUMN_APPLICABLE_LEVEL = "APPLICABLE_LEVEL";

public static final String COLUMN_DEFAULT_QUOTA_POLICY_TYPE = "DEFAULT_QUOTA_TYPE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2350,20 +2350,20 @@ public class SQLConstants {
"VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

public static final String INSERT_SUBSCRIPTION_POLICY_SQL =
"INSERT INTO AM_POLICY_SUBSCRIPTION (NAME, DISPLAY_NAME, TENANT_ID, DESCRIPTION, QUOTA_TYPE, QUOTA, \n"
+ " QUOTA_UNIT, UNIT_TIME, TIME_UNIT, IS_DEPLOYED, UUID, RATE_LIMIT_COUNT, \n"
+ " RATE_LIMIT_TIME_UNIT,STOP_ON_QUOTA_REACH, MAX_DEPTH, MAX_COMPLEXITY, \n"
+ " BILLING_PLAN, TOTAL_TOKEN_COUNT, REQUEST_TOKEN_COUNT, RESPONSE_TOKEN_COUNT, \n"
+ " MONETIZATION_PLAN,FIXED_RATE,BILLING_CYCLE,PRICE_PER_REQUEST,CURRENCY, \n"
+ " CONNECTIONS_COUNT) \n" + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
"INSERT INTO AM_POLICY_SUBSCRIPTION (NAME, DISPLAY_NAME, TENANT_ID, DESCRIPTION, QUOTA_TYPE, QUOTA, \n" +
" QUOTA_UNIT, UNIT_TIME, TIME_UNIT, IS_DEPLOYED, UUID, RATE_LIMIT_COUNT, \n" +
" RATE_LIMIT_TIME_UNIT,STOP_ON_QUOTA_REACH, MAX_DEPTH, MAX_COMPLEXITY, \n" +
" BILLING_PLAN, TOTAL_TOKEN_COUNT, REQUEST_TOKEN_COUNT, RESPONSE_TOKEN_COUNT, \n" +
" MONETIZATION_PLAN,FIXED_RATE,BILLING_CYCLE,PRICE_PER_REQUEST,CURRENCY, \n" +
" CONNECTIONS_COUNT) \n" + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

public static final String INSERT_SUBSCRIPTION_POLICY_WITH_CUSTOM_ATTRIB_SQL =
"INSERT INTO AM_POLICY_SUBSCRIPTION (NAME, DISPLAY_NAME, TENANT_ID, DESCRIPTION, QUOTA_TYPE, QUOTA, \n"
+ " QUOTA_UNIT, UNIT_TIME, TIME_UNIT, IS_DEPLOYED, UUID, RATE_LIMIT_COUNT, \n"
+ " RATE_LIMIT_TIME_UNIT, STOP_ON_QUOTA_REACH, MAX_DEPTH, MAX_COMPLEXITY, \n"
+ " BILLING_PLAN, TOTAL_TOKEN_COUNT, REQUEST_TOKEN_COUNT, RESPONSE_TOKEN_COUNT, CUSTOM_ATTRIBUTES, MONETIZATION_PLAN, \n"
+ " FIXED_RATE, BILLING_CYCLE, PRICE_PER_REQUEST, CURRENCY, CONNECTIONS_COUNT) \n"
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
"INSERT INTO AM_POLICY_SUBSCRIPTION (NAME, DISPLAY_NAME, TENANT_ID, DESCRIPTION, QUOTA_TYPE, QUOTA, \n" +
" QUOTA_UNIT, UNIT_TIME, TIME_UNIT, IS_DEPLOYED, UUID, RATE_LIMIT_COUNT, \n" +
" RATE_LIMIT_TIME_UNIT, STOP_ON_QUOTA_REACH, MAX_DEPTH, MAX_COMPLEXITY, \n" +
" BILLING_PLAN, TOTAL_TOKEN_COUNT, REQUEST_TOKEN_COUNT, RESPONSE_TOKEN_COUNT, CUSTOM_ATTRIBUTES, MONETIZATION_PLAN, \n" +
" FIXED_RATE, BILLING_CYCLE, PRICE_PER_REQUEST, CURRENCY, CONNECTIONS_COUNT) \n" +
" VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";


public static final String INSERT_GLOBAL_POLICY_SQL =
Expand Down Expand Up @@ -2609,7 +2609,7 @@ public class SQLConstants {
"MAX_DEPTH = ?, " +
"MAX_COMPLEXITY = ?, " +
"BILLING_PLAN = ?, " +
"CUSTOM_ATTRIBUTES = ?, "+
"CUSTOM_ATTRIBUTES = ?, " +
"MONETIZATION_PLAN = ?," +
"FIXED_RATE = ?," +
"BILLING_CYCLE = ?," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
import org.wso2.carbon.apimgt.api.model.VHost;
import org.wso2.carbon.apimgt.api.model.WebsubSubscriptionConfiguration;
import org.wso2.carbon.apimgt.api.model.graphql.queryanalysis.GraphqlComplexityInfo;
import org.wso2.carbon.apimgt.api.model.policy.AIQuotaLimit;
import org.wso2.carbon.apimgt.api.model.policy.APIPolicy;
import org.wso2.carbon.apimgt.api.model.policy.ApplicationPolicy;
import org.wso2.carbon.apimgt.api.model.policy.BandwidthLimit;
Expand Down Expand Up @@ -6481,6 +6482,11 @@ public static Map<String, Tier> getTiersFromPolicies(String policyLevel, int ten
tier.setRequestsPerMin(bandwidthLimit.getDataAmount());
tier.setRequestCount(bandwidthLimit.getDataAmount());
tier.setBandwidthDataUnit(bandwidthLimit.getDataUnit());
} else if (limit instanceof AIQuotaLimit){
// Todo: Need to implement this according to publisher and developer portals' requirements
AIQuotaLimit aiQuotaLimit = (AIQuotaLimit) limit;
tier.setRequestsPerMin(aiQuotaLimit.getRequestCount());
tier.setRequestCount(aiQuotaLimit.getRequestCount());
} else {
EventCountLimit eventCountLimit = (EventCountLimit) limit;
tier.setRequestCount(eventCountLimit.getEventCount());
Expand Down Expand Up @@ -6559,6 +6565,11 @@ public static Tier getPolicyByName(String policyLevel, String policyName, String
tier.setRequestsPerMin(bandwidthLimit.getDataAmount());
tier.setRequestCount(bandwidthLimit.getDataAmount());
tier.setBandwidthDataUnit(bandwidthLimit.getDataUnit());
} else if (limit instanceof AIQuotaLimit) {
// Todo: Need to implement this according to publisher and developer portals' requirements
AIQuotaLimit aiQuotaLimit = (AIQuotaLimit) limit;
tier.setRequestsPerMin(aiQuotaLimit.getRequestCount());
tier.setRequestCount(aiQuotaLimit.getRequestCount());
} else {
EventCountLimit eventCountLimit = (EventCountLimit) limit;
tier.setRequestCount(eventCountLimit.getEventCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.apimgt.throttle.policy.deployer.dto;

/**
* Entity for keeping details of a Request Count Limit
* Entity for keeping details of a AI Quota Limit
*/
public class AIQuotaLimit extends Limit {

Expand Down

0 comments on commit 7ef4d05

Please sign in to comment.