Retrieves all Custom Rules. **NOTE:** * Only super tenant users are allowed for this operation.
apim:tier_view
i
GET https://localhost:9443/api/am/admin/v0.11/throttling/policies/custom
Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122
HTTP/1.1 200 OK
Content-Type: application/json
{
"count": 1,
"list": [
{
"policyId": "33662a62-8db1-4d75-af08-afd63c6bd0b4",
"policyName": "custom1",
"displayName": null,
"description": "Allow 10 requests per minute for admin user",
"isDeployed": true,
"siddhiQuery": "FROM RequestStream\nSELECT userId, ( userId == 'admin@carbon.super' ) AS isEligible , str:concat('admin@carbon.super','') as throttleKey\nINSERT INTO EligibilityStream; \n\nFROM EligibilityStream[isEligible==true]#throttler:timeBatch(1 min) \nSELECT throttleKey, (count(userId) >= 10) as isThrottled, expiryTimeStamp group by throttleKey \nINSERT ALL EVENTS into ResultStream;",
"keyTemplate": "$userId"
}
]
}
curl -k -H "Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122" https://localhost:9443/api/am/admin/v0.11/throttling/policies/custom
Type | Name | Description | Schema | Default |
---|---|---|---|---|
Header |
Accept optional |
Media types acceptable for the response. Default is application/json. |
String |
application/json |
Header |
If-None-Match optional |
Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource (Will be supported in future). |
String | |
Header |
If-Modified-Since optional |
Validator for conditional requests; based on Last Modified header of the formerly retrieved variant of the resource (Will be supported in future). |
String |
HTTP Code | Description | Schema |
---|---|---|
200 |
OK. Policies returned |
CustomRuleList |
304 |
Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future). |
|
406 |
Not Acceptable. The requested media type is not supported. |
Error |
Adds a new Custom Rule. **NOTE:** * Only super tenant users are allowed for this operation.
apim:tier_manage
i
POST https://localhost:9443/api/am/admin/v0.11/throttling/policies/custom
Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122
Content-Type: application/json
{
"policyName": "custom1",
"description": "Allow 10 requests per minute for admin user",
"siddhiQuery": "FROM RequestStream\nSELECT userId, ( userId == 'admin@carbon.super' ) AS isEligible , str:concat('admin@carbon.super','') as throttleKey\nINSERT INTO EligibilityStream; \n\nFROM EligibilityStream[isEligible==true]#throttler:timeBatch(1 min) \nSELECT throttleKey, (count(userId) >= 10) as isThrottled, expiryTimeStamp group by throttleKey \nINSERT ALL EVENTS into ResultStream;",
"keyTemplate": "$userId"
}
HTTP/1.1 201 Created
Location: https://localhost:9443/api/am/admin/v0.11/throttling/policies/custom/22c71b7d-7013-4b80-bf7a-e86b471fb575
Content-Type: application/json
{
"policyId": "22c71b7d-7013-4b80-bf7a-e86b471fb575",
"policyName": "custom1",
"displayName": null,
"description": "Allow 10 requests per minute for admin user",
"isDeployed": true,
"siddhiQuery": "FROM RequestStream\nSELECT userId, ( userId == 'admin@carbon.super' ) AS isEligible , str:concat('admin@carbon.super','') as throttleKey\nINSERT INTO EligibilityStream; \n\nFROM EligibilityStream[isEligible==true]#throttler:timeBatch(1 min) \nSELECT throttleKey, (count(userId) >= 10) as isThrottled, expiryTimeStamp group by throttleKey \nINSERT ALL EVENTS into ResultStream;",
"keyTemplate": "$userId"
}
curl -k -X POST -H "Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122" -H "Content-Type: application/json" https://localhost:9443/api/am/admin/v0.11/throttling/policies/custom -d @data.json
Type | Name | Description | Schema | Default |
---|---|---|---|---|
Body |
body required |
Custom Rule object that should to be added |
CustomRule (CustomRule) | |
Header |
Content-Type required |
Media type of the entity in the body. Default is application/json. |
String |
application/json |
HTTP Code | Description | Schema |
---|---|---|
201 |
Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity. |
CustomRule |
400 |
Bad Request. Invalid request or validation error |
Error |
415 |
Unsupported media type. The entity of the request was in a not supported format. |