Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > RightScale API 1.5 > Examples > Deployments > List Deployments

List Deployments

List all Deployments of an account (also referred to as the Deployments Index).

icon_curl_v1.png    icon_rs_api_client_v1.png   icon_powershell_v1.png

Table of Contents

Curl

Prerequisite:  Example assumes you have previously authenticated, and your valid session cookie is in 'mycookie'.

Example Call

#!/bin/sh -e
curl -i -H X_API_VERSION:1.5 -b mycookie -X GET https://my.rightscale.com/api/deployments.xml

Sample Output

Note:  Truncated XML output without headers included (to save space).

<?xml version="1.0" encoding="UTF-8"?>
<deployments>
  <deployment>
    <links>
      <link href="/api/deployments/394" rel="self"/>
      <link href="/api/deployments/394/servers" rel="servers"/>
      <link href="/api/deployments/394/server_arrays" rel="server_arrays"/>
      <link href="/api/deployments/394/inputs" rel="inputs"/>
    </links>
    <server_tag_scope>deployment</server_tag_scope>
    <description>
</description>
    <name>Default</name>
    <actions></actions>
  </deployment>
  <deployment>
    <links>
. . . 
<deployment>
    <links>
      <link href="/api/deployments/306795001" rel="self"/>
      <link href="/api/deployments/306795001/servers" rel="servers"/>
      <link href="/api/deployments/306795001/server_arrays" rel="server_arrays"/>
      <link href="/api/deployments/306795001/inputs" rel="inputs"/>
    </links>
    <server_tag_scope>deployment</server_tag_scope>
    <description>Test out API 1.5.  Craft examples based on http/curl and right_api_client.  Greg Doe</description>
    <name>GD: API 1.5 Sandbox</name>
    <actions></actions>
  </deployment>
</deployments>

right_api_client

Example Call

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. Display output below.
#
pp @client.deployments.index

Sample Output

[#<RightApi::ResourceDetail resource_type="deployment", name="Default">,
  #<RightApi::ResourceDetail resource_type="deployment", name="RightScale Staging">,
  #<RightApi::ResourceDetail resource_type="deployment", name="GD: API 1.5 Sandbox">,
  #<RightApi::ResourceDetail resource_type="deployment", name="Cloned Resat API 1.5">,
. . .  output abbreviated here . . . 
  #<RightApi::ResourceDetail resource_type="deployment", name="Resat API 1.5">,
  #<RightApi::ResourceDetail resource_type="deployment", name="Ride Deployment - 1354684326633">,
  #<RightApi::ResourceDetail resource_type="deployment", name="QA_rspec_Deployment 1354732811">,
  #<RightApi::ResourceDetail resource_type="deployment", name="Knapp">]

Supplemental

Only Show (Filter) certain Deployments

Similar to the way you can "Filter by Nickname" in the Dashboard UI, this example will only display Deployments that contain "api" in their name. 

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.deployments.index(:filter => ['name==API'])   # ONLY show deployments with "api" in the nickname

Note: If you run the above script (e.g. DeploymentListFilter) and total the number of deployments, it should match the number in the Dashboard (Manage > Deployments) if you "filter by" the same nickname.

For example:

$ ruby DeploymentListFilter | wc -l

58

screen-Deployments.jpg

PowerShell

Prerequisite:  Example assumes you have previously authenticated and your session cookie for subsequent requests is in 'cookieContainer'.

Example Call

#get cookie container from authentication $cookieContainer
$listDeploymentsRequest = [System.Net.WebRequest]::Create("https://my.rightscale.com/api/deployments.xml")
$listDeploymentsRequest.Method = "GET"
$listDeploymentsRequest.CookieContainer = $cookieContainer
$listDeploymentsRequest.Headers.Add("X_API_VERSION", "1.5");
[System.Net.WebResponse] $listDeploymentsResponse = $listDeploymentsRequest.GetResponse()
$listDeploymentsResponseStream = $listDeploymentsResponse.GetResponseStream()
$listDeploymentsResponseStreamReader = New-Object System.IO.StreamReader -argumentList $listDeploymentsResponseStream
[string]$listDeploymentsResponseString = $listDeploymentsResponseStreamReader.ReadToEnd()
write-host $listDeploymentsResponseString

 

Sample Output

See http/curl output.

You must to post a comment.
Last modified
14:07, 30 May 2013

Tags

Classifications

This page has no classifications.

Announcements

None


© 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.