Class: EscalationRule
Instance Attribute Summary
Attributes inherited from Pagerduty
#subdomain, #token
Instance Method Summary
collapse
Methods inherited from Pagerduty
#acknowledge, #alerts, #alerts_per_time, #create_escalation_policy, #create_maintenance_window, #create_schedule_override, #create_service, #create_user, #escalation_policies, #escalation_rules, #get_escalation_policy, #get_escalation_rule, #get_incident, #get_incident_counts, #get_log_entries, #get_log_entry, #get_maintenance_window, #get_maintenance_windows, #get_schedule, #get_schedule_users, #get_schedules, #get_service, #get_services, #get_user, #get_users, #has_requirements?, #incidents, #incidents_per_time, #initialize, #notes, #resolve, #trigger
#curl, #has_requirements?
Constructor Details
This class inherits a constructor from Pagerduty
Instance Method Details
#delete ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'lib/pagerduty/models/escalationpolicies.rb', line 52
def delete
res = curl({
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{parent_policy.id}/escalation_rules/#{self.id}",
method: 'DELETE',
raw_response: true
})
res.code == '200' ? 'Successfully deleted' : JSON.parse(res.body)
end
|
#hashify ⇒ Object
39
40
41
42
43
44
|
# File 'lib/pagerduty/models/escalationpolicies.rb', line 39
def hashify
self.attributes.inject({}) { |attrs, (k,v)|
v.class == RuleObject ? attrs[k] = v.to_hash : attrs[k] = v
attrs
}
end
|
#parent_policy ⇒ Object
46
47
48
49
50
|
# File 'lib/pagerduty/models/escalationpolicies.rb', line 46
def parent_policy
escalation_policies.detect { |policy|
policy.escalation_rules.detect { |p| p.id == self.id }
}
end
|
#save ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/pagerduty/models/escalationpolicies.rb', line 62
def save
self.attributes = curl({
uri: "https://#@@subdomain.pagerduty.com/api/v1/escalation_policies/#{parent_policy.id}/escalation_rules/#{self.id}",
data: self.hashify,
method: 'PUT'
})['escalation_rule']
end
|