class Uptrends::ProbeGroup
Public Instance Methods
add_probe(probe)
click to toggle source
# File lib/uptrends/probe_group.rb, line 6 def add_probe(probe) probe_operation(probe, :post) end
members()
click to toggle source
# File lib/uptrends/probe_group.rb, line 14 def members fail("This group does not have a guid.") unless self.attributes.include?(:guid) response = @client.class.get("#{api_url}/#{@guid}/members") self.class.check_error!(response) Uptrends::Probe.parse(self, response) end
remove_probe(probe)
click to toggle source
# File lib/uptrends/probe_group.rb, line 10 def remove_probe(probe) probe_operation(probe, :delete) end
Private Instance Methods
api_url()
click to toggle source
# File lib/uptrends/probe_group.rb, line 23 def api_url "/probegroups" end
probe_operation(probe, method)
click to toggle source
# File lib/uptrends/probe_group.rb, line 27 def probe_operation(probe, method) fail("You must pass an Uptrends::Probe") unless Uptrends::Probe === probe fail("The probe you passed does not have a guid.") unless probe.attributes.include?(:guid) fail("This group does not have a guid.") unless self.attributes.include?(:guid) body = JSON.dump({"ProbeGuid" => probe.guid}) response = @client.class.send(method, "#{api_url}/#{@guid}/members", body: body) self.class.check_error!(response) parsed_response = response.parsed_response if parsed_response.nil? parsed_response else group_guid = parsed_response['Guid'] probe_guid = parsed_response['ProbeGuid'] [ @client.probe_group(group_guid), @client.probe(probe_guid) ] end end