pagerduty-full 0.0.1 → 0.1

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzY4Y2U4OTBhM2ZhYjAyNzZlMTlkZDM4YTQ5YjEzMjllYzVmZmI4MA==
4
+ ZWQ4ZmZmZGVlZTk1OGI5N2I0MWNjZGM5YTM0NGQzNmRjZDM1MDAxZg==
5
5
  data.tar.gz: !binary |-
6
- NjQ0NDA1MjdkY2IxYTc1YWRjYmJjMTVhOTgzNjNkZjJlNTQzYWE3ZQ==
6
+ OGE2ZGE4MGE0MTgxNjdkNzViMzExMDE4NmZkYjQ3ZWFhODJjMjI3Zg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWQ1YjBiNmU0YjM1ZmZjZWIyMjI0ODRlMjkwMTRhNzJlMjFiOWE2NmE2NTVh
10
- MjVmNDIzN2Y5NjMyMWExZjQ4Zjc2NGViNThlMjFlMzRkZjQ5MzkzZDAxYWVl
11
- YTcwYjBhYTM1M2ZmNTVkOTk3ZTZmNDkyMzk0M2E4MmNmNWU0M2Y=
9
+ M2U3ZTEzODYwOTdiZDVmOWNkMjllZDEwMDMwN2M0MzkxZGM2ZmQxOWJjMDM4
10
+ NGY5ZGU3Y2M1OGI0ZDQ2NzlmMGMyNDk5N2VkYjE2ZGE3MTExZGUxNjJiNjAz
11
+ OWQyMzNjNDFjNzFlYTI1M2ZhZjI0OTRlMDM4ZjJlNGY1ZmZlNTI=
12
12
  data.tar.gz: !binary |-
13
- MjcxMDE3ZTYwMTkxNWY0ZGRiZWRlZWM4MzU2MzNkZGI4ZWI4NzFkZjUzNDY0
14
- ZTA0YjA5YzA3MzY5OWI2ZTBkNjA4NjRmZDY2MzAzOTI4MzMyZWEwOGE2OWUw
15
- NzdhNjkwZGUxNGQzODhmZWJlYTkxOTg5Yzg3NjEyNjFjZjg4ZGU=
13
+ OTc2ZGZlMGRmN2M3MTg3YzY0YzgyMWY1MDY3M2ZlMmRkZWUyY2NmNTg5ZTJl
14
+ MDAwNDEwYmEyYWIzMzU1NzRkMTcwMjU4NWY1MTFiMzM4ZjY3YjUyZDJlMjlk
15
+ ZjRkMDIwNzczNjE5YWIwNDU5NjEzM2JhNjg1MTFiMzA2MWI0ZWQ=
@@ -0,0 +1,45 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'uri'
4
+
5
+ module PagerDuty
6
+ class Full
7
+
8
+ attr_reader :apikey, :subdomain
9
+
10
+ def initialize(apikey, subdomain)
11
+ @apikey = apikey
12
+ @subdomain = subdomain
13
+ end
14
+
15
+ def api_call(path, params)
16
+
17
+ uri = URI.parse("http://#{@subdomain}.pagerduty.com/api/v1/#{path}")
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+
20
+ # This is probably stupid
21
+ query_string = ""
22
+ params.each do |key, val|
23
+ next unless val != nil
24
+ query_string << '&' unless key == params.keys.first
25
+ query_string << "#{URI.encode(key.to_s)}=#{URI.encode(params[key])}"
26
+ end
27
+ uri.query = query_string
28
+
29
+ req = Net::HTTP::Get.new(uri.request_uri)
30
+
31
+ res = http.get(uri.to_s, {
32
+ 'Content-type' => 'application/json',
33
+ 'Authorization' => "Token token=#{@apikey}"
34
+ })
35
+ end
36
+
37
+ def Incident()
38
+ PagerDuty::Resource::Incident.new(@apikey, @subdomain)
39
+ end
40
+
41
+ def Schedule()
42
+ PagerDuty::Resource::Schedule.new(@apikey, @subdomain)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,49 @@
1
+ module PagerDuty
2
+ module Resource
3
+
4
+ class Incident < PagerDuty::Full
5
+
6
+ def count(
7
+ assigned_to_user = nil, incident_key = nil, status = nil, service = nil,
8
+ since_date = nil, sort_by = nil, until_date = nil
9
+ )
10
+ res = api_call("incidents/count", {
11
+ :assigned_to_user => assigned_to_user,
12
+ :incident_key => incident_key,
13
+ :service => service,
14
+ :since => since_date,
15
+ :sort_by => sort_by,
16
+ :status => status,
17
+ :until => until_date,
18
+ })
19
+ case res
20
+ when Net::HTTPSuccess
21
+ JSON.parse(res.body)
22
+ else
23
+ res.error!
24
+ end
25
+ end
26
+
27
+ def search(
28
+ assigned_to_user = nil, incident_key = nil, status = nil, service = nil,
29
+ since_date = nil, sort_by = nil, until_date = nil
30
+ )
31
+ res = api_call("incidents", {
32
+ :assigned_to_user => assigned_to_user,
33
+ :incident_key => incident_key,
34
+ :service => service,
35
+ :since => since_date,
36
+ :sort_by => sort_by,
37
+ :status => status,
38
+ :until => until_date,
39
+ })
40
+ case res
41
+ when Net::HTTPSuccess
42
+ JSON.parse(res.body)
43
+ else
44
+ res.error!
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,46 @@
1
+ module PagerDuty
2
+ module Resource
3
+
4
+ class Schedule < PagerDuty::Full
5
+
6
+ def find(id, since_date = nil, until_date = nil)
7
+ res = api_call("schedules/#{id}", {
8
+ :since => since_date,
9
+ :until => until_date
10
+ })
11
+ case res
12
+ when Net::HTTPSuccess
13
+ JSON.parse(res.body)
14
+ else
15
+ res.error!
16
+ end
17
+ end
18
+
19
+ def search(query = nil, requester_id = nil)
20
+ res = api_call("schedules", {
21
+ :query => query,
22
+ :requester_id => requester_id
23
+ })
24
+ case res
25
+ when Net::HTTPSuccess
26
+ JSON.parse(res.body)
27
+ else
28
+ res.error!
29
+ end
30
+ end
31
+
32
+ def users(id, since_date = nil, until_date = nil)
33
+ res = api_call("schedules/#{id}/users", {
34
+ :since => since_date,
35
+ :until => until_date
36
+ })
37
+ case res
38
+ when Net::HTTPSuccess
39
+ JSON.parse(res.body)
40
+ else
41
+ res.error!
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,23 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagerduty-full
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: '0.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Watson
8
+ - Toby Lawrence
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2012-10-01 00:00:00.000000000 Z
12
+ date: 2013-09-09 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: Access to all of PagerDuty's API
14
- email: gphat@onemogin.com
15
+ email: me@yournameistoby.com
15
16
  executables: []
16
17
  extensions: []
17
18
  extra_rdoc_files: []
18
19
  files:
19
20
  - lib/pagerduty/full.rb
20
- homepage: http://github.com/gphat/pagerduty-full
21
+ - lib/pagerduty/base.rb
22
+ - lib/pagerduty/resource/incident.rb
23
+ - lib/pagerduty/resource/schedule.rb
24
+ homepage: http://github.com/tobz/pagerduty-full
21
25
  licenses: []
22
26
  metadata: {}
23
27
  post_install_message: