Class: Pagerduty

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

Direct Known Subclasses

PagerdutyIncident

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_key) ⇒ Pagerduty

Returns a new instance of Pagerduty.



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

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

Instance Attribute Details

#incident_keyObject

Returns the value of attribute incident_key.



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

def incident_key
  @incident_key
end

#service_keyObject (readonly)

Returns the value of attribute service_key.



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

def service_key
  @service_key
end

Instance Method Details

#get_incident(incident_key) ⇒ Object



33
34
35
# File 'lib/pagerduty.rb', line 33

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

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



26
27
28
29
30
31
# File 'lib/pagerduty.rb', line 26

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