Configuring rules define conditions based on which it is possible to determine whether a policy has to be executed or not at runtime.
For example, an XML to JSON policy can be applied only if the Accept Header is set as application/json.
The Add/Edit Rule button at the lower-right part of each Policy Configuration page allows the API author to add additional rules to a policy before a message is passed to a policy.
A sample snapshot of the Monetization Limit Check Policy Configuration page is provided below.
Figure 1: A sample Policy Configuration page with the Add/Edit Rule button
Adding Rule
Click the Add/Edit Rule button to start configuring a rule.
Figure 2: Add/Edit Rule dialog box to configure rules
Adding a statement
To add a statement, perform the following actions in the Update Rule dialog box
- Click the Down arrow
- Click the New statement option.
Figure 3: Navigating to add new statement Click the Edit Statement button. Edit the rule by changing the properties present in the dialog box.
Figure 3: "Add new statement" option to add more rulesClick OK and then click the Save button on top of the screen to apply the changes.
Rule parameters
Property | Description |
Identifier Type | Specify the Message Part Identifier type. Specify the part of the message from where the policy needs to check and validate the condition or criteria specified. Options available are:
|
Variable Name | Select the flow variable from the list of options available in the drop-down list. |
Operator | Choose the operator from the options below to form a condition:
|
Value | Provide the value that is expected from the condition specified. |
Operator options
Choose the operator from the options below to form a condition.
Equals
Compares two strings and returns true if the strings are the same and false if not.
Not Equals
Compares two strings and returns true if the strings are not the same and else false.
Like
Matches whole string or substring in a string. Use wildcard characters to match the substring.
Not Like
The whole string or substring should not be present in a string. Use wildcard characters to match the substring.
One of
Matches any one string added using commma-seperated values and returns true, otherwise false.
Not one of
Not matching any string added using comma-separated values return true, otherwise false.
Adding more statements
For using conditional statements using conjunctions in the rule, add the conjunction (OR/AND) that needs to be used between the statements and then add those statements.
- Click the Down arrow in the Update Rule section
- Click any one of the following:
- add conjunction
- or conjunction
Follow the steps in the Adding a statement section.