Contact Us 1-800-596-4880

To Add Resource Level Policy Support to a Custom Policy

You need to add some YAML and XML code to existing custom policy configuration and definition files, respectively, to support resource level policies in Mule 3.8.1 and later.

  1. In the XML definition file, change the standard pointcut definition as follows:

    FROM:

    <pointcut>
      <api-platform-gw:api-pointcut apiName="{{apiName}}" apiVersion="{{apiVersionName}}"/>
    </pointcut>

    TO:

    {{#pointcutData.length}}
      {{#pointcutData}}
        <pointcut>
          <api-platform-gw:api-pointcut apiName="{{apiName}}" apiVersion="{{apiVersionName}}"/>
          <resource methodRegex="{{methodRegex}}" uriTemplateRegex="{{uriTemplateRegex}}"/>
        </pointcut>
      {{/pointcutData}}
    {{/pointcutData.length}}
    {{^pointcutData.length}}
      <pointcut>
        <api-platform-gw:api-pointcut apiName="{{apiName}}" apiVersion="{{apiVersionName}}"/>
      </pointcut>
    {{/pointcutData.length}}
  2. Add the following key/value pair to the YAML file:

    resourceLevelSupported: true

  3. In Anypoint Platform, click API Manager.

  4. In API Administration, choose Custom policies.

  5. Click Add Custom Policy.

  6. In Add Custom Policy, give the new policy a name, for example myResourceLevelPolicy.

  7. Browse to and select the YAML and XML files you created or downloaded.

Download Example XML and YAML Files