Repository to create an API proxy on Mulesoft Anypoint Api Manager with a postman colection
It has been long time that I wanted to write a post on how to automate API proxy deployment by only Platform API calls.
Most of the time I do démo with UI to my prospects on API Manager topics and I have always the same question coming from them: “How are we going to add this to our CI/CD pipeline.”
So I have decided to show by only using API calls how we can import your swagger to Anypoint Exchange, Create the proxy, deploy it, add SLA tiers, apply policies, tag it then activate monitoring with only one postman collection.
The steps the collection contains are:
For this postman collection I have only used the APIs available on Anypoint Platform APIs.
You should run by order the API Calls as it is already ordered in postman collection. Because each API call gets the values from the response and sets the postman environment variables that will be used for the following API calls.
The following postman environment variables must be filled in:
domainname
-de-c1.cloudhub.io)The very first two steps are the preparation requests to get access token, env_id and org_id
This steps calls the token endpoint to get an access_token to be used as bearer token for the following steps.
For the most of the following steps you will need environment id and organisation id. This request calls the accounts/api/profile to get information on your platform (business org, env, …).
The env_name and org_name variable let us to query the response result and extract Ids
Once we have the variable set for: access_token, org_id and env_id, then we can import the swagger to Exchange, create your api in api manager and depoy the proxy instance to CloudHub via runtime manager
This request will add your swagger to exchange. Check the body of the request to customise the parameters. The important one is the asset: you should give the full path to your swagger file as value to asset.
Creates an API in Api Manager from an existing Exchange API (check body of the request if you want to customise it). It sets apiId postman environment variable from the response.
Creates a proxy for the given apiId, domainName(must be unique, it is part of your api url), env_id and env_name
Now your API is imported to exchange, created in API Manager and deployed to Runtime Manager. The following steps are to customise your APIs: SLA Tiers (Subscription), Policies, Tag and activate monitoring on your API.
This request creates a SLA tiers for the given apiId. Check body of the request to customise it
This request creates a SLA tiers for the given apiId. Check body of the request to customise it
You can use this request to check the SLA tiers created previsouly
Applies the standard Rate limiting SLA based policy to your API. This policy wil use the SLA tiers defined in the previous steps.
Add the following tag to your api: ratelimitingSLAbased
Applies the standard JWT validation policy to your API. Check the body of the request to customise your settings.
Add the following tag to your api: jwt
You can query your API manager by tag name. This lets you to tag your API properly to set a context than query easily all APIs with the specific tags
This steps is optional. It lets you to activate monitoring and visualiser on your proxy app in runtime manager.