List ServerTemplates available to the account.
Note: A revision of zero means its a Head revision.
Table of Contents
Prerequisite: Example assumes you have previously authenticated, and your valid session cookie is in 'mycookie'.
Note: Depending on the account, this can be a fairly expensive (resource intensive) call. Note the Supplmental section which results in a lighter response.
#!/bin/sh curl -i -H X_API_VERSION:1.5 -b mycookie -X GET https://my.rightscale.com/api/server_templates.xml
Note:
<server_template> <actions> <action rel="commit"/> <action rel="clone"/> </actions> <links> <link rel="self" href="/api/server_templates/13"/> <link rel="multi_cloud_images" href="/api/server_templates/13/multi_cloud_images"/> <link rel="default_multi_cloud_image" href="/api/multi_cloud_images/7239"/> <link rel="inputs" href="/api/server_templates/13/inputs"/> <link rel="alert_specs" href="/api/server_templates/13/alert_specs"/> </links> <description>rightgrid_photo_worker(daemon), v1 (based on FC6V2_6) it is the first really gem version</description> <name>rightgrid_photo_worker</name> <revision>0</revision> </server_template> . . . <server_template> <actions> <action rel="commit"/> <action rel="clone"/> </actions> <links> <link rel="self" href="/api/server_templates/20003"/> <link rel="multi_cloud_images" href="/api/server_templates/20003/multi_cloud_images"/> <link rel="default_multi_cloud_image" href="/api/multi_cloud_images/49"/> <link rel="inputs" href="/api/server_templates/20003/inputs"/> <link rel="alert_specs" href="/api/server_templates/20003/alert_specs"/> </links> <description>Development sandbox for Chef recipes. This does not use right_net in anyway.</description> <name>caryp - Chef-Solo</name> <revision>0</revision> </server_template> . . .
Using a filter to show only ServerTemplates with "MySQL" in their name.
#!/bin/sh curl -i -H X_API_VERSION:1.5 -b mycookie \ -d filter[]="name==MySQL" \ -X GET https://my.rightscale.com/api/server_templates.xml
Additional filter to return only ServerTemplates with "MySQL" in their name and "LTS" (lineage reference) in their description.
#!/bin/sh curl -i -H X_API_VERSION:1.5 -b mycookie \ -d filter[]="name==MySQL" \ -d filter[]="description==LTS" \ -X GET https://my.rightscale.com/api/server_templates.xml
Note: As with many API calls, depending on the account this can be an expensive (resource intensive) operation.
require 'rubygems' require 'pp' # Require pretty print Ruby gem require 'right_api_client' # RightScale API client gem user = 'greg.doe@example.com' # Set user email address for using the Dashboard acct = '1234' # Set the account ID pass = 'SomePassword' # Set the password for the user. Create client object so you can use the API. @client = RightApi::Client.new(:email => user, :password => pass, :account_id => acct) # # Setup and authenticate above. Set and use additional variables below, display output, etc. # pp @client.server_templates.index
[#<RightApi::ResourceDetail resource_type="server_template", name="Transcoding worker">, #<RightApi::ResourceDetail resource_type="server_template", name="rightgrid_photo_worker">, #<RightApi::ResourceDetail resource_type="server_template", name="MySQL Master Server">, #<RightApi::ResourceDetail resource_type="server_template", name="Base ServerTemplate for Linux (v13.1) v1">, #<RightApi::ResourceDetail resource_type="server_template", name="Base ServerTemplate for Linux (v13.1) v2">, #<RightApi::ResourceDetail resource_type="server_template", name="Base ServerTemplate for Linux (v13.1) v2">, #<RightApi::ResourceDetail resource_type="server_template", name="Base ServerTemplate for Linux (RSB) (v13.2)">]
Prerequisite: Example assumes you have previously authenticated and your session cookie for subsequent requests is in 'cookieContainer'.
#get cookie container from authentication $cookieContainer $webRequest = [System.Net.WebRequest]::Create("https://my.rightscale.com/api/server_templates.xml") $webRequest.Method = "GET" $webRequest.CookieContainer = $cookieContainer $webRequest.Headers.Add("X_API_VERSION", "1.5"); [System.Net.WebResponse] $webResponse = $webRequest.GetResponse() $responseStream = $webResponse.GetResponseStream() $responseStreamReader = New-Object System.IO.StreamReader -argumentList $responseStream [string]$responseString = $responseStreamReader.ReadToEnd() $responseString
Same as bash/curl example above.
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.