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.
@@ -1,9 +1,9 @@
1
- class Service
2
- include Virtus.model
3
-
4
- attribute :id
5
- attribute :name
6
- attribute :html_url
7
- attribute :delete_at
8
- end
9
-
1
+ class Service
2
+ include Virtus.model
3
+
4
+ attribute :id
5
+ attribute :name
6
+ attribute :html_url
7
+ attribute :delete_at
8
+ end
9
+
@@ -1,53 +1,53 @@
1
- class Pagerduty
2
- class Services
3
- class Objects
4
- include Virtus.model
5
-
6
- class IncidentCount < Pagerduty::Services::Objects
7
- attribute :triggered
8
- attribute :acknowledged
9
- attribute :resolved
10
- attribute :total
11
- end
12
-
13
- class EmailFilter < Pagerduty::Services::Objects
14
- attribute :subject_mode
15
- attribute :subject_regex
16
- attribute :body_mode
17
- attribute :body_regex
18
- attribute :from_email_mode
19
- attribute :from_email_regex
20
- attribute :id
21
- end
22
-
23
- class Service < Pagerduty::Services::Objects
24
- attribute :id
25
- attribute :name
26
- attribute :description
27
- attribute :service_url
28
- attribute :service_key
29
- attribute :auto_resolve_timeout
30
- attribute :acknowledgement_timeout
31
- attribute :created_at
32
- attribute :status
33
- attribute :last_incident_timestamp
34
- attribute :email_incident_creation
35
- attribute :incident_counts
36
- attribute :email_filter_mode
37
- attribute :type
38
- attribute :escalation_policy, 'EscalationPolicy'
39
- attribute :email_filters, Pagerduty::Services::Objects::EmailFilter
40
- attribute :severity_filter
41
- end
42
-
43
- end
44
- end
45
- end
46
-
47
- class Pagerduty
48
- class Services
49
- include Virtus.model
50
-
51
- attribute :services, Array[Pagerduty::Services::Objects::Service]
52
- end
53
- end
1
+ class Pagerduty
2
+ class Services
3
+ class Objects
4
+ include Virtus.model
5
+
6
+ class IncidentCount < Pagerduty::Services::Objects
7
+ attribute :triggered
8
+ attribute :acknowledged
9
+ attribute :resolved
10
+ attribute :total
11
+ end
12
+
13
+ class EmailFilter < Pagerduty::Services::Objects
14
+ attribute :subject_mode
15
+ attribute :subject_regex
16
+ attribute :body_mode
17
+ attribute :body_regex
18
+ attribute :from_email_mode
19
+ attribute :from_email_regex
20
+ attribute :id
21
+ end
22
+
23
+ class Service < Pagerduty::Services::Objects
24
+ attribute :id
25
+ attribute :name
26
+ attribute :description
27
+ attribute :service_url
28
+ attribute :service_key
29
+ attribute :auto_resolve_timeout
30
+ attribute :acknowledgement_timeout
31
+ attribute :created_at
32
+ attribute :status
33
+ attribute :last_incident_timestamp
34
+ attribute :email_incident_creation
35
+ attribute :incident_counts
36
+ attribute :email_filter_mode
37
+ attribute :type
38
+ attribute :escalation_policy, 'EscalationPolicy'
39
+ attribute :email_filters, Pagerduty::Services::Objects::EmailFilter
40
+ attribute :severity_filter
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+
47
+ class Pagerduty
48
+ class Services
49
+ include Virtus.model
50
+
51
+ attribute :services, Array[Pagerduty::Services::Objects::Service]
52
+ end
53
+ end
@@ -1,6 +1,6 @@
1
- class TriggerSummaryData
2
- include Virtus.model
3
-
4
- attribute :subject
5
- end
6
-
1
+ class TriggerSummaryData
2
+ include Virtus.model
3
+
4
+ attribute :subject
5
+ end
6
+
@@ -1,75 +1,75 @@
1
- class Pagerduty
2
- class User < Pagerduty
3
- include Virtus.model
4
-
5
- attribute :id
6
- attribute :name
7
- attribute :email
8
- attribute :time_zone
9
- attribute :color
10
- attribute :role
11
- attribute :avatar_url
12
- attribute :user_url
13
- attribute :invitation_sent
14
- attribute :marketing
15
- attribute :marketing_opt_out
16
- attribute :type, String, default: 'user'
17
-
18
- #def inspect
19
- #puts "<Pagerduty::#{self.class}"
20
- #self.attributes.each { |attr,val|
21
- #puts "\t#{attr}=#{val.inspect}"
22
- #}
23
- #puts ">"
24
-
25
- #self.attributes
26
- #end
27
-
28
- def log_entries(options={})
29
- LogEntries.new(curl({
30
- uri: "https://#@@subdomain.pagerduty.com/api/v1/users/#{self.id}/log_entries",
31
- params: options,
32
- method: 'GET'
33
- }))
34
- end
35
-
36
- def delete
37
- res = curl({
38
- uri: "https://#@@subdomain.pagerduty.com/api/v1/users/#{self.id}",
39
- method: 'DELETE',
40
- raw_response: true
41
- })
42
-
43
- res.code == '204' ? "Successfully deleted User #{self.id}" : JSON.parse(response.body)
44
- end
45
-
46
- def save
47
- saved_user = User.new(curl({
48
- uri: "https://#@@subdomain.pagerduty.com/api/v1/users/#{self.id}",
49
- data: {
50
- role: self.role,
51
- name: self.name,
52
- email: self.email,
53
- time_zone: self.time_zone
54
- },
55
- method: 'PUT'
56
- })['user'])
57
-
58
- self.role = saved_user.role
59
- self.name = saved_user.name
60
- self.email = saved_user.email
61
- self.time_zone = saved_user.time_zone
62
- self
63
- end
64
- end
65
- end
66
-
67
- class Users
68
- include Virtus.model
69
-
70
- attribute :active_account_users
71
- attribute :limit
72
- attribute :offset
73
- attribute :total
74
- attribute :users, Array[Pagerduty::User]
75
- end
1
+ class Pagerduty
2
+ class User < Pagerduty
3
+ include Virtus.model
4
+
5
+ attribute :id
6
+ attribute :name
7
+ attribute :email
8
+ attribute :time_zone
9
+ attribute :color
10
+ attribute :role
11
+ attribute :avatar_url
12
+ attribute :user_url
13
+ attribute :invitation_sent
14
+ attribute :marketing
15
+ attribute :marketing_opt_out
16
+ attribute :type, String, default: 'user'
17
+
18
+ #def inspect
19
+ #puts "<Pagerduty::#{self.class}"
20
+ #self.attributes.each { |attr,val|
21
+ #puts "\t#{attr}=#{val.inspect}"
22
+ #}
23
+ #puts ">"
24
+
25
+ #self.attributes
26
+ #end
27
+
28
+ def log_entries(options={})
29
+ LogEntries.new(curl({
30
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/users/#{self.id}/log_entries",
31
+ params: options,
32
+ method: 'GET'
33
+ }))
34
+ end
35
+
36
+ def delete
37
+ res = curl({
38
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/users/#{self.id}",
39
+ method: 'DELETE',
40
+ raw_response: true
41
+ })
42
+
43
+ res.code == '204' ? "Successfully deleted User #{self.id}" : JSON.parse(response.body)
44
+ end
45
+
46
+ def save
47
+ saved_user = User.new(curl({
48
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/users/#{self.id}",
49
+ data: {
50
+ role: self.role,
51
+ name: self.name,
52
+ email: self.email,
53
+ time_zone: self.time_zone
54
+ },
55
+ method: 'PUT'
56
+ })['user'])
57
+
58
+ self.role = saved_user.role
59
+ self.name = saved_user.name
60
+ self.email = saved_user.email
61
+ self.time_zone = saved_user.time_zone
62
+ self
63
+ end
64
+ end
65
+ end
66
+
67
+ class Users
68
+ include Virtus.model
69
+
70
+ attribute :active_account_users
71
+ attribute :limit
72
+ attribute :offset
73
+ attribute :total
74
+ attribute :users, Array[Pagerduty::User]
75
+ end
@@ -1,1115 +1,1145 @@
1
-
2
- class Pagerduty
3
-
4
- include Pagerduty::Core
5
-
6
- attr_reader :token
7
- attr_reader :subdomain
8
-
9
- def initialize(options)
10
- @@token = options[:token]
11
- @@subdomain = options[:subdomain]
12
- end
13
-
14
-
15
- # Check a Hash object for expected keys
16
- #
17
- # ==== Parameters
18
- # * 'keys'<~Array><~Object> - An array of objects expected to be found as keys in the supplied Hash
19
- # * 'options'<~Hash> - The Hash to perform the check on
20
- #
21
- # ==== Returns
22
- # * Boolean
23
- #
24
- def has_requirements?(keys,options)
25
- (keys - options.keys).empty?
26
- end
27
-
28
-
29
- # List existing alerts for a given time range, optionally filtered by type (SMS, Email, Phone, or Push)
30
- #
31
- # ==== Parameters
32
- # * params<~Hash>
33
- # * 'since'<~String>: The start of the date range over which you want to search. The time element is optional.
34
- # * '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.
35
- # * 'filter'<~String>: Returns only the alerts of the said types. Can be one of SMS, Email, Phone, or Push.
36
- # * 'time_zone'<~TimeZone>: Time zone in which dates in the result will be rendered. Defaults to account time zone.
37
- #
38
- # ==== Returns
39
- # * 'alerts'<~Array><~Alerts>
40
- # * 'id'<~String>
41
- # * 'type'<~String>
42
- # * 'started_at'<~String>
43
- # * 'user'<~Pagerduty::User>
44
- # * 'id'<~String>
45
- # * 'name'<~String>
46
- # * 'email'<~String>
47
- # * 'time_zone'<~String>
48
- # * 'color'<~String>
49
- # * 'avatar_url'<~String>
50
- # * 'user_url'<~String>
51
- # * 'invitation_sent'<~Boolean>
52
- # * 'marketing'<~String>
53
- # * 'marketing_opt_out'<~String>
54
- # * 'type'<~String>
55
- #
56
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/alerts/list]
57
- def alerts(options={})
58
-
59
- unless has_requirements? [:since, :until], options
60
- puts "#> This function requires arguments :since, :until"
61
- puts "Please see: http://developer.pagerduty.com/documentation/rest/alerts/list"
62
- return
63
- end
64
-
65
- Alerts.new(curl({
66
- uri: "https://#@@subdomain.pagerduty.com/api/v1/alerts",
67
- params: options,
68
- method: 'GET'
69
- }))
70
- end
71
-
72
- # List all the existing escalation policies.
73
- #
74
- # ==== Parameters
75
- # * params<~Hash>
76
- # * 'query'<~String> - Filters the result, showing only the escalation policies whose names match the query.
77
- # * 'include'<~Array> - An array of extra data to include with the escalation policies.
78
- #
79
- # ==== Returns
80
- # * <~Array>
81
- # * <~EscalationPolicy>
82
- # * 'id'<~String> - Id of request
83
- # * 'name'<~String> - The policy name
84
- # * 'escalation_rules'<~Array><~EscalationRule>
85
- # * 'escalation_delay_in_minutes'<~Integer> - The escalation delay in minutes
86
- # * 'rule_object'<~RuleObject>:
87
- # * 'id'<~String> - The id of the rule object
88
- # * 'name'<~String> - The name of the rule
89
- # * 'type'<~String> - The type of rule
90
- # * 'email'<~String> - The email address associated with the rule
91
- # * 'time_zone'<~String> - The time zone for the rule
92
- # * 'color'<~String> - The display color of the rule
93
- # * 'services'<~Array><~EscalationService>:
94
- # * 'id'<~String> -
95
- # * 'name'<~String> -
96
- # * 'service_url'<~String> -
97
- # * 'service_key'<~String> -
98
- # * 'auto_resolve_timeout'<~String> -
99
- # * 'acknowledgement_timeout'<~String> -
100
- # * 'created_at'<~String> -
101
- # * 'deleted_at'<~String> -
102
- # * 'status'<~String> -
103
- # * 'last_incident_timestamp'<~String> -
104
- # * 'email_incident_creation'<~String> -
105
- # * 'incident_counts'<~String> -
106
- # * 'email_filter_mode'<~String> -
107
- # * 'type'<~String> -
108
- # * 'num_loops'<~Integer> - The number of times to loop the incident
109
- # * 'limit'<~Integer>
110
- # * 'offset'<~Integer>
111
- # * 'total'<~Integer>
112
- #
113
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/list]
114
- def escalation_policies(options={})
115
- curl({
116
- uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies",
117
- params: { 'query' => options[:query] },
118
- method: 'GET'
119
- })['escalation_policies'].inject([]) { |policies, policy|
120
- policies << EscalationPolicy.new(policy)
121
- }
122
- end
123
-
124
- # Creates a new escalation policy. There must be at least one existing
125
- # escalation rule added to create a new escalation policy
126
- #
127
- # ==== Parameters
128
- # * params<~Hash>
129
- # * 'name'<~String> - The desired name for the escalation policy
130
- # * 'repeat_enabled'<~Boolean> - Whether or not to allow this policy to repeat its escalation rules after the last rule is finished. Defaults to false.
131
- # * 'num_loops'<~Integer> - The number of times to loop over the set of rules in this escalation policy.
132
- # * 'escalation_rules'<~Array> - The escalation rules for this policy. The ordering and available parameters are found under the Escalation Rules API. There must be at least one rule to create a new escalation policy.
133
- #
134
- # ==== Returns
135
- # * response<~EscalationPolicy>:
136
- # * 'id'<~String> - Id of request
137
- # * 'name'<~String> - The policy name
138
- # * 'escalation_rules'<~Array><~EscalationRule>
139
- # * 'escalation_delay_in_minutes'<~Integer> - The escalation delay in minutes
140
- # * 'rule_object'<~RuleObject>:
141
- # * 'id'<~String> - The id of the rule object
142
- # * 'name'<~String> - The name of the rule
143
- # * 'type'<~String> - The type of rule
144
- # * 'email'<~String> - The email address associated with the rule
145
- # * 'time_zone'<~String> - The time zone for the rule
146
- # * 'color'<~String> - The display color of the rule
147
- # * 'services'<~Array><~EscalationService>:
148
- # * 'id'<~String> -
149
- # * 'name'<~String> -
150
- # * 'service_url'<~String> -
151
- # * 'service_key'<~String> -
152
- # * 'auto_resolve_timeout'<~String> -
153
- # * 'acknowledgement_timeout'<~String> -
154
- # * 'created_at'<~String> -
155
- # * 'deleted_at'<~String> -
156
- # * 'status'<~String> -
157
- # * 'last_incident_timestamp'<~String> -
158
- # * 'email_incident_creation'<~String> -
159
- # * 'incident_counts'<~String> -
160
- # * 'email_filter_mode'<~String> -
161
- # * 'type'<~String> -
162
- # * 'num_loops'<~Integer> - The number of times to loop the incident
163
- #
164
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/create]
165
- def create_escalation_policy(options={})
166
-
167
- if options[:escalation_rules]
168
- options[:escalation_rules] = options[:escalation_rules].map { |rule|
169
- rule.class == EscalationRule ? rule.hashify : rule
170
- }
171
- end
172
-
173
- EscalationPolicy.new(curl({
174
- uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies",
175
- data: options,
176
- method: 'POST'
177
- })['escalation_policy'])
178
-
179
- end
180
-
181
- # Get information about an existing escalation policy and its rules
182
- #
183
- # ==== Parameters
184
- #
185
- # * params<~Hash>
186
- # * 'id'<~String>: The id of the escalation policy
187
- #
188
- # ==== Returns
189
- # * response<Array><~Pagerduty::EscalationPolicy>:
190
- # * 'id'<~String> - Id of request
191
- # * 'name'<~String> - The name of the policy
192
- # * 'description'<~String> - Policy description
193
- # * 'escalation_rules'<~Array><~RuleObject>:
194
- # * 'id'<~String> - The id of the rule object
195
- # * 'name'<~String> - The name of the rule
196
- # * 'type'<~String> - The type of rule
197
- # * 'email'<~String> - The email address associated with the rule
198
- # * 'time_zone'<~String> - The time zone for the rule
199
- # * 'color'<~String> - The display color of the rule
200
- # * 'services'<~Array><~EscalationService>:
201
- # * 'id'<~String> -
202
- # * 'name'<~String> -
203
- # * 'service_url'<~String> -
204
- # * 'service_key'<~String> -
205
- # * 'auto_resolve_timeout'<~String> -
206
- # * 'acknowledgement_timeout'<~String> -
207
- # * 'created_at'<~String> -
208
- # * 'deleted_at'<~String> -
209
- # * 'status'<~String> -
210
- # * 'last_incident_timestamp'<~String> -
211
- # * 'email_incident_creation'<~String> -
212
- # * 'incident_counts'<~String> -
213
- # * 'email_filter_mode'<~String> -
214
- # * 'type'<~String> -
215
- # * 'num_loops'<~Integer> - The number of times to loop the incident
216
- #
217
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/show]
218
- def get_escalation_policy(options={})
219
- EscalationPolicy.new(curl({
220
- uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{options[:id]}",
221
- method: 'GET'
222
- })['escalation_policy'])
223
- end
224
-
225
- # List all the escalation rules for an existing escalation policy
226
- #
227
- # ==== Parameters
228
- #
229
- # * params<~Hash>
230
- # * 'escalation_policy_id'<~String>: The id of the escalation policy
231
- #
232
- # ==== Returns
233
- # * response<Array><~Pagerduty::EscalationRule>:
234
- # * 'id'<~String> - Id of request
235
- # * 'escalation_delay_in_minutes'<~Integer> - The escalation delay in minutes
236
- # * <~RuleObject>:
237
- # * 'id'<~String> - The id of the rule object
238
- # * 'name'<~String> - The name of the rule
239
- # * 'type'<~String> - The type of rule
240
- # * 'email'<~String> - The email address associated with the rule
241
- # * 'time_zone'<~String> - The time zone for the rule
242
- # * 'color'<~String> - The display color of the rule
243
- #
244
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/list]
245
- def escalation_rules(options)
246
- curl({
247
- uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{options[:escalation_policy_id]}/escalation_rules",
248
- params: { 'query' => options[:query] },
249
- method: 'GET'
250
- })['escalation_rules'].inject([]) { |rules, rule|
251
- rules << EscalationRule.new(rule)
252
- }
253
- end
254
-
255
- # Show the escalation rule for an existing escalation policy
256
- #
257
- # ==== Parameters
258
- # * params<~Hash>
259
- # * 'escalation_policy_id'<~String>: The id of the escalation policy the rule resides in
260
- # * 'rule_id'<~String>: The id of the rule to retrieve
261
- #
262
- # ==== Returns
263
- # * response<~Pagerduty::EscalationRule>:
264
- # * 'id'<~String> - Id of request
265
- # * 'escalation_delay_in_minutes'<~Integer> - The escalation delay in minutes
266
- # * <~RuleObject>:
267
- # * 'id'<~String> - The id of the rule object
268
- # * 'name'<~String> - The name of the rule
269
- # * 'type'<~String> - The type of rule
270
- # * 'email'<~String> - The email address associated with the rule
271
- # * 'time_zone'<~String> - The time zone for the rule
272
- # * 'color'<~String> - The display color of the rule
273
- #
274
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/show]
275
- def get_escalation_rule(options={})
276
- EscalationRule.new(curl({
277
- uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{options[:escalation_policy_id]}/escalation_rules/#{options[:rule_id]}",
278
- method: 'GET'
279
- })['escalation_rule'])
280
- end
281
-
282
- # Retrieve all incidents
283
- #
284
- # ==== Parameters
285
- # * params<~Hash>
286
- # * 'since'<~String>: The start of the date range over which you want to search. The time element is optional.
287
- # * '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.
288
- # * 'date_range'<~String>: When set to 'all' the 'since' and 'until' params are ignored. Use this to get all incidents since the account was created
289
- # * 'fields'<~String>: Used to restrict the properties of each incident returned to a set of pre-defined fields. If omitted, returned incidents have all fields present. See below for a list of possible fields.
290
- # * 'status'<~String>: Returns only the incidents currently in the passed status(es). Valid status options are triggered, acknowledged, and resolved. More status codes may be introduced in the future.
291
- # * 'incident_key'<~String>: Returns only the incidents with the passed de-duplication key. See the PagerDuty Integration API docs for further details.
292
- # * 'service'<~String>: Returns only the incidents associated with the passed service(s). This expects one or more service IDs. Separate multiple IDs by commas.
293
- # * 'assigned_to_user'<~String>: Returns only the incidents currently assigned to the passed user(s). This expects one or more user IDs. Please see below for more info on how to find your users' IDs. When using the assigned_to_user filter, you will only receive incidents with statuses of triggered or acknowledged. This is because resolved incidents are not assigned to any user.
294
- # * 'time_zone'<~String>: Time zone in which dates in the result will be rendered. Defaults to UTC.
295
- # * 'sort_by'<~String>: Used to specify both the field you wish to sort the results on, as well as the direction See API doc for examples.
296
- #
297
- # ==== Returns
298
- # * response<~Array>:
299
- # * <~Pagerduty::Incident>:
300
- # * 'id'<~String> - Id of request
301
- # * 'incident_number'<~String>:
302
- # * 'created_on'<~String>:
303
- # * 'status'<~String>:
304
- # * 'html_url'<~String>:
305
- # * 'incident_key'<~String>:
306
- # * 'service'<~Pagerduty::Service>
307
- # * 'id'<~String>:
308
- # * 'name'<~String>:
309
- # * 'html_url'<~String>:
310
- # * 'deleted_at'<~String>:
311
- # * 'escalation_policy'<~String>:
312
- # * 'assigned_to_user'<~String>:
313
- # * 'trigger_summary_data'<~String>:
314
- # * 'trigger_details_html_url'<~String>:
315
- # * 'trigger_type'<~String>:
316
- # * 'last_status_change_on'<~String>:
317
- # * 'last_status_change_by'<~Pagerduty::User>:
318
- # * 'id'<~String>:
319
- # * 'name'<~String>:
320
- # * 'email'<~String>:
321
- # * 'html_url'<~String>:
322
- # * 'number_of_escalations'<~Integer>:
323
- # * 'resolved_by_user'<~Pagerduty::ResolvedByUser>:
324
- # * 'id'<~String>:
325
- # * 'name'<~String>:
326
- # * 'email'<~String>:
327
- # * 'html_url'<~String>:
328
- #
329
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/incidents/list]
330
- def incidents(options={})
331
-
332
- Pagerduty::Incidents.new(curl({
333
- uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents",
334
- params: {
335
- since: options[:since] || (Time.now - 1.day).strftime("%Y-%m-%d"),
336
- :until => options[:until] || (Time.now + 1.day).strftime("%Y-%m-%d"),
337
- },
338
- method: 'GET'
339
- }))
340
- end
341
-
342
-
343
- # Show detailed information about an incident. Accepts either an incident id, or an incident number
344
- #
345
- # ==== Parameters
346
- # options<~Hash>
347
- # * 'id'<~String> - The incident id or incident number to look for
348
- #
349
- # ==== Returns
350
- # * <~Pagerduty::Incident>:
351
- # * 'id'<~String> - Id of request
352
- # * 'incident_number'<~String>:
353
- # * 'created_on'<~String>:
354
- # * 'status'<~String>:
355
- # * 'html_url'<~String>:
356
- # * 'incident_key'<~String>:
357
- # * 'service'<~Pagerduty::Service>
358
- # * 'id'<~String>:
359
- # * 'name'<~String>:
360
- # * 'html_url'<~String>:
361
- # * 'deleted_at'<~String>:
362
- # * 'escalation_policy'<~String>:
363
- # * 'assigned_to_user'<~String>:
364
- # * 'trigger_summary_data'<~String>:
365
- # * 'trigger_details_html_url'<~String>:
366
- # * 'trigger_type'<~String>:
367
- # * 'last_status_change_on'<~String>:
368
- # * 'last_status_change_by'<~Pagerduty::User>:
369
- # * 'id'<~String>:
370
- # * 'name'<~String>:
371
- # * 'email'<~String>:
372
- # * 'html_url'<~String>:
373
- # * 'number_of_escalations'<~Integer>:
374
- # * 'resolved_by_user'<~Pagerduty::ResolvedByUser>:
375
- # * 'id'<~String>:
376
- # * 'name'<~String>:
377
- # * 'email'<~String>:
378
- # * 'html_url'<~String>:
379
- #
380
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/incidents/show]
381
- def get_incident(options={})
382
- incidents.incidents.detect { |incident|
383
- incident.id == options[:id] || incident.incident_number == options[:id]
384
- } || 'No results'
385
- end
386
-
387
- # Use this query if you are simply looking for the count of incidents that match a given query. This should be used if you don't need access to the actual incident details.
388
- #
389
- # ==== Parameters
390
- # * options<~Hash>:
391
- # * 'since'<~String> - The start of the date range over which you want to search. The time element is optional.
392
- # * '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.
393
- # * 'date_range'<~String> - When set to all, the since and until parameters and defaults are ignored. Use this to get all counts since the account was created.
394
- # * 'status'<~String> - Only counts the incidents currently in the passed status(es). Valid status options are triggered, acknowledged, and resolved. More status codes may be introduced in the future.
395
- # * 'incident_key'<~String> - Only counts the incidents with the passed de-duplication key. See the PagerDuty Integration API docs for further details.
396
- # * 'service'<~String> - Only counts the incidents associated with the passed service(s). This is expecting one or more service IDs. Separate multiple ids by a comma.
397
- # * 'assigned_to_user'<~String> - Only counts the incidents currently assigned to the passed user(s). This is expecting one or more user IDs. Note: When using the assigned_to_user filter, you will only count incidents with statuses of triggered or acknowledged. This is because resolved incidents are not assigned to any user. Separate multiple ids by a comma.
398
- #
399
- # ==== Returns
400
- # <~Hash>
401
- # * 'total'<~Integer>
402
- #
403
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/incidents/count]
404
- def get_incident_counts(options={})
405
- curl({
406
- uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents/count",
407
- params: options,
408
- method: 'GET',
409
- })
410
- end
411
-
412
- # List users of your PagerDuty account, optionally filtered by a search query.
413
- #
414
- # ==== Parameters
415
- # * options<~Hash>:
416
- # * 'query'<~String> - Filters the result, showing only the users whose names or email addresses match the query
417
- # * 'include'<~Array> - Array of additional details to include. This API accepts contact_methods, and notification_rules
418
- #
419
- # ==== Returns
420
- # * <~Users>
421
- # * 'users'<~Array>:
422
- # * 'user'<~Pagerduty::User>:
423
- # * 'id'<~String>
424
- # * 'name'<~String>
425
- # * 'email'<~String>
426
- # * 'time_zone'<~String>
427
- # * 'color'<~String>
428
- # * 'role'<~String>
429
- # * 'avatar_url'<~String>
430
- # * 'user_url'<~String>
431
- # * 'invitation_sent'<~Boolean>
432
- # * 'marketing'<~String>
433
- # * 'marketing_opt_out'<~String>
434
- # * 'type'<~String>
435
- # * 'active_account_users'<~Integer>
436
- # * 'limit'<~Integer>
437
- # * 'offset'<~Integer>
438
- # * 'total'<~Integer>
439
- #
440
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/users/list]
441
- def get_users(options={})
442
- Users.new(curl({
443
- uri: "https://#@@subdomain.pagerduty.com/api/v1/users",
444
- params: options,
445
- method: 'GET'
446
- }))
447
- end
448
-
449
- # Get information about an existing user.
450
- #
451
- # ==== Parameters
452
- # * options<~Hash>:
453
- # * 'id'<~String> - The ID of the user to retrieve
454
- #
455
- # ==== Returns
456
- # * 'user'<~User>:
457
- # * 'time_zone'<~String>
458
- # * 'color'<~String>
459
- # * 'email'<~String>
460
- # * 'avatar_url'<~String>
461
- # * 'user_url'<~String>
462
- # * 'invitation_sent'<~Boolean>
463
- # * 'role'<~String>
464
- # * 'name'<~String>
465
- # * 'id'<~String>
466
- #
467
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/users/show]
468
- def get_user(options={})
469
- get_users.users.detect { |user| user.id == options[:id] }
470
- end
471
-
472
- # Create a new user for your account. An invite email will be sent asking the user to choose a password
473
- #
474
- # ==== Parameters
475
- # * options<~Hash>:
476
- # * 'role'<~String> - The user's role. This can either be admin or user and defaults to user if not specificed
477
- # * 'name'<~String> - The name of the user
478
- # * 'email'<~String> - The email of the user. The newly created user will receive an email asking to confirm the subscription
479
- # * 'time_zone'<~String> - The time zone the user is in. If not specified, the time zone of the account making the API call will be used
480
- # * 'requester_id'<~String> - The user id of the user creating the user. This is only needed if you are using token based authentication
481
- #
482
- # ==== Returns
483
- # * 'user'<~User>
484
- # * 'time_zone'<~String>
485
- # * 'color'<~String>
486
- # * 'email'<~String>
487
- # * 'avatar_url'<~String>
488
- # * 'user_url'<~String>
489
- # * 'invitation_sent'<~String>
490
- # * 'role'<~String>
491
- # * 'name'<~String>
492
- # * 'id'<~String>
493
- #
494
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/users/create]
495
- def create_user(options={})
496
- User.new(curl({
497
- uri: "https://#@@subdomain.pagerduty.com/api/v1/users",
498
- data: options,
499
- method: 'POST'
500
- })['user'])
501
- end
502
-
503
- # List existing notes for the specified incident.
504
- #
505
- # ==== Parameters
506
- # * options<~Hash>:
507
- # * 'id' - The id of the incident to retrieve notes from
508
- #
509
- # ==== Returns
510
- # * <~Notes>:
511
- # * 'notes'<~Array>:
512
- # * ~<Note>:
513
- # * 'id' -
514
- # * 'user'<~Pagerduty::User>:
515
- # * 'id'<~String>
516
- # * 'name'<~String>
517
- # * 'email'<~String>
518
- # * 'time_zone'<~String>
519
- # * 'color'<~String>
520
- # * 'role'<~String>
521
- # * 'avatar_url'<~String>
522
- # * 'user_url'<~String>
523
- # * 'invitation_sent'<~Boolean>
524
- # * 'marketing'<~String>
525
- # * 'marketing_opt_out'<~String>
526
- # * 'type'<~String>
527
- # * 'content'<~String> -
528
- # * 'created_at'<~String> -
529
- #
530
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/incidents/notes/list]
531
- def notes(id)
532
- Notes.new(curl({
533
- uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents/#{id}/notes",
534
- method: 'GET'
535
- }))
536
- end
537
-
538
-
539
- # List all incident log entries across the entire account
540
- #
541
- # ==== Parameters
542
- # * options<~Hash>:
543
- # * 'time_zone'<~String> -
544
- # * 'since'<~String> - The start of the date range over which you want to search. The time element is optional.
545
- # * '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.
546
- # * 'is_overview'<~Boolean> -
547
- # * 'until'<~Array> - 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.
548
- # * 'include'<~Array> - 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.
549
- #
550
- # ==== Returns
551
- # * 'log_entries'<~Array>:
552
- # * <~Pagerduty::LogEntry>:
553
- # * 'id'<~String> -
554
- # * 'type'<~String> -
555
- # * 'created_at'<~String> -
556
- # * 'note'<~String> -
557
- # * 'agent'<~Pagerduty::User>
558
- # * 'id'<~String>
559
- # * 'name'<~String>
560
- # * 'email'<~String>
561
- # * 'time_zone'<~String>
562
- # * 'color'<~String>
563
- # * 'role'<~String>
564
- # * 'avatar_url'<~String>
565
- # * 'user_url'<~String>
566
- # * 'invitation_sent'<~Boolean>
567
- # * 'marketing'<~String>
568
- # * 'marketing_opt_out'<~String>
569
- # * 'type'<~String>
570
- # * 'user'<~Pagerduty::User>
571
- # * 'id'<~String>
572
- # * 'name'<~String>
573
- # * 'email'<~String>
574
- # * 'time_zone'<~String>
575
- # * 'color'<~String>
576
- # * 'role'<~String>
577
- # * 'avatar_url'<~String>
578
- # * 'user_url'<~String>
579
- # * 'invitation_sent'<~Boolean>
580
- # * 'marketing'<~String>
581
- # * 'marketing_opt_out'<~String>
582
- # * 'type'<~String>
583
- # * 'channel'<~Hash>
584
- # * 'type'
585
- # * 'limit'<~Integer> -
586
- # * 'offset'<~Integer> -
587
- # * 'total'<~Integer> -
588
- #
589
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/log_entries/list]
590
- def get_log_entries(options={})
591
- LogEntries.new(curl({
592
- uri: "https://#@@subdomain.pagerduty.com/api/v1/log_entries",
593
- params: options,
594
- method: 'GET'
595
- }))
596
- end
597
-
598
- # Get details for a specific incident log entry. This method provides additional information you can use to get at raw event data
599
- #
600
- # ==== Parameters
601
- # * options<~Hash>
602
- # * 'time_zone'<~TimeZone> -
603
- # * 'include'<~Array> -
604
- #
605
- # ==== Returns
606
- # * 'log_entry'<~LogEntry>
607
- # * 'id'<~String>
608
- # * 'type'<~String>
609
- # * 'created_at'<~String>
610
- # * 'agent'<~Pagerduty::User>
611
- # * 'id'<~String>
612
- # * 'name'<~String>
613
- # * 'email'<~String>
614
- # * 'time_zone'<~String>
615
- # * 'color'<~String>
616
- # * 'role'<~String>
617
- # * 'avatar_url'<~String>
618
- # * 'user_url'<~String>
619
- # * 'invitation_sent'<~Boolean>
620
- # * 'marketing'<~String>
621
- # * 'marketing_opt_out'<~String>
622
- # * 'type'<~String>
623
- # * 'user'<~Pagerduty::User>
624
- # * 'id'<~String>
625
- # * 'name'<~String>
626
- # * 'email'<~String>
627
- # * 'time_zone'<~String>
628
- # * 'color'<~String>
629
- # * 'role'<~String>
630
- # * 'avatar_url'<~String>
631
- # * 'user_url'<~String>
632
- # * 'invitation_sent'<~Boolean>
633
- # * 'marketing'<~String>
634
- # * 'marketing_opt_out'<~String>
635
- # * 'type'<~String>
636
- # * 'channel'<~Hash>
637
- # * 'summary'<~String>
638
- # * 'type'<~String>
639
- #
640
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/log_entries/show]
641
- def get_log_entry(options={})
642
- LogEntry.new(curl({
643
- uri: "https://#@@subdomain.pagerduty.com/api/v1/log_entries/#{options[:id]}",
644
- params: options,
645
- method: 'GET'
646
- })['log_entry'])
647
- end
648
-
649
- # Get high level statistics about the number of alerts (SMSes, phone calls and emails) sent for the desired time period, summed daily, weekly or monthly.
650
- #
651
- # ==== Parameters
652
- # * options<~Hash>:
653
- # * 'since'<~String> - The start of the date range over which you want to search. The time element is optional.
654
- # * '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.
655
- # * 'rollup'<~String> - Possible values are daily, weekly or monthly. Specifies the bucket duration for each summation. Defaults to monthly. (Example: A time window of two years (based on since and until) with a rollup of monthly will result in 24 sets of data points being returned (one for each month in the span))
656
- #
657
- # ==== Returns
658
- # * 'alerts'<~Array>
659
- # * <~Pagerduty::Reports::Alert>:
660
- # * 'number_of_alerts'<~Integer>
661
- # * 'number_of_phone_alerts'<~Integer>
662
- # * 'number_of_sms_alerts'<~Integer>
663
- # * 'number_of_email_alerts'<~Integer>
664
- # * 'start'<~String>
665
- # * 'end'<~String>
666
- # * 'total_number_of_alerts'<~Integer> -
667
- # * 'total_number_of_phone_alerts'<~Integer> -
668
- # * 'total_number_of_sms_alerts'<~Integer> -
669
- # * 'total_number_of_email_alerts'<~Integer> -
670
- # * 'total_number_of_billable_alerts'<~Integer> -
671
- #
672
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/reports/alerts_per_time]
673
- def alerts_per_time(options={})
674
- Pagerduty::Reports::Alerts.new(curl({
675
- uri: "https://#@@subdomain.pagerduty.com/api/v1/reports/alerts_per_time",
676
- params: options,
677
- method: 'GET'
678
- }))
679
- end
680
-
681
- # Get high level statistics about the number of incidents created for the desired time period, summed daily, weekly or monthly
682
- #
683
- # ==== Parameters
684
- # * options<~Hash>:
685
- # * 'since'<~String>: The start of the date range over which you want to search. The time element is optional.
686
- # * '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.
687
- # * 'rollup'<~String>: Possible values are daily, weekly or monthly. Specifies the bucket duration for each summation. Defaults to monthly. (Example: A time window of two years (based on since and until) with a rollup of monthly will result in 24 sets of data points being returned (one for each month in the span))
688
- #
689
- # ==== Returns
690
- # * <~Pagerduty::Reports::Incidents>
691
- # * 'incidents'<~Array>
692
- # * <~Pagerduty::Reports::Incident>
693
- # * 'number_of_incidents'<~Integer> -
694
- # * 'start'<~String> -
695
- # * 'end'<~String> -
696
- #
697
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/reports/incidents_per_time]
698
- def incidents_per_time(options={})
699
- Pagerduty::Reports::Incidents.new(curl({
700
- uri: "https://#@@subdomain.pagerduty.com/api/v1/reports/incidents_per_time/",
701
- params: options,
702
- method: 'GET'
703
- }))
704
- end
705
-
706
- # List existing maintenance windows, optionally filtered by service, or whether they are from the past, present or future
707
- #
708
- # ==== Parameters
709
- # * options<~Hash>
710
- # * 'query'<~String> - Filters the results, showing only the maintenance windows whose descriptions contain the query
711
- # * 'service_ids'<~Array> - An array of service IDs, specifying services whose maintenance windows shall be returned
712
- # * 'filter'<~String> - Only return maintenance windows that are of this type. Possible values are past, future, ongoing. If this parameter is omitted, all maintenance windows will be returned
713
- #
714
- # ==== Returns
715
- # * <~Pagerduty::MaintenanceWindows>
716
- # * 'maintenance_windows'<~Array>
717
- # * <~Pagerduty::MaintenanceWindow>
718
- # * 'id'<~String>
719
- # * 'sequence_number'<~Integer>
720
- # * 'start_time'<~String>
721
- # * 'end_time'<~String>
722
- # * 'description'<~String>
723
- # * 'created_by'<~Pagerduty::User>
724
- # * 'id'<~String>
725
- # * 'name'<~String>
726
- # * 'email'<~String>
727
- # * 'time_zone'<~String>
728
- # * 'color'<~String>
729
- # * 'role'<~String>
730
- # * 'avatar_url'<~String>
731
- # * 'user_url'<~String>
732
- # * 'invitation_sent'<~Boolean>
733
- # * 'marketing'<~String>
734
- # * 'marketing_opt_out'<~String>
735
- # * 'type'<~String>
736
- # * 'services'<~Array>
737
- # * <~Service>
738
- # * 'id'<~String>
739
- # * 'name'<~String>
740
- # * 'html_url'<~String>
741
- # * 'delete_at'<~String>
742
- # * 'service_ids'<~Array> - An array of strings of all the service IDs associated with the maintenance window
743
- # * 'limit'<~Integer>
744
- # * 'offset'<~Integer>
745
- # * 'total'<~Integer>
746
- # * 'query'<~Integer>
747
- # * 'query'<~String>
748
- # * 'counts'<~Pagerduty::MaintenanceWindow::Count>
749
- # * 'ongoing'<~Integer>
750
- # * 'future'<~Integer>
751
- # * 'past'<~Integer>
752
- # * 'all'<~Integer>
753
- #
754
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/maintenance_windows/list]
755
- def get_maintenance_windows(options={})
756
- Pagerduty::MaintenanceWindows.new(curl({
757
- uri: "https://#@@subdomain.pagerduty.com/api/v1/maintenance_windows",
758
- params: options,
759
- method: 'GET'
760
- }))
761
- end
762
-
763
- # Get details about an existing maintenance window
764
- #
765
- # ==== Parameters
766
- # * 'options'<~Hash>:
767
- # * 'id'<~String> - The id of the maintenance window to retrieve
768
- #
769
- # ==== Returns
770
- # * <~Pagerduty::MaintenanceWindow>
771
- # * 'id'<~String>
772
- # * 'sequence_number'<~Integer>
773
- # * 'start_time'<~String>
774
- # * 'end_time'<~String>
775
- # * 'description'<~String>
776
- # * 'created_by'<~Pagerduty::User>
777
- # * 'id'<~String>
778
- # * 'name'<~String>
779
- # * 'email'<~String>
780
- # * 'time_zone'<~String>
781
- # * 'color'<~String>
782
- # * 'role'<~String>
783
- # * 'avatar_url'<~String>
784
- # * 'user_url'<~String>
785
- # * 'invitation_sent'<~Boolean>
786
- # * 'marketing'<~String>
787
- # * 'marketing_opt_out'<~String>
788
- # * 'type'<~String>
789
- # * 'services'<~Array>
790
- # * <~Service>
791
- # * 'id'<~String>
792
- # * 'name'<~String>
793
- # * 'html_url'<~String>
794
- # * 'delete_at'<~String>
795
- # * 'service_ids'<~Array> - An array of strings of all the service IDs associated with the maintenance window
796
- #
797
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/maintenance_windows/show]
798
- def get_maintenance_window(options={})
799
- Pagerduty::MaintenanceWindow.new(curl({
800
- uri: "https://#@@subdomain.pagerduty.com/api/v1/maintenance_windows/#{options[:id]}",
801
- params: options,
802
- method: 'GET'
803
- })['maintenance_window'])
804
- end
805
-
806
- # Create a new maintenance window for the specified services. No new incidents will be created for a service that is currently in maintenance
807
- #
808
- # ==== Parameters
809
- # * 'options'<~Hash>
810
- # * 'requester_id'<~String>
811
- # * 'maintenance_window'<~Hash>
812
- # * 'start_time'<~String>
813
- # * 'end_time'<~String>
814
- # * 'description'<~String>
815
- # * 'service_ids'<~Array>
816
- #
817
- # ==== Returns
818
- # * <~Pagerduty::MaintenanceWindow>
819
- # * 'id'<~String>
820
- # * 'sequence_number'<~Integer>
821
- # * 'start_time'<~String>
822
- # * 'end_time'<~String>
823
- # * 'description'<~String>
824
- # * 'created_by'<~Pagerduty::User>
825
- # * 'id'<~String>
826
- # * 'name'<~String>
827
- # * 'email'<~String>
828
- # * 'time_zone'<~String>
829
- # * 'color'<~String>
830
- # * 'role'<~String>
831
- # * 'avatar_url'<~String>
832
- # * 'user_url'<~String>
833
- # * 'invitation_sent'<~Boolean>
834
- # * 'marketing'<~String>
835
- # * 'marketing_opt_out'<~String>
836
- # * 'type'<~String>
837
- # * 'services'<~Array>
838
- # * <~Service>
839
- # * 'id'<~String>
840
- # * 'name'<~String>
841
- # * 'html_url'<~String>
842
- # * 'delete_at'<~String>
843
- # * 'service_ids'<~Array> - An array of strings of all the service IDs associated with the maintenance window
844
- #
845
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/maintenance_windows/create]
846
- def create_maintenance_window(options={})
847
- Pagerduty::MaintenanceWindow.new(curl({
848
- uri: "https://#@@subdomain.pagerduty.com/api/v1/maintenance_windows",
849
- data: options,
850
- method: 'POST'
851
- })['maintenance_window'])
852
- end
853
-
854
- # List existing on-call schedules
855
- #
856
- # ==== Parameters
857
- # * options<~Hash>:
858
- # * 'query'<~String> - Filters the result, showing only the schedules whose name matches the query
859
- # * 'requester_id'<~String> - The user id of the user making the request. This will be used to generate the calendar private urls. This is only needed if you are using token based authentication
860
- #
861
- # ==== Returns
862
- # * <~Pagerduty::Schedules>
863
- # * 'schedules'<~Array>
864
- # * <~Pagerduty::Schedules::Schedule>
865
- # * 'id'<~String>
866
- # * 'name'<~String>
867
- # * 'time_zone'<~String>
868
- # * 'today'<~String>
869
- # * 'escalation_policies'<~Array>
870
- # * <~EscalationPolicy>
871
- # * 'id'<~String>
872
- # * 'name'<~String>
873
- # * 'description'<~String>
874
- # * 'escalation_rules'<~Array>
875
- # * 'services'<~Set>
876
- # * 'num_loops'<~Integer>
877
- # * 'limit'<~Integer>
878
- # * 'offset'<~Integer>
879
- # * 'total'<~Integer>
880
- #
881
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/schedules/list]
882
- def get_schedules(options={})
883
- Pagerduty::Schedules.new(curl({
884
- uri: "https://#@@subdomain.pagerduty.com/api/v1/schedules",
885
- params: options,
886
- method: 'GET'
887
- }))
888
- end
889
-
890
- # Show detailed information about a schedule, including entries for each layer and sub-schedule
891
- #
892
- # ==== Parameters
893
- # * options<~Hash>:
894
- # * 'since'<~String> - The start of the date range over which you want to return on-call schedule entries and on-call schedule layers
895
- # * 'until'<~String> - The end of the date range over which you want to return schedule entries and on-call schedule layers
896
- # * 'time_zone'<~TimeZone> - Time zone in which dates in the result will be rendered. Defaults to account time zone
897
- #
898
- # ==== Returns
899
- # * response<~ScheduleInfo>:
900
- # * 'id'<~String>
901
- # * 'name'<~String>
902
- # * 'time_zone'<~String>
903
- # * 'today'<~String>
904
- # * 'escalation_policies'<~Array>:
905
- # * <~EscalationPolicy>:
906
- # * 'id'<~String>
907
- # * 'name'<~String>
908
- # * 'description'<~String>
909
- # * 'escalation_rules'<~Array>
910
- # * 'services'<~Set>
911
- # * 'num_loops'<~Integer>
912
- # * 'schedule_layers'<~Array>:
913
- # * <~Pagerduty::Schedules::ScheduleLayer>:
914
- # * 'name'<~String>
915
- # * 'rendered_schedule_entries'<~Array>
916
- # * 'id'<~String>
917
- # * 'priority'<~Integer>
918
- # * 'start'<~String>
919
- # * 'end'<~String>
920
- # * 'restriction_type'<~String>
921
- # * 'rotation_virtual_start'<~String>
922
- # * 'rotation_turn_length_seconds'<~Integer>
923
- # * 'users'<~Array>
924
- # * <~Pagerduty::Schedules::ScheduleLayer::User>:
925
- # * 'member_order'<~Integer>
926
- # * 'user'<~Pagerduty::User>:
927
- # * 'id'<~String>
928
- # * 'name'<~String>
929
- # * 'email'<~String>
930
- # * 'time_zone'<~String>
931
- # * 'color'<~String>
932
- # * 'role'<~String>
933
- # * 'avatar_url'<~String>
934
- # * 'user_url'<~String>
935
- # * 'invitation_sent'<~Boolean>
936
- # * 'marketing'<~String>
937
- # * 'marketing_opt_out'<~String>
938
- # * 'type'<~String>
939
- # * 'restrictions'<~Array>
940
- # * 'rendered_coverage_percentage'<~Float>
941
- # * 'overrides_schedule'<~Pagerduty::Schedules::Override>:
942
- # * 'name'<~String>
943
- # * 'rendered_schedule_entries'<~Array>
944
- # * 'final_schedule'<~Pagerduty::Schedules::FinalSchedule>:
945
- # * 'name'<~String>
946
- # * 'rendered_schedule_entries'<~Array>
947
- # * 'rendered_coverage_percentage'<~Float>
948
- #
949
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/schedules/show]
950
- def get_schedule(options={})
951
- Pagerduty::ScheduleInfo.new(curl({
952
- uri: "https://#@@subdomain.pagerduty.com/api/v1/schedules/#{options[:id]}",
953
- params: options,
954
- method: 'GET'
955
- })['schedule'])
956
- end
957
-
958
- # List all the users on-call in a given schedule for a given time range.
959
- #
960
- # ==== Parameters
961
- # * options<~Hash>:
962
- # * 'since'<~String> - The start of the date range over which you want to return on-call users
963
- # * 'until'<~String> - The end time of the date range over which you want to return on-call users
964
- #
965
- # ==== Returns
966
- # * <~Array>:
967
- # * <~Pagerduty::User>
968
- # * 'id'<~String>
969
- # * 'name'<~String>
970
- # * 'email'<~String>
971
- # * 'time_zone'<~String>
972
- # * 'color'<~String>
973
- # * 'role'<~String>
974
- # * 'avatar_url'<~String>
975
- # * 'user_url'<~String>
976
- # * 'invitation_sent'<~Boolean>
977
- # * 'marketing'<~String>
978
- # * 'marketing_opt_out'<~String>
979
- # * 'type'<~String>
980
- #
981
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/schedules/users]
982
- def get_schedule_users(options={})
983
- Users.new(curl({
984
- uri: "https://#@@subdomain.pagerduty.com/api/v1/schedules/#{options[:id]}/users",
985
- params: options,
986
- method: 'GET'
987
- })).users
988
- end
989
-
990
- # List existing services
991
- #
992
- # ==== Parameters
993
- # * options<~Hash>:
994
- # * 'include'<~Array> - Include extra information in the response. Possible values are escalation_policy (for inline Escalation Policy) and email_filters (for inline Email Filters)
995
- # * 'time_zone'<~TimeZone> - Time zone in which dates in the result will be rendered. Defaults to account default time zone
996
- #
997
- # ==== Returns
998
- # * services<~Array>:
999
- # * <~Pagerduty::Services::Objects::Service>:
1000
- # * 'id'<~String>
1001
- # * 'name'<~String>
1002
- # * 'description'<~String>
1003
- # * 'service_url'<~String>
1004
- # * 'service_key'<~String>
1005
- # * 'auto_resolve_timeout'<~Integer>
1006
- # * 'acknowledgement_timeout'<~Integer>
1007
- # * 'created_at'<~String>
1008
- # * 'status'<~String>
1009
- # * 'last_incident_timestamp'<~String>
1010
- # * 'email_incident_creation'<~String>
1011
- # * 'incident_counts'<~Hash>
1012
- # * 'triggered'<~Integer>
1013
- # * 'acknowledged'<~Integer>
1014
- # * 'resolved'<~Integer>
1015
- # * 'total'<~Integer>
1016
- # * 'email_filter_mode'<~String>
1017
- # * 'type'<~String>
1018
- # * 'escalation_policy'<~String>
1019
- # * 'email_filters'<~String> - An object containing inline Email Filters. Only present if email_filters is passed as an argument. Note that only generic_email services have Email Filters
1020
- # * 'severity_filter'<~String> - Specifies what severity levels will create a new open incident
1021
- #
1022
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/services/list]
1023
- def get_services(options={})
1024
- Pagerduty::Services.new(curl({
1025
- uri: "https://#@@subdomain.pagerduty.com/api/v1/services",
1026
- params: options,
1027
- method: 'GET'
1028
- }))
1029
- end
1030
-
1031
- # Get details about an existing service
1032
- #
1033
- # ==== Parameters
1034
- # * options<~Hash>:
1035
- # * 'include'<~Array> - Include extra information in the response. Possible values are escalation_policy (for inline Escalation Policy) and email_filters (for inline Email Filters)
1036
- #
1037
- # ==== Returns
1038
- # * <~Pagerduty::Services::Objects::Service>:
1039
- # * 'id'<~String>
1040
- # * 'name'<~String>
1041
- # * 'description'<~String>
1042
- # * 'service_url'<~String>
1043
- # * 'service_key'<~String>
1044
- # * 'auto_resolve_timeout'<~Integer>
1045
- # * 'acknowledgement_timeout'<~Integer>
1046
- # * 'created_at'<~String>
1047
- # * 'status'<~String>
1048
- # * 'last_incident_timestamp'<~String>
1049
- # * 'email_incident_creation'<~String>
1050
- # * 'incident_counts'<~Hash>
1051
- # * 'triggered'<~Integer>
1052
- # * 'acknowledged'<~Integer>
1053
- # * 'resolved'<~Integer>
1054
- # * 'total'<~Integer>
1055
- # * 'email_filter_mode'<~String>
1056
- # * 'type'<~String>
1057
- # * 'escalation_policy'<~String>
1058
- # * 'email_filters'<~String> - An object containing inline Email Filters. Only present if email_filters is passed as an argument. Note that only generic_email services have Email Filters
1059
- # * 'severity_filter'<~String> - Specifies what severity levels will create a new open incident
1060
- #
1061
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/services/show]
1062
- def get_service(options={})
1063
- Pagerduty::Services::Objects::Service.new(curl({
1064
- uri: "https://#@@subdomain.pagerduty.com/api/v1/services/#{options[:id]}",
1065
- params: options,
1066
- method: 'GET'
1067
- })['service'])
1068
- end
1069
-
1070
- # Create a new service
1071
- #
1072
- # ==== Parameters
1073
- # * options<~Hash>:
1074
- # * 'name'<~String> - The name of the service
1075
- # * 'escalation_policy_id'<~String> - The id of the escalation policy to be used by this service
1076
- # * 'type'<~String> - The type of service to create. Can be one of generic_email, generic_events_api, keynote, nagios, pingdom, server_density or sql_monitor
1077
- # * 'description'<~String> - A description for your service. 1024 character maximum
1078
- # * 'acknowledgement_timeout'<~Integer> - The duration in seconds before an incidents acknowledged in this service become triggered again. (Defaults to 30 minutes)
1079
- # * 'auto_resolve_timeout'<~Integer> - The duration in seconds before a triggered incident auto-resolves itself. (Defaults to 4 hours)
1080
- # * 'severity_filter'<~String> - Specifies what severity levels will create a new open incident
1081
- #
1082
- # ==== Returns
1083
- # * <~Pagerduty::Services::Objects::Service>:
1084
- # * 'id'<~String>
1085
- # * 'name'<~String>
1086
- # * 'description'<~String>
1087
- # * 'service_url'<~String>
1088
- # * 'service_key'<~String>
1089
- # * 'auto_resolve_timeout'<~Integer>
1090
- # * 'acknowledgement_timeout'<~Integer>
1091
- # * 'created_at'<~String>
1092
- # * 'status'<~String>
1093
- # * 'last_incident_timestamp'<~String>
1094
- # * 'email_incident_creation'<~String>
1095
- # * 'incident_counts'<~Hash>
1096
- # * 'triggered'<~Integer>
1097
- # * 'acknowledged'<~Integer>
1098
- # * 'resolved'<~Integer>
1099
- # * 'total'<~Integer>
1100
- # * 'email_filter_mode'<~String>
1101
- # * 'type'<~String>
1102
- # * 'escalation_policy'<~String>
1103
- # * 'email_filters'<~String> - An object containing inline Email Filters. Only present if email_filters is passed as an argument. Note that only generic_email services have Email Filters
1104
- # * 'severity_filter'<~String> - Specifies what severity levels will create a new open incident
1105
- #
1106
- # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/services/create]
1107
- def create_service(options={})
1108
- Pagerduty::Services::Objects::Service.new(curl({
1109
- uri: "https://#@@subdomain.pagerduty.com/api/v1/services",
1110
- data: { service: options },
1111
- method: 'POST'
1112
- })['service'])
1113
- end
1114
-
1115
- end
1
+
2
+ class Pagerduty
3
+
4
+ include Pagerduty::Core
5
+
6
+ attr_reader :token
7
+ attr_reader :subdomain
8
+
9
+ def initialize(options)
10
+ @@token = options[:token]
11
+ @@subdomain = options[:subdomain]
12
+ end
13
+
14
+
15
+ # Check a Hash object for expected keys
16
+ #
17
+ # ==== Parameters
18
+ # * 'keys'<~Array><~Object> - An array of objects expected to be found as keys in the supplied Hash
19
+ # * 'options'<~Hash> - The Hash to perform the check on
20
+ #
21
+ # ==== Returns
22
+ # * Boolean
23
+ #
24
+ def has_requirements?(keys,options)
25
+ (keys - options.keys).empty?
26
+ end
27
+
28
+
29
+ # List existing alerts for a given time range, optionally filtered by type (SMS, Email, Phone, or Push)
30
+ #
31
+ # ==== Parameters
32
+ # * params<~Hash>
33
+ # * 'since'<~String>: The start of the date range over which you want to search. The time element is optional.
34
+ # * '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.
35
+ # * 'filter'<~String>: Returns only the alerts of the said types. Can be one of SMS, Email, Phone, or Push.
36
+ # * 'time_zone'<~TimeZone>: Time zone in which dates in the result will be rendered. Defaults to account time zone.
37
+ #
38
+ # ==== Returns
39
+ # * 'alerts'<~Array><~Alerts>
40
+ # * 'id'<~String>
41
+ # * 'type'<~String>
42
+ # * 'started_at'<~String>
43
+ # * 'user'<~Pagerduty::User>
44
+ # * 'id'<~String>
45
+ # * 'name'<~String>
46
+ # * 'email'<~String>
47
+ # * 'time_zone'<~String>
48
+ # * 'color'<~String>
49
+ # * 'avatar_url'<~String>
50
+ # * 'user_url'<~String>
51
+ # * 'invitation_sent'<~Boolean>
52
+ # * 'marketing'<~String>
53
+ # * 'marketing_opt_out'<~String>
54
+ # * 'type'<~String>
55
+ #
56
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/alerts/list]
57
+ def alerts(options={})
58
+
59
+ unless has_requirements? [:since, :until], options
60
+ puts "#> This function requires arguments :since, :until"
61
+ puts "Please see: http://developer.pagerduty.com/documentation/rest/alerts/list"
62
+ return
63
+ end
64
+
65
+ Alerts.new(curl({
66
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/alerts",
67
+ params: options,
68
+ method: 'GET'
69
+ }))
70
+ end
71
+
72
+ # List all the existing escalation policies.
73
+ #
74
+ # ==== Parameters
75
+ # * params<~Hash>
76
+ # * 'query'<~String> - Filters the result, showing only the escalation policies whose names match the query.
77
+ # * 'include'<~Array> - An array of extra data to include with the escalation policies.
78
+ #
79
+ # ==== Returns
80
+ # * <~Array>
81
+ # * <~EscalationPolicy>
82
+ # * 'id'<~String> - Id of request
83
+ # * 'name'<~String> - The policy name
84
+ # * 'escalation_rules'<~Array><~EscalationRule>
85
+ # * 'escalation_delay_in_minutes'<~Integer> - The escalation delay in minutes
86
+ # * 'rule_object'<~RuleObject>:
87
+ # * 'id'<~String> - The id of the rule object
88
+ # * 'name'<~String> - The name of the rule
89
+ # * 'type'<~String> - The type of rule
90
+ # * 'email'<~String> - The email address associated with the rule
91
+ # * 'time_zone'<~String> - The time zone for the rule
92
+ # * 'color'<~String> - The display color of the rule
93
+ # * 'services'<~Array><~EscalationService>:
94
+ # * 'id'<~String> -
95
+ # * 'name'<~String> -
96
+ # * 'service_url'<~String> -
97
+ # * 'service_key'<~String> -
98
+ # * 'auto_resolve_timeout'<~String> -
99
+ # * 'acknowledgement_timeout'<~String> -
100
+ # * 'created_at'<~String> -
101
+ # * 'deleted_at'<~String> -
102
+ # * 'status'<~String> -
103
+ # * 'last_incident_timestamp'<~String> -
104
+ # * 'email_incident_creation'<~String> -
105
+ # * 'incident_counts'<~String> -
106
+ # * 'email_filter_mode'<~String> -
107
+ # * 'type'<~String> -
108
+ # * 'num_loops'<~Integer> - The number of times to loop the incident
109
+ # * 'limit'<~Integer>
110
+ # * 'offset'<~Integer>
111
+ # * 'total'<~Integer>
112
+ #
113
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/list]
114
+ def escalation_policies(options={})
115
+ curl({
116
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies",
117
+ params: { 'query' => options[:query] },
118
+ method: 'GET'
119
+ })['escalation_policies'].inject([]) { |policies, policy|
120
+ policies << EscalationPolicy.new(policy)
121
+ }
122
+ end
123
+
124
+ # Creates a new escalation policy. There must be at least one existing
125
+ # escalation rule added to create a new escalation policy
126
+ #
127
+ # ==== Parameters
128
+ # * params<~Hash>
129
+ # * 'name'<~String> - The desired name for the escalation policy
130
+ # * 'repeat_enabled'<~Boolean> - Whether or not to allow this policy to repeat its escalation rules after the last rule is finished. Defaults to false.
131
+ # * 'num_loops'<~Integer> - The number of times to loop over the set of rules in this escalation policy.
132
+ # * 'escalation_rules'<~Array> - The escalation rules for this policy. The ordering and available parameters are found under the Escalation Rules API. There must be at least one rule to create a new escalation policy.
133
+ #
134
+ # ==== Returns
135
+ # * response<~EscalationPolicy>:
136
+ # * 'id'<~String> - Id of request
137
+ # * 'name'<~String> - The policy name
138
+ # * 'escalation_rules'<~Array><~EscalationRule>
139
+ # * 'escalation_delay_in_minutes'<~Integer> - The escalation delay in minutes
140
+ # * 'rule_object'<~RuleObject>:
141
+ # * 'id'<~String> - The id of the rule object
142
+ # * 'name'<~String> - The name of the rule
143
+ # * 'type'<~String> - The type of rule
144
+ # * 'email'<~String> - The email address associated with the rule
145
+ # * 'time_zone'<~String> - The time zone for the rule
146
+ # * 'color'<~String> - The display color of the rule
147
+ # * 'services'<~Array><~EscalationService>:
148
+ # * 'id'<~String> -
149
+ # * 'name'<~String> -
150
+ # * 'service_url'<~String> -
151
+ # * 'service_key'<~String> -
152
+ # * 'auto_resolve_timeout'<~String> -
153
+ # * 'acknowledgement_timeout'<~String> -
154
+ # * 'created_at'<~String> -
155
+ # * 'deleted_at'<~String> -
156
+ # * 'status'<~String> -
157
+ # * 'last_incident_timestamp'<~String> -
158
+ # * 'email_incident_creation'<~String> -
159
+ # * 'incident_counts'<~String> -
160
+ # * 'email_filter_mode'<~String> -
161
+ # * 'type'<~String> -
162
+ # * 'num_loops'<~Integer> - The number of times to loop the incident
163
+ #
164
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/create]
165
+ def create_escalation_policy(options={})
166
+
167
+ if options[:escalation_rules]
168
+ options[:escalation_rules] = options[:escalation_rules].map { |rule|
169
+ rule.class == EscalationRule ? rule.hashify : rule
170
+ }
171
+ end
172
+
173
+ EscalationPolicy.new(curl({
174
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies",
175
+ data: options,
176
+ method: 'POST'
177
+ })['escalation_policy'])
178
+
179
+ end
180
+
181
+ # Get information about an existing escalation policy and its rules
182
+ #
183
+ # ==== Parameters
184
+ #
185
+ # * params<~Hash>
186
+ # * 'id'<~String>: The id of the escalation policy
187
+ #
188
+ # ==== Returns
189
+ # * response<Array><~Pagerduty::EscalationPolicy>:
190
+ # * 'id'<~String> - Id of request
191
+ # * 'name'<~String> - The name of the policy
192
+ # * 'description'<~String> - Policy description
193
+ # * 'escalation_rules'<~Array><~RuleObject>:
194
+ # * 'id'<~String> - The id of the rule object
195
+ # * 'name'<~String> - The name of the rule
196
+ # * 'type'<~String> - The type of rule
197
+ # * 'email'<~String> - The email address associated with the rule
198
+ # * 'time_zone'<~String> - The time zone for the rule
199
+ # * 'color'<~String> - The display color of the rule
200
+ # * 'services'<~Array><~EscalationService>:
201
+ # * 'id'<~String> -
202
+ # * 'name'<~String> -
203
+ # * 'service_url'<~String> -
204
+ # * 'service_key'<~String> -
205
+ # * 'auto_resolve_timeout'<~String> -
206
+ # * 'acknowledgement_timeout'<~String> -
207
+ # * 'created_at'<~String> -
208
+ # * 'deleted_at'<~String> -
209
+ # * 'status'<~String> -
210
+ # * 'last_incident_timestamp'<~String> -
211
+ # * 'email_incident_creation'<~String> -
212
+ # * 'incident_counts'<~String> -
213
+ # * 'email_filter_mode'<~String> -
214
+ # * 'type'<~String> -
215
+ # * 'num_loops'<~Integer> - The number of times to loop the incident
216
+ #
217
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/show]
218
+ def get_escalation_policy(options={})
219
+ EscalationPolicy.new(curl({
220
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{options[:id]}",
221
+ method: 'GET'
222
+ })['escalation_policy'])
223
+ end
224
+
225
+ # List all the escalation rules for an existing escalation policy
226
+ #
227
+ # ==== Parameters
228
+ #
229
+ # * params<~Hash>
230
+ # * 'escalation_policy_id'<~String>: The id of the escalation policy
231
+ #
232
+ # ==== Returns
233
+ # * response<Array><~Pagerduty::EscalationRule>:
234
+ # * 'id'<~String> - Id of request
235
+ # * 'escalation_delay_in_minutes'<~Integer> - The escalation delay in minutes
236
+ # * <~RuleObject>:
237
+ # * 'id'<~String> - The id of the rule object
238
+ # * 'name'<~String> - The name of the rule
239
+ # * 'type'<~String> - The type of rule
240
+ # * 'email'<~String> - The email address associated with the rule
241
+ # * 'time_zone'<~String> - The time zone for the rule
242
+ # * 'color'<~String> - The display color of the rule
243
+ #
244
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/list]
245
+ def escalation_rules(options)
246
+ curl({
247
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{options[:escalation_policy_id]}/escalation_rules",
248
+ params: { 'query' => options[:query] },
249
+ method: 'GET'
250
+ })['escalation_rules'].inject([]) { |rules, rule|
251
+ rules << EscalationRule.new(rule)
252
+ }
253
+ end
254
+
255
+ # Show the escalation rule for an existing escalation policy
256
+ #
257
+ # ==== Parameters
258
+ # * params<~Hash>
259
+ # * 'escalation_policy_id'<~String>: The id of the escalation policy the rule resides in
260
+ # * 'rule_id'<~String>: The id of the rule to retrieve
261
+ #
262
+ # ==== Returns
263
+ # * response<~Pagerduty::EscalationRule>:
264
+ # * 'id'<~String> - Id of request
265
+ # * 'escalation_delay_in_minutes'<~Integer> - The escalation delay in minutes
266
+ # * <~RuleObject>:
267
+ # * 'id'<~String> - The id of the rule object
268
+ # * 'name'<~String> - The name of the rule
269
+ # * 'type'<~String> - The type of rule
270
+ # * 'email'<~String> - The email address associated with the rule
271
+ # * 'time_zone'<~String> - The time zone for the rule
272
+ # * 'color'<~String> - The display color of the rule
273
+ #
274
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules/show]
275
+ def get_escalation_rule(options={})
276
+ EscalationRule.new(curl({
277
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{options[:escalation_policy_id]}/escalation_rules/#{options[:rule_id]}",
278
+ method: 'GET'
279
+ })['escalation_rule'])
280
+ end
281
+
282
+ # Retrieve all incidents
283
+ #
284
+ # ==== Parameters
285
+ # * params<~Hash>
286
+ # * 'since'<~String>: The start of the date range over which you want to search. The time element is optional.
287
+ # * '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.
288
+ # * 'date_range'<~String>: When set to 'all' the 'since' and 'until' params are ignored. Use this to get all incidents since the account was created
289
+ # * 'fields'<~String>: Used to restrict the properties of each incident returned to a set of pre-defined fields. If omitted, returned incidents have all fields present. See below for a list of possible fields.
290
+ # * 'status'<~String>: Returns only the incidents currently in the passed status(es). Valid status options are triggered, acknowledged, and resolved. More status codes may be introduced in the future.
291
+ # * 'incident_key'<~String>: Returns only the incidents with the passed de-duplication key. See the PagerDuty Integration API docs for further details.
292
+ # * 'service'<~String>: Returns only the incidents associated with the passed service(s). This expects one or more service IDs. Separate multiple IDs by commas.
293
+ # * 'assigned_to_user'<~String>: Returns only the incidents currently assigned to the passed user(s). This expects one or more user IDs. Please see below for more info on how to find your users' IDs. When using the assigned_to_user filter, you will only receive incidents with statuses of triggered or acknowledged. This is because resolved incidents are not assigned to any user.
294
+ # * 'time_zone'<~String>: Time zone in which dates in the result will be rendered. Defaults to UTC.
295
+ # * 'sort_by'<~String>: Used to specify both the field you wish to sort the results on, as well as the direction See API doc for examples.
296
+ #
297
+ # ==== Returns
298
+ # * response<~Array>:
299
+ # * <~Pagerduty::Incident>:
300
+ # * 'id'<~String> - Id of request
301
+ # * 'incident_number'<~String>:
302
+ # * 'created_on'<~String>:
303
+ # * 'status'<~String>:
304
+ # * 'html_url'<~String>:
305
+ # * 'incident_key'<~String>:
306
+ # * 'service'<~Pagerduty::Service>
307
+ # * 'id'<~String>:
308
+ # * 'name'<~String>:
309
+ # * 'html_url'<~String>:
310
+ # * 'deleted_at'<~String>:
311
+ # * 'escalation_policy'<~String>:
312
+ # * 'assigned_to_user'<~String>:
313
+ # * 'trigger_summary_data'<~String>:
314
+ # * 'trigger_details_html_url'<~String>:
315
+ # * 'trigger_type'<~String>:
316
+ # * 'last_status_change_on'<~String>:
317
+ # * 'last_status_change_by'<~Pagerduty::User>:
318
+ # * 'id'<~String>:
319
+ # * 'name'<~String>:
320
+ # * 'email'<~String>:
321
+ # * 'html_url'<~String>:
322
+ # * 'number_of_escalations'<~Integer>:
323
+ # * 'resolved_by_user'<~Pagerduty::ResolvedByUser>:
324
+ # * 'id'<~String>:
325
+ # * 'name'<~String>:
326
+ # * 'email'<~String>:
327
+ # * 'html_url'<~String>:
328
+ #
329
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/incidents/list]
330
+ def incidents(options={})
331
+
332
+ Pagerduty::Incidents.new(curl({
333
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents",
334
+ params: {
335
+ since: options[:since] || (Time.now - 1.day).strftime("%Y-%m-%d"),
336
+ :until => options[:until] || (Time.now + 1.day).strftime("%Y-%m-%d"),
337
+ },
338
+ method: 'GET'
339
+ }))
340
+ end
341
+
342
+
343
+ # Show detailed information about an incident. Accepts either an incident id, or an incident number
344
+ #
345
+ # ==== Parameters
346
+ # options<~Hash>
347
+ # * 'id'<~String> - The incident id or incident number to look for
348
+ #
349
+ # ==== Returns
350
+ # * <~Pagerduty::Incident>:
351
+ # * 'id'<~String> - Id of request
352
+ # * 'incident_number'<~String>:
353
+ # * 'created_on'<~String>:
354
+ # * 'status'<~String>:
355
+ # * 'html_url'<~String>:
356
+ # * 'incident_key'<~String>:
357
+ # * 'service'<~Pagerduty::Service>
358
+ # * 'id'<~String>:
359
+ # * 'name'<~String>:
360
+ # * 'html_url'<~String>:
361
+ # * 'deleted_at'<~String>:
362
+ # * 'escalation_policy'<~String>:
363
+ # * 'assigned_to_user'<~String>:
364
+ # * 'trigger_summary_data'<~String>:
365
+ # * 'trigger_details_html_url'<~String>:
366
+ # * 'trigger_type'<~String>:
367
+ # * 'last_status_change_on'<~String>:
368
+ # * 'last_status_change_by'<~Pagerduty::User>:
369
+ # * 'id'<~String>:
370
+ # * 'name'<~String>:
371
+ # * 'email'<~String>:
372
+ # * 'html_url'<~String>:
373
+ # * 'number_of_escalations'<~Integer>:
374
+ # * 'resolved_by_user'<~Pagerduty::ResolvedByUser>:
375
+ # * 'id'<~String>:
376
+ # * 'name'<~String>:
377
+ # * 'email'<~String>:
378
+ # * 'html_url'<~String>:
379
+ #
380
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/incidents/show]
381
+ def get_incident(options={})
382
+ incidents.incidents.detect { |incident|
383
+ incident.id == options[:id] || incident.incident_number == options[:id]
384
+ } || 'No results'
385
+ end
386
+
387
+ # Use this query if you are simply looking for the count of incidents that match a given query. This should be used if you don't need access to the actual incident details.
388
+ #
389
+ # ==== Parameters
390
+ # * options<~Hash>:
391
+ # * 'since'<~String> - The start of the date range over which you want to search. The time element is optional.
392
+ # * '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.
393
+ # * 'date_range'<~String> - When set to all, the since and until parameters and defaults are ignored. Use this to get all counts since the account was created.
394
+ # * 'status'<~String> - Only counts the incidents currently in the passed status(es). Valid status options are triggered, acknowledged, and resolved. More status codes may be introduced in the future.
395
+ # * 'incident_key'<~String> - Only counts the incidents with the passed de-duplication key. See the PagerDuty Integration API docs for further details.
396
+ # * 'service'<~String> - Only counts the incidents associated with the passed service(s). This is expecting one or more service IDs. Separate multiple ids by a comma.
397
+ # * 'assigned_to_user'<~String> - Only counts the incidents currently assigned to the passed user(s). This is expecting one or more user IDs. Note: When using the assigned_to_user filter, you will only count incidents with statuses of triggered or acknowledged. This is because resolved incidents are not assigned to any user. Separate multiple ids by a comma.
398
+ #
399
+ # ==== Returns
400
+ # <~Hash>
401
+ # * 'total'<~Integer>
402
+ #
403
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/incidents/count]
404
+ def get_incident_counts(options={})
405
+ curl({
406
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents/count",
407
+ params: options,
408
+ method: 'GET',
409
+ })
410
+ end
411
+
412
+ # List users of your PagerDuty account, optionally filtered by a search query.
413
+ #
414
+ # ==== Parameters
415
+ # * options<~Hash>:
416
+ # * 'query'<~String> - Filters the result, showing only the users whose names or email addresses match the query
417
+ # * 'include'<~Array> - Array of additional details to include. This API accepts contact_methods, and notification_rules
418
+ #
419
+ # ==== Returns
420
+ # * <~Users>
421
+ # * 'users'<~Array>:
422
+ # * 'user'<~Pagerduty::User>:
423
+ # * 'id'<~String>
424
+ # * 'name'<~String>
425
+ # * 'email'<~String>
426
+ # * 'time_zone'<~String>
427
+ # * 'color'<~String>
428
+ # * 'role'<~String>
429
+ # * 'avatar_url'<~String>
430
+ # * 'user_url'<~String>
431
+ # * 'invitation_sent'<~Boolean>
432
+ # * 'marketing'<~String>
433
+ # * 'marketing_opt_out'<~String>
434
+ # * 'type'<~String>
435
+ # * 'active_account_users'<~Integer>
436
+ # * 'limit'<~Integer>
437
+ # * 'offset'<~Integer>
438
+ # * 'total'<~Integer>
439
+ #
440
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/users/list]
441
+ def get_users(options={})
442
+ Users.new(curl({
443
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/users",
444
+ params: options,
445
+ method: 'GET'
446
+ }))
447
+ end
448
+
449
+ # Get information about an existing user.
450
+ #
451
+ # ==== Parameters
452
+ # * options<~Hash>:
453
+ # * 'id'<~String> - The ID of the user to retrieve
454
+ #
455
+ # ==== Returns
456
+ # * 'user'<~User>:
457
+ # * 'time_zone'<~String>
458
+ # * 'color'<~String>
459
+ # * 'email'<~String>
460
+ # * 'avatar_url'<~String>
461
+ # * 'user_url'<~String>
462
+ # * 'invitation_sent'<~Boolean>
463
+ # * 'role'<~String>
464
+ # * 'name'<~String>
465
+ # * 'id'<~String>
466
+ #
467
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/users/show]
468
+ def get_user(options={})
469
+ get_users.users.detect { |user| user.id == options[:id] }
470
+ end
471
+
472
+ # Create a new user for your account. An invite email will be sent asking the user to choose a password
473
+ #
474
+ # ==== Parameters
475
+ # * options<~Hash>:
476
+ # * 'role'<~String> - The user's role. This can either be admin or user and defaults to user if not specificed
477
+ # * 'name'<~String> - The name of the user
478
+ # * 'email'<~String> - The email of the user. The newly created user will receive an email asking to confirm the subscription
479
+ # * 'time_zone'<~String> - The time zone the user is in. If not specified, the time zone of the account making the API call will be used
480
+ # * 'requester_id'<~String> - The user id of the user creating the user. This is only needed if you are using token based authentication
481
+ #
482
+ # ==== Returns
483
+ # * 'user'<~User>
484
+ # * 'time_zone'<~String>
485
+ # * 'color'<~String>
486
+ # * 'email'<~String>
487
+ # * 'avatar_url'<~String>
488
+ # * 'user_url'<~String>
489
+ # * 'invitation_sent'<~String>
490
+ # * 'role'<~String>
491
+ # * 'name'<~String>
492
+ # * 'id'<~String>
493
+ #
494
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/users/create]
495
+ def create_user(options={})
496
+ User.new(curl({
497
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/users",
498
+ data: options,
499
+ method: 'POST'
500
+ })['user'])
501
+ end
502
+
503
+ # List existing notes for the specified incident.
504
+ #
505
+ # ==== Parameters
506
+ # * options<~Hash>:
507
+ # * 'id' - The id of the incident to retrieve notes from
508
+ #
509
+ # ==== Returns
510
+ # * <~Notes>:
511
+ # * 'notes'<~Array>:
512
+ # * ~<Note>:
513
+ # * 'id' -
514
+ # * 'user'<~Pagerduty::User>:
515
+ # * 'id'<~String>
516
+ # * 'name'<~String>
517
+ # * 'email'<~String>
518
+ # * 'time_zone'<~String>
519
+ # * 'color'<~String>
520
+ # * 'role'<~String>
521
+ # * 'avatar_url'<~String>
522
+ # * 'user_url'<~String>
523
+ # * 'invitation_sent'<~Boolean>
524
+ # * 'marketing'<~String>
525
+ # * 'marketing_opt_out'<~String>
526
+ # * 'type'<~String>
527
+ # * 'content'<~String> -
528
+ # * 'created_at'<~String> -
529
+ #
530
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/incidents/notes/list]
531
+ def notes(id)
532
+ Notes.new(curl({
533
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/incidents/#{id}/notes",
534
+ method: 'GET'
535
+ }))
536
+ end
537
+
538
+
539
+ # List all incident log entries across the entire account
540
+ #
541
+ # ==== Parameters
542
+ # * options<~Hash>:
543
+ # * 'time_zone'<~String> -
544
+ # * 'since'<~String> - The start of the date range over which you want to search. The time element is optional.
545
+ # * '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.
546
+ # * 'is_overview'<~Boolean> -
547
+ # * 'until'<~Array> - 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.
548
+ # * 'include'<~Array> - 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.
549
+ #
550
+ # ==== Returns
551
+ # * 'log_entries'<~Array>:
552
+ # * <~Pagerduty::LogEntry>:
553
+ # * 'id'<~String> -
554
+ # * 'type'<~String> -
555
+ # * 'created_at'<~String> -
556
+ # * 'note'<~String> -
557
+ # * 'agent'<~Pagerduty::User>
558
+ # * 'id'<~String>
559
+ # * 'name'<~String>
560
+ # * 'email'<~String>
561
+ # * 'time_zone'<~String>
562
+ # * 'color'<~String>
563
+ # * 'role'<~String>
564
+ # * 'avatar_url'<~String>
565
+ # * 'user_url'<~String>
566
+ # * 'invitation_sent'<~Boolean>
567
+ # * 'marketing'<~String>
568
+ # * 'marketing_opt_out'<~String>
569
+ # * 'type'<~String>
570
+ # * 'user'<~Pagerduty::User>
571
+ # * 'id'<~String>
572
+ # * 'name'<~String>
573
+ # * 'email'<~String>
574
+ # * 'time_zone'<~String>
575
+ # * 'color'<~String>
576
+ # * 'role'<~String>
577
+ # * 'avatar_url'<~String>
578
+ # * 'user_url'<~String>
579
+ # * 'invitation_sent'<~Boolean>
580
+ # * 'marketing'<~String>
581
+ # * 'marketing_opt_out'<~String>
582
+ # * 'type'<~String>
583
+ # * 'channel'<~Hash>
584
+ # * 'type'
585
+ # * 'limit'<~Integer> -
586
+ # * 'offset'<~Integer> -
587
+ # * 'total'<~Integer> -
588
+ #
589
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/log_entries/list]
590
+ def get_log_entries(options={})
591
+ LogEntries.new(curl({
592
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/log_entries",
593
+ params: options,
594
+ method: 'GET'
595
+ }))
596
+ end
597
+
598
+ # Get details for a specific incident log entry. This method provides additional information you can use to get at raw event data
599
+ #
600
+ # ==== Parameters
601
+ # * options<~Hash>
602
+ # * 'time_zone'<~TimeZone> -
603
+ # * 'include'<~Array> -
604
+ #
605
+ # ==== Returns
606
+ # * 'log_entry'<~LogEntry>
607
+ # * 'id'<~String>
608
+ # * 'type'<~String>
609
+ # * 'created_at'<~String>
610
+ # * 'agent'<~Pagerduty::User>
611
+ # * 'id'<~String>
612
+ # * 'name'<~String>
613
+ # * 'email'<~String>
614
+ # * 'time_zone'<~String>
615
+ # * 'color'<~String>
616
+ # * 'role'<~String>
617
+ # * 'avatar_url'<~String>
618
+ # * 'user_url'<~String>
619
+ # * 'invitation_sent'<~Boolean>
620
+ # * 'marketing'<~String>
621
+ # * 'marketing_opt_out'<~String>
622
+ # * 'type'<~String>
623
+ # * 'user'<~Pagerduty::User>
624
+ # * 'id'<~String>
625
+ # * 'name'<~String>
626
+ # * 'email'<~String>
627
+ # * 'time_zone'<~String>
628
+ # * 'color'<~String>
629
+ # * 'role'<~String>
630
+ # * 'avatar_url'<~String>
631
+ # * 'user_url'<~String>
632
+ # * 'invitation_sent'<~Boolean>
633
+ # * 'marketing'<~String>
634
+ # * 'marketing_opt_out'<~String>
635
+ # * 'type'<~String>
636
+ # * 'channel'<~Hash>
637
+ # * 'summary'<~String>
638
+ # * 'type'<~String>
639
+ #
640
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/log_entries/show]
641
+ def get_log_entry(options={})
642
+ LogEntry.new(curl({
643
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/log_entries/#{options[:id]}",
644
+ params: options,
645
+ method: 'GET'
646
+ })['log_entry'])
647
+ end
648
+
649
+ # Get high level statistics about the number of alerts (SMSes, phone calls and emails) sent for the desired time period, summed daily, weekly or monthly.
650
+ #
651
+ # ==== Parameters
652
+ # * options<~Hash>:
653
+ # * 'since'<~String> - The start of the date range over which you want to search. The time element is optional.
654
+ # * '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.
655
+ # * 'rollup'<~String> - Possible values are daily, weekly or monthly. Specifies the bucket duration for each summation. Defaults to monthly. (Example: A time window of two years (based on since and until) with a rollup of monthly will result in 24 sets of data points being returned (one for each month in the span))
656
+ #
657
+ # ==== Returns
658
+ # * 'alerts'<~Array>
659
+ # * <~Pagerduty::Reports::Alert>:
660
+ # * 'number_of_alerts'<~Integer>
661
+ # * 'number_of_phone_alerts'<~Integer>
662
+ # * 'number_of_sms_alerts'<~Integer>
663
+ # * 'number_of_email_alerts'<~Integer>
664
+ # * 'start'<~String>
665
+ # * 'end'<~String>
666
+ # * 'total_number_of_alerts'<~Integer> -
667
+ # * 'total_number_of_phone_alerts'<~Integer> -
668
+ # * 'total_number_of_sms_alerts'<~Integer> -
669
+ # * 'total_number_of_email_alerts'<~Integer> -
670
+ # * 'total_number_of_billable_alerts'<~Integer> -
671
+ #
672
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/reports/alerts_per_time]
673
+ def alerts_per_time(options={})
674
+ Pagerduty::Reports::Alerts.new(curl({
675
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/reports/alerts_per_time",
676
+ params: options,
677
+ method: 'GET'
678
+ }))
679
+ end
680
+
681
+ # Get high level statistics about the number of incidents created for the desired time period, summed daily, weekly or monthly
682
+ #
683
+ # ==== Parameters
684
+ # * options<~Hash>:
685
+ # * 'since'<~String>: The start of the date range over which you want to search. The time element is optional.
686
+ # * '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.
687
+ # * 'rollup'<~String>: Possible values are daily, weekly or monthly. Specifies the bucket duration for each summation. Defaults to monthly. (Example: A time window of two years (based on since and until) with a rollup of monthly will result in 24 sets of data points being returned (one for each month in the span))
688
+ #
689
+ # ==== Returns
690
+ # * <~Pagerduty::Reports::Incidents>
691
+ # * 'incidents'<~Array>
692
+ # * <~Pagerduty::Reports::Incident>
693
+ # * 'number_of_incidents'<~Integer> -
694
+ # * 'start'<~String> -
695
+ # * 'end'<~String> -
696
+ #
697
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/reports/incidents_per_time]
698
+ def incidents_per_time(options={})
699
+ Pagerduty::Reports::Incidents.new(curl({
700
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/reports/incidents_per_time/",
701
+ params: options,
702
+ method: 'GET'
703
+ }))
704
+ end
705
+
706
+ # List existing maintenance windows, optionally filtered by service, or whether they are from the past, present or future
707
+ #
708
+ # ==== Parameters
709
+ # * options<~Hash>
710
+ # * 'query'<~String> - Filters the results, showing only the maintenance windows whose descriptions contain the query
711
+ # * 'service_ids'<~Array> - An array of service IDs, specifying services whose maintenance windows shall be returned
712
+ # * 'filter'<~String> - Only return maintenance windows that are of this type. Possible values are past, future, ongoing. If this parameter is omitted, all maintenance windows will be returned
713
+ #
714
+ # ==== Returns
715
+ # * <~Pagerduty::MaintenanceWindows>
716
+ # * 'maintenance_windows'<~Array>
717
+ # * <~Pagerduty::MaintenanceWindow>
718
+ # * 'id'<~String>
719
+ # * 'sequence_number'<~Integer>
720
+ # * 'start_time'<~String>
721
+ # * 'end_time'<~String>
722
+ # * 'description'<~String>
723
+ # * 'created_by'<~Pagerduty::User>
724
+ # * 'id'<~String>
725
+ # * 'name'<~String>
726
+ # * 'email'<~String>
727
+ # * 'time_zone'<~String>
728
+ # * 'color'<~String>
729
+ # * 'role'<~String>
730
+ # * 'avatar_url'<~String>
731
+ # * 'user_url'<~String>
732
+ # * 'invitation_sent'<~Boolean>
733
+ # * 'marketing'<~String>
734
+ # * 'marketing_opt_out'<~String>
735
+ # * 'type'<~String>
736
+ # * 'services'<~Array>
737
+ # * <~Service>
738
+ # * 'id'<~String>
739
+ # * 'name'<~String>
740
+ # * 'html_url'<~String>
741
+ # * 'delete_at'<~String>
742
+ # * 'service_ids'<~Array> - An array of strings of all the service IDs associated with the maintenance window
743
+ # * 'limit'<~Integer>
744
+ # * 'offset'<~Integer>
745
+ # * 'total'<~Integer>
746
+ # * 'query'<~Integer>
747
+ # * 'query'<~String>
748
+ # * 'counts'<~Pagerduty::MaintenanceWindow::Count>
749
+ # * 'ongoing'<~Integer>
750
+ # * 'future'<~Integer>
751
+ # * 'past'<~Integer>
752
+ # * 'all'<~Integer>
753
+ #
754
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/maintenance_windows/list]
755
+ def get_maintenance_windows(options={})
756
+ Pagerduty::MaintenanceWindows.new(curl({
757
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/maintenance_windows",
758
+ params: options,
759
+ method: 'GET'
760
+ }))
761
+ end
762
+
763
+ # Get details about an existing maintenance window
764
+ #
765
+ # ==== Parameters
766
+ # * 'options'<~Hash>:
767
+ # * 'id'<~String> - The id of the maintenance window to retrieve
768
+ #
769
+ # ==== Returns
770
+ # * <~Pagerduty::MaintenanceWindow>
771
+ # * 'id'<~String>
772
+ # * 'sequence_number'<~Integer>
773
+ # * 'start_time'<~String>
774
+ # * 'end_time'<~String>
775
+ # * 'description'<~String>
776
+ # * 'created_by'<~Pagerduty::User>
777
+ # * 'id'<~String>
778
+ # * 'name'<~String>
779
+ # * 'email'<~String>
780
+ # * 'time_zone'<~String>
781
+ # * 'color'<~String>
782
+ # * 'role'<~String>
783
+ # * 'avatar_url'<~String>
784
+ # * 'user_url'<~String>
785
+ # * 'invitation_sent'<~Boolean>
786
+ # * 'marketing'<~String>
787
+ # * 'marketing_opt_out'<~String>
788
+ # * 'type'<~String>
789
+ # * 'services'<~Array>
790
+ # * <~Service>
791
+ # * 'id'<~String>
792
+ # * 'name'<~String>
793
+ # * 'html_url'<~String>
794
+ # * 'delete_at'<~String>
795
+ # * 'service_ids'<~Array> - An array of strings of all the service IDs associated with the maintenance window
796
+ #
797
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/maintenance_windows/show]
798
+ def get_maintenance_window(options={})
799
+ Pagerduty::MaintenanceWindow.new(curl({
800
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/maintenance_windows/#{options[:id]}",
801
+ params: options,
802
+ method: 'GET'
803
+ })['maintenance_window'])
804
+ end
805
+
806
+ # Create a new maintenance window for the specified services. No new incidents will be created for a service that is currently in maintenance
807
+ #
808
+ # ==== Parameters
809
+ # * 'options'<~Hash>
810
+ # * 'requester_id'<~String>
811
+ # * 'maintenance_window'<~Hash>
812
+ # * 'start_time'<~String>
813
+ # * 'end_time'<~String>
814
+ # * 'description'<~String>
815
+ # * 'service_ids'<~Array>
816
+ #
817
+ # ==== Returns
818
+ # * <~Pagerduty::MaintenanceWindow>
819
+ # * 'id'<~String>
820
+ # * 'sequence_number'<~Integer>
821
+ # * 'start_time'<~String>
822
+ # * 'end_time'<~String>
823
+ # * 'description'<~String>
824
+ # * 'created_by'<~Pagerduty::User>
825
+ # * 'id'<~String>
826
+ # * 'name'<~String>
827
+ # * 'email'<~String>
828
+ # * 'time_zone'<~String>
829
+ # * 'color'<~String>
830
+ # * 'role'<~String>
831
+ # * 'avatar_url'<~String>
832
+ # * 'user_url'<~String>
833
+ # * 'invitation_sent'<~Boolean>
834
+ # * 'marketing'<~String>
835
+ # * 'marketing_opt_out'<~String>
836
+ # * 'type'<~String>
837
+ # * 'services'<~Array>
838
+ # * <~Service>
839
+ # * 'id'<~String>
840
+ # * 'name'<~String>
841
+ # * 'html_url'<~String>
842
+ # * 'delete_at'<~String>
843
+ # * 'service_ids'<~Array> - An array of strings of all the service IDs associated with the maintenance window
844
+ #
845
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/maintenance_windows/create]
846
+ def create_maintenance_window(options={})
847
+ Pagerduty::MaintenanceWindow.new(curl({
848
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/maintenance_windows",
849
+ data: options,
850
+ method: 'POST'
851
+ })['maintenance_window'])
852
+ end
853
+
854
+ # List existing on-call schedules
855
+ #
856
+ # ==== Parameters
857
+ # * options<~Hash>:
858
+ # * 'query'<~String> - Filters the result, showing only the schedules whose name matches the query
859
+ # * 'requester_id'<~String> - The user id of the user making the request. This will be used to generate the calendar private urls. This is only needed if you are using token based authentication
860
+ #
861
+ # ==== Returns
862
+ # * <~Pagerduty::Schedules>
863
+ # * 'schedules'<~Array>
864
+ # * <~Pagerduty::Schedules::Schedule>
865
+ # * 'id'<~String>
866
+ # * 'name'<~String>
867
+ # * 'time_zone'<~String>
868
+ # * 'today'<~String>
869
+ # * 'escalation_policies'<~Array>
870
+ # * <~EscalationPolicy>
871
+ # * 'id'<~String>
872
+ # * 'name'<~String>
873
+ # * 'description'<~String>
874
+ # * 'escalation_rules'<~Array>
875
+ # * 'services'<~Set>
876
+ # * 'num_loops'<~Integer>
877
+ # * 'limit'<~Integer>
878
+ # * 'offset'<~Integer>
879
+ # * 'total'<~Integer>
880
+ #
881
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/schedules/list]
882
+ def get_schedules(options={})
883
+ Pagerduty::Schedules.new(curl({
884
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/schedules",
885
+ params: options,
886
+ method: 'GET'
887
+ }))
888
+ end
889
+
890
+ # Show detailed information about a schedule, including entries for each layer and sub-schedule
891
+ #
892
+ # ==== Parameters
893
+ # * options<~Hash>:
894
+ # * 'since'<~String> - The start of the date range over which you want to return on-call schedule entries and on-call schedule layers
895
+ # * 'until'<~String> - The end of the date range over which you want to return schedule entries and on-call schedule layers
896
+ # * 'time_zone'<~TimeZone> - Time zone in which dates in the result will be rendered. Defaults to account time zone
897
+ #
898
+ # ==== Returns
899
+ # * response<~ScheduleInfo>:
900
+ # * 'id'<~String>
901
+ # * 'name'<~String>
902
+ # * 'time_zone'<~String>
903
+ # * 'today'<~String>
904
+ # * 'escalation_policies'<~Array>:
905
+ # * <~EscalationPolicy>:
906
+ # * 'id'<~String>
907
+ # * 'name'<~String>
908
+ # * 'description'<~String>
909
+ # * 'escalation_rules'<~Array>
910
+ # * 'services'<~Set>
911
+ # * 'num_loops'<~Integer>
912
+ # * 'schedule_layers'<~Array>:
913
+ # * <~Pagerduty::Schedules::ScheduleLayer>:
914
+ # * 'name'<~String>
915
+ # * 'rendered_schedule_entries'<~Array>
916
+ # * 'id'<~String>
917
+ # * 'priority'<~Integer>
918
+ # * 'start'<~String>
919
+ # * 'end'<~String>
920
+ # * 'restriction_type'<~String>
921
+ # * 'rotation_virtual_start'<~String>
922
+ # * 'rotation_turn_length_seconds'<~Integer>
923
+ # * 'users'<~Array>
924
+ # * <~Pagerduty::Schedules::ScheduleLayer::User>:
925
+ # * 'member_order'<~Integer>
926
+ # * 'user'<~Pagerduty::User>:
927
+ # * 'id'<~String>
928
+ # * 'name'<~String>
929
+ # * 'email'<~String>
930
+ # * 'time_zone'<~String>
931
+ # * 'color'<~String>
932
+ # * 'role'<~String>
933
+ # * 'avatar_url'<~String>
934
+ # * 'user_url'<~String>
935
+ # * 'invitation_sent'<~Boolean>
936
+ # * 'marketing'<~String>
937
+ # * 'marketing_opt_out'<~String>
938
+ # * 'type'<~String>
939
+ # * 'restrictions'<~Array>
940
+ # * 'rendered_coverage_percentage'<~Float>
941
+ # * 'overrides_schedule'<~Pagerduty::Schedules::Override>:
942
+ # * 'name'<~String>
943
+ # * 'rendered_schedule_entries'<~Array>
944
+ # * 'final_schedule'<~Pagerduty::Schedules::FinalSchedule>:
945
+ # * 'name'<~String>
946
+ # * 'rendered_schedule_entries'<~Array>
947
+ # * 'rendered_coverage_percentage'<~Float>
948
+ #
949
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/schedules/show]
950
+ def get_schedule(options={})
951
+ Pagerduty::ScheduleInfo.new(curl({
952
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/schedules/#{options[:id]}",
953
+ params: options,
954
+ method: 'GET'
955
+ })['schedule'])
956
+ end
957
+
958
+ # List all the users on-call in a given schedule for a given time range.
959
+ #
960
+ # ==== Parameters
961
+ # * options<~Hash>:
962
+ # * 'since'<~String> - The start of the date range over which you want to return on-call users
963
+ # * 'until'<~String> - The end time of the date range over which you want to return on-call users
964
+ #
965
+ # ==== Returns
966
+ # * <~Array>:
967
+ # * <~Pagerduty::User>
968
+ # * 'id'<~String>
969
+ # * 'name'<~String>
970
+ # * 'email'<~String>
971
+ # * 'time_zone'<~String>
972
+ # * 'color'<~String>
973
+ # * 'role'<~String>
974
+ # * 'avatar_url'<~String>
975
+ # * 'user_url'<~String>
976
+ # * 'invitation_sent'<~Boolean>
977
+ # * 'marketing'<~String>
978
+ # * 'marketing_opt_out'<~String>
979
+ # * 'type'<~String>
980
+ #
981
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/schedules/users]
982
+ def get_schedule_users(options={})
983
+ Users.new(curl({
984
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/schedules/#{options[:id]}/users",
985
+ params: options,
986
+ method: 'GET'
987
+ })).users
988
+ end
989
+
990
+ # Create an override for a specific user covering the specified time range. If you create an override on top of an existing one, the last created override will have priority.
991
+ #
992
+ # ==== Parameters
993
+ # * 'options'<~Hash>
994
+ # * 'id' - the id of the schedule to be overridden
995
+ # * 'override'<~Hash>
996
+ # * 'start'<~String>
997
+ # * 'end'<~String>
998
+ # * 'user_id'<~String>
999
+ #
1000
+ # ==== Returns
1001
+ # * <~Pagerduty::Schedules::Overrides::Override>
1002
+ # * 'id'<~String>
1003
+ # * 'start'<~String>
1004
+ # * 'end'<~String>
1005
+ # * 'user'<~Pagerduty::User>
1006
+ # * 'id'<~String>
1007
+ # * 'name'<~String>
1008
+ # * 'email'<~String>
1009
+ # * 'color'<~String>
1010
+ #
1011
+ # {Pagerduty API Reference}[https://developer.pagerduty.com/documentation/rest/schedules/overrides/create]
1012
+ def create_schedule_override(options={})
1013
+ Pagerduty::Schedules::Overrides::Override.new(curl({
1014
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/schedules/#{options[:id]}/overrides",
1015
+ data: options.except(:id),
1016
+ method: 'POST'
1017
+ })['override'])
1018
+ end
1019
+
1020
+ # List existing services
1021
+ #
1022
+ # ==== Parameters
1023
+ # * options<~Hash>:
1024
+ # * 'include'<~Array> - Include extra information in the response. Possible values are escalation_policy (for inline Escalation Policy) and email_filters (for inline Email Filters)
1025
+ # * 'time_zone'<~TimeZone> - Time zone in which dates in the result will be rendered. Defaults to account default time zone
1026
+ #
1027
+ # ==== Returns
1028
+ # * services<~Array>:
1029
+ # * <~Pagerduty::Services::Objects::Service>:
1030
+ # * 'id'<~String>
1031
+ # * 'name'<~String>
1032
+ # * 'description'<~String>
1033
+ # * 'service_url'<~String>
1034
+ # * 'service_key'<~String>
1035
+ # * 'auto_resolve_timeout'<~Integer>
1036
+ # * 'acknowledgement_timeout'<~Integer>
1037
+ # * 'created_at'<~String>
1038
+ # * 'status'<~String>
1039
+ # * 'last_incident_timestamp'<~String>
1040
+ # * 'email_incident_creation'<~String>
1041
+ # * 'incident_counts'<~Hash>
1042
+ # * 'triggered'<~Integer>
1043
+ # * 'acknowledged'<~Integer>
1044
+ # * 'resolved'<~Integer>
1045
+ # * 'total'<~Integer>
1046
+ # * 'email_filter_mode'<~String>
1047
+ # * 'type'<~String>
1048
+ # * 'escalation_policy'<~String>
1049
+ # * 'email_filters'<~String> - An object containing inline Email Filters. Only present if email_filters is passed as an argument. Note that only generic_email services have Email Filters
1050
+ # * 'severity_filter'<~String> - Specifies what severity levels will create a new open incident
1051
+ #
1052
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/services/list]
1053
+ def get_services(options={})
1054
+ Pagerduty::Services.new(curl({
1055
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/services",
1056
+ params: options,
1057
+ method: 'GET'
1058
+ }))
1059
+ end
1060
+
1061
+ # Get details about an existing service
1062
+ #
1063
+ # ==== Parameters
1064
+ # * options<~Hash>:
1065
+ # * 'include'<~Array> - Include extra information in the response. Possible values are escalation_policy (for inline Escalation Policy) and email_filters (for inline Email Filters)
1066
+ #
1067
+ # ==== Returns
1068
+ # * <~Pagerduty::Services::Objects::Service>:
1069
+ # * 'id'<~String>
1070
+ # * 'name'<~String>
1071
+ # * 'description'<~String>
1072
+ # * 'service_url'<~String>
1073
+ # * 'service_key'<~String>
1074
+ # * 'auto_resolve_timeout'<~Integer>
1075
+ # * 'acknowledgement_timeout'<~Integer>
1076
+ # * 'created_at'<~String>
1077
+ # * 'status'<~String>
1078
+ # * 'last_incident_timestamp'<~String>
1079
+ # * 'email_incident_creation'<~String>
1080
+ # * 'incident_counts'<~Hash>
1081
+ # * 'triggered'<~Integer>
1082
+ # * 'acknowledged'<~Integer>
1083
+ # * 'resolved'<~Integer>
1084
+ # * 'total'<~Integer>
1085
+ # * 'email_filter_mode'<~String>
1086
+ # * 'type'<~String>
1087
+ # * 'escalation_policy'<~String>
1088
+ # * 'email_filters'<~String> - An object containing inline Email Filters. Only present if email_filters is passed as an argument. Note that only generic_email services have Email Filters
1089
+ # * 'severity_filter'<~String> - Specifies what severity levels will create a new open incident
1090
+ #
1091
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/services/show]
1092
+ def get_service(options={})
1093
+ Pagerduty::Services::Objects::Service.new(curl({
1094
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/services/#{options[:id]}",
1095
+ params: options,
1096
+ method: 'GET'
1097
+ })['service'])
1098
+ end
1099
+
1100
+ # Create a new service
1101
+ #
1102
+ # ==== Parameters
1103
+ # * options<~Hash>:
1104
+ # * 'name'<~String> - The name of the service
1105
+ # * 'escalation_policy_id'<~String> - The id of the escalation policy to be used by this service
1106
+ # * 'type'<~String> - The type of service to create. Can be one of generic_email, generic_events_api, keynote, nagios, pingdom, server_density or sql_monitor
1107
+ # * 'description'<~String> - A description for your service. 1024 character maximum
1108
+ # * 'acknowledgement_timeout'<~Integer> - The duration in seconds before an incidents acknowledged in this service become triggered again. (Defaults to 30 minutes)
1109
+ # * 'auto_resolve_timeout'<~Integer> - The duration in seconds before a triggered incident auto-resolves itself. (Defaults to 4 hours)
1110
+ # * 'severity_filter'<~String> - Specifies what severity levels will create a new open incident
1111
+ #
1112
+ # ==== Returns
1113
+ # * <~Pagerduty::Services::Objects::Service>:
1114
+ # * 'id'<~String>
1115
+ # * 'name'<~String>
1116
+ # * 'description'<~String>
1117
+ # * 'service_url'<~String>
1118
+ # * 'service_key'<~String>
1119
+ # * 'auto_resolve_timeout'<~Integer>
1120
+ # * 'acknowledgement_timeout'<~Integer>
1121
+ # * 'created_at'<~String>
1122
+ # * 'status'<~String>
1123
+ # * 'last_incident_timestamp'<~String>
1124
+ # * 'email_incident_creation'<~String>
1125
+ # * 'incident_counts'<~Hash>
1126
+ # * 'triggered'<~Integer>
1127
+ # * 'acknowledged'<~Integer>
1128
+ # * 'resolved'<~Integer>
1129
+ # * 'total'<~Integer>
1130
+ # * 'email_filter_mode'<~String>
1131
+ # * 'type'<~String>
1132
+ # * 'escalation_policy'<~String>
1133
+ # * 'email_filters'<~String> - An object containing inline Email Filters. Only present if email_filters is passed as an argument. Note that only generic_email services have Email Filters
1134
+ # * 'severity_filter'<~String> - Specifies what severity levels will create a new open incident
1135
+ #
1136
+ # {Pagerduty API Reference}[http://developer.pagerduty.com/documentation/rest/services/create]
1137
+ def create_service(options={})
1138
+ Pagerduty::Services::Objects::Service.new(curl({
1139
+ uri: "https://#@@subdomain.pagerduty.com/api/v1/services",
1140
+ data: { service: options },
1141
+ method: 'POST'
1142
+ })['service'])
1143
+ end
1144
+
1145
+ end