API Guide

ServiceTemplate is deployed. Otherwise the parameter is optional. For example, the server host name is required in this extracted
snippet of the ServiceTemplate. Save the result above to a le inspect the full XML for a ServiceTemplate.
<parameters>
<id>os_host_name</id>
<value/>
<type>STRING</type>
<displayName>Host Name</displayName>
<required>true</required>
<requiredAtDeployment>true</requiredAtDeployment>
<hideFromTemplate>true</hideFromTemplate>
<min>0</min>
<max>0</max>
<dependencyTarget>generate_host_name</dependencyTarget>
<dependencyValue>false</dependencyValue>
</parameters>
Publish a ServiceTemplate
In order to use a ServiceTemplate to deploy a Service, the ServiceTemplate must be rst published. This is accomplished by setting
the ServiceTemplate element <draft> to false. i.e. it is no longer in the draft state.
require 'ASMConfig'
templateId = "ff8080814be03f17014bea250f100b7d"
url = ASM::API::URI("/ServiceTemplate/%s"%templateId)
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
20