pagerduty 1.1.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/Gemfile +3 -11
- data/README.md +1 -1
- data/Rakefile +2 -24
- data/lib/pagerduty.rb +35 -23
- data/lib/pagerduty/version.rb +3 -0
- data/pagerduty.gemspec +17 -58
- metadata +35 -134
- data/VERSION +0 -1
data/.gitignore
ADDED
data/Gemfile
CHANGED
@@ -1,12 +1,4 @@
|
|
1
|
-
source
|
2
|
-
|
3
|
-
gem "json", "~> 1.4.6"
|
4
|
-
gem "curb", "~> 0.7.8"
|
5
|
-
|
6
|
-
group :development do
|
7
|
-
gem "bundler", "~> 1.0.0"
|
8
|
-
gem "jeweler", "~> 1.5.1"
|
9
|
-
gem "json", "~> 1.4.6"
|
10
|
-
gem "curb", "~> 0.7.8"
|
11
|
-
end
|
1
|
+
source 'https://rubygems.org'
|
12
2
|
|
3
|
+
# Specify your gem's dependencies in pagerduty.gemspec
|
4
|
+
gemspec
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ Usage
|
|
15
15
|
|
16
16
|
Pagerduty exposes three classes, `Pagerduty`, `PagerdutyIncident` and `PagerdutyException`. Instances of `PagerdutyIncident` are created and returned for every API call.
|
17
17
|
|
18
|
-
`Pagerduty`'s constructor takes
|
18
|
+
`Pagerduty`'s constructor takes 2 arguments - your `service_key` and an optional argument to set the 'incident_key' You can then use the method `trigger` to trigger a new incident with Pagerduty:
|
19
19
|
|
20
20
|
require 'pagerduty'
|
21
21
|
p = Pagerduty.new "your_pagerduty_service_key"
|
data/Rakefile
CHANGED
@@ -1,27 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'rake'
|
11
|
-
|
12
|
-
require 'jeweler'
|
13
|
-
Jeweler::Tasks.new do |gem|
|
14
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
-
gem.name = "pagerduty"
|
16
|
-
gem.homepage = "http://github.com/envato/pagerduty"
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.summary = "Pagerduty API client library"
|
19
|
-
gem.description = "Provides a simple interface for calling into the Pagerduty API"
|
20
|
-
gem.email = "charlie@charliesomerville.com"
|
21
|
-
gem.authors = ["charliesome"]
|
22
|
-
# Include your dependencies in Gemfile.
|
23
|
-
end
|
24
|
-
Jeweler::RubygemsDotOrgTasks.new
|
1
|
+
require "bundler/gem_tasks"
|
25
2
|
|
26
3
|
require 'rake/rdoctask'
|
27
4
|
Rake::RDocTask.new do |rdoc|
|
@@ -32,3 +9,4 @@ Rake::RDocTask.new do |rdoc|
|
|
32
9
|
rdoc.rdoc_files.include('README*')
|
33
10
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
34
11
|
end
|
12
|
+
|
data/lib/pagerduty.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'json'
|
2
|
-
require '
|
2
|
+
require 'net/http'
|
3
|
+
require 'pagerduty/version'
|
3
4
|
|
4
5
|
class PagerdutyException < Exception
|
5
6
|
attr_reader :pagerduty_instance, :api_response
|
6
|
-
|
7
|
+
|
7
8
|
def initialize(instance, resp)
|
8
9
|
@pagerduty_instance = instance
|
9
10
|
@api_response = resp
|
@@ -11,57 +12,68 @@ class PagerdutyException < Exception
|
|
11
12
|
end
|
12
13
|
|
13
14
|
class Pagerduty
|
14
|
-
|
15
|
+
|
15
16
|
attr_reader :service_key, :incident_key
|
16
|
-
|
17
|
-
def initialize(service_key)
|
17
|
+
|
18
|
+
def initialize(service_key, incident_key = nil)
|
18
19
|
@service_key = service_key
|
19
|
-
@incident_key =
|
20
|
+
@incident_key = incident_key
|
20
21
|
end
|
21
|
-
|
22
|
+
|
22
23
|
def trigger(description, details = {})
|
23
24
|
resp = api_call("trigger", description, details = {})
|
24
25
|
throw PagerdutyException.new(self, resp) unless resp["status"] == "success"
|
25
|
-
|
26
|
+
|
26
27
|
PagerdutyIncident.new @service_key, resp["incident_key"]
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
def get_incident(incident_key)
|
30
31
|
PagerdutyIncident.new @service_key, incident_key
|
31
32
|
end
|
32
|
-
|
33
|
+
|
33
34
|
protected
|
34
35
|
def api_call(event_type, description, details = {})
|
35
36
|
params = { :event_type => event_type, :service_key => @service_key, :description => description, :details => details }
|
36
37
|
params.merge!({ :incident_key => @incident_key }) unless @incident_key == nil
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
|
39
|
+
url = URI.parse("http://events.pagerduty.com/generic/2010-04-15/create_event.json")
|
40
|
+
|
41
|
+
|
42
|
+
http = Net::HTTP.new(url.host, url.port)
|
43
|
+
|
44
|
+
req = Net::HTTP::Post.new(url.request_uri)
|
45
|
+
req.body = JSON.generate(params)
|
46
|
+
|
47
|
+
res = http.request(req)
|
48
|
+
case res
|
49
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
50
|
+
JSON.parse(res.body)
|
51
|
+
else
|
52
|
+
res.error!
|
53
|
+
end
|
42
54
|
end
|
43
|
-
|
55
|
+
|
44
56
|
end
|
45
57
|
|
46
58
|
class PagerdutyIncident < Pagerduty
|
47
|
-
|
59
|
+
|
48
60
|
def initialize(service_key, incident_key)
|
49
61
|
super service_key
|
50
62
|
@incident_key = incident_key
|
51
63
|
end
|
52
|
-
|
64
|
+
|
53
65
|
def acknowledge(description, details = {})
|
54
66
|
resp = api_call("acknowledge", description, details = {})
|
55
67
|
throw PagerdutyException.new(self, resp) unless resp["status"] == "success"
|
56
|
-
|
68
|
+
|
57
69
|
self
|
58
70
|
end
|
59
|
-
|
71
|
+
|
60
72
|
def resolve(description, details = {})
|
61
73
|
resp = api_call("resolve", description, details = {})
|
62
74
|
throw PagerdutyException.new(self, resp) unless resp["status"] == "success"
|
63
|
-
|
75
|
+
|
64
76
|
self
|
65
77
|
end
|
66
|
-
|
67
|
-
end
|
78
|
+
|
79
|
+
end
|
data/pagerduty.gemspec
CHANGED
@@ -1,63 +1,22 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pagerduty/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "pagerduty"
|
8
|
+
gem.version = Pagerduty::VERSION
|
9
|
+
gem.authors = ["Charlie Somerville"]
|
10
|
+
gem.email = ["charlie@charliesomerville.com"]
|
11
|
+
gem.description = %q{Provides a simple interface for calling into the Pagerduty API}
|
12
|
+
gem.summary = %q{Pagerduty API client library}
|
13
|
+
gem.homepage = "http://github.com/envato/pagerduty"
|
14
|
+
gem.license = "MIT"
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
s.email = %q{charlie@charliesomerville.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
"Gemfile",
|
22
|
-
"LICENSE.txt",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/pagerduty.rb",
|
27
|
-
"pagerduty.gemspec"
|
28
|
-
]
|
29
|
-
s.homepage = %q{http://github.com/envato/pagerduty}
|
30
|
-
s.licenses = ["MIT"]
|
31
|
-
s.require_paths = ["lib"]
|
32
|
-
s.rubygems_version = %q{1.3.7}
|
33
|
-
s.summary = %q{Pagerduty API client library}
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
34
20
|
|
35
|
-
|
36
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
37
|
-
s.specification_version = 3
|
38
|
-
|
39
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
-
s.add_runtime_dependency(%q<json>, ["~> 1.4.6"])
|
41
|
-
s.add_runtime_dependency(%q<curb>, ["~> 0.7.8"])
|
42
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
43
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
44
|
-
s.add_development_dependency(%q<json>, ["~> 1.4.6"])
|
45
|
-
s.add_development_dependency(%q<curb>, ["~> 0.7.8"])
|
46
|
-
else
|
47
|
-
s.add_dependency(%q<json>, ["~> 1.4.6"])
|
48
|
-
s.add_dependency(%q<curb>, ["~> 0.7.8"])
|
49
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
51
|
-
s.add_dependency(%q<json>, ["~> 1.4.6"])
|
52
|
-
s.add_dependency(%q<curb>, ["~> 0.7.8"])
|
53
|
-
end
|
54
|
-
else
|
55
|
-
s.add_dependency(%q<json>, ["~> 1.4.6"])
|
56
|
-
s.add_dependency(%q<curb>, ["~> 0.7.8"])
|
57
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
58
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
59
|
-
s.add_dependency(%q<json>, ["~> 1.4.6"])
|
60
|
-
s.add_dependency(%q<curb>, ["~> 0.7.8"])
|
61
|
-
end
|
21
|
+
gem.add_runtime_dependency "json", ["~> 1.4.6"]
|
62
22
|
end
|
63
|
-
|
metadata
CHANGED
@@ -1,170 +1,71 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagerduty
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 1.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
7
|
+
authors:
|
8
|
+
- Charlie Somerville
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 11
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 4
|
31
|
-
- 6
|
32
|
-
version: 1.4.6
|
33
|
-
type: :runtime
|
12
|
+
date: 2012-10-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
34
15
|
name: json
|
35
|
-
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
39
17
|
none: false
|
40
|
-
requirements:
|
18
|
+
requirements:
|
41
19
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
- 7
|
47
|
-
- 8
|
48
|
-
version: 0.7.8
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.4.6
|
49
22
|
type: :runtime
|
50
|
-
name: curb
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
|
-
requirements:
|
57
|
-
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
hash: 23
|
60
|
-
segments:
|
61
|
-
- 1
|
62
|
-
- 0
|
63
|
-
- 0
|
64
|
-
version: 1.0.0
|
65
|
-
type: :development
|
66
|
-
name: bundler
|
67
23
|
prerelease: false
|
68
|
-
version_requirements:
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
25
|
none: false
|
72
|
-
requirements:
|
26
|
+
requirements:
|
73
27
|
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
hash: 1
|
76
|
-
segments:
|
77
|
-
- 1
|
78
|
-
- 5
|
79
|
-
- 1
|
80
|
-
version: 1.5.1
|
81
|
-
type: :development
|
82
|
-
name: jeweler
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: *id004
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
|
-
requirements:
|
89
|
-
- - ~>
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
hash: 11
|
92
|
-
segments:
|
93
|
-
- 1
|
94
|
-
- 4
|
95
|
-
- 6
|
28
|
+
- !ruby/object:Gem::Version
|
96
29
|
version: 1.4.6
|
97
|
-
type: :development
|
98
|
-
name: json
|
99
|
-
prerelease: false
|
100
|
-
version_requirements: *id005
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
|
-
requirements:
|
105
|
-
- - ~>
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
hash: 19
|
108
|
-
segments:
|
109
|
-
- 0
|
110
|
-
- 7
|
111
|
-
- 8
|
112
|
-
version: 0.7.8
|
113
|
-
type: :development
|
114
|
-
name: curb
|
115
|
-
prerelease: false
|
116
|
-
version_requirements: *id006
|
117
30
|
description: Provides a simple interface for calling into the Pagerduty API
|
118
|
-
email:
|
31
|
+
email:
|
32
|
+
- charlie@charliesomerville.com
|
119
33
|
executables: []
|
120
|
-
|
121
34
|
extensions: []
|
122
|
-
|
123
|
-
|
124
|
-
- LICENSE.txt
|
125
|
-
- README.md
|
126
|
-
files:
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
127
37
|
- .document
|
38
|
+
- .gitignore
|
128
39
|
- Gemfile
|
129
40
|
- LICENSE.txt
|
130
41
|
- README.md
|
131
42
|
- Rakefile
|
132
|
-
- VERSION
|
133
43
|
- lib/pagerduty.rb
|
44
|
+
- lib/pagerduty/version.rb
|
134
45
|
- pagerduty.gemspec
|
135
|
-
has_rdoc: true
|
136
46
|
homepage: http://github.com/envato/pagerduty
|
137
|
-
licenses:
|
47
|
+
licenses:
|
138
48
|
- MIT
|
139
49
|
post_install_message:
|
140
50
|
rdoc_options: []
|
141
|
-
|
142
|
-
require_paths:
|
51
|
+
require_paths:
|
143
52
|
- lib
|
144
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
54
|
none: false
|
146
|
-
requirements:
|
147
|
-
- -
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
|
150
|
-
|
151
|
-
- 0
|
152
|
-
version: "0"
|
153
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
60
|
none: false
|
155
|
-
requirements:
|
156
|
-
- -
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
|
159
|
-
segments:
|
160
|
-
- 0
|
161
|
-
version: "0"
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
162
65
|
requirements: []
|
163
|
-
|
164
66
|
rubyforge_project:
|
165
|
-
rubygems_version: 1.
|
67
|
+
rubygems_version: 1.8.23
|
166
68
|
signing_key:
|
167
69
|
specification_version: 3
|
168
70
|
summary: Pagerduty API client library
|
169
71
|
test_files: []
|
170
|
-
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.1.1
|