class PagerdutyIncident

Attributes

incident_key[R]

Public Class Methods

new(service_key, incident_key, options = {}) click to toggle source

@param [String] service_key The GUID of one of your “Generic API” services.

This is the "service key" listed on a Generic API's service detail page.

@param [String] #incident_key The unique identifier for the incident.

Calls superclass method Pagerduty.new
# File lib/pagerduty.rb, line 126
def initialize(service_key, incident_key, options = {})
  super service_key, options
  @incident_key = incident_key
end

Public Instance Methods

acknowledge(description = nil, details = nil) click to toggle source

Acknowledge the referenced incident. While an incident is acknowledged, it won't generate any additional notifications, even if it receives new trigger events. Send PagerDuty an acknowledge event when you know someone is presently working on the problem.

@param [String] description Text that will appear in the incident's log

associated with this event.

@param [Hash] details An arbitrary hash containing any data you'd like

included in the incident log.

@return [PagerdutyIncident] self

@raise [PagerdutyException] If PagerDuty responds with a status that is not

"success"
# File lib/pagerduty.rb, line 153
def acknowledge(description = nil, details = nil)
  modify_incident("acknowledge", description, details)
end
resolve(description = nil, details = nil) click to toggle source

Resolve the referenced incident. Once an incident is resolved, it won't generate any additional notifications. New trigger events with the same #incident_key as a resolved incident won't re-open the incident. Instead, a new incident will be created. Send PagerDuty a resolve event when the problem that caused the initial trigger event has been fixed.

@param [String] description Text that will appear in the incident's log

associated with this event.

@param [Hash] details An arbitrary hash containing any data you'd like

included in the incident log.

@return [PagerdutyIncident] self

@raise [PagerdutyException] If PagerDuty responds with a status that is not

"success"
# File lib/pagerduty.rb, line 174
def resolve(description = nil, details = nil)
  modify_incident("resolve", description, details)
end
trigger(description, options = {}) click to toggle source

@param (see Pagerduty#trigger) @option (see Pagerduty#trigger)

Calls superclass method Pagerduty#trigger
# File lib/pagerduty.rb, line 133
def trigger(description, options = {})
  super(description, { incident_key: incident_key }.merge(options))
end

Private Instance Methods

modify_incident(event_type, description, details) click to toggle source
# File lib/pagerduty.rb, line 180
def modify_incident(event_type, description, details)
  options = { incident_key: incident_key }
  options[:description] = description if description
  options[:details] = details if details
  resp = api_call(event_type, options)
  ensure_success(resp)
  self
end