Salesforce

How to get CloudHub application information using Anypoint Platform API

« Go Back

Information

 
Content
GOAL

This article gives sample steps on how to use Anypoint Platform API to get CloudHub application information 

PROCEDURE
 
1) Use the org admin's username/password to get the access token
curl -ik https://anypoint.mulesoft.com/accounts/login -X POST --data 'username=someuser&password=somepass'
the output I got here is: 
{
  "access_token": "43687b37-aac5-42c7-a0a4-60817b3909d1",
  "token_type": "bearer",
  "redirectUrl": "/home/"
}

 
Note: 
  • If you go to Core Services UI -> Access Management -> Organization -> <your org> you will see the configurable session timeout. The TTL specified there is the time of validity of the token.
  • If your organization has external identity configured, you can use the user account existed before federation, or ask your external identity administrator to get a SAML token then send to https://anypoint.mulesoft.com/accounts/login/receive-id to get access_token.
 
2) use the access token to get the Org ID
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" https://anypoint.mulesoft.com/accounts/api/me

 
 
the output snippet which contains the Org ID: 
"organization": { 
"name": "user.name", 
"id": "8503f31b-a18c-4ab2-8692-c78a93b87dd6",

 
 
3) use the access token, Org ID to get environment ID
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" https://anypoint.mulesoft.com/accounts/api/organizations/YOUR_ORG_ID/environments

 
 
the output snippet which contains the environment ID: 
{ 
"id": "5521f78ee4b04de4b3895697", 
"name": "USProduction", 
"organizationId": "8503f31b-a18c-4ab2-8692-c78a93b87dd6", 
"isProduction": true 
}

 
 
4) use the access token, environment ID to get the applications
 
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "X-ANYPNT-ENV-ID: YOUR_ENV_ID" https://anypoint.mulesoft.com/cloudhub/api/v2/applications
 
the output snippet which contains the application name: 
 
{"id":"56aeeb17e4b0fad5e1d5de86","href":"http://anypoint.mulesoft.com:8080/api/applications/appName","domain":"appName","fullDomain":"appName.cloudhub.io" 
 
5) get the deployment details
curl -v -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "X-ANYPNT-ENV-ID: YOUR_ENV_ID" https://anypoint.mulesoft.com/cloudhub/api/v2/applications/YOUR_APPLICATION_NAME/deployments

 
 
the output snippet which contains the application logging entries: 
{
      "deploymentId": "57f898f6e4b01493138e126d",
      "createTime": "2016-10-08T06:57:58.329Z",
      "startTime": "2016-10-08T06:58:00.066Z",
      "endTime": "2016-10-08T07:04:50.097Z",
      "instances": [
        {
          "instanceId": "57f898f6e4b01493138e125d-0",
          "publicIPAddress": "52.65.4.110",
          "status": "STARTED",
          "region": "ap-southeast-2"
        }
      ]
    }

 
For more details, please reference API document.
Attachments

Powered by