Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add REST API Changes to Support Token Based Subscription Policies #12534

Closed

Conversation

SavinduDimal
Copy link
Contributor

Purpose

Description

  • In order to support token based subscription policies, this PR introduces a new default limit type AIQUOTALIMIT.
  • A sample payload for adding new subscription policy is given below.
{
    "policyName": "sampleAISubscriptionPolicy",
    "description": "Test AI subscription policy",
    "defaultLimit": {
        "type": "AIQUOTALIMIT",
        "aiQuota": {
            "requestCount": "40",
            "totalTokenCount": "1000",
            "requestTokenCount": "300",
            "responseTokenCount": "400",
            "timeUnit": "min",
            "unitTime": "1"
        }
    },
    "subscriberCount": 0,
    "rateLimitCount": "30",
    "rateLimitTimeUnit": "sec",
    "billingPlan": "FREE",
    "stopOnQuotaReach": true,
    "customAttributes": [],
    "graphQLMaxComplexity": 0,
    "graphQLMaxDepth": 0,
    "monetization": {
        "monetizationPlan": "FIXEDRATE",
        "properties": {
            "fixedPrice": "",
            "pricePerRequest": "",
            "currencyType": "",
            "billingCycle": "week"
        }
    },
    "permissions": null
}
  • When adding a new subscription policy with type AIQUOTALIMIT,

    • requestCount is the only quota that is mandatory. The default value for token count quotas are set to 0.
  • When updating an existing subscription policy with type AIQUOTALIMIT,

    • defaultType can not be changed to AIQUOTALIMIT or from AIQUOTALIMIT.
    • if token count quotas are not given in the request the existing values will not be updated.
  • Please note that Siddhi template given in this PR is subject to change.

  • We need to implement org.wso2.carbon.apimgt.impl.utils.APIUtil#getTiersFromPolicies and org.wso2.carbon.apimgt.impl.utils.APIUtil#getPolicyByName according to the requirements in the publisher portal and developer portal.

Update internal APIs to support AI subscription policies
Add sample AI subscription policy template
Add new columns for token counts in AM_POLICY_SUBSCRIPTION table
Remove extra spaces
Fix publisher REST APIs for fetching subscription policies
@SavinduDimal
Copy link
Contributor Author

Following tests failures will be fixed by PR: wso2/product-apim#13526

2024-09-03T10:02:22.7525403Z [ERROR] Failures: 
2024-09-03T10:02:22.7527145Z [ERROR] org.wso2.am.integration.tests.restapi.admin.throttlingpolicy.ThrottlePolicyExportImportTestCase.testAdvancedThrottlePolicyExport
2024-09-03T10:02:22.7529918Z [ERROR]   Run 1: ThrottlePolicyExportImportTestCase.testAdvancedThrottlePolicyExport:361 » IllegalArgument
2024-09-03T10:02:22.7531670Z [ERROR]   Run 2: ThrottlePolicyExportImportTestCase.testAdvancedThrottlePolicyExport:361 » IllegalArgument
2024-09-03T10:02:22.7532628Z [INFO] 
2024-09-03T10:02:22.7534006Z [ERROR] org.wso2.am.integration.tests.restapi.admin.throttlingpolicy.ThrottlePolicyExportImportTestCase.testApplicationThrottlePolicyExport
2024-09-03T10:02:22.7536496Z [ERROR]   Run 1: ThrottlePolicyExportImportTestCase.testApplicationThrottlePolicyExport:333 » IllegalArgument
2024-09-03T10:02:22.7538692Z [ERROR]   Run 2: ThrottlePolicyExportImportTestCase.testApplicationThrottlePolicyExport:333 » IllegalArgument
2024-09-03T10:02:22.7539878Z [INFO] 
2024-09-03T10:02:22.7541634Z [ERROR] org.wso2.am.integration.tests.restapi.admin.throttlingpolicy.ThrottlePolicyExportImportTestCase.testSubscriptionThrottlePolicyExport
2024-09-03T10:02:22.7544747Z [ERROR]   Run 1: ThrottlePolicyExportImportTestCase.testSubscriptionThrottlePolicyExport:305 » IllegalArgument
2024-09-03T10:02:22.7546967Z [ERROR]   Run 2: ThrottlePolicyExportImportTestCase.testSubscriptionThrottlePolicyExport:305 » IllegalArgument

Rename class names and variables to be more meaningful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce AI-specific (Token-based) Policy Creation - Admin API
2 participants