Reference Guide
response = ASM::API::sign {
RestClient.get url
}
# Set draft to false
payload = ASM::Payload.from_xml(response)
payload.set('//draft', 'false')
# Send it back as a PUT
response = ASM::API::sign {
RestClient.put url, payload.to_xml, :content_type => :xml
}
Deployment
While the ASM UI refers to a Service, the REST API resource is not Service, but rather Deployment. The
two terms are synonymous. Deployments require an instance of a ServiceTemplate with its required
parameters supplied.
Get all deployed Services
require 'ASMConfig'
response = ASM::API::sign {
url = ASM::API::URI("/Deployment")
RestClient.get url
}
doc = Nokogiri::parse(response)
doc.xpath('//Deployment').each do |deploy|
id = deploy.at_xpath('id').content
name = deploy.at_xpath('deploymentName').content
status = deploy.at_xpath('jobStatus').content
print "%s : %s : %s\n" % [id,name,status]
end
After getting all Services we print the id, name, and status of each. Services that are still in the act of being
deployed will have a status of IN_PROGRESS. So calling this method with the Deployment Id as a path
parameter can also be used to periodically poll a Deployment to find out when it has finished.
Deploy a new Service
Here, after having previously gotten an existing ServiceTemplate by name, and saved it to a file, we then
set the required parameters in the ServiceTemplate file, and finally embed the ServiceTemplate into a
prefabricated Deployment structure that is read from a file. As mentioned previously we can monitor the
status of this Deployment by performing a GET with the deployment id as a path parameter.
require 'ASMConfig'
url = ASM::API::URI('/Deployment')
template_name = 'TwoServers'
template = ASM::Payload::load_xml("%s.xml"%template_name)
deployment = ASM::Payload::load_xml('deployment_skeleton.xml')
# Set Deployment parameters
deployment.set("deploymentName", 'ManualAPIDeploymentDeux')
deployment.set("deploymentDescription", 'Manual API Deployment')
20