Method: Cloudfuji::Command.put_command

Defined in:
lib/cloudfuji/command.rb

.put_command(url, params, meta = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cloudfuji/command.rb', line 48

def put_command(url, params, meta={})
  @@request_count += 1
  
  if meta[:force]
    params.merge!({:auth_token => Cloudfuji::Platform.key}) if params[:auth_token].nil? unless Cloudfuji::Platform.key.nil?

    begin
      raw = RestClient.put(url, params.to_json,  :content_type => :json)
    rescue # => e
      # puts e.inspect
      @@last_request_successful = false
      return nil
    end

  else
    params.merge!({:auth_token => Cloudfuji::Platform.key}) if params[:auth_token].nil? unless Cloudfuji::Platform.key.nil?

    begin
      raw = RestClient.put(url, params.to_json,  :content_type => :json)
    rescue # => e
      #puts e.inspect
      @@last_request_successful = false
      return nil
    end
  end
  
  @@last_request_successful = true
  @@last_request = JSON.parse raw
end