Custom Rules (Individual)


Delete a Custom Rule

DELETE https://apis.wso2.com/api/am/admin/v0.12/throttling/policies/custom/{ruleId}

Delete a Custom Rule. We need to provide the Id of the policy as a path parameter. **NOTE:** * Only super tenant users are allowed for this operation.

OAuth 2.0 Scope

apim:tier_managei

Request

DELETE https://localhost:9443/api/am/admin/v0.12/throttling/policies/custom/33662a62-8db1-4d75-af08-afd63c6bd0b4 Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122

Response

HTTP/1.1 200 OK

Sample CURL

curl -k -X DELETE -H "Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122" https://localhost:9443/api/am/admin/v0.12/throttling/policies/custom/33662a62-8db1-4d75-af08-afd63c6bd0b4

Parameters

Type Name Description Schema Default
Path

ruleId

required

Custom rule UUID

String

Header

If-Match

optional

Validator for conditional requests; based on ETag (Will be supported in future).

String

Header

If-Unmodified-Since

optional

Validator for conditional requests; based on Last Modified header (Will be supported in future).

String

Responses

HTTP Code Description Schema

200

OK. Resource successfully deleted.

404

Not Found. Resource to be deleted does not exist.

Error

412

Precondition Failed. The request has not been performed because one of the preconditions is not met (Will be supported in future).

Error

Get a Custom Rule

GET https://apis.wso2.com/api/am/admin/v0.12/throttling/policies/custom/{ruleId}

Retrieves a Custom Rule. We need to provide the policy Id as a path parameter. **NOTE:** * Only super tenant users are allowed for this operation.

OAuth 2.0 Scope

apim:tier_viewi

Request

GET https://localhost:9443/api/am/admin/v0.12/throttling/policies/custom/33662a62-8db1-4d75-af08-afd63c6bd0b4 Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122

Response

HTTP/1.1 200 OK Content-Type: application/json { "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" }

Sample CURL

curl -k -H "Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122" https://localhost:9443/api/am/admin/v0.12/throttling/policies/custom/33662a62-8db1-4d75-af08-afd63c6bd0b4

Parameters

Type Name Description Schema Default
Path

ruleId

required

Custom rule UUID

String

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

Responses

HTTP Code Description Schema

200

OK. Policy returned

CustomRule

304

Not Modified. Empty body because the client has already the latest version of the requested resource (Will be supported in future).

404

Not Found. Requested Policy does not exist.

Error

406

Not Acceptable. The requested media type is not supported.

Error

Update a Custom Rule

PUT https://apis.wso2.com/api/am/admin/v0.12/throttling/policies/custom/{ruleId}

Updates an existing Custom Rule. **NOTE:** * Only super tenant users are allowed for this operation.

OAuth 2.0 Scope

apim:tier_managei

Request

PUT https://localhost:9443/api/am/admin/v0.12/throttling/policies/custom/33662a62-8db1-4d75-af08-afd63c6bd0b4 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" }

Response

HTTP/1.1 200 OK Content-Type: application/json { "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" }

Sample CURL

curl -k -X PUT -H "Authorization: Bearer 0d63e133-7ad6-3aeb-9ca9-9299e0708122" -H "Content-Type: application/json" https://localhost:9443/api/am/admin/v0.12/throttling/policies/custom/33662a62-8db1-4d75-af08-afd63c6bd0b4 -d @data.json

Parameters

Type Name Description Schema Default
Path

ruleId

required

Custom rule UUID

String

Body

body

required

Policy object that needs to be modified

CustomRule (CustomRule)

Header

Content-Type

required

Media type of the entity in the body. Default is application/json.

String

application/json

Header

If-Match

optional

Validator for conditional requests; based on ETag (Will be supported in future).

String

Header

If-Unmodified-Since

optional

Validator for conditional requests; based on Last Modified header (Will be supported in future).

String

Responses

HTTP Code Description Schema

200

OK. Policy updated.

CustomRule

400

Bad Request. Invalid request or validation error.

Error

404

Not Found. The resource to be updated does not exist.

Error

412

Precondition Failed. The request has not been performed because one of the preconditions is not met (Will be supported in future).

Error