Contact Us 1-800-596-4880

Creating Mule Gateway PDK Policies

Flex Gateway Policy Development Kit (PDK) supports creating Mule Gateway policies to enhance your experience:

  • Creating policies

  • Defining the configuration schema

  • Deploying policies to Exchange

The PDK Anypoint CLI plugin generates custom policy folders with all required policy files. In the folder, PDK includes a Makefile with commands to build the policy UI and deploy to Exchange.

To create Mule custom policies:

Before You Begin

Before you begin, ensure you meet the these prerequisites:

  • PDK supported operating system with Make installed

  • Anypoint CLI

  • Java

    For supported Java versions, see Java Support.

  • Apache Maven

    Apache Maven is a prerequisite for the Mule Maven Plugin. PDK Mule Policy projects include an embedded Mule Maven Plugin so downloading the plugin is not required. To ensure your Maven version is compatible with the latest plugin, see Mule Maven Plugin Release Notes.

  • MuleSoft’s Maven archetype

    Configure MuleSoft’s Maven archetype by adding the following code section to Maven’s settings.xml file:

     <profiles>
       <profile>
         <id>archetype-repository</id>
         <repositories>
           <repository>
             <id>archetype</id>
             <name>Mule Repository</name>
             <url>https://repository.mulesoft.org/nexus/content/repositories/public</url>
             <releases>
               <enabled>true</enabled>
               <checksumPolicy>fail</checksumPolicy>
             </releases>
             <snapshots>
               <enabled>true</enabled>
               <checksumPolicy>warn</checksumPolicy>
             </snapshots>
           </repository>
         </repositories>
       </profile>
     </profiles>

Create a Mule Custom Policy with PDK

To create your custom policy execute:

pdk policy-project create --name <policy-name> --implementation-technology mule4

Running this command generates a custom policy folder with the policy name. The folder contains a makefile that provides all the callable actions required during the policy development lifecycle.

Define a Policy Schema

Use the gcl.yaml file inside you policy project to define the policy’s schema. PDK generates your policy’s UI json from the parameters defined in the schema definition. This replaces the previous need of manually writing a config.json schema file.

To define a schema definition, see Defining a Policy Schema Definition. Include all parameters in schema that you reference in you template.xml file.

Mule Gateway custom policies support the Dataweave format, but don’t support DataWeave Bindings. For more information, see DataWeave Expressions.

Define the Policy Logic

Define the policy logic in the template.xml file.

The template.xml file, by default, contains the logic for a basic policy that sets the returned HTTP Response payload to a “Hello World!” message. View the file to see the logic.

For more policy logic examples, see:

Publish and Release Policies

PDK publishes Mule Gateway and Flex Gateway policies in the same way.

To publish and release policies, see Uploading Custom Policies to Exchange.