This API enables you calculate the Runtime Fabric Cores being used by your Organization and business groups so that you are able to keep a tab on the usage of cores and stay within the license limits.
As of now the Anypoint Platform does not provide this information for RTF, like it does for CloudHub.
In RTF, you install your applications on a RTF cluster which is made up of controllers and workers. The workers are where the applications get deployed. You can set up your RTF cluster with as many cores as you need so that you can also account for future business needs. The number of cores provisioned on the workers does not have any correlation to the cores licensed to a customer for use.
Also the cores are only used on the workers when the application is running. Even if the application is deployed but not running it will not be using cores.
This API only takes into account the running APIs when doing the count for the cores.
This API can be used by anytime you need to know how many cores are being utilized by your applications running on your RTF Cluster. It can also help you keep track of your usage and ensure that you never go beyond your allotted license.
The API has well defined contract and can be launched in Studio to run it. You can pass the parameters as needed and it will get you the desired results.
The following provides a step by step instruction to use this API
- Clone this repository
- Launch Anypoint Studio and open this application in Anypoint Studio.
- The application does not need any special configurations to run.
- Start the application
- Launch your favorite REST client or use cURL (the choice is yours).
- The call to the API is as follows,
curl --location --request POST 'http://localhost:8081/api/calculate' \
--header 'responseType: value' \
--header 'authType: value' \
--header 'Authorization: Basic Token' \
--header 'Content-Type: application/json' \
--data-raw '{
"masterOrgId": "master-org-id",
"includeSubOrgs": true,
"environments": "type"
}'
The following is the explanation for the above URL
POST
responseType: This API can provide you the response as a JSON Object or as a CSV file. The values taken by this header are either "json" or "csv". The header is optional and if you don't provide a value, it defaults to JSON
authType: This API provides 2 modes of authentication. You can either use an Anypoint Username and Password or you can use Client ID and Client Secret generated by a Connected App that has been configured and given appropriate access. In both the cases you would need to ensure that you provide the right permissions to the user or to the connected app.
For individual user you would need provide the Organization Administrator access along with Read Applications access for Runtime Manager for all the environments. If you are also looking to get the details for the business groups, the same access for that user would need to be provisioned for the business groups as well. If using an individual user the value for the authType header is userpass
For connected app, you need to provide the following scopes for all the business groups and its associated environments,
- View Environment
- View Organization
- Read Applications
If using Connected App, the value of the authType header is connectedApp
This header is required
Content-Type: Set this value to application/json
Authorization: This is the authorization header. This header is required.
When the authType is set to userpass, the value of this header is base64(anypoint_username:anypoint_password)
When the authType is set to connectedApp, the value of this header is base64(client_id:client_secret)
The body for this call is as follows,
{
"masterOrgId": "master-org-id",
"includeSubOrgs": true,
"environments": "type"
}
masterOrgId: This is the parent organization for which you need to get the core usage count. This parent organization may or may not have child organizations or business groups
includeSubOrgs: If your parent organization has one or more sub organizations in a nested structure and you want to get the core usage count for those as well, set this value to true. If you need to skip those, set it to false
environments: You can get a core count for either the Production or Non Production environments. If you only need to get a count of the production enviornments set this to production, else set it to sandbox