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.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/pager_tree/integrations/alert.rb +3 -1
  3. data/app/models/pager_tree/integrations/app_dynamics/v3.rb +74 -0
  4. data/app/models/pager_tree/integrations/auvik/v3.rb +94 -0
  5. data/app/models/pager_tree/integrations/aws_cloudwatch/v3.rb +108 -0
  6. data/app/models/pager_tree/integrations/azure_monitor/v3.rb +79 -0
  7. data/app/models/pager_tree/integrations/boolean_store_accessor.rb +42 -0
  8. data/app/models/pager_tree/integrations/channel/hangouts/v3.rb +176 -0
  9. data/app/models/pager_tree/integrations/channel/mattermost/v3.rb +6 -0
  10. data/app/models/pager_tree/integrations/channel/microsoft_teams/v3.rb +142 -0
  11. data/app/models/pager_tree/integrations/channel/slack/v3.rb +136 -0
  12. data/app/models/pager_tree/integrations/cronitor/v3.rb +64 -0
  13. data/app/models/pager_tree/integrations/datadog/v3.rb +72 -0
  14. data/app/models/pager_tree/integrations/dead_mans_snitch/v3.rb +76 -0
  15. data/app/models/pager_tree/integrations/elast_alert/v3.rb +63 -0
  16. data/app/models/pager_tree/integrations/form/v3.rb +114 -0
  17. data/app/models/pager_tree/integrations/freshdesk/v3.rb +103 -0
  18. data/app/models/pager_tree/integrations/freshservice/v3.rb +103 -0
  19. data/app/models/pager_tree/integrations/grafana/v3.rb +67 -0
  20. data/app/models/pager_tree/integrations/healthchecks/v3.rb +68 -0
  21. data/app/models/pager_tree/integrations/honeybadger/v3.rb +76 -0
  22. data/app/models/pager_tree/integrations/hyperping/v3.rb +60 -0
  23. data/app/models/pager_tree/integrations/integration.rb +28 -6
  24. data/app/models/pager_tree/integrations/jira_server/v3.rb +61 -0
  25. data/app/models/pager_tree/integrations/jotform/v3.rb +50 -0
  26. data/app/models/pager_tree/integrations/kapacitor/v3.rb +65 -0
  27. data/app/models/pager_tree/integrations/logic_monitor/v3.rb +79 -0
  28. data/app/models/pager_tree/integrations/mattermost/outgoing_webhook/v3.rb +77 -0
  29. data/app/models/pager_tree/integrations/new_relic/v3.rb +67 -0
  30. data/app/models/pager_tree/integrations/outgoing_event.rb +2 -0
  31. data/app/models/pager_tree/integrations/outgoing_webhook/v3.rb +37 -6
  32. data/app/models/pager_tree/integrations/outgoing_webhook_delivery/hook_relay.rb +8 -6
  33. data/app/models/pager_tree/integrations/outgoing_webhook_delivery.rb +1 -1
  34. data/app/models/pager_tree/integrations/pingdom/v3.rb +71 -0
  35. data/app/models/pager_tree/integrations/prometheus/v3.rb +79 -0
  36. data/app/models/pager_tree/integrations/prtg/v3.rb +58 -0
  37. data/app/models/pager_tree/integrations/server_guard24/v3.rb +74 -0
  38. data/app/models/pager_tree/integrations/site24x7/v3.rb +68 -0
  39. data/app/models/pager_tree/integrations/solar_winds/v3.rb +77 -0
  40. data/app/models/pager_tree/integrations/stackdriver/v3.rb +60 -0
  41. data/app/models/pager_tree/integrations/status_cake/v3.rb +65 -0
  42. data/app/models/pager_tree/integrations/twilio/incoming_sms/v3.rb +78 -0
  43. data/app/models/pager_tree/integrations/typeform/v3.rb +43 -0
  44. data/app/models/pager_tree/integrations/uptime/v3.rb +68 -0
  45. data/app/models/pager_tree/integrations/uptime_robot/v3.rb +79 -0
  46. data/app/models/pager_tree/integrations/webhook/v3.rb +112 -0
  47. data/app/models/pager_tree/integrations/zendesk/v3.rb +83 -0
  48. data/app/views/pager_tree/integrations/app_dynamics/v3/_form_options.html.erb +0 -0
  49. data/app/views/pager_tree/integrations/app_dynamics/v3/_show_options.html.erb +0 -0
  50. data/app/views/pager_tree/integrations/auvik/v3/_form_options.html.erb +0 -0
  51. data/app/views/pager_tree/integrations/auvik/v3/_show_options.html.erb +0 -0
  52. data/app/views/pager_tree/integrations/aws_cloudwatch/v3/_form_options.html.erb +0 -0
  53. data/app/views/pager_tree/integrations/aws_cloudwatch/v3/_show_options.html.erb +0 -0
  54. data/app/views/pager_tree/integrations/azure_monitor/v3/_form_options.html.erb +0 -0
  55. data/app/views/pager_tree/integrations/azure_monitor/v3/_show_options.html.erb +0 -0
  56. data/app/views/pager_tree/integrations/channel/hangouts/v3/_form_options.html.erb +34 -0
  57. data/app/views/pager_tree/integrations/channel/hangouts/v3/_show_options.html.erb +40 -0
  58. data/app/views/pager_tree/integrations/channel/mattermost/v3/_form_options.html.erb +1 -0
  59. data/app/views/pager_tree/integrations/channel/mattermost/v3/_show_options.html.erb +1 -0
  60. data/app/views/pager_tree/integrations/channel/microsoft_teams/v3/_form_options.html.erb +34 -0
  61. data/app/views/pager_tree/integrations/channel/microsoft_teams/v3/_show_options.html.erb +40 -0
  62. data/app/views/pager_tree/integrations/channel/slack/v3/_form_options.html.erb +34 -0
  63. data/app/views/pager_tree/integrations/channel/slack/v3/_show_options.html.erb +40 -0
  64. data/app/views/pager_tree/integrations/cronitor/v3/_form_options.html.erb +0 -0
  65. data/app/views/pager_tree/integrations/cronitor/v3/_show_options.html.erb +0 -0
  66. data/app/views/pager_tree/integrations/datadog/v3/_form_options.html.erb +0 -0
  67. data/app/views/pager_tree/integrations/datadog/v3/_show_options.html.erb +0 -0
  68. data/app/views/pager_tree/integrations/dead_mans_snitch/v3/_form_options.html.erb +0 -0
  69. data/app/views/pager_tree/integrations/dead_mans_snitch/v3/_show_options.html.erb +0 -0
  70. data/app/views/pager_tree/integrations/elast_alert/v3/_form_options.html.erb +0 -0
  71. data/app/views/pager_tree/integrations/elast_alert/v3/_show_options.html.erb +0 -0
  72. data/app/views/pager_tree/integrations/form/v3/_form_options.html.erb +64 -0
  73. data/app/views/pager_tree/integrations/form/v3/_show_options.html.erb +122 -0
  74. data/app/views/pager_tree/integrations/freshdesk/v3/_form_options.html.erb +0 -0
  75. data/app/views/pager_tree/integrations/freshdesk/v3/_show_options.html.erb +0 -0
  76. data/app/views/pager_tree/integrations/freshservice/v3/_form_options.html.erb +0 -0
  77. data/app/views/pager_tree/integrations/freshservice/v3/_show_options.html.erb +0 -0
  78. data/app/views/pager_tree/integrations/grafana/v3/_form_options.html.erb +0 -0
  79. data/app/views/pager_tree/integrations/grafana/v3/_show_options.html.erb +0 -0
  80. data/app/views/pager_tree/integrations/healthchecks/v3/_form_options.html.erb +0 -0
  81. data/app/views/pager_tree/integrations/healthchecks/v3/_show_options.html.erb +0 -0
  82. data/app/views/pager_tree/integrations/honeybadger/v3/_form_options.html.erb +7 -0
  83. data/app/views/pager_tree/integrations/honeybadger/v3/_show_options.html.erb +12 -0
  84. data/app/views/pager_tree/integrations/hyperping/v3/_form_options.html.erb +0 -0
  85. data/app/views/pager_tree/integrations/hyperping/v3/_show_options.html.erb +0 -0
  86. data/app/views/pager_tree/integrations/jira_server/v3/_form_options.html.erb +7 -0
  87. data/app/views/pager_tree/integrations/jira_server/v3/_show_options.html.erb +12 -0
  88. data/app/views/pager_tree/integrations/jotform/v3/_form_options.html.erb +0 -0
  89. data/app/views/pager_tree/integrations/jotform/v3/_show_options.html.erb +0 -0
  90. data/app/views/pager_tree/integrations/kapacitor/v3/_form_options.html.erb +0 -0
  91. data/app/views/pager_tree/integrations/kapacitor/v3/_show_options.html.erb +0 -0
  92. data/app/views/pager_tree/integrations/logic_monitor/v3/_form_options.html.erb +0 -0
  93. data/app/views/pager_tree/integrations/logic_monitor/v3/_show_options.html.erb +0 -0
  94. data/app/views/pager_tree/integrations/mattermost/outgoing_webhook/v3/_form_options.html.erb +7 -0
  95. data/app/views/pager_tree/integrations/mattermost/outgoing_webhook/v3/_show_options.html.erb +12 -0
  96. data/app/views/pager_tree/integrations/new_relic/v3/_form_options.html.erb +0 -0
  97. data/app/views/pager_tree/integrations/new_relic/v3/_show_options.html.erb +0 -0
  98. data/app/views/pager_tree/integrations/outgoing_webhook/v3/_form_options.html.erb +12 -4
  99. data/app/views/pager_tree/integrations/outgoing_webhook/v3/_show_options.html.erb +20 -2
  100. data/app/views/pager_tree/integrations/pingdom/v3/_form_options.html.erb +0 -0
  101. data/app/views/pager_tree/integrations/pingdom/v3/_show_options.html.erb +0 -0
  102. data/app/views/pager_tree/integrations/prometheus/v3/_form_options.html.erb +0 -0
  103. data/app/views/pager_tree/integrations/prometheus/v3/_show_options.html.erb +0 -0
  104. data/app/views/pager_tree/integrations/prtg/v3/_form_options.html.erb +0 -0
  105. data/app/views/pager_tree/integrations/prtg/v3/_show_options.html.erb +0 -0
  106. data/app/views/pager_tree/integrations/server_guard24/v3/_form_options.html.erb +7 -0
  107. data/app/views/pager_tree/integrations/server_guard24/v3/_show_options.html.erb +12 -0
  108. data/app/views/pager_tree/integrations/site24x7/v3/_form_options.html.erb +0 -0
  109. data/app/views/pager_tree/integrations/site24x7/v3/_show_options.html.erb +0 -0
  110. data/app/views/pager_tree/integrations/solar_winds/v3/_form_options.html.erb +0 -0
  111. data/app/views/pager_tree/integrations/solar_winds/v3/_show_options.html.erb +0 -0
  112. data/app/views/pager_tree/integrations/stackdriver/v3/_form_options.html.erb +0 -0
  113. data/app/views/pager_tree/integrations/stackdriver/v3/_show_options.html.erb +0 -0
  114. data/app/views/pager_tree/integrations/status_cake/v3/_form_options.html.erb +0 -0
  115. data/app/views/pager_tree/integrations/status_cake/v3/_show_options.html.erb +0 -0
  116. data/app/views/pager_tree/integrations/twilio/incoming_sms/v3/_form_options.html.erb +0 -0
  117. data/app/views/pager_tree/integrations/twilio/incoming_sms/v3/_show_options.html.erb +0 -0
  118. data/app/views/pager_tree/integrations/typeform/v3/_form_options.html.erb +0 -0
  119. data/app/views/pager_tree/integrations/typeform/v3/_show_options.html.erb +0 -0
  120. data/app/views/pager_tree/integrations/uptime/v3/_form_options.html.erb +0 -0
  121. data/app/views/pager_tree/integrations/uptime/v3/_show_options.html.erb +0 -0
  122. data/app/views/pager_tree/integrations/uptime_robot/v3/_form_options.html.erb +0 -0
  123. data/app/views/pager_tree/integrations/uptime_robot/v3/_show_options.html.erb +0 -0
  124. data/app/views/pager_tree/integrations/webhook/v3/_form_options.html.erb +15 -0
  125. data/app/views/pager_tree/integrations/webhook/v3/_show_options.html.erb +26 -0
  126. data/app/views/pager_tree/integrations/zendesk/v3/_form_options.html.erb +0 -0
  127. data/app/views/pager_tree/integrations/zendesk/v3/_show_options.html.erb +0 -0
  128. data/config/locales/en.yml +83 -23
  129. data/lib/generators/integration/integration_generator.rb +2 -1
  130. data/lib/generators/integration/templates/model.rb.tt +16 -6
  131. data/lib/pager_tree/integrations/version.rb +1 -1
  132. metadata +121 -3
