class UptrendsExtended::Client
Attributes
username[R]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/uptrends_extended/client.rb, line 14 def initialize(opts = {}) @username = opts[:username] ? opts[:username] : fail('You must specify the :username option') password = opts[:password] ? opts[:password] : fail('You must specify the :password option') # This makes it so that every request uses basic auth self.class.basic_auth(@username, password) # This makes it so that every request uses ?format=json self.class.default_params({format: 'json'}) # This makes it so that every request uses ?format=json self.class.headers({'Content-Type' => 'application/json', 'Accept' => 'application/json'}) end
Public Instance Methods
add_probe(opts = {})
click to toggle source
# File lib/uptrends_extended/client.rb, line 46 def add_probe(opts = {}) p = UptrendsExtended::Probe.new(self, nil, opts) p.create! end
add_probe_group(opts = {})
click to toggle source
# File lib/uptrends_extended/client.rb, line 51 def add_probe_group(opts = {}) pg = UptrendsExtended::ProbeGroup.new(self, nil, opts) pg.create! end
checkpoints()
click to toggle source
# File lib/uptrends_extended/client.rb, line 38 def checkpoints get(UptrendsExtended::Checkpoint, all: true) end
probe(guid)
click to toggle source
# File lib/uptrends_extended/client.rb, line 26 def probe(guid) get(UptrendsExtended::Probe, guid: guid) end
probe_group(guid)
click to toggle source
# File lib/uptrends_extended/client.rb, line 30 def probe_group(guid) get(UptrendsExtended::ProbeGroup, guid: guid) end
probe_groups()
click to toggle source
# File lib/uptrends_extended/client.rb, line 42 def probe_groups get(UptrendsExtended::ProbeGroup, all: true) end
probes()
click to toggle source
# File lib/uptrends_extended/client.rb, line 34 def probes get(UptrendsExtended::Probe, all: true) end
Private Instance Methods
get(type, opts = {})
click to toggle source
# File lib/uptrends_extended/client.rb, line 57 def get(type, opts = {}) all = opts[:all] ? opts[:all] : false guid = opts[:guid] ? opts[:guid] : nil if type == UptrendsExtended::Probe uri = '/probes' elsif type == UptrendsExtended::ProbeGroup uri = '/probegroups' elsif type == UptrendsExtended::Checkpoint uri = '/checkpointservers' else fail('You passed an unknown type. Try UptrendsExtended::Probe, UptrendsExtended::ProbeGroup or UptrendsExtended::Checkpoint') end if all response = self.class.get(uri) elsif guid response = self.class.get("#{uri}/#{guid}") end type.parse(self, response) end