Add Message logging policy using tools

Not applicable

I am doing continuous integration CI for API proxies and want to automate creating proxy bundle (openAPI2apigee/wsdl2apigee) and deployment (maven).

As second part of api proxy bundle deployment, I want to attach Message logging policy to api proxy. As i want to automate the process I need to attach the policy using some tool/commands.

Is there a way I can achieve this ??

Regards,

Jatin Sharma

Solved Solved
0 1 240
1 ACCEPTED SOLUTION

Yes, it can be accomplished and it will need some engineering.

You are trying to do two things:

- Generate a proxy bundle from a swagger/wsdl file

- Insert reusable shared flows/steps in this generated proxy bundle.(For now it's a logging policy)

If you look at the sample code of OpenAPI2Apigee , you will realize that it :

1. Creates the whole proxy and target XML from scratch

2. Appends pre defined policy steps in the XML using the approach documented by @Anil Sagar @https://community.apigee.com/articles/9478/openapi2apigee-020-version-generating-apigee-policies.html

3. Consumes your swagger to generate routes and flow conditions.

You could have used the volos module approach but it doesn't support logging yet. Additionally, i don't see it supporting shared flows which are really helpful.

So, you could write a wrapper utility which takes one of the two approaches :

Approach 1:

1. Clones a skeletal proxy bundle template with references to reusable policies/shared flows(instead of generating it from scratch). You would store this in your SCM.

2. Overlays the output of OpenAPI2Apigee and WSDL2Apigee onto your cloned template.

First, try running OpenAPI2Apigee/WSDL2Apigee on your spec and see the sections/files in which the proxy bundle is customized. That will help you figure out how complex the overlay routine is going to get.

Approach 2:

1. Run the bundle generation utilities as you originally planned

2. Write a script to append XML nodes, copy files to the proxy bundle generated in step 1.

While Approach 1 and 2 might look similar, they have a significant difference. In the first approach, your reusable snippets are an actual proxy bundle template. This makes it easy to author and update them. In the second approach, they are stored in code.

In the end, you are essentially merging XML's (or reading selective paths of generated XML to merge into template xml) and copying files.

View solution in original post

1 REPLY 1

Yes, it can be accomplished and it will need some engineering.

You are trying to do two things:

- Generate a proxy bundle from a swagger/wsdl file

- Insert reusable shared flows/steps in this generated proxy bundle.(For now it's a logging policy)

If you look at the sample code of OpenAPI2Apigee , you will realize that it :

1. Creates the whole proxy and target XML from scratch

2. Appends pre defined policy steps in the XML using the approach documented by @Anil Sagar @https://community.apigee.com/articles/9478/openapi2apigee-020-version-generating-apigee-policies.html

3. Consumes your swagger to generate routes and flow conditions.

You could have used the volos module approach but it doesn't support logging yet. Additionally, i don't see it supporting shared flows which are really helpful.

So, you could write a wrapper utility which takes one of the two approaches :

Approach 1:

1. Clones a skeletal proxy bundle template with references to reusable policies/shared flows(instead of generating it from scratch). You would store this in your SCM.

2. Overlays the output of OpenAPI2Apigee and WSDL2Apigee onto your cloned template.

First, try running OpenAPI2Apigee/WSDL2Apigee on your spec and see the sections/files in which the proxy bundle is customized. That will help you figure out how complex the overlay routine is going to get.

Approach 2:

1. Run the bundle generation utilities as you originally planned

2. Write a script to append XML nodes, copy files to the proxy bundle generated in step 1.

While Approach 1 and 2 might look similar, they have a significant difference. In the first approach, your reusable snippets are an actual proxy bundle template. This makes it easy to author and update them. In the second approach, they are stored in code.

In the end, you are essentially merging XML's (or reading selective paths of generated XML to merge into template xml) and copying files.