Reuse of policies across proxies

Can we reuse policies across proxies? I understand that policies need to be contained within a proxy. If I have to create 200 APIs, all of which will have verifyAPI key and Assign Message (set message headers) common, is there a way to create once and reuse?

It may be sounding like inheritence, is this possible?

Solved Solved
3 6 1,773
1 ACCEPTED SOLUTION

Not applicable

Currently, there is no easy way to do this. You bring up a good point that if you are creating multiple proxies with the same policies configured the same way, it would be good to package them up into some reusable entity. I think it is a great suggestion and I'll forward it on to the PM team for consideration. Thank you for your question.

View solution in original post

6 REPLIES 6

Not applicable

Currently, there is no easy way to do this. You bring up a good point that if you are creating multiple proxies with the same policies configured the same way, it would be good to package them up into some reusable entity. I think it is a great suggestion and I'll forward it on to the PM team for consideration. Thank you for your question.

We discuss this a little in our Best Practices doc topic. See "Framework-style coding". Policy reuse currently needs to be done out of source control.

http://apigee.com/docs/api-services/content/best-practices-api-proxy-design-and-development#developm...

Not applicable

Take a look at https://github.com/apigee/proxy-dependency-maven-plugin - this plugin facilitates maintaining common code in a single spot, then at deploy time copying that code into a deployment bundle.

You still have to manage policy flows but this solves one part of the problem.

@David Allen

How can we copy node js resources. Using the plugin we can copy javascript files and policy file. I tried using the latest plugin 2.1.0, but yet couldn't copy node js files. Can you please let me know if there is any other way to achieve this.

Not applicable

Even this feature is not available out-of-the-box for reusing XML policies, as David suggests above, you can still leverage some offline tools to assemble the code and apply some design patterns. With Proxy Dependency Maven Plugin, you can do this if you're more into Java-live tools. If you're into JavaScript-like tools, I'd recommend taking a look at Apigee Deploy Grunt Plugin, which leverages the concept of Git Submodules from either a common repo or a common branch. The code above provides an example of this solution. A third option even more powerful is to leverage Node.js and NPM native capabilities, with Apigee Node.js API Proxies you can leverage packages, so with modules you can reuse any code. You'd need to publish your code to NPM or private npm, also NPM is planning to release this year a way to publish private modules.

This can be achived by integrating Apiee Edge with Eclipse (Kepler/Luna comes with inbuilt Maven plugin). We can import the downloaded bundles from Apigee Edge into Eclipse Maven project (It will form a folder structure there and one folder with the policies will also be created). Like wise we can copy the xml files (specific to one policy) from one Maven project to another (1 Maven project can be created for a project).

|-apiproxy

|---proxies

|---resources

|---stepdefinitions

|---targets