Packaging and importing your policies into IBM API Connect
Make your user-defined policy available to API developers by packaging it and importing it into an IBM® API Connect Catalog.
Before you begin
Before you can package a user-defined
policy and import it into
IBM
API Connect, you must complete
the following tasks:
Procedure
To package and import your user-defined policy, complete the following steps:
What to do next
Make your user-defined
policy
package accessible to the API Designer UI. To display
user-defined policies in the API Designer UI, edit the
.apiconnect/config file to point to the directory containing the
policy.yaml file. You can edit the global config file
(~/.apiconnect/config) or a project-specific config file
(~/ProjectA/.apiconnect/config). Follow these steps:
- Create one or more directories to hold your policy.yaml files that are accessible to Node.js, and copy the user-defined policy package into this directory. For example, create directories named /ProjectA/Policies and /ProjectB/Policies.
- Extract the policy package so that the folder structure is visible, for example policy.yaml and implementation/policy-name.zip. The file containing the custom policies must be named policy.yaml.
- Add the
userPolicies: [ ]
array object to the config file in ~/ProjectA/.apiconnect/ or ~/.apiconnect/, and edit the array object so it contains the absolute path to the director(ies) containing the policy.yaml file.Following is an example of an ~/.apiconnect/config file showing the userPolicies entry pointing to the directory containing the policy.yaml file:
apim_server: us.apiconnect.ibmcloud.com us.apiconnect.ibmcloud.com.meta: formFactor: BLUEMIX_PUBLIC serverCapabilities: authTypes: - basic - token toolkit: version_recommended: 2.1.30 version_minimum: 2.1.30 catalog: >- apic-catalog://us.apiconnect.ibmcloud.com/orgs/sampleorg-myspace2/catalogs/sb app: >- apic-app://us.apiconnect.ibmcloud.com/orgs/sampleorg-myspace2/apps/acme-bank userPolicies: - /ProjectA/Policies
Note:- The
userPolicies: []
array object contains a list of absolute paths to the policy director(ies). The values can point to a parent location, for exampleuserPolicies: ["~/mypolicies"]
. Alternatively, each policy location can be specified in the array, for exampleuserPolicies: ["~/mypolicies/policya", ~/mypolicies/policyb"]
. However, do not use both of these approaches in the same directory. For example, do not create policies in a directory structure like this ~/mypolicies, ~/mypolicies/policya, and ~/mypolicies/policyb.
- The
- Open the API Designer UI. The user-defined policy is available on the policy assembly palette, and you can add the policy to your API definition.