Implementing your policy
Create an implementation for your user-defined policy by using DataPower® processing rules and actions.
Before you begin
You must create a policy YAML file before you create an implementation. For more information, see Describing your policy.
You can create an implementation for your policy by using the usual tools available to IBM®
DataPower Gateway developers.
However, the DataPower user
interface is typically the tool that is used to create processing rules and actions.
Note: You must
be skilled in DataPower tooling
and concepts, before you can create a policy implementation.
In order for your processing actions to work well under the API Gateway configuration,
and also to enable the use of contextual information that is relevant to the processing actions, a
library of functions and templates is available that you can use to assist you in writing the XSLT
or GatewayScript transformations. This library provides the following mechanisms:
- Access to input property values (input from the assembly editor).
- Access to context values (the API Gateway runtime context).
- Access to the runtime payload message and media-type.
- Ability to modify the payload message.
- Ability to end the policy execution with an error.
About this task
You create an implementation for your user-defined
policy in the IBM
DataPower Gateway. The
implementation must adhere to the following conventions:
- You must create a main processing rule, and this rule will be the starting point for the policy.
The rule name must start with the name of the policy (the value of the
name
property in the "info" section of the policy YAML file), followed by -main; for example checkmembership-main. - There are no restrictions on what actions the processing rule can execute, on condition that the rule adheres to the naming convention in point 1. and the instructions that are detailed in this topic.
- The names of the processing actions and all other objects also must start with the name of the
user-defined
policy (the value of
the
name
property in the "info" section of the policy YAML file). - If your processing rule runs transformation actions that use XSLT or GatewayScript files, these files must be stored in the following location: local://policy/<policy-name>.
- If you have certificate and key files that must be stored in the cert: folder, the names of these files also must start with the name of the user-defined policy (as defined in the policy YAML file).
- If your policy is using GatewayScript transformations, your policy code must require
apim.custom.js
, for example:var apic = require('local://isp/policy/apim.custom.js');