pagerduty-sdk 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ class Pagerduty
2
+ module Requests
3
+ module Alerts
4
+
5
+ extend Pagerduty::Core
6
+
7
+ # List existing alerts for a given time range, optionally filtered by type (SMS, Email, Phone, or Push)
8
+ #
9
+ # ==== Parameters
10
+ # * params<~Hash>
11
+ # * 'since'<~String>: The start of the date range over which you want to search. The time element is optional.
12
+ # * 'until'<~String>: The end of the date range over which you want to search. This should be in the same format as since. The size of the date range must be less than 3 months.
13
+ # * 'filter'<~String>: Returns only the alerts of the said types. Can be one of SMS, Email, Phone, or Push.
14
+ # * 'time_zone'<~TimeZone>: Time zone in which dates in the result will be rendered. Defaults to account time zone.
15
+ #
16
+ # ==== Returns
17
+ # * 'alerts'<~Array><~Alerts>
18
+ # * 'id'<~String>
19
+ # * 'type'<~String>
20
+ # * 'started_at'<~String>
21
+ # * 'user'<~Pagerduty::User>
22
+ # * 'id'<~String>
23
+ # * 'name'<~String>
24
+ # * 'email'<~String>
25
+ # * 'time_zone'<~String>
26
+ # * 'color'<~String>
27
+ # * 'avatar_url'<~String>
28
+ # * 'user_url'<~String>
29
+ # * 'invitation_sent'<~Boolean>
30
+ # * 'marketing'<~String>
31
+ # * 'marketing_opt_out'<~String>
32
+ # * 'type'<~String>
33
+ #
34
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/alerts/list]
35
+ def self.alerts(options={})
36
+
37
+ unless has_requirements? [:since, :until], options
38
+ puts "#> This function requires arguments :since, :until"
39
+ puts "Please see: http://developer.pagerduty.com/documentation/rest/alerts/list"
40
+ return
41
+ end
42
+
43
+ Pagerduty::Alerts.new(curl({
44
+ uri: "https://#{Pagerduty.class_variable_get(:@@subdomain)}.pagerduty.com/api/v1/alerts",
45
+ params: options,
46
+ method: 'GET'
47
+ }))
48
+ end
49
+
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,66 @@
1
+ class Pagerduty
2
+ class Incidents
3
+ class Incident
4
+ include Pagerduty::Core
5
+
6
+ def initialize(options={})
7
+ super
8
+ @@subdomain = Pagerduty.class_variable_get(:@@subdomain)
9
+ end
10
+
11
+ def inspect
12
+ puts "<Pagerduty::#{self.class}"
13
+ self.attributes.each { |attr,val|
14
+ puts "\t#{attr}=#{val.class == Class ? "BLOCK" : val.inspect}"
15
+ }
16
+ puts ">"
17
+
18
+ self.attributes
19
+ end
20
+
21
+ def notes
22
+ super(self.id)
23
+ end
24
+
25
+ def acknowledge
26
+ curl({
27
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents/#{self.id}/acknowledge",
28
+ data: { 'requester_id' => self.assigned_to_user.id },
29
+ method: 'PUT'
30
+ })
31
+ end
32
+
33
+ def resolve
34
+ curl({
35
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents/#{self.id}/resolve",
36
+ data: { 'requester_id' => self.assigned_to_user.id },
37
+ method: 'PUT'
38
+ })
39
+ end
40
+
41
+ def reassign(options={})
42
+ curl({
43
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents/#{self.id}/resolve",
44
+ data: { 'requester_id' => self.assigned_to_user.id, }.merge(options),
45
+ method: 'PUT'
46
+ })
47
+ end
48
+
49
+ self.instance_eval do
50
+ %w(triggered open acknowledged resolved).each do |status|
51
+ define_method("#{status}?") { self.status == "#{status}" }
52
+ end
53
+ end
54
+
55
+
56
+ def log_entries(options={})
57
+ LogEntries.new(curl({
58
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents/#{self.id}/log_entries",
59
+ params: options,
60
+ method: 'GET'
61
+ }))
62
+ end
63
+
64
+ end
65
+ end
66
+ end
@@ -1,11 +1,12 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pagerduty/core'
4
5
  require 'pagerduty/pagerduty'
5
6
 
6
7
  Gem::Specification.new do |gem|
7
8
  gem.name = "pagerduty-sdk"
8
- gem.version = '1.0.2'
9
+ gem.version = '1.0.3'
9
10
  gem.authors = ["Alfred Moreno"]
10
11
  gem.email = ["kryptek@gmail.com"]
11
12
  gem.description = %q{An SDK for Pagerduty's API}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagerduty-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alfred Moreno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-01 00:00:00.000000000 Z
11
+ date: 2013-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_support
@@ -66,14 +66,17 @@ files:
66
66
  - lib/pagerduty/core.rb
67
67
  - lib/pagerduty/models/agent.rb
68
68
  - lib/pagerduty/models/alert.rb
69
+ - lib/pagerduty/models/alerts.rb
69
70
  - lib/pagerduty/models/assigneduser.rb
70
71
  - lib/pagerduty/models/channels.rb
71
72
  - lib/pagerduty/models/escalationpolicies.rb
72
73
  - lib/pagerduty/models/incident.rb
74
+ - lib/pagerduty/models/incidents.rb
73
75
  - lib/pagerduty/models/laststatuschangeby.rb
74
76
  - lib/pagerduty/models/log_entry.rb
75
77
  - lib/pagerduty/models/maintenance_window.rb
76
78
  - lib/pagerduty/models/note.rb
79
+ - lib/pagerduty/models/notes.rb
77
80
  - lib/pagerduty/models/notification.rb
78
81
  - lib/pagerduty/models/report.rb
79
82
  - lib/pagerduty/models/resolvedbyuser.rb
@@ -83,6 +86,8 @@ files:
83
86
  - lib/pagerduty/models/triggersummarydata.rb
84
87
  - lib/pagerduty/models/user.rb
85
88
  - lib/pagerduty/pagerduty.rb
89
+ - lib/pagerduty/requests/alerts.rb
90
+ - lib/pagerduty/requests/incident.rb
86
91
  - pagerduty-sdk.gemspec
87
92
  homepage: https://github.com/kryptek/pagerduty-sdk
88
93
  licenses: