pagerduty-sdk 1.0.6 → 1.0.9

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: c9a3e841c8a49716d4a1fcd2a637c97cdfa2a9eb
4
- data.tar.gz: b99104fc5790dfca35321a1ccbe2381bf2248166
3
+ metadata.gz: 3615e824687a6029d74efa61346ba14df587148d
4
+ data.tar.gz: 2121221e4a5c337f5b533f346fb8f2056b0234fa
5
5
  SHA512:
6
- metadata.gz: a1f7bc4d0c27b6730e3044513bf4140ec98ac4ce7830b009a805f42d72e9402d724083978ff0500b502bc36384717517331a8591f76aa4973aceaf4e5706bbb2
7
- data.tar.gz: 714a20c32a41b86d925ccff56a9f074e2839525802ef4f6d943cd9ec94573c68d64f63f4f0a262fabaddc7dcd5eb64c93a316cea2cf5720f854bcc02d38aa63c
6
+ metadata.gz: 9ca44e74d0afa2088c881a8b7f0c399d58a5857d26f3f55ce59e67064faf4386469aeb5f751afaf9dbbf4937c41035560e3230ba6808c7485715b3b453eb3283
7
+ data.tar.gz: f117c1839194dd70108f1733b324c973cbb0b28f36099b526e0f5065a016baa5925461b995fc0f74c0ec7bd1780a46fe4593670fde98619c8220b20bed799ab5
data/.gitignore CHANGED
@@ -1,19 +1,19 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .DS_Store
6
- coverage
7
- InstalledFiles
8
- lib/bundler/man
9
- pkg
10
- rdoc
11
- spec/reports
12
- test/tmp
13
- test/version_tmp
14
- tmp
15
-
16
- # YARD artifacts
17
- .yardoc
18
- _yardoc
19
- doc/
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .DS_Store
6
+ coverage
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
data/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 Alfred Moreno
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Alfred Moreno
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,44 +1,44 @@
1
- pagerduty-sdk
2
- =============
3
-
4
- pagerduty-sdk is a Ruby Gem for communicating with the entire
5
- [Pagerduty](http://www.pagerduty.com) API. It was designed to be as
6
- fully object-oriented as possible. Although it is still under some
7
- construction, it is functional and ready for use.
8
-
9
- I plan to do much more work on this gem, and your feedback is greatly
10
- appreciated!
11
-
12
- ## Requirements
13
- * Ruby 1.9.3+
14
- * A Pagerduty account token
15
-
16
- ## Installation
17
- ```
18
- gem install pagerduty-sdk
19
- ```
20
-
21
- ### Building/Installing a local gem
22
-
23
- Rake tasks to build and install the gem:
24
-
25
- ```
26
- rake buildgem
27
- rake installgem
28
- ```
29
-
30
- Or in one fell swoop
31
-
32
- ```
33
- rake gem
34
- ```
35
-
36
- ## Usage
37
- ```ruby
38
- require 'pagerduty'
39
-
40
- pagerduty = Pagerduty.new(token: "#{token}", subdomain: "#{subdomain}")
41
- #<Pagerduty:0x007f9a340fc410>
42
- ```
43
-
44
- See [YARD documentation](http://rubydoc.info/github/kryptek/pagerduty-sdk/master/frames) for specific function usage.
1
+ pagerduty-sdk
2
+ =============
3
+
4
+ pagerduty-sdk is a Ruby Gem for communicating with the entire
5
+ [Pagerduty](http://www.pagerduty.com) API. It was designed to be as
6
+ fully object-oriented as possible. Although it is still under some
7
+ construction, it is functional and ready for use.
8
+
9
+ I plan to do much more work on this gem, and your feedback is greatly
10
+ appreciated!
11
+
12
+ ## Requirements
13
+ * Ruby 1.9.3+
14
+ * A Pagerduty account token
15
+
16
+ ## Installation
17
+ ```
18
+ gem install pagerduty-sdk
19
+ ```
20
+
21
+ ### Building/Installing a local gem
22
+
23
+ Rake tasks to build and install the gem:
24
+
25
+ ```
26
+ rake buildgem
27
+ rake installgem
28
+ ```
29
+
30
+ Or in one fell swoop
31
+
32
+ ```
33
+ rake gem
34
+ ```
35
+
36
+ ## Usage
37
+ ```ruby
38
+ require 'pagerduty'
39
+
40
+ pagerduty = Pagerduty.new(token: "#{token}", subdomain: "#{subdomain}")
41
+ #<Pagerduty:0x007f9a340fc410>
42
+ ```
43
+
44
+ See [YARD documentation](http://rubydoc.info/github/kryptek/pagerduty-sdk/master/frames) for specific function usage.
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
- desc "Build gem file"
2
- task :buildgem do
3
- sh "gem build pagerduty-sdk.gemspec"
4
- end
5
- desc "Install local gem file"
6
- task :installgem do
7
- sh "gem install pagerduty-sdk"
8
- end
9
-
10
- desc "Build and install local gem file"
11
- task :gem => [ :buildgem, :installgem ]
1
+ desc "Build gem file"
2
+ task :buildgem do
3
+ sh "gem build pagerduty-sdk.gemspec"
4
+ end
5
+ desc "Install local gem file"
6
+ task :installgem do
7
+ sh "gem install pagerduty-sdk"
8
+ end
9
+
10
+ desc "Build and install local gem file"
11
+ task :gem => [ :buildgem, :installgem ]
data/lib/pagerduty.rb CHANGED
@@ -1,42 +1,42 @@
1
- __LIB_DIR__ = File.expand_path(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift __LIB_DIR__ unless $LOAD_PATH.include?(__LIB_DIR__)
3
-
4
- require 'active_support/all'
5
- require 'json'
6
- require 'net/http'
7
- require 'net/https'
8
- require 'uri'
9
- require 'virtus'
10
-
11
- # Core
12
- require 'pagerduty/core'
13
- require 'pagerduty/pagerduty'
14
-
15
- # Models
16
- require 'pagerduty/models/report'
17
- require 'pagerduty/models/agent'
18
- require 'pagerduty/models/assigneduser'
19
- require 'pagerduty/models/laststatuschangeby'
20
- require 'pagerduty/models/resolvedbyuser'
21
- require 'pagerduty/models/service'
22
- require 'pagerduty/models/escalationpolicies'
23
- require 'pagerduty/models/triggersummarydata'
24
- require 'pagerduty/models/user'
25
- require 'pagerduty/models/schedule'
26
- require 'pagerduty/models/maintenance_window'
27
- require 'pagerduty/models/notification'
28
- require 'pagerduty/models/log_entry'
29
- require 'pagerduty/models/channels'
30
- require 'pagerduty/models/alert'
31
- require 'pagerduty/models/alerts'
32
- require 'pagerduty/models/note'
33
- require 'pagerduty/models/notes'
34
- require 'pagerduty/models/incident'
35
- require 'pagerduty/models/incidents'
36
- require 'pagerduty/models/services'
37
- require 'pagerduty/models/integration'
38
-
39
- # Requests
40
- require 'pagerduty/requests/incident'
41
- require 'pagerduty/requests/integration'
42
- #require 'pagerduty/requests/alerts'
1
+ __LIB_DIR__ = File.expand_path(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift __LIB_DIR__ unless $LOAD_PATH.include?(__LIB_DIR__)
3
+
4
+ require 'active_support/all'
5
+ require 'json'
6
+ require 'net/http'
7
+ require 'net/https'
8
+ require 'uri'
9
+ require 'virtus'
10
+
11
+ # Core
12
+ require 'pagerduty/core'
13
+ require 'pagerduty/pagerduty'
14
+
15
+ # Models
16
+ require 'pagerduty/models/report'
17
+ require 'pagerduty/models/agent'
18
+ require 'pagerduty/models/assigneduser'
19
+ require 'pagerduty/models/laststatuschangeby'
20
+ require 'pagerduty/models/resolvedbyuser'
21
+ require 'pagerduty/models/service'
22
+ require 'pagerduty/models/escalationpolicies'
23
+ require 'pagerduty/models/triggersummarydata'
24
+ require 'pagerduty/models/user'
25
+ require 'pagerduty/models/schedule'
26
+ require 'pagerduty/models/maintenance_window'
27
+ require 'pagerduty/models/notification'
28
+ require 'pagerduty/models/log_entry'
29
+ require 'pagerduty/models/channels'
30
+ require 'pagerduty/models/alert'
31
+ require 'pagerduty/models/alerts'
32
+ require 'pagerduty/models/note'
33
+ require 'pagerduty/models/notes'
34
+ require 'pagerduty/models/incident'
35
+ require 'pagerduty/models/incidents'
36
+ require 'pagerduty/models/services'
37
+ require 'pagerduty/models/integration'
38
+
39
+ # Requests
40
+ require 'pagerduty/requests/incident'
41
+ require 'pagerduty/requests/integration'
42
+ #require 'pagerduty/requests/alerts'
@@ -1,94 +1,100 @@
1
- class Pagerduty
2
- module Core
3
-
4
- ###################################################################################
5
- # def curl
6
- #
7
- # Purpose: Performs a CURL request
8
- #
9
- # Params: options<~Hash> - The options Hash to send
10
- # uri<~String> - The URI to curl
11
- # ssl<~Boolean><Optional> - Whether or not to use SSL
12
- # port<~Integer><Optional> - The port number to connect to
13
- # params<~Hash><Optional> - The params to send in the curl request
14
- # headers<~Hash><Optional> - The headers to send in the curl request
15
- # method<~String> - The HTTP method to perform
16
- # basic_auth<~Hash><Optional>
17
- # user<~String> - Basic auth user
18
- # password<~String> - Basic auth password
19
- #
20
- # Returns: <String>
21
- ###################################################################################
22
- def curl(options)
23
-
24
- curl_request = {
25
- ssl: true,
26
- port: 443,
27
- headers: {
28
- "Content-Type" => "application/json",
29
- "Authorization" => "Token token=#{Pagerduty.class_variable_get(:@@token)}",
30
- },
31
- }
32
-
33
- options.merge! curl_request
34
-
35
- url = URI.parse(options[:uri])
36
-
37
- if options[:params]
38
- parameters = options[:params].map { |k,v| "#{k}=#{v}" }.join("&")
39
- url += "?#{parameters}"
40
- end
41
-
42
- http = Net::HTTP.new(url.host, 443)
43
- http.use_ssl = true
44
-
45
- request = case options[:method]
46
- when 'DELETE'
47
- Net::HTTP::Delete.new(url)
48
- when 'GET'
49
- Net::HTTP::Get.new(url)
50
- when 'POST'
51
- Net::HTTP::Post.new(url)
52
- when 'PUT'
53
- Net::HTTP::Put.new(url)
54
- end
55
-
56
- if options.has_key?(:data)
57
- request.set_form_data(options[:data])
58
- end
59
-
60
- if options.has_key?(:basic_auth)
61
- request.basic_auth options[:basic_auth][:user], options[:basic_auth][:password]
62
- end
63
-
64
- request.body = options[:body]
65
-
66
- options[:headers].each { |key,val| request.add_field(key,val) }
67
-
68
- response = if options[:method] == 'POST'
69
- http.post(url.path,options[:data].to_json,options[:headers])
70
- elsif options[:method] == 'PUT'
71
- http.put(url.path,options[:data].to_json,options[:headers])
72
- else
73
- http.request(request)
74
- end
75
-
76
- options[:raw_response] == true ? response : JSON.parse(response.body)
77
- end
78
-
79
-
80
- # Check a Hash object for expected keys
81
- #
82
- # ==== Parameters
83
- # * 'keys'<~Array><~Object> - An array of objects expected to be found as keys in the supplied Hash
84
- # * 'options'<~Hash> - The Hash to perform the check on
85
- #
86
- # ==== Returns
87
- # * Boolean
88
- #
89
- def has_requirements?(keys,options)
90
- (keys - options.keys).empty?
91
- end
92
-
93
- end
94
- end
1
+ class Pagerduty
2
+ module Core
3
+
4
+ ###################################################################################
5
+ # def curl
6
+ #
7
+ # Purpose: Performs a CURL request
8
+ #
9
+ # Params: options<~Hash> - The options Hash to send
10
+ # uri<~String> - The URI to curl
11
+ # ssl<~Boolean><Optional> - Whether or not to use SSL
12
+ # port<~Integer><Optional> - The port number to connect to
13
+ # params<~Hash><Optional> - The params to send in the curl request
14
+ # headers<~Hash><Optional> - The headers to send in the curl request
15
+ # method<~String> - The HTTP method to perform
16
+ # basic_auth<~Hash><Optional>
17
+ # user<~String> - Basic auth user
18
+ # password<~String> - Basic auth password
19
+ #
20
+ # Returns: <String>
21
+ ###################################################################################
22
+ def curl(options)
23
+
24
+ curl_request = {
25
+ ssl: true,
26
+ port: 443,
27
+ headers: {
28
+ "Content-Type" => "application/json",
29
+ "Authorization" => "Token token=#{Pagerduty.class_variable_get(:@@token)}",
30
+ },
31
+ }
32
+
33
+ options.merge! curl_request
34
+
35
+ url = URI.parse(options[:uri])
36
+
37
+ if options[:params]
38
+ parameters = options[:params].map { |k,v| v.to_query(k) }.join("&")
39
+ url += "?#{parameters}"
40
+ end
41
+
42
+ http = Net::HTTP.new(url.host, 443)
43
+ http.use_ssl = true
44
+
45
+ request = case options[:method]
46
+ when 'DELETE'
47
+ Net::HTTP::Delete.new(url)
48
+ when 'GET'
49
+ Net::HTTP::Get.new(url)
50
+ when 'POST'
51
+ Net::HTTP::Post.new(url)
52
+ when 'PUT'
53
+ Net::HTTP::Put.new(url)
54
+ end
55
+
56
+ if options.has_key?(:data)
57
+ request.set_form_data(options[:data])
58
+ end
59
+
60
+ if options.has_key?(:basic_auth)
61
+ request.basic_auth options[:basic_auth][:user], options[:basic_auth][:password]
62
+ end
63
+
64
+ request.body = options[:body]
65
+
66
+ options[:headers].each { |key,val| request.add_field(key,val) }
67
+
68
+ response = if options[:method] == 'POST'
69
+ http.post(url.path,options[:data].to_json,options[:headers])
70
+ elsif options[:method] == 'PUT'
71
+ http.put(url.path,options[:data].to_json,options[:headers])
72
+ else
73
+ http.request(request)
74
+ end
75
+
76
+ if options[:raw_response] == true
77
+ response
78
+ elsif response.body
79
+ JSON.parse(response.body)
80
+ else
81
+ { 'code' => response.code, 'message' => response.message }
82
+ end
83
+ end
84
+
85
+
86
+ # Check a Hash object for expected keys
87
+ #
88
+ # ==== Parameters
89
+ # * 'keys'<~Array><~Object> - An array of objects expected to be found as keys in the supplied Hash
90
+ # * 'options'<~Hash> - The Hash to perform the check on
91
+ #
92
+ # ==== Returns
93
+ # * Boolean
94
+ #
95
+ def has_requirements?(keys,options)
96
+ (keys - options.keys).empty?
97
+ end
98
+
99
+ end
100
+ end