pingdom-cli 0.2.0 → 0.3.0
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/bin/pingdom-cli +0 -2
- data/lib/pingdom/cli/cli.rb +19 -8
- data/lib/pingdom/cli/core.rb +31 -20
- data/lib/pingdom/cli/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d26b9daf54a57d95ad034c06430f3bc6dce57358
|
|
4
|
+
data.tar.gz: 58256c3143d356b4f68eb8acd21844f4c195c5de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9fdbc50dbe9338006c0e409791e0a3b66ef27fcd210b1562d52e50c1a47c745a462f74f8dac947f40e486b4e52112ed3bb3c52be1f71d940afd2b8f979018d2b
|
|
7
|
+
data.tar.gz: 996b2788483c515e6335073705361d66f671beca3538a725d944610fb2b9f3f41daf346cf80b3f51098e81e020d49928f95fad9125f8fa8b4fa731c6e7d016ee
|
data/bin/pingdom-cli
CHANGED
data/lib/pingdom/cli/cli.rb
CHANGED
|
@@ -19,42 +19,47 @@ module Pingdom
|
|
|
19
19
|
|
|
20
20
|
desc "config", "config"
|
|
21
21
|
def config
|
|
22
|
-
|
|
22
|
+
puts_json @config
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
desc "checks", "checks"
|
|
26
26
|
def checks
|
|
27
|
-
|
|
27
|
+
puts_json @core.checks
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
desc "actions", "actions"
|
|
31
31
|
def actions
|
|
32
|
-
|
|
32
|
+
puts_json @core.actions
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
desc "contacts", "contacts"
|
|
36
36
|
def contacts
|
|
37
|
-
|
|
37
|
+
puts_json @core.contacts
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
desc "probes", "probes"
|
|
41
41
|
def probes
|
|
42
|
-
|
|
42
|
+
puts_json @core.probes
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
desc "reference", "reference"
|
|
46
46
|
def reference
|
|
47
|
-
|
|
47
|
+
puts_json @core.reference
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
desc "reports_public", "reports_public"
|
|
51
51
|
def reports_public
|
|
52
|
-
|
|
52
|
+
puts_json @core.reports_public
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
desc "settings", "settings"
|
|
56
56
|
def settings
|
|
57
|
-
|
|
57
|
+
puts_json @core.settings
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc "credits", "credits"
|
|
61
|
+
def credits
|
|
62
|
+
puts_json @core.credits
|
|
58
63
|
end
|
|
59
64
|
|
|
60
65
|
desc "pause", "pause"
|
|
@@ -72,6 +77,12 @@ module Pingdom
|
|
|
72
77
|
def update
|
|
73
78
|
puts @core.update(options['params'])
|
|
74
79
|
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
def puts_json(object)
|
|
84
|
+
puts JSON.pretty_generate(object)
|
|
85
|
+
end
|
|
75
86
|
end
|
|
76
87
|
end
|
|
77
88
|
end
|
data/lib/pingdom/cli/core.rb
CHANGED
|
@@ -7,59 +7,70 @@ module Pingdom
|
|
|
7
7
|
|
|
8
8
|
def initialize(config)
|
|
9
9
|
@config = config
|
|
10
|
-
@url_base = "https
|
|
11
|
-
@header = {"App-Key" => @config['app_key']}
|
|
10
|
+
@url_base = "https://api.pingdom.com/api/2.0/"
|
|
11
|
+
@header = { "App-Key" => @config['app_key'] }
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def checks
|
|
15
|
-
response =
|
|
15
|
+
response = get_resource('checks').get
|
|
16
16
|
results = JSON.parse(response.body, :symbolize_names => true)
|
|
17
|
-
results[
|
|
17
|
+
results[__method__].each do |result|
|
|
18
18
|
result[:lasttesttime] = Time.at(result[:lasttesttime]) unless result[:lasttesttime].nil?
|
|
19
19
|
result[:lasterrortime] = Time.at(result[:lasterrortime]) unless result[:lasterrortime].nil?
|
|
20
20
|
result[:created] = Time.at(result[:created]) unless result[:created].nil?
|
|
21
21
|
end
|
|
22
|
-
results
|
|
22
|
+
results[__method__]
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def actions
|
|
26
|
-
response =
|
|
27
|
-
JSON.parse(response.body, :symbolize_names => true)
|
|
26
|
+
response = get_resource('actions').get
|
|
27
|
+
JSON.parse(response.body, :symbolize_names => true)[__method__]
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def contacts
|
|
31
|
-
response =
|
|
32
|
-
JSON.parse(response.body, :symbolize_names => true)
|
|
31
|
+
response = get_resource('contacts').get
|
|
32
|
+
JSON.parse(response.body, :symbolize_names => true)[__method__]
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def probes
|
|
36
|
-
response =
|
|
37
|
-
JSON.parse(response.body, :symbolize_names => true)
|
|
36
|
+
response = get_resource('probes').get
|
|
37
|
+
JSON.parse(response.body, :symbolize_names => true)[__method__]
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def reference
|
|
41
|
-
response =
|
|
42
|
-
JSON.parse(response.body, :symbolize_names => true)
|
|
41
|
+
response = get_resource('reference').get
|
|
42
|
+
JSON.parse(response.body, :symbolize_names => true)[__method__]
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def reports_public
|
|
46
|
-
response =
|
|
47
|
-
JSON.parse(response.body, :symbolize_names => true)
|
|
46
|
+
response = get_resource('reports.public').get
|
|
47
|
+
JSON.parse(response.body, :symbolize_names => true)[__method__]
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def settings
|
|
51
|
-
response =
|
|
52
|
-
JSON.parse(response.body, :symbolize_names => true)
|
|
51
|
+
response = get_resource('settings').get
|
|
52
|
+
JSON.parse(response.body, :symbolize_names => true)[__method__]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def credits
|
|
56
|
+
response = get_resource('credits').get
|
|
57
|
+
JSON.parse(response.body, :symbolize_names => true)[__method__]
|
|
53
58
|
end
|
|
54
59
|
|
|
55
60
|
def update(params)
|
|
56
|
-
response =
|
|
61
|
+
response = get_resource('checks').put(params)
|
|
57
62
|
response.body
|
|
58
63
|
end
|
|
59
64
|
|
|
60
65
|
private
|
|
61
|
-
def
|
|
62
|
-
|
|
66
|
+
def get_resource(action)
|
|
67
|
+
resource = RestClient::Resource.new(
|
|
68
|
+
@url_base + action,
|
|
69
|
+
:user => @config['user'],
|
|
70
|
+
:password => @config['password'],
|
|
71
|
+
:headers => { 'App-Key' => @config['app_key'] },
|
|
72
|
+
:verify_ssl => false
|
|
73
|
+
)
|
|
63
74
|
end
|
|
64
75
|
end
|
|
65
76
|
end
|
data/lib/pingdom/cli/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pingdom-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hiroshi Toyama
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
182
182
|
version: '0'
|
|
183
183
|
requirements: []
|
|
184
184
|
rubyforge_project:
|
|
185
|
-
rubygems_version: 2.
|
|
185
|
+
rubygems_version: 2.4.2
|
|
186
186
|
signing_key:
|
|
187
187
|
specification_version: 4
|
|
188
188
|
summary: pingdom simple command line interface
|