Nav

To Add Resource Level Policy Support to a Custom Policy (Jul 2017)

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:

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

    TO:

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    {{#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