API Management

Configuring Rule

Contents

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.

AddEditRuleicon.jpg
Figure 1: A sample Policy Configuration page with the Add/Edit Rule button

Adding Rule

Click the Add/Edit Rule  AddEditIcon.png  button to start configuring a rule.

UpdateRuleoption.png
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

  1. Click the Down  Downarrow.png arrow

  2. Click the New statement option.

    UpdateRule1.png
    Figure 3: Navigating to add new statement

  3. Click the Edit Statement  Editbutton.png button. Edit the rule by changing the properties present in the dialog box. 

    Each property in the dialog box is explained in the table after the steps.

    EditStatement.png
    Figure 3: "Add new statement" option to add more rules

  4. Click OK and then click the Save button on top of the screen to apply the changes.

    AddedRule.png

    The Preview option helps in cross-verifying whether or not the rule is defined as intended.

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.

Example

 api.quota.weight, client.ip, proxy.request.method

Operator

Choose the operator from the options below to form a condition:

  • Equals

  • Not Equals

  • Like

  • Not Like

  • One of

  • Not one of

Value

Provide the value that is expected from the condition specified.

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.

  1. Click the Down  Downarrow.png arrow in the Update Rule section

  2. Click any one of the following:

    1. add conjunction

    2. or conjunction

    UpdateRule1.png

  3. Follow the steps in the Configuring Rule | id (12.0)ConfiguringRule Addingastatement section.

    Click the Edit Editbutton.png button to edit the statements added.