pagerduty-sonian 1.1.2

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.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
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
12
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Envato & Charlie Somerville
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,34 @@
1
+ pagerduty
2
+ =========
3
+
4
+ Provides a simple interface for calling into the [Pagerduty](http://pagerduty.com) API.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Install pagerduty with this command:
10
+
11
+ gem install pagerduty
12
+
13
+ Usage
14
+ -----
15
+
16
+ Pagerduty exposes three classes, `Pagerduty`, `PagerdutyIncident` and `PagerdutyException`. Instances of `PagerdutyIncident` are created and returned for every API call.
17
+
18
+ `Pagerduty`'s constructor takes a single argument - your `service_key`. You can then use the method `trigger` to trigger a new incident with Pagerduty:
19
+
20
+ require 'pagerduty'
21
+ p = Pagerduty.new "your_pagerduty_service_key"
22
+ incident = p.trigger "Everything went down!"
23
+
24
+ Incidents can be retriggered, acknowledged with the `PagerdutyIncident#acknowledge` method, and resolved with `PagerdutyIncident#resolve`.
25
+
26
+ Additionally, all API methods (`trigger`, `acknowledge`, `resolve`) take an optional second parameter `details`, which should be a hash containing any extra information that should be recorded with Pagerduty.
27
+
28
+ If the Pagerduty API does not return success, a `PagerdutyException` will be thrown which has the properties `pagerduty_instance` (the instance of either `Pagerduty` or `PagerdutyException` that caused the exception) and `api_response`, which is a hash representation of the JSON response from the Pagerduty API.
29
+
30
+ Copyright
31
+ ---------
32
+
33
+ Copyright (c) 2010 [Envato](http://envato.com) & [Charlie Somerville](http://charliesomerville.com). See LICENSE.txt for further details.
34
+
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
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
25
+
26
+ require 'rake/rdoctask'
27
+ Rake::RDocTask.new do |rdoc|
28
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
29
+
30
+ rdoc.rdoc_dir = 'rdoc'
31
+ rdoc.title = "pagerduty #{version}"
32
+ rdoc.rdoc_files.include('README*')
33
+ rdoc.rdoc_files.include('lib/**/*.rb')
34
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.2
@@ -0,0 +1,71 @@
1
+ require 'json'
2
+ require 'curb'
3
+
4
+ class PagerdutyException < Exception
5
+ attr_reader :pagerduty_instance, :api_response
6
+
7
+ def initialize(instance, resp)
8
+ @pagerduty_instance = instance
9
+ @api_response = resp
10
+ end
11
+ end
12
+
13
+ class Pagerduty
14
+
15
+ attr_reader :service_key, :incident_key
16
+
17
+ def initialize(service_key)
18
+ @service_key = service_key
19
+ @incident_key = nil
20
+ end
21
+
22
+ def incident_key=(incident_key)
23
+ @incident_key = incident_key
24
+ end
25
+
26
+ def trigger(description, details = {})
27
+ resp = api_call("trigger", description, details)
28
+ throw PagerdutyException.new(self, resp) unless resp["status"] == "success"
29
+
30
+ PagerdutyIncident.new @service_key, resp["incident_key"]
31
+ end
32
+
33
+ def get_incident(incident_key)
34
+ PagerdutyIncident.new @service_key, incident_key
35
+ end
36
+
37
+ protected
38
+ def api_call(event_type, description, details = {})
39
+ params = { :event_type => event_type, :service_key => @service_key, :description => description, :details => details }
40
+ params.merge!({ :incident_key => @incident_key }) unless @incident_key == nil
41
+
42
+ curl = Curl::Easy.new
43
+ curl.url = "http://events.pagerduty.com/generic/2010-04-15/create_event.json"
44
+ curl.http_post JSON.generate(params)
45
+ JSON.parse curl.body_str
46
+ end
47
+
48
+ end
49
+
50
+ class PagerdutyIncident < Pagerduty
51
+
52
+ def initialize(service_key, incident_key)
53
+ super service_key
54
+ @incident_key = incident_key
55
+ end
56
+
57
+ def acknowledge(description, details = {})
58
+ resp = api_call("acknowledge", description, details = {})
59
+ throw PagerdutyException.new(self, resp) unless resp["status"] == "success"
60
+
61
+ self
62
+ end
63
+
64
+ def resolve(description, details = {})
65
+ resp = api_call("resolve", description, details = {})
66
+ throw PagerdutyException.new(self, resp) unless resp["status"] == "success"
67
+
68
+ self
69
+ end
70
+
71
+ end
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "pagerduty-sonian"
8
+ s.version = "1.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["charliesome"]
12
+ s.date = %q{2010-11-17}
13
+ s.description = %q{Provides a simple interface for calling into the Pagerduty API}
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}
34
+
35
+ if s.respond_to? :specification_version then
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
62
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pagerduty-sonian
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.1.2
6
+ platform: ruby
7
+ authors:
8
+ - charliesome
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-11-17 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.4.6
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: curb
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.7.8
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.5.1
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: json
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 1.4.6
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: curb
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 0.7.8
79
+ type: :development
80
+ version_requirements: *id006
81
+ description: Provides a simple interface for calling into the Pagerduty API
82
+ email: charlie@charliesomerville.com
83
+ executables: []
84
+
85
+ extensions: []
86
+
87
+ extra_rdoc_files:
88
+ - LICENSE.txt
89
+ - README.md
90
+ files:
91
+ - .document
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - VERSION
97
+ - lib/pagerduty.rb
98
+ - pagerduty.gemspec
99
+ homepage: http://github.com/envato/pagerduty
100
+ licenses:
101
+ - MIT
102
+ post_install_message:
103
+ rdoc_options: []
104
+
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "0"
119
+ requirements: []
120
+
121
+ rubyforge_project:
122
+ rubygems_version: 1.8.7
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Pagerduty API client library
126
+ test_files: []
127
+