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 > Delete Server

Delete Server

Delete a server based on the specified server ID.

icon_curl_v1.png    icon_rs_api_client_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
SERVER="532922001"
curl -i -H X_API_VERSION:1.5 -b mycookie -X DELETE https://my.rightscale.com/api/servers/$SERVER

Sample Output

Notes

  • There is no XML/JSON content, just headers.
  • You cannot delete a running Server, or a "next" server.  (HTTP 422 and "ActionNotAllowed: The server has a current instance.")
HTTP/1.1 204 No Content
Server: nginx/1.0.15
Date: Fri, 12 Oct 2012 16:25:00 GMT
Connection: keep-alive
Status: 204 No Content
X-Runtime: 1390
X-Request-Uuid: 6c1eb0c8c21b4835ad425d1bb6fb2b59
Set-Cookie: _session_id=92ede080c999a3e5734035f582d11b0e; path=/; Secure; HttpOnly
Cache-Control: no-cache

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 = '626129001'
pp @client.servers(:id => server_id).destroy

Sample Output

nil

If the "destroy" method was not prefaced with "pp" (pretty print), then no output is returned, the action (delete/destroy) is executed with no output.

Note:  Similar to the http/curl example, you cannot delete a running or "next" server.  In the above right_api_client call you will receive a message similar to:

/usr/lib64/ruby/gems/1.8/gems/right_api_client-1.5.9/lib/right_api_client/client.rb:215:in `do_delete': Error: HTTP Code: 422, Response body: ActionNotAllowed: The server has a current instance. (RightApi::Exceptions::ApiException)

 

You must to post a comment.
Last modified
14:21, 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.