-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathv3.rb
More file actions
63 lines (52 loc) · 1.4 KB
/
Copy pathv3.rb
File metadata and controls
63 lines (52 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module PagerTree::Integrations
class UptimeObserver::V3 < Integration
OPTIONS = []
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
after_initialize do
end
def adapter_supports_incoming?
true
end
def adapter_supports_outgoing?
false
end
def adapter_incoming_can_defer?
true
end
def adapter_thirdparty_id
adapter_incoming_request_params.dig("incident_id")
end
def adapter_action
case adapter_incoming_request_params.dig("incident_status")
when "Active"
:create
when "Resolved"
:resolve
else
:other
end
end
def adapter_process_create
Alert.new(
title: _title,
description: _description,
thirdparty_id: adapter_thirdparty_id,
dedup_keys: [adapter_thirdparty_id],
additional_data: _additional_datums
)
end
private
def _title
adapter_incoming_request_params.dig("title")
end
def _description
adapter_incoming_request_params.dig("description")
end
def _additional_datums
[
AdditionalDatum.new(format: "link", label: "Incident URL", value: adapter_incoming_request_params.dig("incident_url")),
AdditionalDatum.new(format: "link", label: "Monitor URL", value: adapter_incoming_request_params.dig("monitor_url"))
]
end
end
end