Custom filters

How to create a custom filters & load to use in apigee?Any sample reference please?

0 6 501
6 REPLIES 6

@vinay poreddy , Can you please provide more details regarding custom filters you are referring to ?

In general is it possible to create a custom filters?

what is a custom filter?

are you referring to servlet filters? -- in that case, refer to David's answer on how you would configure it in Apigee,

I meant custom policy like creating a own policy.You have inbuilt policies like Assign message,Extract Variable etc.If we need to create a custom policy for specific requirement which can be re-used across the api proxies.

You can do so using java/python/javascript/node,js etc. @vinay poreddy . To make them available across multiple proxies you can upload the custom code as a resource file.

Not applicable

I am going to take a stab at this.

In your definition of a proxy or target you can create flows. These flows can have an optional condition attached to both the flow and the individual steps within a flow. These conditions act as a filter allowing you to take action based on attributes of the inbound request or other conditions you set. While we don't call these "filters" they achieve something similar.

In that regard you can filter a request to a specific target, take action based on attributes of the request, etc.

The following is a snippet which demonstrates a "filter" based on the request url, and one of the query parameters. The filter is acheived via the condition tags, with individual steps within the flow having conditions as well:

<Flow name="EntitledItems">
    <Request>
        <Step>
            <Name>extractVariables</Name>
            <Condition>(proxy.pathsuffix MatchesPath "/{version}/profile/{profile.id}/catalog/entitled**")</Condition>
        </Step>
        <Step>
            <Name>jsOptionsCatalog</Name>
            <Condition>(proxy.pathsuffix MatchesPath "/{version}/profile/{profile.id}/catalog/entitled**")</Condition>
        </Step>
        <Step>
            <Name>jsOptionsProduct</Name>
            <Condition>(proxy.pathsuffix MatchesPath "/{version}/profile/{profile.id}/product/entitled**")</Condition>
        </Step>
        <Step>
            <Name>buildEntitledItemsAll</Name>
        </Step>
    </Request>
    <Response>
        <Step>
            <Name>jsMediationEntitledItems</Name>
        </Step>
    </Response>
    <Condition>(proxy.pathsuffix MatchesPath "/{version}/profile/{profile.id}/catalog/entitled**") or (proxy.pathsuffix MatchesPath "/{version}/profile/{profile.id}/products/entitled")</Condition>
</Flow>