Create a gist now

Instantly share code, notes, and snippets.

# An example of using Cloudkick's oauth API. Make sure the
# key you're using has read/write privileges (the default
# is just execute privileges). You'll need the json and
# the oauth gems installed as well for this to work properly.
require 'rubygems'
require 'oauth'
require 'json'
# make the consumer out of your secret and key
consumer_key = "<key>"
consumer_secret = "<secret>"
consumer =, consumer_secret,
:site => "",
:http_method => :get)
# make the access token from your consumer
access_token =
# make a signed request!
req = access_token.get("/1.0/query/nodes")
case req.response.code
when "200"
nodes = JSON.parse(req.response.body, :symbolize_names => true)
puts "error: #{req.inspect}"
# loop through all nodes, removing any that have agents in the disconnected state
nodes.each do |node|
if node[:agent_state] == "disconnected"
puts "removing #{node[:name]}..."
req = access_token.delete("/1.0/node/#{node[:id]}")
puts req.inspect # 204 => successful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment