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 > Servers > Show Server

Show Server

Show the information on a single server.

icon_curl_v1.png    icon_rs_api_client_v1.png  

Table of Contents

Curl

Example Call

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

#!/bin/sh -e
SERVER="527725001"
curl -i -H X_API_VERSION:1.5 -b mycookie -X GET https://my.rightscale.com/api/servers/$SERVER.xml

Sample Output

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

<server>
  <updated_at>2012/10/09 21:42:04 +0000</updated_at>
  <links>
    <link href="/api/servers/527725001" rel="self"/>
    <link href="/api/deployments/306795001" rel="deployment"/>
    <link href="/api/clouds/2112/instances/2BFJC99QC8FJA" rel="current_instance"/>
    <link href="/api/clouds/2112/instances/B469CS55K5VRQ" rel="next_instance"/>
    <link href="/api/servers/527725001/alert_specs" rel="alert_specs"/>
  </links>
  <description></description>
  <created_at>2012/10/09 21:41:34 +0000</created_at>
  <name>Base ServerTemplate for Linux (v12.11.0-LTS)</name>
  <actions>
    <action rel="terminate"/>
  </actions>
  <state>operational</state>
</server>

 

Note: If your server ID is incorrect, you will receive:

  • HTTP 422 Unprocessable Entity
  • ResourceNotFound: Couldn't find Server with ID=123456789

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. Set and use additional variables below, display output, etc.
#
server_id = '527725001'
pp @client.servers(:id => server_id).show

Sample Output

#<RightApi::ResourceDetail resource_type="server", name="Base ServerTemplate for Linux (v12.11.0-LTS)">

 

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
$SERVER='761004'      # Set the Server ID. Obtain via the API or Dashboard navigation and the URL.

$webRequest = [System.Net.WebRequest]::Create("https://my.rightscale.com/api/servers/$SERVER.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

Sample Output

Same as the bash/curl output.

 

 

You must to post a comment.
Last modified
09:59, 11 Oct 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.