Class: PagerdutyIncident

Inherits:
Pagerduty show all
Defined in:
lib/pagerduty.rb

Constant Summary

Constants inherited from Pagerduty

Pagerduty::VERSION

Instance Attribute Summary collapse

Attributes inherited from Pagerduty

#service_key

Instance Method Summary collapse

Methods inherited from Pagerduty

#get_incident

Constructor Details

#initialize(service_key, incident_key, options = {}) ⇒ PagerdutyIncident

Returns a new instance of PagerdutyIncident.

Parameters:

  • service_key (String)

    The GUID of one of your “Generic API” services. This is the “service key” listed on a Generic API’s service detail page.

  • incident_key (String)

    The unique identifier for the incident.



126
127
128
129
# File 'lib/pagerduty.rb', line 126

def initialize(service_key, incident_key, options = {})
  super service_key, options
  @incident_key = incident_key
end

Instance Attribute Details

#incident_keyObject (readonly)

Returns the value of attribute incident_key.



119
120
121
# File 'lib/pagerduty.rb', line 119

def incident_key
  @incident_key
end

Instance Method Details

#acknowledge(description = nil, details = nil) ⇒ PagerdutyIncident

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.

Parameters:

  • description (String) (defaults to: nil)

    Text that will appear in the incident’s log associated with this event.

  • details (Hash) (defaults to: nil)

    An arbitrary hash containing any data you’d like included in the incident log.

Returns:

Raises:



153
154
155
# File 'lib/pagerduty.rb', line 153

def acknowledge(description = nil, details = nil)
  modify_incident("acknowledge", description, details)
end

#resolve(description = nil, details = nil) ⇒ PagerdutyIncident

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.

Parameters:

  • description (String) (defaults to: nil)

    Text that will appear in the incident’s log associated with this event.

  • details (Hash) (defaults to: nil)

    An arbitrary hash containing any data you’d like included in the incident log.

Returns:

Raises:



174
175
176
# File 'lib/pagerduty.rb', line 174

def resolve(description = nil, details = nil)
  modify_incident("resolve", description, details)
end

#trigger(description, options = {}) ⇒ Object

Parameters:

  • description (String)

    A short description of the problem that led to this trigger. This field (or a truncated version) will be used when generating phone calls, SMS messages and alert emails. It will also appear on the incidents tables in the PagerDuty UI. The maximum length is 1024 characters.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :incident_key (String)

    Identifies the incident to which this trigger event should be applied. If there’s no open (i.e. unresolved) incident with this key, a new one will be created. If there’s already an open incident with a matching key, this event will be appended to that incident’s log. The event key provides an easy way to “de-dup” problem reports. If this field isn’t provided, PagerDuty will automatically open a new incident with a unique key.

  • :client (String)

    The name of the monitoring client that is triggering this event.

  • :client_url (String)

    The URL of the monitoring client that is triggering this event.

  • :details (Hash)

    An arbitrary hash containing any data you’d like included in the incident log.



133
134
135
# File 'lib/pagerduty.rb', line 133

def trigger(description, options = {})
  super(description, { incident_key: incident_key }.merge(options))
end