beeper 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/ruby
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-18mode # JRuby in 1.8 mode
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-18mode
7
+ - rbx-19mode
8
+ - 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in beeper.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Trae Robrock
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Beeper
2
+ [![Build Status](https://travis-ci.org/trobrock/beeper.png?branch=master)](https://travis-ci.org/trobrock/beeper)
3
+
4
+ Simple api wrapper for PagerDuty
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'beeper'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install beeper
19
+
20
+ ## Usage
21
+
22
+ TODO: Write usage instructions here
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/beeper.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'beeper/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "beeper"
8
+ gem.version = Beeper::VERSION
9
+ gem.authors = ["Trae Robrock"]
10
+ gem.email = ["trobrock@gmail.com"]
11
+ gem.description = %q{Simple api wrapper for PagerDuty}
12
+ gem.summary = %q{Simple api wrapper for PagerDuty}
13
+ gem.homepage = "https://github.com/trobrock/beeper"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "faraday", "~> 0.8.4"
21
+ gem.add_dependency "faraday_middleware", "~> 0.9.0"
22
+ gem.add_dependency "rash", "~> 0.3.2"
23
+ gem.add_dependency "json", "~> 1.7.5"
24
+
25
+ gem.add_development_dependency "rake", "~> 10.0.2"
26
+ gem.add_development_dependency "rspec", "~> 2.12.0"
27
+ gem.add_development_dependency "mocha", "~> 0.13.1"
28
+ gem.add_development_dependency "vcr", "~> 2.3.0"
29
+ gem.add_development_dependency "webmock", "~> 1.8.0"
30
+ end
@@ -0,0 +1,61 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module Beeper
5
+ class Client
6
+ attr_accessor :api_key, :subdomain, :requester_id
7
+
8
+ def configured?
9
+ !@api_key.nil? && !@subdomain.nil?
10
+ end
11
+
12
+ def incidents
13
+ get(:incidents)
14
+ end
15
+
16
+ def services
17
+ get(:services)
18
+ end
19
+
20
+ def maintenance_windows(options={})
21
+ get(:maintenance_windows, options)
22
+ end
23
+
24
+ def create_maintenance_window(maintenance_window)
25
+ post(:maintenance_windows, maintenance_window)
26
+ end
27
+
28
+ private
29
+
30
+ def get(collection, options={})
31
+ results = connection.get(collection.to_s, options)
32
+ results.body.send(collection.to_sym)
33
+ end
34
+
35
+ def post(collection, options={})
36
+ options = authenticated_post_options.merge(collection.to_s[0..-2].to_sym => options)
37
+
38
+ results = connection.post(collection.to_s, options)
39
+ results.body
40
+ end
41
+
42
+ def authenticated_post_options
43
+ {
44
+ :requester_id => @requester_id
45
+ }
46
+ end
47
+
48
+ def connection
49
+ @connection ||= Faraday.new("https://#@subdomain.pagerduty.com/api/v1") do |conn|
50
+ conn.request :json
51
+ conn.token_auth @api_key
52
+
53
+ conn.response :rashify
54
+ conn.response :json, :content_type => /\bjson$/
55
+
56
+ conn.adapter Faraday.default_adapter
57
+ end
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module Beeper
2
+ VERSION = "0.0.1"
3
+ end
data/lib/beeper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require "beeper/version"
2
+ require "beeper/client"
3
+
4
+ module Beeper
5
+ def self.configure
6
+ client = Client.new
7
+ yield client
8
+ client
9
+ end
10
+ end
@@ -0,0 +1,163 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Beeper::Client do
4
+ use_vcr_cassette
5
+
6
+ let(:client) do
7
+ Beeper.configure do |c|
8
+ c.api_key = Beeper::Test::API_KEY
9
+ c.subdomain = "outright"
10
+ end
11
+ end
12
+
13
+ it "should be able to list incidents" do
14
+ client.incidents.size.should == 2
15
+ end
16
+
17
+ it "should be able to list services" do
18
+ client.services.should == services
19
+ end
20
+
21
+ describe "maintenance windows" do
22
+ it "should be able to list" do
23
+ client.maintenance_windows.should == []
24
+ end
25
+
26
+ it "should be able to list by type" do
27
+ client.maintenance_windows(:type => :future).should == future_maintenance
28
+ end
29
+
30
+ it "should be able to create" do
31
+ client = Beeper.configure do |c|
32
+ c.api_key = Beeper::Test::API_KEY
33
+ c.subdomain = "outright"
34
+ c.requester_id = Beeper::Test::REQUESTER_ID
35
+ end
36
+
37
+ client.create_maintenance_window(
38
+ :start_time => Time.now,
39
+ :end_time => Time.now + 3600,
40
+ :service_ids => ["POM55DP"]
41
+ ).should == new_maintenance_window
42
+ end
43
+ end
44
+ end
45
+
46
+ def new_maintenance_window
47
+ {
48
+ "maintenance_window" => {
49
+ "id"=>"P89LAYQ",
50
+ "sequence_number"=>1,
51
+ "start_time"=>"2012-12-18T14:34:16-08:00",
52
+ "end_time"=>"2012-12-18T15:34:15-08:00",
53
+ "description"=>nil,
54
+ "created_by"=>{
55
+ "id"=>"#{Beeper::Test::REQUESTER_ID}",
56
+ "name"=>"Bob Smith",
57
+ "email"=>"bob@example.com",
58
+ "time_zone"=>"Pacific Time (US & Canada)",
59
+ "color"=>"green",
60
+ "role"=>"admin",
61
+ "avatar_url"=>"https://secure.gravatar.com/avatar/71c3bbda60a46a241bf9a2d68e41cbec.png?d=mm&r=PG",
62
+ "user_url"=>"/users/#{Beeper::Test::REQUESTER_ID}",
63
+ "invitation_sent"=>false,
64
+ "marketing_opt_out"=>false
65
+ },
66
+ "services"=>[
67
+ {
68
+ "id"=>"POM55DP",
69
+ "name"=>"Application",
70
+ "service_url"=>"/services/POM55DP",
71
+ "service_key"=>"application@outright.pagerduty.com",
72
+ "auto_resolve_timeout"=>14400,
73
+ "acknowledgement_timeout"=>600,
74
+ "created_at"=>"2012-12-01T13:59:54-08:00",
75
+ "status"=>"maintenance",
76
+ "last_incident_timestamp"=>nil,
77
+ "email_incident_creation"=>"on_new_email_subject",
78
+ "incident_counts"=>{"triggered"=>0, "acknowledged"=>0, "resolved"=>0, "total"=>0},
79
+ "email_filter_mode"=>"all-email",
80
+ "type"=>"pingdom"
81
+ }
82
+ ]
83
+ }
84
+ }
85
+ end
86
+
87
+ def services
88
+ [
89
+ Hashie::Rash.new({
90
+ "id"=>"POM55DP",
91
+ "name"=>"Pingdom Aggregation",
92
+ "service_url"=>"/services/POM55DP",
93
+ "service_key"=>"aggregation@outright.pagerduty.com",
94
+ "auto_resolve_timeout"=>14400,
95
+ "acknowledgement_timeout"=>600,
96
+ "created_at"=>"2012-12-01T13:59:54-08:00",
97
+ "status"=>"active",
98
+ "last_incident_timestamp"=>nil,
99
+ "email_incident_creation"=>"on_new_email_subject",
100
+ "incident_counts"=>{"triggered"=>0, "acknowledged"=>0, "resolved"=>0, "total"=>0},
101
+ "email_filter_mode"=>"all-email",
102
+ "type"=>"pingdom"
103
+ }),
104
+ Hashie::Rash.new({
105
+ "id"=>"PW7E752",
106
+ "name"=>"Pingdom Application",
107
+ "service_url"=>"/services/PW7E752",
108
+ "service_key"=>"application@outright.pagerduty.com",
109
+ "auto_resolve_timeout"=>14400,
110
+ "acknowledgement_timeout"=>600,
111
+ "created_at"=>"2012-12-01T13:51:47-08:00",
112
+ "status"=>"active",
113
+ "last_incident_timestamp"=>nil,
114
+ "email_incident_creation"=>"on_new_email_subject",
115
+ "incident_counts"=>{"triggered"=>0, "acknowledged"=>0, "resolved"=>0, "total"=>0},
116
+ "email_filter_mode"=>"all-email",
117
+ "type"=>"pingdom"
118
+ })
119
+ ]
120
+ end
121
+
122
+ def future_maintenance
123
+ [
124
+ {
125
+ "id"=>"PW4ICCT",
126
+ "sequence_number"=>1,
127
+ "start_time"=>"2012-12-18T16:00:00-08:00",
128
+ "end_time"=>"2012-12-18T17:00:00-08:00",
129
+ "description"=>"testing",
130
+ "created_by"=>
131
+ {
132
+ "id"=>"#{Beeper::Test::REQUESTER_ID}",
133
+ "name"=>"Bob Smith",
134
+ "email"=>"bob@example.com",
135
+ "time_zone"=>"Pacific Time (US & Canada)",
136
+ "color"=>"green",
137
+ "role"=>"admin",
138
+ "avatar_url"=>
139
+ "https://secure.gravatar.com/avatar/71c3bbda60a46a241bf9a2d68e41cbec.png?d=mm&r=PG",
140
+ "user_url"=>"/users/#{Beeper::Test::REQUESTER_ID}",
141
+ "invitation_sent"=>false,
142
+ "marketing_opt_out"=>false
143
+ },
144
+ "services"=>[
145
+ {
146
+ "id"=>"PZ9VM86",
147
+ "name"=>"Application",
148
+ "service_url"=>"/services/PZ9VM86",
149
+ "service_key"=>"application@outright.pagerduty.com",
150
+ "auto_resolve_timeout"=>14400,
151
+ "acknowledgement_timeout"=>600,
152
+ "created_at"=>"2012-03-07T15:44:09-08:00",
153
+ "status"=>"active",
154
+ "last_incident_timestamp"=>"2012-12-17T09:11:11-08:00",
155
+ "email_incident_creation"=>"on_new_email_subject",
156
+ "incident_counts"=>{"triggered"=>0, "acknowledged"=>0, "resolved"=>166, "total"=>166},
157
+ "email_filter_mode"=>"all-email",
158
+ "type"=>"generic_email"
159
+ }
160
+ ]
161
+ }
162
+ ]
163
+ end
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ describe Beeper do
4
+ it "should be able to configure itself" do
5
+ client = Beeper.configure do |c|
6
+ c.api_key = "00000000000"
7
+ c.subdomain = "testdomain"
8
+ end
9
+
10
+ client.configured?.should == true
11
+ end
12
+ end
@@ -0,0 +1,249 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://outright.pagerduty.com/api/v1/incidents
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Token token="API_KEY"
12
+ response:
13
+ status:
14
+ code: 200
15
+ message:
16
+ headers:
17
+ server:
18
+ - nginx/1.0.14
19
+ date:
20
+ - Tue, 18 Dec 2012 18:33:32 GMT
21
+ content-type:
22
+ - application/json; charset=utf-8
23
+ transfer-encoding:
24
+ - chunked
25
+ connection:
26
+ - keep-alive
27
+ status:
28
+ - 200 OK
29
+ x-ua-compatible:
30
+ - IE=Edge,chrome=1
31
+ etag:
32
+ - ! '"d1b5dee8546d999c78d82cd08b9e7855"'
33
+ cache-control:
34
+ - must-revalidate, private, max-age=0
35
+ set-cookie:
36
+ - _pagerduty_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWFhYTIzMjliZWIwMTQ3ZmQyZDA3OTkwMzQ1OGFmNTViBjsAVEkiHHdhcmRlbi51c2VyLmFwaV9rZXkua2V5BjsAVFsISSILQXBpS2V5BjsARlsGaQKUATA%3D--c70789a0af4bf7cf09ee7665e32c1c4dba02dd9a;
37
+ path=/; HttpOnly, uid=CvgRmlDQtvzB3Si+TZMJAg==; expires=Thu, 31-Dec-37 23:55:55
38
+ GMT; domain=pagerduty.com; path=/
39
+ x-request-id:
40
+ - d0e97db26c0e27f1ae025a3776f758cc
41
+ x-runtime:
42
+ - '0.537506'
43
+ x-rack-cache:
44
+ - miss
45
+ body:
46
+ encoding: US-ASCII
47
+ string: ! '{"incidents":[{"id":"PPACGEI","incident_number":336,"created_on":"2012-11-22T05:05:18Z","status":"resolved","html_url":"http://outright.pagerduty.com/incidents/PPACGEI","incident_key":"__TRIGGERED_VIA_EMAIL__","service":{"id":"PGV50ZJ","name":"Pingdom","html_url":"http://outright.pagerduty.com/services/PGV50ZJ"},"assigned_to_user":null,"trigger_summary_data":{"subject":"DOWN
48
+ alert: Thrift (secure.outright.com) is DOWN"},"trigger_details_html_url":"http://outright.pagerduty.com/incidents/PPACGEI/log_entries/PTYKKQ6","last_status_change_on":"2012-11-22T05:15:52Z","last_status_change_by":{"id":"REQUESTER_ID","name":"Trae
49
+ Robrock","email":"trae@outright.com","html_url":"http://outright.pagerduty.com/users/REQUESTER_ID"},"number_of_escalations":1},{"id":"P0M3DH0","incident_number":337,"created_on":"2012-11-24T12:03:45Z","status":"resolved","html_url":"http://outright.pagerduty.com/incidents/P0M3DH0","incident_key":"__TRIGGERED_VIA_EMAIL__","service":{"id":"PGV50ZJ","name":"Pingdom","html_url":"http://outright.pagerduty.com/services/PGV50ZJ"},"assigned_to_user":null,"trigger_summary_data":{"subject":"DOWN
50
+ alert: Thrift (secure.outright.com) is DOWN"},"trigger_details_html_url":"http://outright.pagerduty.com/incidents/P0M3DH0/log_entries/PIHR7C3","last_status_change_on":"2012-11-24T12:25:04Z","last_status_change_by":{"id":"P3859OT","name":"Julio
51
+ Santos","email":"julio@outright.com","html_url":"http://outright.pagerduty.com/users/P3859OT"},"number_of_escalations":0}],"limit":100,"offset":0,"total":2}'
52
+ http_version:
53
+ recorded_at: Tue, 18 Dec 2012 18:33:32 GMT
54
+ - request:
55
+ method: get
56
+ uri: https://outright.pagerduty.com/api/v1/services
57
+ body:
58
+ encoding: US-ASCII
59
+ string: ''
60
+ headers:
61
+ Authorization:
62
+ - Token token="API_KEY"
63
+ response:
64
+ status:
65
+ code: 200
66
+ message:
67
+ headers:
68
+ server:
69
+ - nginx/1.0.14
70
+ date:
71
+ - Tue, 18 Dec 2012 18:52:53 GMT
72
+ content-type:
73
+ - application/json; charset=utf-8
74
+ transfer-encoding:
75
+ - chunked
76
+ connection:
77
+ - keep-alive
78
+ status:
79
+ - 200 OK
80
+ x-ua-compatible:
81
+ - IE=Edge,chrome=1
82
+ etag:
83
+ - ! '"421a503a66656e436169a5013973b9a3"'
84
+ cache-control:
85
+ - must-revalidate, private, max-age=0
86
+ set-cookie:
87
+ - _pagerduty_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTcxOTE3ODJlNjMxNTFhNGE0NzFhNTc1ZTE3NmY0ZDUzBjsAVEkiHHdhcmRlbi51c2VyLmFwaV9rZXkua2V5BjsAVFsISSILQXBpS2V5BjsARlsGaQKUATA%3D--f193ea42280964d4723a59595f2860a269a862b9;
88
+ path=/; HttpOnly, uid=CvgRmlDQu4XB3Si+TaevAg==; expires=Thu, 31-Dec-37 23:55:55
89
+ GMT; domain=pagerduty.com; path=/
90
+ x-request-id:
91
+ - f132f07609f9f5870ea1fed3f1b73486
92
+ x-runtime:
93
+ - '0.282396'
94
+ x-rack-cache:
95
+ - miss
96
+ body:
97
+ encoding: US-ASCII
98
+ string: ! '{"services":[{"id":"POM55DP","name":"Pingdom Aggregation","service_url":"/services/POM55DP","service_key":"aggregation@outright.pagerduty.com","auto_resolve_timeout":14400,"acknowledgement_timeout":600,"created_at":"2012-12-01T13:59:54-08:00","status":"active","last_incident_timestamp":null,"email_incident_creation":"on_new_email_subject","incident_counts":{"triggered":0,"acknowledged":0,"resolved":0,"total":0},"email_filter_mode":"all-email","type":"pingdom"},{"id":"PW7E752","name":"Pingdom
99
+ Application","service_url":"/services/PW7E752","service_key":"application@outright.pagerduty.com","auto_resolve_timeout":14400,"acknowledgement_timeout":600,"created_at":"2012-12-01T13:51:47-08:00","status":"active","last_incident_timestamp":null,"email_incident_creation":"on_new_email_subject","incident_counts":{"triggered":0,"acknowledged":0,"resolved":0,"total":0},"email_filter_mode":"all-email","type":"pingdom"}],"limit":25,"offset":0,"total":2}'
100
+ http_version:
101
+ recorded_at: Tue, 18 Dec 2012 18:52:53 GMT
102
+ - request:
103
+ method: get
104
+ uri: https://outright.pagerduty.com/api/v1/maintenance_windows
105
+ body:
106
+ encoding: US-ASCII
107
+ string: ''
108
+ headers:
109
+ Authorization:
110
+ - Token token="API_KEY"
111
+ response:
112
+ status:
113
+ code: 200
114
+ message:
115
+ headers:
116
+ server:
117
+ - nginx/1.0.14
118
+ date:
119
+ - Tue, 18 Dec 2012 21:20:46 GMT
120
+ content-type:
121
+ - application/json; charset=utf-8
122
+ transfer-encoding:
123
+ - chunked
124
+ connection:
125
+ - keep-alive
126
+ status:
127
+ - 200 OK
128
+ x-ua-compatible:
129
+ - IE=Edge,chrome=1
130
+ etag:
131
+ - ! '"6919d6c47a3676a76a87c183ec2b1c12"'
132
+ cache-control:
133
+ - must-revalidate, private, max-age=0
134
+ set-cookie:
135
+ - _pagerduty_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTQzODI0NTc4YTBmMTkwZDEwYWYwMmYyYjM5MDg0MDZkBjsAVEkiHHdhcmRlbi51c2VyLmFwaV9rZXkua2V5BjsAVFsISSILQXBpS2V5BjsARlsGaQKUATA%3D--3b0365f664301282b5ab3f149e5b8d4cdec50483;
136
+ path=/; HttpOnly, uid=CvQdAlDQ3i5M5GH+U/MuAg==; expires=Thu, 31-Dec-37 23:55:55
137
+ GMT; domain=pagerduty.com; path=/
138
+ x-request-id:
139
+ - 700c013cfae5ea7e9b3e2a8bf09dcdce
140
+ x-runtime:
141
+ - '0.061321'
142
+ x-rack-cache:
143
+ - miss
144
+ body:
145
+ encoding: US-ASCII
146
+ string: ! '{"maintenance_windows":[],"counts":{"ongoing":0,"future":0,"past":0,"all":0},"limit":25,"offset":0,"total":0}'
147
+ http_version:
148
+ recorded_at: Tue, 18 Dec 2012 21:20:46 GMT
149
+ - request:
150
+ method: get
151
+ uri: https://outright.pagerduty.com/api/v1/maintenance_windows?type=future
152
+ body:
153
+ encoding: US-ASCII
154
+ string: ''
155
+ headers:
156
+ Authorization:
157
+ - Token token="API_KEY"
158
+ response:
159
+ status:
160
+ code: 200
161
+ message:
162
+ headers:
163
+ server:
164
+ - nginx/1.0.14
165
+ date:
166
+ - Tue, 18 Dec 2012 22:13:46 GMT
167
+ content-type:
168
+ - application/json; charset=utf-8
169
+ transfer-encoding:
170
+ - chunked
171
+ connection:
172
+ - keep-alive
173
+ status:
174
+ - 200 OK
175
+ x-ua-compatible:
176
+ - IE=Edge,chrome=1
177
+ etag:
178
+ - ! '"16d4bc0e609530a306c4638faa3cea1b"'
179
+ cache-control:
180
+ - must-revalidate, private, max-age=0
181
+ set-cookie:
182
+ - _pagerduty_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWRmYjJmMmEzN2M5ZjVjMmMyMWY1NjgxYWI0MWEwMmE3BjsAVEkiHHdhcmRlbi51c2VyLmFwaV9rZXkua2V5BjsAVFsISSILQXBpS2V5BjsARlsGaQKUATA%3D--0e97d08829ed876ff7ed576ddaf1c06978474294;
183
+ path=/; HttpOnly, uid=CvgRmlDQ6prBtCi9WXnOAg==; expires=Thu, 31-Dec-37 23:55:55
184
+ GMT; domain=pagerduty.com; path=/
185
+ x-request-id:
186
+ - 08f9e553ed4685a415f337163dc2668c
187
+ x-runtime:
188
+ - '0.121836'
189
+ x-rack-cache:
190
+ - miss
191
+ body:
192
+ encoding: US-ASCII
193
+ string: ! '{"maintenance_windows":[{"id":"PW4ICCT","sequence_number":1,"start_time":"2012-12-18T16:00:00-08:00","end_time":"2012-12-18T17:00:00-08:00","description":"testing","created_by":{"id":"REQUESTER_ID","name":"Bob
194
+ Smith","email":"bob@example.com","time_zone":"Pacific Time (US & Canada)","color":"green","role":"admin","avatar_url":"https://secure.gravatar.com/avatar/71c3bbda60a46a241bf9a2d68e41cbec.png?d=mm&r=PG","user_url":"/users/REQUESTER_ID","invitation_sent":false,"marketing_opt_out":false},"services":[{"id":"PZ9VM86","name":"Application","service_url":"/services/PZ9VM86","service_key":"application@outright.pagerduty.com","auto_resolve_timeout":14400,"acknowledgement_timeout":600,"created_at":"2012-03-07T15:44:09-08:00","status":"active","last_incident_timestamp":"2012-12-17T09:11:11-08:00","email_incident_creation":"on_new_email_subject","incident_counts":{"triggered":0,"acknowledged":0,"resolved":166,"total":166},"email_filter_mode":"all-email","type":"generic_email"}]}],"counts":{"ongoing":0,"future":1,"past":0,"all":1},"limit":25,"offset":0,"total":1}'
195
+ http_version:
196
+ recorded_at: Tue, 18 Dec 2012 22:13:46 GMT
197
+ - request:
198
+ method: post
199
+ uri: https://outright.pagerduty.com/api/v1/maintenance_windows
200
+ body:
201
+ encoding: UTF-8
202
+ string: ! '{"requester_id":"REQUESTER_ID","maintenance_window":{"start_time":"2012-12-18
203
+ 14:34:15 -0800","end_time":"2012-12-18 15:34:15 -0800","service_ids":["POM55DP"]}}'
204
+ headers:
205
+ Authorization:
206
+ - Token token="API_KEY"
207
+ Content-Type:
208
+ - application/json
209
+ response:
210
+ status:
211
+ code: 201
212
+ message:
213
+ headers:
214
+ server:
215
+ - nginx/1.0.14
216
+ date:
217
+ - Tue, 18 Dec 2012 22:34:16 GMT
218
+ content-type:
219
+ - application/json; charset=utf-8
220
+ transfer-encoding:
221
+ - chunked
222
+ connection:
223
+ - keep-alive
224
+ status:
225
+ - 201 Created
226
+ x-ua-compatible:
227
+ - IE=Edge,chrome=1
228
+ etag:
229
+ - ! '"e4ddc778f459f50c19db8ae8b5369253"'
230
+ cache-control:
231
+ - max-age=0, private, must-revalidate
232
+ set-cookie:
233
+ - _pagerduty_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTU5NmNmNzRjMDZjOWY2YjdhOTEzYWIxMmQxNWU2NjZkBjsAVEkiHHdhcmRlbi51c2VyLmFwaV9rZXkua2V5BjsAVFsISSILQXBpS2V5BjsARlsGaQKUATA%3D--d6cb585a9c5d9b16cfbac15ab9543cd056a0060e;
234
+ path=/; HttpOnly, uid=CvgRmlDQ72jBtCi9WZLHAg==; expires=Thu, 31-Dec-37 23:55:55
235
+ GMT; domain=pagerduty.com; path=/
236
+ x-request-id:
237
+ - e6c239f2048e99d5a2b12315cceccc34
238
+ x-runtime:
239
+ - '0.331142'
240
+ x-rack-cache:
241
+ - invalidate, pass
242
+ body:
243
+ encoding: US-ASCII
244
+ string: ! '{"maintenance_window":{"id":"P89LAYQ","sequence_number":1,"start_time":"2012-12-18T14:34:16-08:00","end_time":"2012-12-18T15:34:15-08:00","description":null,"created_by":{"id":"REQUESTER_ID","name":"Bob
245
+ Smith","email":"bob@example.com","time_zone":"Pacific Time (US & Canada)","color":"green","role":"admin","avatar_url":"https://secure.gravatar.com/avatar/71c3bbda60a46a241bf9a2d68e41cbec.png?d=mm&r=PG","user_url":"/users/REQUESTER_ID","invitation_sent":false,"marketing_opt_out":false},"services":[{"id":"POM55DP","name":"Application",
246
+ "service_url":"/services/POM55DP","service_key":"application@outright.pagerduty.com","auto_resolve_timeout":14400,"acknowledgement_timeout":600,"created_at":"2012-12-01T13:59:54-08:00","status":"maintenance","last_incident_timestamp":null,"email_incident_creation":"on_new_email_subject","incident_counts":{"triggered":0,"acknowledged":0,"resolved":0,"total":0},"email_filter_mode":"all-email","type":"pingdom"}]}}'
247
+ http_version:
248
+ recorded_at: Tue, 18 Dec 2012 22:34:16 GMT
249
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,6 @@
1
+ module Beeper
2
+ class Test
3
+ API_KEY = ENV["PAGERDUTY_API_KEY"] || "000000000000000"
4
+ REQUESTER_ID = ENV["PAGERDUTY_REQUESTER_ID"] || "000000"
5
+ end
6
+ end
@@ -0,0 +1,31 @@
1
+ require "beeper"
2
+ require "mocha/api"
3
+ require "vcr"
4
+
5
+ require "credentials"
6
+
7
+ RSpec.configure do |config|
8
+ config.extend VCR::RSpec::Macros
9
+
10
+ # Use color in STDOUT
11
+ config.color_enabled = true
12
+
13
+ # Use color not only in STDOUT but also in pagers and files
14
+ config.tty = true
15
+
16
+ # Use the specified formatter
17
+ config.formatter = :documentation # :progress, :html, :textmate
18
+
19
+ config.mock_framework = :mocha
20
+ end
21
+
22
+ VCR.configure do |c|
23
+ c.cassette_library_dir = 'spec/cassettes'
24
+ c.hook_into :faraday, :webmock
25
+
26
+ # Add sensitive fields here
27
+ # Constants in Etsy::Test will be auto filtered
28
+ Beeper::Test.constants.reverse.each do |const|
29
+ c.filter_sensitive_data(const.to_s) { Beeper::Test.const_get(const) }
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: beeper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Trae Robrock
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: faraday_middleware
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rash
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.2
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: json
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.7.5
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.7.5
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 10.0.2
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 10.0.2
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 2.12.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.12.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: mocha
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.13.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.13.1
126
+ - !ruby/object:Gem::Dependency
127
+ name: vcr
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 2.3.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 2.3.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: webmock
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 1.8.0
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 1.8.0
158
+ description: Simple api wrapper for PagerDuty
159
+ email:
160
+ - trobrock@gmail.com
161
+ executables: []
162
+ extensions: []
163
+ extra_rdoc_files: []
164
+ files:
165
+ - .gitignore
166
+ - .travis.yml
167
+ - Gemfile
168
+ - LICENSE.txt
169
+ - README.md
170
+ - Rakefile
171
+ - beeper.gemspec
172
+ - lib/beeper.rb
173
+ - lib/beeper/client.rb
174
+ - lib/beeper/version.rb
175
+ - spec/beeper/client_spec.rb
176
+ - spec/beeper_spec.rb
177
+ - spec/cassettes/Beeper_Client.yml
178
+ - spec/credentials.rb
179
+ - spec/spec_helper.rb
180
+ homepage: https://github.com/trobrock/beeper
181
+ licenses: []
182
+ post_install_message:
183
+ rdoc_options: []
184
+ require_paths:
185
+ - lib
186
+ required_ruby_version: !ruby/object:Gem::Requirement
187
+ none: false
188
+ requirements:
189
+ - - ! '>='
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ segments:
193
+ - 0
194
+ hash: -2184976759273684924
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ none: false
197
+ requirements:
198
+ - - ! '>='
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ segments:
202
+ - 0
203
+ hash: -2184976759273684924
204
+ requirements: []
205
+ rubyforge_project:
206
+ rubygems_version: 1.8.24
207
+ signing_key:
208
+ specification_version: 3
209
+ summary: Simple api wrapper for PagerDuty
210
+ test_files:
211
+ - spec/beeper/client_spec.rb
212
+ - spec/beeper_spec.rb
213
+ - spec/cassettes/Beeper_Client.yml
214
+ - spec/credentials.rb
215
+ - spec/spec_helper.rb