Related
- I Reverse-Engineered 50 API Breaches. The Same Five Mistakes Keep Appearing.
- The Documentation Crisis Nobody Sees: Why AI Agents Are Breaking Faster Than Humans Can Document Them
- A Practical Blueprint for Deploying Agentic Solutions
- Beyond Manual Annotation: Engineering Self-Correcting Pseudo-Labeling Pipelines
Trending
- Conversational Risk Accumulation: Stateful Guardrails Beyond Single-Turn LLM Checks
- The AI Autonomy Spectrum: 7 Architecture Patterns for Intelligent Applications
- Cutting Data Pipeline Costs and Data Freshness Issues With Netflix Maestro and Apache Iceberg: A Practical Tutorial
- Rust-Native Alternatives to Spark SQL and DataFrame Workloads
- DZone
- Data Engineering
- Databases
- Using Mule CloudHub APIs
Using Mule CloudHub APIs
Learn about how to access Mule ESB functions programmatically by deploying applications in the CloudHub API environment.
Join the DZone community and get the full member experience.
Join For FreeCloudHub APIs provide a way to access Mule ESB functions programmatically. CloudHub provides many APIs to use in external applications. In this article, some of the important APIs will be discussed.
Where To Get The APIs
All the APIs exposed by Anypoint Platform can be found here. The URL of the Cloudhub APIs can be accessed here. Also, the Mule documentation contains some important information on how to use the Cloudhub APIs. It can be found here .
Deploy Using Cloudhub API
Here in this section, the important and necessary steps to deploy a Mule application using all those APIs in the above section will be discussed.
Login API
First, you will need to get the access token. Here is how to get it:
API Endpoint |
https://anypoint.mulesoft.com/accounts/login |
Method |
POST |
| Input | |
| Output | |
Get Anypoint Platform Account Information
After getting the token, let's get the information about our Anypoint Platform account.
| API Endpoint | https://anypoint.mulesoft.com/accounts/api/me |
| Method | GET |
Content-Type |
application/json |
| Header | Authorization โ token we retrieved at Login step |
| Output | |
In the output, the value of our concern is the Organization ID.
Get the Environment ID
The Environment (Development, Production, Quality) ID can be obtained in two ways:
Using CLI tools.
Using the API.
Using CLI tools
Please check this link to install and configure Anypoint CLI. After installing, please log into Anypoint Platform.
๐ Screen Shot 2017-06-06 at 6.13.21 PM.png
After login, execute the following command: account environment list
๐ Screen Shot 2017-06-06 at 6.16.55 PM.png
It will show the environments and their respective IDs.
Using the API
| API Endpoint | https://anypoint.mulesoft.com/accounts/api/organizations/{ORGANIZATION_ID}/environments |
| Header | Authorization โ token we retrieved at Login step |
| URI Param | ORGANIZATION_ID โ It can be found in the step where we retrieved the Anypoint Platform account information. |
| Method | GET |
| Content-Type | application/json |
| Output | |
Deploy to the Environment
| API Endpoint | https://anypoint.mulesoft.com/cloudhub/api/v2/applications |
| Authentication | Basic Authentication โ Anypoint Platform Login and Password |
| Header | X-ANYPNT-ENV-ID โ The environment ID we have retrieved in the previous step |
| Method | POST |
| Content-Type | multipart/form-data Required parameters are, file โ Browse to the zip archive to be deployed appInfoJson โ |
| Output | |
At this step, the application is uploaded to CloudHub but is not yet deployed. To deploy, please use the following API.
Start the Application
| API Endpoint | https://anypoint.mulesoft.com/cloudhub/api/applications/{APP_NAME}/status |
| Authentication | Basic Authentication โ Anypoint Platform Login and Password |
| Header | X-ANYPNT-ENV-ID โ Environment ID we have extracted |
| URI param | APP_NAME โ Name of the app to be started |
| Method | POST |
| Content-Type | application/json |
| Input | |
| Output | {} |
Conclusion
In this article, I have discussed some of the important APIs exposed by Cloudhub. For a detailed explanation of all the APIs exposed by CloudHub, please have a look at the developer portal exposed by Anypoint Platform. Interestingly, the mule-maven-plugin is created using all these APIs.
N.B.: All the above APIs have been tested with Postman only.
Opinions expressed by DZone contributors are their own.
Related
-
I Reverse-Engineered 50 API Breaches. The Same Five Mistakes Keep Appearing.
-
The Documentation Crisis Nobody Sees: Why AI Agents Are Breaking Faster Than Humans Can Document Them
-
A Practical Blueprint for Deploying Agentic Solutions
-
Beyond Manual Annotation: Engineering Self-Correcting Pseudo-Labeling Pipelines
