Describing your policy
Describe your user-defined policy by creating a definition file in YAML format to document metadata about the policy.
About this task
A policy YAML file contains the following sections:
- A specification version.
- An information section.
- An attach section.
- A properties section.
- A gateways section.
You can create a policy YAML file by using any editor of your choice. Both .yaml and .yml file extensions are supported, but the use of the .yaml file extension is recommended by yaml.org.
Note: IBM® API
Connect
Micro Gateway is deprecated in IBM API
Connect Version 5.0.8 in favor of DataPower® Gateway. From 1 April 2020, Micro Gateway, and associated toolkit CLI commands, will no longer
be supported. Existing users can migrate their API definitions to IBM
DataPower Gateways. For information on supported API policies, see
Built-in
policies.
Note: All keys and enumeration values that are specified in this topic are case-sensitive.
Procedure
The following steps describe how to construct a policy YAML file.
Results
Example
policy: 1.0.0
info:
title: Sample Policy
name: sampleimpl
version: 1.0.1
description: This is a sample policy.
contact:
name: Steve Product Manager
url: http://developer.acme.com/contacturl
email: steve-product-manager@someemailservice.com
attach:
- rest
- soap
properties:
$schema: "http://json-schema.org/draft-04/schema#"
type: object
properties:
samplestring:
label: String Property
description: Sample string property
type: string
sampleboolean:
label: Boolean Property
description: Sample boolean property
type: boolean
sampleinteger:
label: Integer Property
description: Sample integer property
type: integer
samplenumber:
label: Number Property
description: Sample number property
type: number
samplestringwithenum:
label: Enum Property
description: Sample string enum property
enum:
- one
- two
- three
default: one
type: string
samplearray:
label: Array of properties
description: Sample array of properties
type: array
items:
type: object
properties:
string:
label: String Property
description: Sample string property in array
type: string
boolean:
label: Boolean Property
description: Sample boolean property in array
type: boolean
required:
- string
required:
- samplestring
- sampleboolean
- sampleinteger
- samplenumber
- samplearray
gateways:
- datapower-gateway
In the following code block, an example of a policy definition file for modifying
message payload is shown.
policy: 1.0.0
info:
title: Run GatewayScript
name: gatewayscript-policy
version: 1.0.0
description: Execute GatewayScript
contact:
name: IBM DataPower Samples
url: https://github.com/ibm-datapower/
email: steve-product-manager@ibm.com
attach:
- rest
- soap
gateways:
- datapower-gateway
properties:
$schema: "http://json-schema.org/draft-04/schema#"
type: object
properties:
source:
label: "GatewayScript Source"
description: "The location of the GatewayScript file to execute"
type: string
default: store:///identity.js
value:
label: "New Value"
description: "The value to be added to the payload"
type: string
default: "Hello Policy"
required:
- source
- value