Class: Pagerduty

Inherits:
Object
  • Object
show all
Defined in:
lib/pagerduty.rb,
lib/pagerduty/version.rb

Direct Known Subclasses

PagerdutyIncident

Constant Summary collapse

VERSION =
"1.3.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_key, incident_key = nil) ⇒ Pagerduty

Returns a new instance of Pagerduty.



18
19
20
21
# File 'lib/pagerduty.rb', line 18

def initialize(service_key, incident_key = nil)
  @service_key = service_key
  @incident_key = incident_key
end

Instance Attribute Details

#incident_keyObject (readonly)

Returns the value of attribute incident_key.



16
17
18
# File 'lib/pagerduty.rb', line 16

def incident_key
  @incident_key
end

#service_keyObject (readonly)

Returns the value of attribute service_key.



16
17
18
# File 'lib/pagerduty.rb', line 16

def service_key
  @service_key
end

Instance Method Details

#get_incident(incident_key) ⇒ Object



30
31
32
# File 'lib/pagerduty.rb', line 30

def get_incident(incident_key)
  PagerdutyIncident.new @service_key, incident_key
end

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



23
24
25
26
27
28
# File 'lib/pagerduty.rb', line 23

def trigger(description, details = {})
  resp = api_call("trigger", description, details)
  throw PagerdutyException.new(self, resp) unless resp["status"] == "success"

  PagerdutyIncident.new @service_key, resp["incident_key"]
end