uptrends_extended 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +23 -0
- data/.travis.yml +11 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +9 -0
- data/examples/add_new_probes.rb +71 -0
- data/examples/add_probes_to_probe_group.rb +26 -0
- data/examples/get_checkpoint_ips.rb +12 -0
- data/examples/update_all_probe_attributes.rb +17 -0
- data/lib/uptrends_extended.rb +3 -0
- data/lib/uptrends_extended/api_error.rb +4 -0
- data/lib/uptrends_extended/base.rb +121 -0
- data/lib/uptrends_extended/checkpoint.rb +36 -0
- data/lib/uptrends_extended/client.rb +82 -0
- data/lib/uptrends_extended/probe.rb +32 -0
- data/lib/uptrends_extended/probe_group.rb +48 -0
- data/lib/uptrends_extended/version.rb +3 -0
- data/spec/fixtures/vcr_cassettes/GET_Checkpoints.yml +373 -0
- data/spec/fixtures/vcr_cassettes/GET_Probe.yml +44 -0
- data/spec/fixtures/vcr_cassettes/GET_Probe_Group.yml +43 -0
- data/spec/fixtures/vcr_cassettes/GET_Probe_Groups.yml +49 -0
- data/spec/fixtures/vcr_cassettes/GET_Probes.yml +289 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/uptrends_extended/client_spec.rb +191 -0
- data/spec/uptrends_extended/probe_group_spec.rb +43 -0
- data/spec/uptrends_extended/probe_spec.rb +47 -0
- data/uptrends_extended.gemspec +25 -0
- metadata +118 -0
@@ -0,0 +1,191 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe UptrendsExtended::Client do
|
4
|
+
let(:username) { ENV['UPTRENDS_USERNAME'] }
|
5
|
+
let(:password) { ENV['UPTRENDS_PASSWORD'] }
|
6
|
+
|
7
|
+
describe 'Setting up testing' do
|
8
|
+
it 'should have a username defined in an env varible: UPTRENDS_USERNAME' do
|
9
|
+
username.wont_be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have a password defined in an env varible: UPTRENDS_PASSWORD' do
|
13
|
+
password.wont_be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'must be an instance of UptrendsExtended::Client' do
|
18
|
+
UptrendsExtended::Client.new(username: username, password: password).must_be_instance_of UptrendsExtended::Client
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'Initializing with a username and password is required' do
|
22
|
+
it 'should raise RuntimeError when username is not provided.' do
|
23
|
+
proc { UptrendsExtended::Client.new(password: password) }.must_raise RuntimeError
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should raise RuntimeError when password is not provided.' do
|
27
|
+
proc { UptrendsExtended::Client.new(username: username) }.must_raise RuntimeError
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'default attributes' do
|
32
|
+
it 'must include httparty methods' do
|
33
|
+
UptrendsExtended::Client.must_include HTTParty
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'must have the base url set to the UptrendsExtended API endpoint' do
|
37
|
+
UptrendsExtended::Client.base_uri.must_equal 'https://api.uptrends.com/v3'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'must have the format set to json' do
|
41
|
+
UptrendsExtended::Client.format.must_equal :json
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'When initializing a new UptrendsExtended::Client with a username and password' do
|
46
|
+
let(:uc) { UptrendsExtended::Client.new(username: username, password: password) }
|
47
|
+
|
48
|
+
it 'auth[:username] should match the username provided' do
|
49
|
+
uc.class.default_options[:basic_auth][:username].must_equal username
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'auth[:password] should match the password provided' do
|
53
|
+
uc.class.default_options[:basic_auth][:password].must_equal password
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'default_params[:format] should be set to json' do
|
57
|
+
uc.class.default_params[:format].must_equal 'json'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'headers should be set to application/json' do
|
61
|
+
uc.class.headers.must_equal({'Content-Type' => 'application/json', 'Accept' => 'application/json'})
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'After UptrendsExtended::Client is initialized' do
|
66
|
+
let(:uc) { UptrendsExtended::Client.new(username: username, password: password) }
|
67
|
+
|
68
|
+
it 'should have a #username method' do
|
69
|
+
uc.must_respond_to :username
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should have a #probe method' do
|
73
|
+
uc.must_respond_to :probe
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should have a #probe_group method' do
|
77
|
+
uc.must_respond_to :probe_group
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should have a #probes method' do
|
81
|
+
uc.must_respond_to :probes
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should have a #checkpoints method' do
|
85
|
+
uc.must_respond_to :checkpoints
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should have a #probe_groups method' do
|
89
|
+
uc.must_respond_to :probe_groups
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should have a #add_probe method' do
|
93
|
+
uc.must_respond_to :add_probe
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should have a #add_probe_group method' do
|
97
|
+
uc.must_respond_to :add_probe_group
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'Querying UptrendsExtended' do
|
102
|
+
let(:uc) { UptrendsExtended::Client.new(username: username, password: password) }
|
103
|
+
|
104
|
+
describe '#probe' do
|
105
|
+
before do
|
106
|
+
VCR.insert_cassette('GET Probe', :record => :new_episodes, match_requests_on: [:method, :body, :headers, :query, :path])
|
107
|
+
#Did you mean one of :method, :uri, :body, :headers, :host, :path, :query, :body_as_json?
|
108
|
+
end
|
109
|
+
|
110
|
+
after do
|
111
|
+
VCR.eject_cassette
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should return a single UptrendsExtended::Probe object' do
|
115
|
+
probe = uc.probe('bbfc88d4-8f71-1234-ae02-00c7f479cc90')
|
116
|
+
probe.class.must_equal UptrendsExtended::Probe
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#probes' do
|
121
|
+
before do
|
122
|
+
VCR.insert_cassette('GET Probes', :record => :new_episodes, match_requests_on: [:method, :body, :headers, :query, :path])
|
123
|
+
#Did you mean one of :method, :uri, :body, :headers, :host, :path, :query, :body_as_json?
|
124
|
+
end
|
125
|
+
|
126
|
+
after do
|
127
|
+
VCR.eject_cassette
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should return an array of UptrendsExtended::Probe objects' do
|
131
|
+
probes = uc.probes
|
132
|
+
probes.each do |probe|
|
133
|
+
probe.class.must_equal UptrendsExtended::Probe
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#probe_group' do
|
139
|
+
before do
|
140
|
+
VCR.insert_cassette('GET Probe Group', :record => :new_episodes, match_requests_on: [:method, :body, :headers, :query, :path])
|
141
|
+
#Did you mean one of :method, :uri, :body, :headers, :host, :path, :query, :body_as_json?
|
142
|
+
end
|
143
|
+
|
144
|
+
after do
|
145
|
+
VCR.eject_cassette
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should return a single UptrendsExtended::ProbeGroup object' do
|
149
|
+
probe = uc.probe_group('819ddc84-a4f2-1234-a046-4e40559fde07')
|
150
|
+
probe.class.must_equal UptrendsExtended::ProbeGroup
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#probe_groups' do
|
155
|
+
before do
|
156
|
+
VCR.insert_cassette('GET Probe Groups', :record => :new_episodes, match_requests_on: [:method, :body, :headers, :query, :path])
|
157
|
+
#Did you mean one of :method, :uri, :body, :headers, :host, :path, :query, :body_as_json?
|
158
|
+
end
|
159
|
+
|
160
|
+
after do
|
161
|
+
VCR.eject_cassette
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should return an array of UptrendsExtended::ProbeGroup objects' do
|
165
|
+
probe_groups = uc.probe_groups
|
166
|
+
probe_groups.each do |probe_group|
|
167
|
+
probe_group.class.must_equal UptrendsExtended::ProbeGroup
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#checkpoints' do
|
173
|
+
before do
|
174
|
+
VCR.insert_cassette('GET Checkpoints', :record => :new_episodes, match_requests_on: [:method, :body, :headers, :query, :path])
|
175
|
+
#Did you mean one of :method, :uri, :body, :headers, :host, :path, :query, :body_as_json?
|
176
|
+
end
|
177
|
+
|
178
|
+
after do
|
179
|
+
VCR.eject_cassette
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should return an array of UptrendsExtended::Checkpoint objects' do
|
183
|
+
checkpoints = uc.checkpoints
|
184
|
+
checkpoints.each do |checkpoint|
|
185
|
+
checkpoint.class.must_equal UptrendsExtended::Checkpoint
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe UptrendsExtended::ProbeGroup do
|
4
|
+
let(:username) { ENV['UPTRENDS_USERNAME'] }
|
5
|
+
let(:password) { ENV['UPTRENDS_PASSWORD'] }
|
6
|
+
let(:uc) { UptrendsExtended::Client.new(username: username, password: password) }
|
7
|
+
let(:up) { UptrendsExtended::ProbeGroup.new(uc, nil, {'Guid' => 'myguid', 'Name' => 'myvalue', 'other' => 'thing'}) }
|
8
|
+
|
9
|
+
it '#guid' do
|
10
|
+
up.must_respond_to :guid
|
11
|
+
up.guid.must_equal 'myguid'
|
12
|
+
end
|
13
|
+
|
14
|
+
it '#guid= must NOT exist' do
|
15
|
+
up.wont_respond_to :guid=
|
16
|
+
end
|
17
|
+
|
18
|
+
it '#name' do
|
19
|
+
up.must_respond_to :name
|
20
|
+
up.name.must_equal 'myvalue'
|
21
|
+
end
|
22
|
+
|
23
|
+
it '#name=' do
|
24
|
+
up.must_respond_to :name=
|
25
|
+
up.name = 'updates to hello_you='
|
26
|
+
up.name.must_equal 'updates to hello_you='
|
27
|
+
end
|
28
|
+
|
29
|
+
it '#other' do
|
30
|
+
up.must_respond_to :other
|
31
|
+
up.other.must_equal 'thing'
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#other=' do
|
35
|
+
up.must_respond_to :other=
|
36
|
+
up.other = 'updates to other'
|
37
|
+
up.other.must_equal 'updates to other'
|
38
|
+
end
|
39
|
+
|
40
|
+
it '#to_s' do
|
41
|
+
up.to_s.must_equal "guid: myguid\nname: myvalue\nother: thing"
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe UptrendsExtended::Probe do
|
4
|
+
let(:username) { ENV['UPTRENDS_USERNAME'] }
|
5
|
+
let(:password) { ENV['UPTRENDS_PASSWORD'] }
|
6
|
+
let(:uc) { UptrendsExtended::Client.new(username: username, password: password) }
|
7
|
+
let(:up) { UptrendsExtended::Probe.new(uc, nil, {'Guid' => 'myguid', 'HelloYou' => 'myvalue', 'other' => 'thing'}) }
|
8
|
+
|
9
|
+
it '#guid' do
|
10
|
+
up.must_respond_to :guid
|
11
|
+
up.guid.must_equal 'myguid'
|
12
|
+
end
|
13
|
+
|
14
|
+
it '#guid= must NOT exist' do
|
15
|
+
up.wont_respond_to :guid=
|
16
|
+
end
|
17
|
+
|
18
|
+
it '#hello_you' do
|
19
|
+
up.must_respond_to :hello_you
|
20
|
+
up.hello_you.must_equal 'myvalue'
|
21
|
+
end
|
22
|
+
|
23
|
+
it '#hello_you=' do
|
24
|
+
up.must_respond_to :hello_you=
|
25
|
+
up.hello_you = 'updates to hello_you='
|
26
|
+
up.hello_you.must_equal 'updates to hello_you='
|
27
|
+
end
|
28
|
+
|
29
|
+
it '#other' do
|
30
|
+
up.must_respond_to :other
|
31
|
+
up.other.must_equal 'thing'
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#other=' do
|
35
|
+
up.must_respond_to :other=
|
36
|
+
up.other = 'updates to other'
|
37
|
+
up.other.must_equal 'updates to other'
|
38
|
+
end
|
39
|
+
|
40
|
+
it '#to_s' do
|
41
|
+
up.to_s.must_equal "guid: myguid\nhello_you: myvalue\nother: thing"
|
42
|
+
end
|
43
|
+
|
44
|
+
it '#api_url (private)' do
|
45
|
+
up.send(:api_url).must_equal '/probes'
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uptrends_extended/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'uptrends_extended'
|
8
|
+
spec.version = UptrendsExtended::VERSION
|
9
|
+
spec.authors = ['Jason Barnett', 'René Schultz Madsen']
|
10
|
+
spec.email = %w(J@sonBarnett.com rm@microting.com)
|
11
|
+
spec.summary = %q{Ruby wrapper around the Uptrends API, http://www.uptrends.com/}
|
12
|
+
spec.description = %Q{This is a ruby wrapper around the Uptrends API. Uptrends is a monitoring service that let's you monitor Web pages, Web services, Mail servers, Database servers, DNS, SSL certificates, FTP and more.\n\nNOTE: This is a 3rd party gem and not an official product from Uptrends.}
|
13
|
+
spec.homepage = 'https://github.com/microting/uptrends-gem'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.required_ruby_version = '>= 1.9.3'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'httparty', '~> 0.13'
|
24
|
+
spec.add_dependency 'activesupport', '~> 3.2'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uptrends_extended
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Barnett
|
8
|
+
- René Schultz Madsen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.13'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.13'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activesupport
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3.2'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3.2'
|
42
|
+
description: ! 'This is a ruby wrapper around the Uptrends API. Uptrends is a monitoring
|
43
|
+
service that let''s you monitor Web pages, Web services, Mail servers, Database
|
44
|
+
servers, DNS, SSL certificates, FTP and more.
|
45
|
+
|
46
|
+
|
47
|
+
NOTE: This is a 3rd party gem and not an official product from Uptrends.'
|
48
|
+
email:
|
49
|
+
- J@sonBarnett.com
|
50
|
+
- rm@microting.com
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- .travis.yml
|
57
|
+
- CHANGELOG.md
|
58
|
+
- Gemfile
|
59
|
+
- LICENSE.txt
|
60
|
+
- README.md
|
61
|
+
- Rakefile
|
62
|
+
- examples/add_new_probes.rb
|
63
|
+
- examples/add_probes_to_probe_group.rb
|
64
|
+
- examples/get_checkpoint_ips.rb
|
65
|
+
- examples/update_all_probe_attributes.rb
|
66
|
+
- lib/uptrends_extended.rb
|
67
|
+
- lib/uptrends_extended/api_error.rb
|
68
|
+
- lib/uptrends_extended/base.rb
|
69
|
+
- lib/uptrends_extended/checkpoint.rb
|
70
|
+
- lib/uptrends_extended/client.rb
|
71
|
+
- lib/uptrends_extended/probe.rb
|
72
|
+
- lib/uptrends_extended/probe_group.rb
|
73
|
+
- lib/uptrends_extended/version.rb
|
74
|
+
- spec/fixtures/vcr_cassettes/GET_Checkpoints.yml
|
75
|
+
- spec/fixtures/vcr_cassettes/GET_Probe.yml
|
76
|
+
- spec/fixtures/vcr_cassettes/GET_Probe_Group.yml
|
77
|
+
- spec/fixtures/vcr_cassettes/GET_Probe_Groups.yml
|
78
|
+
- spec/fixtures/vcr_cassettes/GET_Probes.yml
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/uptrends_extended/client_spec.rb
|
81
|
+
- spec/uptrends_extended/probe_group_spec.rb
|
82
|
+
- spec/uptrends_extended/probe_spec.rb
|
83
|
+
- uptrends_extended.gemspec
|
84
|
+
homepage: https://github.com/microting/uptrends-gem
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.9.3
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.4.6
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Ruby wrapper around the Uptrends API, http://www.uptrends.com/
|
108
|
+
test_files:
|
109
|
+
- spec/fixtures/vcr_cassettes/GET_Checkpoints.yml
|
110
|
+
- spec/fixtures/vcr_cassettes/GET_Probe.yml
|
111
|
+
- spec/fixtures/vcr_cassettes/GET_Probe_Group.yml
|
112
|
+
- spec/fixtures/vcr_cassettes/GET_Probe_Groups.yml
|
113
|
+
- spec/fixtures/vcr_cassettes/GET_Probes.yml
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- spec/uptrends_extended/client_spec.rb
|
116
|
+
- spec/uptrends_extended/probe_group_spec.rb
|
117
|
+
- spec/uptrends_extended/probe_spec.rb
|
118
|
+
has_rdoc:
|