lib/ragios-client.rb in ragios-client-0.0.4 vs lib/ragios-client.rb in ragios-client-0.0.5

- old
+ new

@@ -13,22 +13,22 @@ attr_reader :password def initialize(args = {}) @address = args.fetch(:address, 'http://127.0.0.1') @port = args.fetch(:port, '5041') - @username = args.fetch(:username, '') - @password = args.fetch(:password, '') + @username = args.fetch(:username, nil) + @password = args.fetch(:password, nil) end def login(username,password) @username = username @password = password auth_session end - def add(monitors) - api_request { RestClient.post "#{address_port}/monitors/", generate_json(monitors), http_request_options } + def add(monitor) + api_request { RestClient.post "#{address_port}/monitors/", generate_json(monitor), http_request_options } end def find(monitor_id) api_request { RestClient.get "#{address_port}/monitors/#{monitor_id}/", auth_cookie } end def all @@ -87,9 +87,10 @@ def parse_json(str) JSON.parse(str, symbolize_names: true) end def auth_session + return "" if [@username, @password].any? { |e| e.nil? } auth = RestClient.post "#{address_port}/session", { :username=> @username, :password => @password} hash = parse_json(auth) hash[:AuthSession] rescue => e raise_error(e)