Class: Uptrends::Client
- Inherits:
-
Object
- Object
- Uptrends::Client
- Includes:
- HTTParty
- Defined in:
- lib/uptrends/client.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #add_probe(opts = {}) ⇒ Object
- #add_probe_group(opts = {}) ⇒ Object
- #checkpoints ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #probe(guid) ⇒ Object
- #probe_group(guid) ⇒ Object
- #probe_groups ⇒ Object
- #probes ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/uptrends/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") @debug = opts[:debug] # 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 |
Instance Attribute Details
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
12 13 14 |
# File 'lib/uptrends/client.rb', line 12 def debug @debug end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
12 13 14 |
# File 'lib/uptrends/client.rb', line 12 def username @username end |
Instance Method Details
#add_probe(opts = {}) ⇒ Object
47 48 49 50 |
# File 'lib/uptrends/client.rb', line 47 def add_probe(opts = {}) p = Uptrends::Probe.new(self, nil, opts) p.create! end |
#add_probe_group(opts = {}) ⇒ Object
52 53 54 55 |
# File 'lib/uptrends/client.rb', line 52 def add_probe_group(opts = {}) pg = Uptrends::ProbeGroup.new(self, nil, opts) pg.create! end |
#checkpoints ⇒ Object
39 40 41 |
# File 'lib/uptrends/client.rb', line 39 def checkpoints get(Uptrends::Checkpoint, all: true) end |
#probe(guid) ⇒ Object
27 28 29 |
# File 'lib/uptrends/client.rb', line 27 def probe(guid) get(Uptrends::Probe, guid: guid) end |
#probe_group(guid) ⇒ Object
31 32 33 |
# File 'lib/uptrends/client.rb', line 31 def probe_group(guid) get(Uptrends::ProbeGroup, guid: guid) end |
#probe_groups ⇒ Object
43 44 45 |
# File 'lib/uptrends/client.rb', line 43 def probe_groups get(Uptrends::ProbeGroup, all: true) end |