pager_tree-integrations 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/pager_tree/integrations/alert.rb +3 -1
- data/app/models/pager_tree/integrations/app_dynamics/v3.rb +74 -0
- data/app/models/pager_tree/integrations/auvik/v3.rb +94 -0
- data/app/models/pager_tree/integrations/aws_cloudwatch/v3.rb +108 -0
- data/app/models/pager_tree/integrations/azure_monitor/v3.rb +79 -0
- data/app/models/pager_tree/integrations/boolean_store_accessor.rb +42 -0
- data/app/models/pager_tree/integrations/channel/hangouts/v3.rb +176 -0
- data/app/models/pager_tree/integrations/channel/mattermost/v3.rb +6 -0
- data/app/models/pager_tree/integrations/channel/microsoft_teams/v3.rb +142 -0
- data/app/models/pager_tree/integrations/channel/slack/v3.rb +136 -0
- data/app/models/pager_tree/integrations/cronitor/v3.rb +64 -0
- data/app/models/pager_tree/integrations/datadog/v3.rb +72 -0
- data/app/models/pager_tree/integrations/dead_mans_snitch/v3.rb +76 -0
- data/app/models/pager_tree/integrations/elast_alert/v3.rb +63 -0
- data/app/models/pager_tree/integrations/form/v3.rb +114 -0
- data/app/models/pager_tree/integrations/freshdesk/v3.rb +103 -0
- data/app/models/pager_tree/integrations/freshservice/v3.rb +103 -0
- data/app/models/pager_tree/integrations/grafana/v3.rb +67 -0
- data/app/models/pager_tree/integrations/healthchecks/v3.rb +68 -0
- data/app/models/pager_tree/integrations/honeybadger/v3.rb +76 -0
- data/app/models/pager_tree/integrations/hyperping/v3.rb +60 -0
- data/app/models/pager_tree/integrations/integration.rb +28 -6
- data/app/models/pager_tree/integrations/jira_server/v3.rb +61 -0
- data/app/models/pager_tree/integrations/jotform/v3.rb +50 -0
- data/app/models/pager_tree/integrations/kapacitor/v3.rb +65 -0
- data/app/models/pager_tree/integrations/logic_monitor/v3.rb +79 -0
- data/app/models/pager_tree/integrations/mattermost/outgoing_webhook/v3.rb +77 -0
- data/app/models/pager_tree/integrations/new_relic/v3.rb +67 -0
- data/app/models/pager_tree/integrations/outgoing_event.rb +2 -0
- data/app/models/pager_tree/integrations/outgoing_webhook/v3.rb +37 -6
- data/app/models/pager_tree/integrations/outgoing_webhook_delivery/hook_relay.rb +8 -6
- data/app/models/pager_tree/integrations/outgoing_webhook_delivery.rb +1 -1
- data/app/models/pager_tree/integrations/pingdom/v3.rb +71 -0
- data/app/models/pager_tree/integrations/prometheus/v3.rb +79 -0
- data/app/models/pager_tree/integrations/prtg/v3.rb +58 -0
- data/app/models/pager_tree/integrations/server_guard24/v3.rb +74 -0
- data/app/models/pager_tree/integrations/site24x7/v3.rb +68 -0
- data/app/models/pager_tree/integrations/solar_winds/v3.rb +77 -0
- data/app/models/pager_tree/integrations/stackdriver/v3.rb +60 -0
- data/app/models/pager_tree/integrations/status_cake/v3.rb +65 -0
- data/app/models/pager_tree/integrations/twilio/incoming_sms/v3.rb +78 -0
- data/app/models/pager_tree/integrations/typeform/v3.rb +43 -0
- data/app/models/pager_tree/integrations/uptime/v3.rb +68 -0
- data/app/models/pager_tree/integrations/uptime_robot/v3.rb +79 -0
- data/app/models/pager_tree/integrations/webhook/v3.rb +112 -0
- data/app/models/pager_tree/integrations/zendesk/v3.rb +83 -0
- data/app/views/pager_tree/integrations/app_dynamics/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/app_dynamics/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/auvik/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/auvik/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/aws_cloudwatch/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/aws_cloudwatch/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/azure_monitor/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/azure_monitor/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/channel/hangouts/v3/_form_options.html.erb +34 -0
- data/app/views/pager_tree/integrations/channel/hangouts/v3/_show_options.html.erb +40 -0
- data/app/views/pager_tree/integrations/channel/mattermost/v3/_form_options.html.erb +1 -0
- data/app/views/pager_tree/integrations/channel/mattermost/v3/_show_options.html.erb +1 -0
- data/app/views/pager_tree/integrations/channel/microsoft_teams/v3/_form_options.html.erb +34 -0
- data/app/views/pager_tree/integrations/channel/microsoft_teams/v3/_show_options.html.erb +40 -0
- data/app/views/pager_tree/integrations/channel/slack/v3/_form_options.html.erb +34 -0
- data/app/views/pager_tree/integrations/channel/slack/v3/_show_options.html.erb +40 -0
- data/app/views/pager_tree/integrations/cronitor/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/cronitor/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/datadog/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/datadog/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/dead_mans_snitch/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/dead_mans_snitch/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/elast_alert/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/elast_alert/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/form/v3/_form_options.html.erb +64 -0
- data/app/views/pager_tree/integrations/form/v3/_show_options.html.erb +122 -0
- data/app/views/pager_tree/integrations/freshdesk/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/freshdesk/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/freshservice/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/freshservice/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/grafana/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/grafana/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/healthchecks/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/healthchecks/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/honeybadger/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/honeybadger/v3/_show_options.html.erb +12 -0
- data/app/views/pager_tree/integrations/hyperping/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/hyperping/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/jira_server/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/jira_server/v3/_show_options.html.erb +12 -0
- data/app/views/pager_tree/integrations/jotform/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/jotform/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/kapacitor/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/kapacitor/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/logic_monitor/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/logic_monitor/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/mattermost/outgoing_webhook/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/mattermost/outgoing_webhook/v3/_show_options.html.erb +12 -0
- data/app/views/pager_tree/integrations/new_relic/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/new_relic/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/outgoing_webhook/v3/_form_options.html.erb +12 -4
- data/app/views/pager_tree/integrations/outgoing_webhook/v3/_show_options.html.erb +20 -2
- data/app/views/pager_tree/integrations/pingdom/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/pingdom/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/prometheus/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/prometheus/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/prtg/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/prtg/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/server_guard24/v3/_form_options.html.erb +7 -0
- data/app/views/pager_tree/integrations/server_guard24/v3/_show_options.html.erb +12 -0
- data/app/views/pager_tree/integrations/site24x7/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/site24x7/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/solar_winds/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/solar_winds/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/stackdriver/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/stackdriver/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/status_cake/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/status_cake/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/twilio/incoming_sms/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/twilio/incoming_sms/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/typeform/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/typeform/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/uptime/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/uptime/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/uptime_robot/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/uptime_robot/v3/_show_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/webhook/v3/_form_options.html.erb +15 -0
- data/app/views/pager_tree/integrations/webhook/v3/_show_options.html.erb +26 -0
- data/app/views/pager_tree/integrations/zendesk/v3/_form_options.html.erb +0 -0
- data/app/views/pager_tree/integrations/zendesk/v3/_show_options.html.erb +0 -0
- data/config/locales/en.yml +83 -23
- data/lib/generators/integration/integration_generator.rb +2 -1
- data/lib/generators/integration/templates/model.rb.tt +16 -6
- data/lib/pager_tree/integrations/version.rb +1 -1
- metadata +121 -3
@@ -0,0 +1,103 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Freshdesk::V3 < Integration
|
3
|
+
FD_TICKET_STATUS = {
|
4
|
+
open: 2,
|
5
|
+
pending: 3,
|
6
|
+
resolved: 4,
|
7
|
+
closed: 5
|
8
|
+
}
|
9
|
+
|
10
|
+
FD_TICKET_PRIORITY = {
|
11
|
+
low: 1,
|
12
|
+
medium: 2,
|
13
|
+
high: 3,
|
14
|
+
urgent: 4
|
15
|
+
}
|
16
|
+
|
17
|
+
OPTIONS = []
|
18
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
19
|
+
|
20
|
+
after_initialize do
|
21
|
+
end
|
22
|
+
|
23
|
+
def adapter_supports_incoming?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def adapter_supports_outgoing?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def adapter_incoming_can_defer?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
def adapter_thirdparty_id
|
36
|
+
_freshdesk_webhook.dig("ticket_id")
|
37
|
+
end
|
38
|
+
|
39
|
+
def adapter_action
|
40
|
+
status = _freshdesk_webhook.dig("ticket_status")
|
41
|
+
status_i = status&.to_i
|
42
|
+
if status_i == FD_TICKET_STATUS[:open] || status == "Open" || status_i == FD_TICKET_STATUS[:pending] || status == "Pending"
|
43
|
+
:create
|
44
|
+
elsif status_i == FD_TICKET_STATUS[:resolved] || status == "Resolved" || status_i == FD_TICKET_STATUS[:closed] || status == "Closed"
|
45
|
+
:resolve
|
46
|
+
else
|
47
|
+
:other
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def adapter_process_create
|
52
|
+
Alert.new(
|
53
|
+
title: _title,
|
54
|
+
description: _description,
|
55
|
+
urgency: _urgency,
|
56
|
+
thirdparty_id: adapter_thirdparty_id,
|
57
|
+
dedup_keys: [adapter_thirdparty_id],
|
58
|
+
additional_data: _additional_datums
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def _freshdesk_webhook
|
65
|
+
adapter_incoming_request_params.dig("freshdesk_webhook")
|
66
|
+
end
|
67
|
+
|
68
|
+
def _title
|
69
|
+
_freshdesk_webhook.dig("ticket_subject")
|
70
|
+
end
|
71
|
+
|
72
|
+
def _description
|
73
|
+
_freshdesk_webhook.dig("ticket_description")
|
74
|
+
end
|
75
|
+
|
76
|
+
def _urgency
|
77
|
+
priority = _freshdesk_webhook.dig("ticket_priority")
|
78
|
+
priority_i = priority&.to_i
|
79
|
+
|
80
|
+
if priority_i == FD_TICKET_PRIORITY[:low] || priority == "Low"
|
81
|
+
:low
|
82
|
+
elsif priority_i == FD_TICKET_PRIORITY[:medium] || priority == "Normal"
|
83
|
+
:medium
|
84
|
+
elsif priority_i == FD_TICKET_PRIORITY[:high] || priority == "High"
|
85
|
+
:high
|
86
|
+
elsif priority_i == FD_TICKET_PRIORITY[:urgent] || priority == "Urgent"
|
87
|
+
:critical
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def _additional_datums
|
92
|
+
[
|
93
|
+
AdditionalDatum.new(format: "link", label: "Ticket URL", value: _freshdesk_webhook.dig("ticket_url")),
|
94
|
+
AdditionalDatum.new(format: "datetime", label: "Due By", value: _freshdesk_webhook.dig("ticket_due_by_time")),
|
95
|
+
AdditionalDatum.new(format: "text", label: "Source", value: _freshdesk_webhook.dig("ticket_source")),
|
96
|
+
AdditionalDatum.new(format: "text", label: "Requester Name", value: _freshdesk_webhook.dig("ticket_requester_name")),
|
97
|
+
AdditionalDatum.new(format: "text", label: "Requester Email", value: _freshdesk_webhook.dig("ticket_requester_email")),
|
98
|
+
AdditionalDatum.new(format: "text", label: "Requester Phone", value: _freshdesk_webhook.dig("ticket_requester_phone")),
|
99
|
+
AdditionalDatum.new(format: "text", label: "Company", value: _freshdesk_webhook.dig("ticket_company_name"))
|
100
|
+
]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Freshservice::V3 < Integration
|
3
|
+
FS_TICKET_STATUS = {
|
4
|
+
open: 2,
|
5
|
+
pending: 3,
|
6
|
+
resolved: 4,
|
7
|
+
closed: 5
|
8
|
+
}
|
9
|
+
|
10
|
+
FS_TICKET_PRIORITY = {
|
11
|
+
low: 1,
|
12
|
+
medium: 2,
|
13
|
+
high: 3,
|
14
|
+
urgent: 4
|
15
|
+
}
|
16
|
+
|
17
|
+
OPTIONS = []
|
18
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
19
|
+
|
20
|
+
after_initialize do
|
21
|
+
end
|
22
|
+
|
23
|
+
def adapter_supports_incoming?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def adapter_supports_outgoing?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def adapter_incoming_can_defer?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
def adapter_thirdparty_id
|
36
|
+
_freshservice_webhook.dig("ticket_public_url")
|
37
|
+
end
|
38
|
+
|
39
|
+
def adapter_action
|
40
|
+
status = _freshservice_webhook.dig("ticket_status")
|
41
|
+
status_i = status&.to_i
|
42
|
+
|
43
|
+
if status_i == FS_TICKET_STATUS[:open] || status == "Open" || status_i == FS_TICKET_STATUS[:pending] || status == "Pending"
|
44
|
+
:create
|
45
|
+
elsif status_i == FS_TICKET_STATUS[:resolved] || status == "Resolved" || status_i == FS_TICKET_STATUS[:closed] || status == "Closed"
|
46
|
+
:resolve
|
47
|
+
else
|
48
|
+
:other
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def adapter_process_create
|
53
|
+
Alert.new(
|
54
|
+
title: _title,
|
55
|
+
description: _description,
|
56
|
+
urgency: _urgency,
|
57
|
+
thirdparty_id: adapter_thirdparty_id,
|
58
|
+
dedup_keys: [adapter_thirdparty_id],
|
59
|
+
additional_data: _additional_datums
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def _freshservice_webhook
|
66
|
+
# this is not a mistake, the webhook says fresh**desk**, not fresh**service**
|
67
|
+
adapter_incoming_request_params.dig("freshdesk_webhook")
|
68
|
+
end
|
69
|
+
|
70
|
+
def _title
|
71
|
+
_freshservice_webhook.dig("ticket_subject")
|
72
|
+
end
|
73
|
+
|
74
|
+
def _description
|
75
|
+
_freshservice_webhook.dig("ticket_description")
|
76
|
+
end
|
77
|
+
|
78
|
+
def _urgency
|
79
|
+
priority = _freshservice_webhook.dig("ticket_priority")
|
80
|
+
priority_i = priority&.to_i
|
81
|
+
|
82
|
+
if priority_i == FS_TICKET_PRIORITY[:low] || priority == "Low"
|
83
|
+
:low
|
84
|
+
elsif priority_i == FS_TICKET_PRIORITY[:medium] || priority == "Normal" || priority == "Medium"
|
85
|
+
:medium
|
86
|
+
elsif priority_i == FS_TICKET_PRIORITY[:high] || priority == "High"
|
87
|
+
:high
|
88
|
+
elsif priority_i == FS_TICKET_PRIORITY[:urgent] || priority == "Urgent"
|
89
|
+
:critical
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def _additional_datums
|
94
|
+
[
|
95
|
+
AdditionalDatum.new(format: "text", label: "Ticket ID", value: _freshservice_webhook.dig("ticket_id")),
|
96
|
+
AdditionalDatum.new(format: "link", label: "Ticket URL", value: _freshservice_webhook.dig("ticket_url")),
|
97
|
+
AdditionalDatum.new(format: "text", label: "Requester Email", value: _freshservice_webhook.dig("ticket_email")),
|
98
|
+
AdditionalDatum.new(format: "text", label: "To Email", value: _freshservice_webhook.dig("ticket_to_email")),
|
99
|
+
AdditionalDatum.new(format: "text", label: "CC Email", value: _freshservice_webhook.dig("ticket_cc_email"))
|
100
|
+
]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Grafana::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("ruleId")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
case _state
|
27
|
+
when "alerting"
|
28
|
+
:create
|
29
|
+
when "ok"
|
30
|
+
:resolve
|
31
|
+
else
|
32
|
+
:other
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def adapter_process_create
|
37
|
+
Alert.new(
|
38
|
+
title: _title,
|
39
|
+
description: _description,
|
40
|
+
thirdparty_id: adapter_thirdparty_id,
|
41
|
+
dedup_keys: [adapter_thirdparty_id],
|
42
|
+
additional_data: _additional_datums
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def _title
|
49
|
+
adapter_incoming_request_params.dig("ruleName")
|
50
|
+
end
|
51
|
+
|
52
|
+
def _description
|
53
|
+
adapter_incoming_request_params.dig("message")
|
54
|
+
end
|
55
|
+
|
56
|
+
def _state
|
57
|
+
adapter_incoming_request_params.dig("state")
|
58
|
+
end
|
59
|
+
|
60
|
+
def _additional_datums
|
61
|
+
[
|
62
|
+
AdditionalDatum.new(format: "link", label: "URL", value: adapter_incoming_request_params.dig("ruleURL")),
|
63
|
+
AdditionalDatum.new(format: "img", label: "Image", value: adapter_incoming_request_params.dig("imageUrl"))
|
64
|
+
]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Healthchecks::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("incident_key")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
case adapter_incoming_request_params.dig("event_type")
|
27
|
+
when "trigger"
|
28
|
+
:create
|
29
|
+
when "resolve"
|
30
|
+
:resolve
|
31
|
+
else
|
32
|
+
:other
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def adapter_process_create
|
37
|
+
Alert.new(
|
38
|
+
title: _title,
|
39
|
+
description: _description,
|
40
|
+
thirdparty_id: adapter_thirdparty_id,
|
41
|
+
dedup_keys: [adapter_thirdparty_id],
|
42
|
+
additional_data: _additional_datums,
|
43
|
+
tags: _tags
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def _title
|
50
|
+
adapter_incoming_request_params.dig("title")
|
51
|
+
end
|
52
|
+
|
53
|
+
def _description
|
54
|
+
adapter_incoming_request_params.dig("description")
|
55
|
+
end
|
56
|
+
|
57
|
+
def _additional_datums
|
58
|
+
[
|
59
|
+
AdditionalDatum.new(format: "link", label: "Client URL", value: adapter_incoming_request_params.dig("client_url")),
|
60
|
+
AdditionalDatum.new(format: "text", label: "Client", value: adapter_incoming_request_params.dig("client"))
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
64
|
+
def _tags
|
65
|
+
(adapter_incoming_request_params.dig("tags") || "").split(" ").map(&:strip).uniq.compact
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Honeybadger::V3 < Integration
|
3
|
+
OPTIONS = [
|
4
|
+
# only used if they set this up as a "webhook" from honeybadger, the native PT integration doesn't have the token option
|
5
|
+
{key: :token, type: :string, default: nil}
|
6
|
+
]
|
7
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
8
|
+
|
9
|
+
after_initialize do
|
10
|
+
self.option_token ||= nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_should_block_incoming?(request)
|
14
|
+
self.option_token.present? && (request.headers["honeybadger-token"] != self.option_token)
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_supports_incoming?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_supports_outgoing?
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_incoming_can_defer?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def adapter_thirdparty_id
|
30
|
+
adapter_incoming_request_params.dig("fault", "url") || adapter_incoming_request_params.dig("outage", "details_url") || adapter_incoming_request_params.dig("check_in", "details_url")
|
31
|
+
end
|
32
|
+
|
33
|
+
def adapter_action
|
34
|
+
event = adapter_incoming_request_params.dig("event").to_s.downcase
|
35
|
+
case event
|
36
|
+
when "occurred", "down", "check_in_missing"
|
37
|
+
:create
|
38
|
+
when "resolved", "up", "check_in_reporting"
|
39
|
+
:resolve
|
40
|
+
else
|
41
|
+
:other
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def adapter_process_create
|
46
|
+
Alert.new(
|
47
|
+
title: _title,
|
48
|
+
thirdparty_id: adapter_thirdparty_id,
|
49
|
+
dedup_keys: [adapter_thirdparty_id],
|
50
|
+
additional_data: _additional_datums,
|
51
|
+
tags: _tags
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def _title
|
58
|
+
adapter_incoming_request_params.dig("message")
|
59
|
+
end
|
60
|
+
|
61
|
+
def _additional_datums
|
62
|
+
[
|
63
|
+
AdditionalDatum.new(format: "link", label: "Fault URL", value: adapter_incoming_request_params.dig("fault", "url")),
|
64
|
+
AdditionalDatum.new(format: "text", label: "Environment", value: adapter_incoming_request_params.dig("fault", "environment")),
|
65
|
+
AdditionalDatum.new(format: "link", label: "Outage URL", value: adapter_incoming_request_params.dig("outage", "details_url")),
|
66
|
+
AdditionalDatum.new(format: "link", label: "Check In URL", value: adapter_incoming_request_params.dig("check_in", "details_url"))
|
67
|
+
]
|
68
|
+
end
|
69
|
+
|
70
|
+
def _tags
|
71
|
+
(
|
72
|
+
Array(adapter_incoming_request_params.dig("fault", "tags") || []) + Array(adapter_incoming_request_params.dig("fault", "environment"))
|
73
|
+
).map(&:strip).uniq.compact
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Hyperping::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("check", "url")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
event = adapter_incoming_request_params.dig("event")
|
27
|
+
case event
|
28
|
+
when "check.down"
|
29
|
+
:create
|
30
|
+
when "check.up"
|
31
|
+
:resolve
|
32
|
+
else
|
33
|
+
:other
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def adapter_process_create
|
38
|
+
Alert.new(
|
39
|
+
title: _title,
|
40
|
+
thirdparty_id: adapter_thirdparty_id,
|
41
|
+
dedup_keys: [adapter_thirdparty_id],
|
42
|
+
additional_data: _additional_datums
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def _title
|
49
|
+
adapter_incoming_request_params.dig("check", "url") + " is DOWN"
|
50
|
+
end
|
51
|
+
|
52
|
+
def _additional_datums
|
53
|
+
[
|
54
|
+
AdditionalDatum.new(format: "link", label: "URL", value: adapter_incoming_request_params.dig("check", "url")),
|
55
|
+
AdditionalDatum.new(format: "text", label: "Status Code", value: adapter_incoming_request_params.dig("check", "status")),
|
56
|
+
AdditionalDatum.new(format: "datetime", label: "Down Since", value: Time.at(adapter_incoming_request_params.dig("check", "date") / 1000).utc.to_datetime)
|
57
|
+
]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module PagerTree::Integrations
|
2
2
|
class Integration < PagerTree::Integrations.integration_parent_class.constantize
|
3
|
+
extend PagerTree::Integrations::BooleanStoreAccessor
|
4
|
+
|
3
5
|
serialize :options, JSON
|
4
6
|
encrypts :options
|
5
7
|
|
@@ -7,16 +9,14 @@ module PagerTree::Integrations
|
|
7
9
|
{key: :title_template, type: :string, default: nil},
|
8
10
|
{key: :title_template_enabled, type: :boolean, default: false},
|
9
11
|
{key: :description_template, type: :string, default: nil},
|
10
|
-
{key: :description_template_enabled, type: :
|
12
|
+
{key: :description_template_enabled, type: :boolean, default: false}
|
11
13
|
]
|
12
14
|
store_accessor :options, *GENERIC_OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
13
15
|
|
14
16
|
before_validation :cast_types
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
attribute :option_title_template, :string, default: nil
|
19
|
-
attribute :option_description_template, :string, default: nil
|
18
|
+
boolean_store_accessor :option_title_template_enabled
|
19
|
+
boolean_store_accessor :option_description_template_enabled
|
20
20
|
|
21
21
|
# careful controller is not always guaranteed
|
22
22
|
attribute :adapter_controller
|
@@ -34,6 +34,11 @@ module PagerTree::Integrations
|
|
34
34
|
false
|
35
35
|
end
|
36
36
|
|
37
|
+
# a function to determine if we should block the incoming request (e.g. if the payload doesn't match a signature)
|
38
|
+
def adapter_should_block_incoming?(request)
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
37
42
|
# A unique identifier for this integration/alert
|
38
43
|
def adapter_thirdparty_id
|
39
44
|
ULID.generate
|
@@ -50,6 +55,9 @@ module PagerTree::Integrations
|
|
50
55
|
|
51
56
|
def adapter_process_create
|
52
57
|
end
|
58
|
+
|
59
|
+
def adapter_process_other
|
60
|
+
end
|
53
61
|
# END basic incoming functions
|
54
62
|
|
55
63
|
# START basic outgoing functions
|
@@ -65,6 +73,20 @@ module PagerTree::Integrations
|
|
65
73
|
end
|
66
74
|
# END basic outgoing functions
|
67
75
|
|
76
|
+
# START template functions
|
77
|
+
def adapter_supports_title_template?
|
78
|
+
true
|
79
|
+
end
|
80
|
+
|
81
|
+
def adapter_supports_description_template?
|
82
|
+
true
|
83
|
+
end
|
84
|
+
# END template functions
|
85
|
+
|
86
|
+
def adapter_supports_cnames?
|
87
|
+
false
|
88
|
+
end
|
89
|
+
|
68
90
|
# START basic show functions
|
69
91
|
def adapter_show_alerts?
|
70
92
|
adapter_supports_incoming?
|
@@ -100,7 +122,7 @@ module PagerTree::Integrations
|
|
100
122
|
end
|
101
123
|
|
102
124
|
def adapter_response_blocked
|
103
|
-
adapter_controller&.head(:
|
125
|
+
adapter_controller&.head(:forbidden)
|
104
126
|
end
|
105
127
|
|
106
128
|
def adapter_response_deferred
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class JiraServer::V3 < Integration
|
3
|
+
OPTIONS = [
|
4
|
+
{key: :issue_updated, type: :boolean, default: false}
|
5
|
+
]
|
6
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
7
|
+
|
8
|
+
validates :option_issue_updated, inclusion: {in: [true, false]}
|
9
|
+
|
10
|
+
after_initialize do
|
11
|
+
self.option_issue_updated ||= false
|
12
|
+
end
|
13
|
+
|
14
|
+
def adapter_supports_incoming?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def adapter_supports_outgoing?
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
def adapter_incoming_can_defer?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def adapter_thirdparty_id
|
27
|
+
adapter_incoming_request_params.dig("issue", "id")
|
28
|
+
end
|
29
|
+
|
30
|
+
def adapter_action
|
31
|
+
event = adapter_incoming_request_params.dig("webhookEvent")
|
32
|
+
event == "jira:issue_created" || (self.option_issue_updated == true && event == "jira:issue_updated") ? :create : :other
|
33
|
+
end
|
34
|
+
|
35
|
+
def adapter_process_create
|
36
|
+
Alert.new(
|
37
|
+
title: _title,
|
38
|
+
description: _description,
|
39
|
+
thirdparty_id: adapter_thirdparty_id,
|
40
|
+
dedup_keys: [adapter_thirdparty_id],
|
41
|
+
additional_data: _additional_datums
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def _title
|
48
|
+
adapter_incoming_request_params.dig("issue", "fields", "summary") || adapter_incoming_request_params.dig("issue", "key")
|
49
|
+
end
|
50
|
+
|
51
|
+
def _description
|
52
|
+
adapter_incoming_request_params.dig("issue", "fields", "description")
|
53
|
+
end
|
54
|
+
|
55
|
+
def _additional_datums
|
56
|
+
[
|
57
|
+
AdditionalDatum.new(format: "link", label: "Issue URL", value: adapter_incoming_request_params.dig("issue", "self"))
|
58
|
+
]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module PagerTree::Integrations
|
2
|
+
class Jotform::V3 < Integration
|
3
|
+
OPTIONS = []
|
4
|
+
store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
|
5
|
+
|
6
|
+
after_initialize do
|
7
|
+
end
|
8
|
+
|
9
|
+
def adapter_supports_incoming?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def adapter_supports_outgoing?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def adapter_incoming_can_defer?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def adapter_thirdparty_id
|
22
|
+
adapter_incoming_request_params.dig("submissionID")
|
23
|
+
end
|
24
|
+
|
25
|
+
def adapter_action
|
26
|
+
:create
|
27
|
+
end
|
28
|
+
|
29
|
+
def adapter_process_create
|
30
|
+
Alert.new(
|
31
|
+
title: _title,
|
32
|
+
thirdparty_id: adapter_thirdparty_id,
|
33
|
+
dedup_keys: [adapter_thirdparty_id],
|
34
|
+
additional_data: _additional_datums
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def _title
|
41
|
+
[adapter_incoming_request_params.dig("formTitle"), adapter_incoming_request_params.dig("submissionID")].join(" ")
|
42
|
+
end
|
43
|
+
|
44
|
+
def _additional_datums
|
45
|
+
[
|
46
|
+
AdditionalDatum.new(format: "link", label: "Submission URL", value: "https://www.jotform.com/submission/#{adapter_incoming_request_params.dig("submissionID")}")
|
47
|
+
]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|