pingdom-cli 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05c6ccfa4fce781ee7ff2f29c52e9bce2016c69d
4
- data.tar.gz: f410898d6418681582e5acc46829e5f7bd491f93
3
+ metadata.gz: 0ffa63ace83f83dd9b97e1dd159ba7a753f70d41
4
+ data.tar.gz: 0b16ddc7d7e923543e228472541122220b76f24c
5
5
  SHA512:
6
- metadata.gz: 2367cdad02781b39ac8fa9b1b1c7cb6dd73c3566ca9c15e6e31842e5a4b082627a11a276aee7fe55df5ecc0f72b1586c2cb7e3d7a49cfdf7755a1116b94f05ac
7
- data.tar.gz: 4195282a2d201c071313a62b20a7b5b380f84afd4375ac2306fe85bcfb3ddff292bdb13dd4b5d2f3a7a7d87df0b14b789aa960ce95cf4c3f2eae2bd9c0ce431a
6
+ metadata.gz: 07d58bfd20ee1718ca48e8d9b4816beb6ba7293a350333e48dc22dcc007519c933b55c29f331f592487494f9938485472ad0b590c88c77bb1d56337731b6d9bc
7
+ data.tar.gz: 0823efdca46119122eebfe6f2a4863f9d251b16af724cfe2033f9eb49634e29e2fc1423685b60684bfe31915eabaebe4317fdcbcea70126877714ed32315f350
data/README.md CHANGED
@@ -16,6 +16,16 @@ pingdom simple command line interface
16
16
 
17
17
  $ pingdom-cli unpause
18
18
 
19
+ ## Settings
20
+
21
+ create $HOME/.pingdomrc
22
+
23
+ ```yaml
24
+ user: 'hogehoge@gmail.com'
25
+ password: 'hogehoge'
26
+ app_key: '123456hogehogehogehogehogehogehogehogehogehoge'
27
+ ```
28
+
19
29
  ## Installation
20
30
 
21
31
  Add this line to your application's Gemfile:
@@ -27,6 +27,36 @@ module Pingdom
27
27
  puts @core.checks.to_json
28
28
  end
29
29
 
30
+ desc "actions", "actions"
31
+ def actions
32
+ puts @core.actions.to_json
33
+ end
34
+
35
+ desc "contacts", "contacts"
36
+ def contacts
37
+ puts @core.contacts.to_json
38
+ end
39
+
40
+ desc "probes", "probes"
41
+ def probes
42
+ puts @core.probes.to_json
43
+ end
44
+
45
+ desc "reference", "reference"
46
+ def reference
47
+ puts @core.reference.to_json
48
+ end
49
+
50
+ desc "reports_public", "reports_public"
51
+ def reports_public
52
+ puts @core.reports_public.to_json
53
+ end
54
+
55
+ desc "settings", "settings"
56
+ def settings
57
+ puts @core.settings.to_json
58
+ end
59
+
30
60
  desc "pause", "pause"
31
61
  def pause
32
62
  puts @core.update({ paused: true })
@@ -7,20 +7,60 @@ module Pingdom
7
7
 
8
8
  def initialize(config)
9
9
  @config = config
10
- @url = "https://#{CGI::escape @config['user']}:#{CGI::escape @config['password']}@api.pingdom.com/api/2.0/checks"
10
+ @url_base = "https://#{CGI::escape @config['user']}:#{CGI::escape @config['password']}@api.pingdom.com/api/2.0/"
11
11
  @header = {"App-Key" => @config['app_key']}
12
12
  end
13
13
 
14
14
  def checks
15
- response = RestClient.get(@url, @header)
15
+ response = RestClient.get(get_url('checks'), @header)
16
+ results = JSON.parse(response.body, :symbolize_names => true)
17
+ results[:checks].each do |result|
18
+ result[:lasttesttime] = Time.at(result[:lasttesttime]) unless result[:lasttesttime].nil?
19
+ result[:lasterrortime] = Time.at(result[:lasterrortime]) unless result[:lasterrortime].nil?
20
+ result[:created] = Time.at(result[:created]) unless result[:created].nil?
21
+ end
22
+ results
23
+ end
24
+
25
+ def actions
26
+ response = RestClient.get(get_url('actions'), @header)
27
+ JSON.parse(response.body, :symbolize_names => true)
28
+ end
29
+
30
+ def contacts
31
+ response = RestClient.get(get_url('contacts'), @header)
32
+ JSON.parse(response.body, :symbolize_names => true)
33
+ end
34
+
35
+ def probes
36
+ response = RestClient.get(get_url('probes'), @header)
37
+ JSON.parse(response.body, :symbolize_names => true)
38
+ end
39
+
40
+ def reference
41
+ response = RestClient.get(get_url('reference'), @header)
42
+ JSON.parse(response.body, :symbolize_names => true)
43
+ end
44
+
45
+ def reports_public
46
+ response = RestClient.get(get_url('reports.public'), @header)
47
+ JSON.parse(response.body, :symbolize_names => true)
48
+ end
49
+
50
+ def settings
51
+ response = RestClient.get(get_url('settings'), @header)
16
52
  JSON.parse(response.body, :symbolize_names => true)
17
53
  end
18
54
 
19
55
  def update(params)
20
- response = RestClient.put(@url, params, @header)
56
+ response = RestClient.put(get_url('checks'), params, @header)
21
57
  response.body
22
58
  end
23
59
 
60
+ private
61
+ def get_url(action)
62
+ @url_base + action
63
+ end
24
64
  end
25
65
  end
26
66
  end
@@ -1,6 +1,6 @@
1
1
  module Pingdom
2
2
  module Cli
3
3
  # pingdom-cli version
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
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.1.0
4
+ version: 0.2.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: 2014-09-26 00:00:00.000000000 Z
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor