IBM APIc ships a set of policy. However you can extend those capabilities by creating your own policy. This gives step by step on how that can be done, it also provides a template to help you jump start the process.
2. Pre-requsite (download toolkit)
• Download the toolkit, and set the MODE=apim
• How to use toolkit https://www.slideshare.net/ShiuFunPoon/ibm-apic-toolkit-cheatsheet
• Using provider
• To get the realm, use the command identity-providers:list
• Result : realm === provider/default-idp-2
• Set up the toolkit credentials (after downloading)
3. Create the policy
• Create a yaml file, contains [policy, info, attach, gateways, properties, and assembly]
• An example to get started https://github.com/shiup/apic-code-example/blob/master/apigw/policy-template
• Link on what you can do with the assembly section (https://www.ibm.com/docs/en/api-connect/10.0.x?topic=policies-
authoring-datapower-api-gateway)
• Suggestion:
• use the api development ->
• source tab, c&p the section that is interested
• In this case, assembly
4. On your machine, prepare the directory
• I created a directory policy, create a policy as follow
• info-> name is very important for next step
5. Package the policy
• Zip the policy.yaml into <info->name>.zip
• In the example, policy hello.zip is created
6. In order to upload, you will have to use
toolkit
• Login using toolkit
apic-slim login --server https://<server> --username steve --password <password> --realm provider/default-idp-2
• Cli command to upload the policy
• In order to see the policy in development, policy must be uploaded to sandbox
• If the policy will be used in another catalog (e.g. wicked) after the development, you will need to upload the policy to catalog wicked
apic-slim policies:create --catalog <catalog> --configured-gateway-service <gws> --org <org> --server https://<server> --scope
catalog hello.zip
7. Support cli command
• Get the orgs
apic-slim orgs:list --fields title,name,id --my --server https://<servername>
• Get the catalogs
apic-slim catalogs:list --fields title,name,id --my --server https://<servername> --org <orgname|orgid>
• Get the gateway configured
apic-slim configured-gateway-services:list --scope catalog --server https://<servername> --org <orgname|orgid> --catalog
<catalogname|catalogid>
8. Support cli command for policy
• List of all policies
apic-slim policies:list-all --catalog <catalogname|catalogid> --configured-gateway-service <gwname|gwid> --org <orgname|orgid> --
server https://<server> --scope catalog
• Create the policy
apic-slim policies:create --catalog <catalog> --configured-gateway-service <gwname|gwid> --org <org> --server https://<server> --
scope catalog hello.zip
• Delete the policy
apic-slim policies:delete <policyname:version> --catalog <catalogname|catalogid> --configured-gateway-service <gwname|gwid> --org
<orgname|orgid> --server https://<server> --scope catalog