@@ -0,0 +1,74 @@
1
+ module PagerTree::Integrations
2
+ class ServerGuard24::V3 < Integration
3
+ OPTIONS = [
4
+ {key: :resolve_warn, type: :boolean, default: false}
5
+ ]
6
+ store_accessor :options, *OPTIONS.map { |x| x[:key] }.map(&:to_s), prefix: "option"
7
+
8
+ validates :option_resolve_warn, inclusion: {in: [true, false]}
9
+
10
+ after_initialize do
11
+ self.option_resolve_warn ||= 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("server_name"), adapter_incoming_request_params.dig("service_shortname")].compact_blank.join("_")
28
+ end
29
+
30
+ def adapter_action
31
+ check_result = adapter_incoming_request_params.dig("check_result")
32
+
33
+ if check_result == "CRITICAL"
34
+ :create
35
+ elsif check_result == "OK" || (check_result == "WARNING" && self.option_resolve_warn == true)
36
+ :resolve
37
+ else
38
+ :other
39
+ end
40
+ end
41
+
42
+ def adapter_process_create
43
+ Alert.new(
44
+ title: _title,
45
+ description: _description,
46
+ thirdparty_id: adapter_thirdparty_id,
47
+ dedup_keys: [adapter_thirdparty_id],
48
+ additional_data: _additional_datums
49
+ )
50
+ end
51
+
52
+ private
53
+
54
+ def _title
55
+ "#{adapter_incoming_request_params.dig("server_name")} is DOWN"
56
+ end
57
+
58
+ def _description
59
+ "#{adapter_incoming_request_params.dig("server_name")} is DOWN because #{adapter_incoming_request_params.dig("check_output")}"
60
+ end
61
+
62
+ def _additional_datums
63
+ [
64
+ AdditionalDatum.new(format: "text", label: "Server Name", value: adapter_incoming_request_params.dig("server_name")),
65
+ AdditionalDatum.new(format: "text", label: "Server Address", value: adapter_incoming_request_params.dig("server_address")),
66
+ AdditionalDatum.new(format: "text", label: "Service Name", value: adapter_incoming_request_params.dig("service_name")),
67
+ AdditionalDatum.new(format: "text", label: "Service Short Name", value: adapter_incoming_request_params.dig("service_shortname")),
68
+ AdditionalDatum.new(format: "datetime", label: "Notification Time", value: adapter_incoming_request_params.dig("notification_time")),
69
+ AdditionalDatum.new(format: "text", label: "Check Result", value: adapter_incoming_request_params.dig("check_result")),
70
+ AdditionalDatum.new(format: "text", label: "Check Output", value: adapter_incoming_request_params.dig("check_output"))
71
+ ]
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,68 @@
1
+ module PagerTree::Integrations
2
+ class Site24x7::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("MONITOR_ID")
23
+ end
24
+
25
+ def adapter_action
26
+ case adapter_incoming_request_params.dig("STATUS")
27
+ when "DOWN"
28
+ :create
29
+ when "UP"
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("MONITORNAME")} is DOWN"
50
+ end
51
+
52
+ def _description
53
+ "#{adapter_incoming_request_params.dig("MONITORNAME")} is DOWN because #{adapter_incoming_request_params.dig("INCIDENT_REASON")}"
54
+ end
55
+
56
+ def _additional_datums
57
+ [
58
+ AdditionalDatum.new(format: "link", label: "Site 24x7 Dashboard URL", value: adapter_incoming_request_params.dig("MONITOR_DASHBOARD_LINK")),
59
+ AdditionalDatum.new(format: "text", label: "Monitor Name", value: adapter_incoming_request_params.dig("MONITORNAME")),
60
+ AdditionalDatum.new(format: "link", label: "Monitor URL", value: adapter_incoming_request_params.dig("MONITORURL")),
61
+ AdditionalDatum.new(format: "text", label: "Group Name", value: adapter_incoming_request_params.dig("MONITOR_GROUPNAME")),
62
+ AdditionalDatum.new(format: "text", label: "Reason", value: adapter_incoming_request_params.dig("INCIDENT_REASON")),
63
+ AdditionalDatum.new(format: "text", label: "Failed Locations", value: adapter_incoming_request_params.dig("FAILED_LOCATIONS")),
64
+ AdditionalDatum.new(format: "datetime", label: "Failed At", value: adapter_incoming_request_params.dig("INCIDENT_TIME_ISO"))
65
+ ]
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,77 @@
1
+ module PagerTree::Integrations
2
+ class SolarWinds::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("AlertID")
23
+ end
24
+
25
+ def adapter_action
26
+ case adapter_incoming_request_params.dig("ActionType").to_s.downcase
27
+ when "create"
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
+ urgency: _urgency,
41
+ thirdparty_id: adapter_thirdparty_id,
42
+ dedup_keys: [adapter_thirdparty_id],
43
+ additional_data: _additional_datums
44
+ )
45
+ end
46
+
47
+ private
48
+
49
+ def _title
50
+ adapter_incoming_request_params.dig("AlertMessage")
51
+ end
52
+
53
+ def _description
54
+ adapter_incoming_request_params.dig("AlertDescription")
55
+ end
56
+
57
+ def _urgency
58
+ case adapter_incoming_request_params.dig(:severity).to_s.downcase
59
+ when "notice", "informational"
60
+ "low"
61
+ when "warning"
62
+ "medium"
63
+ when "serious"
64
+ "high"
65
+ when "critical"
66
+ "critical"
67
+ end
68
+ end
69
+
70
+ def _additional_datums
71
+ [
72
+ AdditionalDatum.new(format: "link", label: "Alert Details URL", value: adapter_incoming_request_params.dig("AlertDetailsURL")),
73
+ AdditionalDatum.new(format: "text", label: "Node", value: adapter_incoming_request_params.dig("NodeName"))
74
+ ]
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,60 @@
1
+ module PagerTree::Integrations
2
+ class Stackdriver::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", "incident_id")
23
+ end
24
+
25
+ def adapter_action
26
+ case adapter_incoming_request_params.dig("incident", "state")
27
+ when "open"
28
+ :create
29
+ when "closed"
30
+ :resolve
31
+ else
32
+ :other
33
+ end
34
+ end
35
+
36
+ def adapter_process_create
37
+ Alert.new(
38
+ title: _title,
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("incident", "summary")
49
+ end
50
+
51
+ def _additional_datums
52
+ [
53
+ AdditionalDatum.new(format: "link", label: "Incident URL", value: adapter_incoming_request_params.dig("incident", "url")),
54
+ AdditionalDatum.new(format: "text", label: "Policy Name", value: adapter_incoming_request_params.dig("incident", "policy_name")),
55
+ AdditionalDatum.new(format: "text", label: "Condition Name", value: adapter_incoming_request_params.dig("incident", "condition_name")),
56
+ AdditionalDatum.new(format: "text", label: "Resource Name", value: adapter_incoming_request_params.dig("incident", "resource_name"))
57
+ ]
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,65 @@
1
+ module PagerTree::Integrations
2
+ class StatusCake::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("URL")
23
+ end
24
+
25
+ def adapter_action
26
+ case adapter_incoming_request_params.dig("Status").to_s.downcase
27
+ when "down"
28
+ :create
29
+ when "up"
30
+ :resolve
31
+ else
32
+ :other
33
+ end
34
+ end
35
+
36
+ def adapter_process_create
37
+ Alert.new(
38
+ title: _title,
39
+ thirdparty_id: adapter_thirdparty_id,
40
+ dedup_keys: [adapter_thirdparty_id],
41
+ additional_data: _additional_datums,
42
+ tags: _tags
43
+ )
44
+ end
45
+
46
+ private
47
+
48
+ def _title
49
+ "#{adapter_incoming_request_params.dig("Name")} is down"
50
+ end
51
+
52
+ def _additional_datums
53
+ [
54
+ AdditionalDatum.new(format: "link", label: "URL", value: adapter_incoming_request_params.dig("URL")),
55
+ AdditionalDatum.new(format: "text", label: "Status Code", value: adapter_incoming_request_params.dig("StatusCode")),
56
+ AdditionalDatum.new(format: "text", label: "IP", value: adapter_incoming_request_params.dig("IP")),
57
+ AdditionalDatum.new(format: "text", label: "Check Rate", value: adapter_incoming_request_params.dig("Check Rate"))
58
+ ]
59
+ end
60
+
61
+ def _tags
62
+ adapter_incoming_request_params.dig("Tags").to_s.split(",").map(&:strip).uniq
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,78 @@
1
+ module PagerTree::Integrations
2
+ class Twilio::IncomingSms::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("MessageSid")
23
+ end
24
+
25
+ def adapter_action
26
+ :create
27
+ end
28
+
29
+ def adapter_process_create
30
+ Alert.new(
31
+ title: _title,
32
+ description: _description,
33
+ thirdparty_id: adapter_thirdparty_id,
34
+ dedup_keys: [adapter_thirdparty_id],
35
+ additional_data: _additional_datums
36
+ )
37
+ end
38
+
39
+ private
40
+
41
+ def _title
42
+ "Incoming SMS from #{adapter_incoming_request_params.dig("From")} - See description for details"
43
+ end
44
+
45
+ def _description
46
+ adapter_incoming_request_params.dig("Body")
47
+ end
48
+
49
+ def _additional_datums
50
+ datums = [
51
+ AdditionalDatum.new(format: "link", label: "Twilio URL", value: "https://www.twilio.com/console/sms/logs/#{adapter_incoming_request_params.dig("MessageSid")}"),
52
+ AdditionalDatum.new(format: "text", label: "Account SID", value: adapter_incoming_request_params.dig("AccountSid")),
53
+ AdditionalDatum.new(format: "text", label: "Message SID", value: adapter_incoming_request_params.dig("MessageSid")),
54
+ AdditionalDatum.new(format: "phone", label: "To", value: adapter_incoming_request_params.dig("To")),
55
+ AdditionalDatum.new(format: "phone", label: "From", value: adapter_incoming_request_params.dig("From")),
56
+ AdditionalDatum.new(format: "text", label: "From Country", value: adapter_incoming_request_params.dig("FromCountry")),
57
+ AdditionalDatum.new(format: "text", label: "From State", value: adapter_incoming_request_params.dig("FromState")),
58
+ AdditionalDatum.new(format: "text", label: "From City", value: adapter_incoming_request_params.dig("FromCity")),
59
+ AdditionalDatum.new(format: "text", label: "From Zip", value: adapter_incoming_request_params.dig("FromZip"))
60
+ ]
61
+
62
+ num_media = adapter_incoming_request_params.dig("NumMedia").to_i
63
+ index = 0
64
+
65
+ while index < num_media
66
+ media_content_type = adapter_incoming_request_params.dig("MediaContentType#{index}")
67
+ datums.push(AdditionalDatum.new(
68
+ format: media_content_type.starts_with?("im") ? "img" : "link",
69
+ label: "Media ##{index + 1}",
70
+ value: adapter_incoming_request_params.dig("MediaUrl#{index}")
71
+ ))
72
+ index += 1
73
+ end
74
+
75
+ datums
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,43 @@
1
+ module PagerTree::Integrations
2
+ class Typeform::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("form_response", "token")
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
+ )
35
+ end
36
+
37
+ private
38
+
39
+ def _title
40
+ [adapter_incoming_request_params.dig("form_response", "definition", "title"), adapter_incoming_request_params.dig("form_response", "submitted_at")].compact_blank.join(": ")
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,68 @@
1
+ module PagerTree::Integrations
2
+ class Uptime::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("data", "service", "id")
23
+ end
24
+
25
+ def adapter_action
26
+ case adapter_incoming_request_params.dig("event")
27
+ when "alert_raised"
28
+ :create
29
+ when "alert_cleared"
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("data", "service", "display_name")
51
+ end
52
+
53
+ def _description
54
+ adapter_incoming_request_params.dig("data", "alert", "output")
55
+ end
56
+
57
+ def _tags
58
+ Array(adapter_incoming_request_params.dig("data", "service", "tags")).compact_blank.uniq
59
+ end
60
+
61
+ def _additional_datums
62
+ [
63
+ AdditionalDatum.new(format: "text", label: "Service Name", value: adapter_incoming_request_params.dig("data", "service", "name")),
64
+ AdditionalDatum.new(format: "text", label: "Service Address", value: adapter_incoming_request_params.dig("data", "service", "msp_address"))
65
+ ]
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,79 @@
1
+ module PagerTree::Integrations
2
+ class UptimeRobot::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
+ monitor_id = adapter_incoming_request_params.dig("monitorID")
23
+
24
+ # LEGACY: We offerred the ability to aggregate for one of our customers
25
+ # we did this through a groupSeconds parameter. Technically, with our new aggregration
26
+ # this shouldn't be here, but to support our legacy customers it is.
27
+ group_seconds = adapter_incoming_request_params.dig("groupSeconds").to_i
28
+
29
+ return monitor_id unless group_seconds > 0
30
+
31
+ alert_datetime = Time.at(adapter_incoming_request_params.dig("alertDateTime").to_i)
32
+
33
+ # return the rounded off time as the id (as so to group them together by id)
34
+ _round_off(alert_datetime, group_seconds.seconds).to_i
35
+ end
36
+
37
+ def adapter_action
38
+ case adapter_incoming_request_params.dig("alertTypeFriendlyName").to_s.downcase
39
+ when "down"
40
+ :create
41
+ when "up"
42
+ :resolve
43
+ else
44
+ :other
45
+ end
46
+ end
47
+
48
+ def adapter_process_create
49
+ Alert.new(
50
+ title: _title,
51
+ description: _description,
52
+ thirdparty_id: adapter_thirdparty_id,
53
+ dedup_keys: [adapter_thirdparty_id],
54
+ additional_data: _additional_datums
55
+ )
56
+ end
57
+
58
+ private
59
+
60
+ def _title
61
+ "#{adapter_incoming_request_params.dig("monitorFriendlyName")} is DOWN"
62
+ end
63
+
64
+ def _description
65
+ "#{adapter_incoming_request_params.dig("monitorFriendlyName")} is DOWN because #{adapter_incoming_request_params.dig("alertDetails")}"
66
+ end
67
+
68
+ def _additional_datums
69
+ [
70
+ AdditionalDatum.new(format: "link", label: "Monitor URL", value: adapter_incoming_request_params.dig("monitorURL")),
71
+ AdditionalDatum.new(format: "datetime", label: "Triggered At", value: Time.at(adapter_incoming_request_params.dig("alertDateTime").to_i).utc.to_datetime)
72
+ ]
73
+ end
74
+
75
+ def _round_off(time, seconds)
76
+ Time.at((time.to_f / seconds).floor * seconds).utc
77
+ end
78
+ end
79
+ end