Skip to content

Instantly share code, notes, and snippets.

@sean3z
Created March 11, 2016 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sean3z/7077c1d3e1f03ff8c54c to your computer and use it in GitHub Desktop.
Save sean3z/7077c1d3e1f03ff8c54c to your computer and use it in GitHub Desktop.
why do I suck
require 'rest-client'
class Reports
def initialize(host, args={})
@host = host
@username = args[:username] || 'exampleuser'
@password = args[:password] || 'examplepass'
@foreman_host = args[:foreman_host] || 'http://foreman.example.com'
end
def all_reports
JSON.parse(request('/api/path/1').get)
end
def last_report
JSON.parse(request('/api/path/2').get)
end
def request(path)
return RestClient::Resource.new({:url => @foreman_host.concat(path), :username => 'exampleuser', :password => 'examplepass'})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment