uptrends 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +30 -5
- data/lib/uptrends/api_client.rb +4 -1
- data/lib/uptrends/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63e0d2b7ad081a62966062a0f10be4a37b1f2990
|
4
|
+
data.tar.gz: a9680e84d9c634a9dfaacdc9935968b6f080b846
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d871f61e0b342f7ceba9ccc91b2ba540000023d4acee35d761d8039ad4f6296aa1a959bc0839b73a6e0e0ba60a501b5dddba88ffaf8c7ad80c718919e22a917
|
7
|
+
data.tar.gz: 275568a6050f301ce8113d843185a1313322dd16ac01082ce44b0f7c2fa1754f80e3aaace5696d32ee4aa8d20b00069c1e179c8da1e8033093182ec9748a94d6
|
data/README.md
CHANGED
@@ -24,15 +24,20 @@ First initialize an instance of the API Client and then we play with it:
|
|
24
24
|
u = Uptrends::ApiClient.new(username: 'my@email.com', password: 'MyP@sswo0rd')
|
25
25
|
# => #<Uptrends::ApiClient:0x00000101309e48 @username="my@email.com">
|
26
26
|
|
27
|
-
|
27
|
+
Query your account for all probes:
|
28
28
|
|
29
29
|
probes = u.probes # Returns an array of probes
|
30
|
-
# => [#<Uptrends::Probe:0x0000010336cac8...>, #<Uptrends::Probe:0x0000010336cac9...>, ... ]
|
30
|
+
# => [#<Uptrends::Probe:0x0000010336cac8 ...>, #<Uptrends::Probe:0x0000010336cac9 ...>, ... ]
|
31
31
|
|
32
|
-
|
32
|
+
Query your account for all probe __groups__:
|
33
|
+
|
34
|
+
probe_groups = u.probe_groups # Returns an array of probe groups
|
35
|
+
# => [#<Uptrends::ProbeGroup:0x000001021594f8 ...>, #<Uptrends::ProbeGroup:0x000001021592f0 ...>, ... ]
|
36
|
+
|
37
|
+
Let's select the first probe and look at it's attributes
|
33
38
|
|
34
39
|
p = probes.first
|
35
|
-
# => #<Uptrends::Probe:0x0000010336cac8...>
|
40
|
+
# => #<Uptrends::Probe:0x0000010336cac8 ...>
|
36
41
|
|
37
42
|
p.attributes
|
38
43
|
# => [:guid, :name, :url, :port, :checkfrequency, :probetype, :isactive, :generatealert, :notes, :performancelimit1, :performancelimit2, :erroronlimit1, :erroronlimit2, :minbytes, :erroronminbytes, :timeout, :tcpconnecttimeout, :matchpattern, :dnslookupmode, :useragent, :username, :password, :iscompetitor, :checkpoints, :httpmethod, :postdata]
|
@@ -43,7 +48,21 @@ Let's select the first one and look at it's attributes
|
|
43
48
|
p.name
|
44
49
|
# => "My Probe's Name"
|
45
50
|
|
46
|
-
|
51
|
+
Let's select the first probe __group__ and look at it's attributes
|
52
|
+
|
53
|
+
pg = probe_groups.first
|
54
|
+
# => #<Uptrends::ProbeGroup:0x000001021594f8 ...>
|
55
|
+
|
56
|
+
pg.attributes
|
57
|
+
# => [:guid, :name, :isall, :isclientprobegroup]
|
58
|
+
|
59
|
+
pg.guid
|
60
|
+
# => "c8d6a0f704494c37823850f3d4fd4273"
|
61
|
+
|
62
|
+
pg.name
|
63
|
+
# => "All probes"
|
64
|
+
|
65
|
+
If you wanted to update the probe, all you need to do is change as many attributes as you want and then update, e.g.
|
47
66
|
|
48
67
|
# Let's change the name of the probe:
|
49
68
|
|
@@ -54,6 +73,12 @@ If you wanted to update the probe, all you need to do is change it's attributes
|
|
54
73
|
response.response
|
55
74
|
# => #<Net::HTTPOK 200 OK readbody=true>
|
56
75
|
|
76
|
+
Let's add our probe to a probe group
|
77
|
+
|
78
|
+
response = u.add_probe_to_group(probe: p, group: pg)
|
79
|
+
response.response
|
80
|
+
# => #<Net::HTTPCreated 201 Created readbody=true>
|
81
|
+
|
57
82
|
## Contributing
|
58
83
|
|
59
84
|
1. Fork it ( https://github.com/jasonwbarnett/uptrends-gem/fork )
|
data/lib/uptrends/api_client.rb
CHANGED
@@ -26,6 +26,10 @@ module Uptrends
|
|
26
26
|
@probes ||= get_probes
|
27
27
|
end
|
28
28
|
|
29
|
+
def probe_groups
|
30
|
+
@probe_groups ||= get_probe_groups
|
31
|
+
end
|
32
|
+
|
29
33
|
def get_probes
|
30
34
|
parsed_response = self.class.get('/probes').parsed_response
|
31
35
|
@probes = parsed_response.inject([]) do |memo, x|
|
@@ -53,7 +57,6 @@ module Uptrends
|
|
53
57
|
|
54
58
|
|
55
59
|
post_body = JSON.dump({"ProbeGuid" => probe_guid})
|
56
|
-
puts "post_body: #{post_body}"
|
57
60
|
self.class.post("/probegroups/#{group_guid}/members", body: post_body)
|
58
61
|
end
|
59
62
|
|
data/lib/uptrends/version.rb
CHANGED