What Is API Autodiscovery?
API Autodiscovery is a mechanism that manages an API from API Manager by pairing the deployed application to an API created on the platform. API Management includes tracking, enforcing policies if you apply any, and reporting API analytics. Critical to the Autodiscovery process is identifying the API by providing the API name and version.
By configuring autodiscovery, you can use policy management and API Analytics accessed from within API Manager.
When autodiscovery is correctly configured in your Mule application, you can say that your application’s API is tracked by the API Manager.
Prerequisites
To configure auto discovery for Mule application..
1. API must exist in API Manager
2. Mule must be configured to use AnyPoint Platform credentials in AnyPoint Studio
3. The auto discovery element must be configured in Mule application.
4. Need environment client_id and client_secret.
client_id and client_secret are available from AnyPoint Platform>Access Management>Environment.
NOTE: An API in a Mule runtime can only be connected with one Autodiscovery instance. Two/more Autodiscoveries can't be connected with same API
Step 1: Create an API
Create a sample API specification in the Design Center.
Follow below steps to create sample RAML
AnyPoint Platform > DesignCenter > Create New
Step 2: Test the API
You can test the API by enabling the mocking service. If you see any issues, then verify the RAML and fix the issues and test it again
If there are no errors, then Publish it to Exchange.
Step3:
Once the RAML is published to Exchange, it can be managed through API Manager
In the API Manager> click on Manage API and select Manage API from Exchange.
Enter few characters of your API name and then select it from drop down menu.
Check the box for the Mule version as we are managing it in Mule4.
Click on Save
Then, API is visible in the API manager but the status is “Unregistered"
It means, it has not yet been associated with an actual API implementation.
You can see API Autodicovery tag and API ID
This will help us to pair the API in the API Manger to its deployed Mule Application.
Note: Copy API ID
Go to Policies
Select Rate limiting policy and click on Configure Policy
Here the policy allows only 5 requests in 1 min. You can change it as per your requirement.
Under Actions: you can Edit, Disable, Remove if required.
Step 4:
Go to Access Management
Click on Environments and select Sandbox
Copy Client ID and Client Secret and paste it in Notepad and remove any trailing spaces
Step 5: CREATE A MULE PROJECT
Go to Anypoint studio. Create a Mule Project, and import the newly created API from the design center. You can do any necessary changes required according to your requirement.
No comments:
Post a Comment