ARM REST Services
Server Management Examples
Register a New Server
The Runtime Manager provides a REST API to manage servers and the applications deployed on them. A server has to first be registered into the Runtime Manager console to be managed.
To register a server you must first authenticate against the Anypoint Platform Authentication Manager and get an authentication token. With this token you need to obtain a registration token to be used to register a server.
POST https://anypoint.mulesoft.com/hybrid/api/v1/servers
{
"muleVersion": "3.6.0",
"gatewayVersion": "1.0",
"signatureRequest": "-----BEGIN CERTIFICATE REQUEST-----MIIByjCCATMCAQAwgYkxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgSW5jMR8wHQYDVQQLExZJbmZvcm1hdGlvbiBUZWNobm9sb2d5MRcwFQYDVQQDEw53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEApZtYJCHJ4VpVXHfVIlstQTlO4qC03hjX+ZkPyvdYd1Q4+qbAeTwXmCUKYHThVRd5aXSqlPzyIBwieMZrWFlRQddZ1IzXAlVRDWwAo60KecqeAXnnUK+5fXoTI/UgWshre8tJ+x/TMHaQKR/JcIWPhqaQhsJuzZbvAdGA80BLxdMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIhl4PvFq+e7ipARgI5ZM+GZx6mpCz44DTo0JkwfRDf+BtrsaC0q68eTf2XhYOsq4fkHQ0uA0aVog3f5iJxCa3Hp5gxbJQ6zV6kJ0TEsuaaOhEko9sdpCoPOnRBm2i/XRD2D6iNh8f8z0ShGsFqjDgFHyF3o+lUyj+UC6H1QW7bn-----END CERTIFICATE REQUEST-----",
"muleLabel": "TestServer"
}
Note: The Runtime Manager provides a script that registers a server automatically! No need to perform this sequence of requests manually.
Creating a Server Group
A server group is a set of servers that act as a single deployment target, in which instances of the applications are completely isolated from each other.
You can create a server group through a request such as:
POST https://anypoint.mulesoft.com/hybrid/api/v1/serverGroups
{
"name": "Group2",
"serverIds":[1,2,3]
}
Note: A server group can only be created from individual servers, you can't create a server group from other existing server groups or clusters.
Creating a Cluster
A Cluster is a set of servers that act as a single deployment target, in which instances of the application are aware of one another and share common information and synchronize statuses.
You can create a multicast cluster through a request like this:
POST https://anypoint.mulesoft.com/hybrid/api/v1/clusters
{ "name": "cluster\\_name",
"multicastEnabled": "true",
"servers": [ {"serverId": 2} ]
}
The cluster can also be configured as unicast, in that case you must specify the IP address of each server:
POST https://anypoint.mulesoft.com/hybrid/api/v1/clusters
{ "name": "cluster\\_name",
"multicastEnabled": "false",
"servers": [ {"serverId" : 2, "serverIp":"192.168.1.1"} ]
}
Working with Servers
After a server is registered in Runtime Manager, you can request information about it through a call like this:
GET https://anypoint.mulesoft.com/hybrid/api/v1/servers/{serverId}
You can also request for the full list of registered servers through a call like this:
GET https://anypoint.mulesoft.com/hybrid/api/v1/servers
To unregister a server, you must delete it from the Runtime Manager with a request like this:
DELETE https://anypoint.mulesoft.com/hybrid/api/v1/servers/{serverId}
The response of this call is always No Content for application deletion, whether the applications existed initially or not.
Working with Server Groups
List the server groups:
GET https://anypoint.mulesoft.com/hybrid/api/v1/serverGroups
Retrieve the information of a particular server group:
GET https://anypoint.mulesoft.com/hybrid/api/v1/serverGroups/{serverGroupId}
Add a server to a server group:
POST https://anypoint.mulesoft.com/hybrid/api/v1/serverGroups/{serverGroupId}/servers/{serverId}
After adding a server to a server group, all applications associated to that particular server group are deployed into the new server.
You can add servers that are not currently running to a server group.
If you attempt to add a server that already belongs to a server group, the request fails.
Remove a server from a server group:
DELETE https://anypoint.mulesoft.com/hybrid/api/v1/serverGroups/{serverGroupId}/servers/{serverId}
When a server is removed from the server group then the applications living in that server will remain in it.
Working with Applications
An application target is a target to which you can deploy applications, it may either be a server, server group, or a cluster.
A deployment is a resource handled in the Runtime Manager. To create a deployment, you must execute the following request:
POST https://anypoint.mulesoft.com/hybrid/api/v1/applications -H "Content-Type: multipart/form-data"
file: octet/stream, artifactName: "test", targetId:"1"
You can check for the status of the applications in your organization through the following call:
GET https://anypoint.mulesoft.com/hybrid/api/v1/applications
The call below deletes a specified application:
DELETE https://anypoint.mulesoft.com/hybrid/api/v1/applications/{applicationId}
The response to this call is always No Content for application deletion, whether the applications existed initially or not.
The call below changes the binary file of the application (in this case to a patch with the new file):
PATCH https://anypoint.mulesoft.com/hybrid/api/v1/applications/{applicationId} -H "Content-Type: multipart/form-data"
file: octet/stream
If the last request is done without an attached file, Runtime Manager assumes you want to redeploy the same file that currently exists.
The request below starts an application:
PATCH https://anypoint.mulesoft.com/hybrid/api/v1/applications/{applicationId}
{
"desiredStatus": "STARTED"
}
The request below stops an application:
PATCH https://anypoint.mulesoft.com/hybrid/api/v1/applications/{applicationId}
{
"desiredStatus": "STOPPED"
}