SAP API Management: Discover Integration Flows from CPI tenants and auto-generate APIs
SAP Cloud Platform API Management can be used to create connected omni-channel experiences for your consumers, partners and employees. And in many cases, building integrations to link processes and data across applications or across businesses form an intrinsic part of this exercise. Cloud Platform Integration can help you implement these integration scenarios. For more information about Cloud Platform Integration (CPI) refer to this link. Once you have the integrations in place API Management will help you bring in additional security compliance, traffic management, implement Usage reporting, monetization etc.
A typical solution pattern where API Management and Cloud Platform Integration services are used in conjunction is depicted in the figure below. You can build enterprise integration scenarios using CPI and the pre-packaged content from SAP API Business Hub. Connectivity with SAP Cloud Integrations will be achieved via API Providers. Security risks can be minimized by applying security best practices from SAP API Management. You can also gain insights on API usage and traffic with the inbuilt Analytics dashboard.
In order to achieve the above solution architecture, you should be able to discover the Integration Flows from CPI and create corresponding APIs in API Management to further strengthen it with security or traffic management policies.
In this blog, I write about how easily you can discover the Integrations Flows deployed in your CPI tenant from your API Portal and generate an API for the same with minimal steps.
- You already have a CPI tenant and have atleast one OData type Integration Flow deployed on it for your integration scenario.
- You already have setup API Management and have access to API Portal as an Administrator.
Create an API Provider
To begin with, you need to create an abstraction to your CPI tenant where all your Integration Flows are hosted. In order to do so, create an API Provider of type ‘Cloud Platform Integration’ with all the necessary details.
Note: You need to enter the co-ordinates and the credentials to connect to your CPI Web UI tenant. This feature is only available for CPI Neo environment as of now.
Once the API Provider is saved, you can also check your details by clicking on the ‘Test Connection’ action. If everything looks fine, you are ready to use this API Provider to browse through the Integration Flows and generate an API for any chosen Integration Flow.
Generate an API
Start creating the API from the Develop tab.
Choose the API Provider that you just created and click on ‘Discover’.
A dialog displays all the OData Integration Flows from the tenant. Choose the one for which you need to generate an API and click on ‘Next’.
Enter the credentials to connect to the Integration Flow and click on ‘Done’.
Now the details of the Integration Flow will be used to populate the API details. You can edit basic details like name, title, description, base path etc. tailored to your needs.
You will then be taken to the API details page where you can decide to browse through the created resources.
Add Policies to manage traffic
Click on ‘Policies’ to enter the Policy Designer page. Select ‘PreFlow’ under ‘ProxyEndpoint’ and add a ‘Quota’ policy on the incoming request stream. Let’s leave the default policy snippet as is, which allows a maximum of 2 calls on the API within a minute. Deploy the API with the changes.
Test your API
A quick verification of the API can be done by invoking the API Proxy URL in either the Test console or any other client like a Web browser or Postman. If you make more than 2 calls within a minute, the API responds with a failure message since the allowed quota is exceeded.
As you can see, in less than a few minutes you could discover the Integration Flows in your CPI system, create an API for a selected Integration Flow and add policies to bring in the necessary behaviors on the API. This empowers you to easily implement best practice solution architectures in your enterprise integration projects. Give this feature a try and let us know what you think.