Class: SolarWinds::V3
- Inherits:
-
Integration
- Object
- Integration
- SolarWinds::V3
- Defined in:
- app/models/pager_tree/integrations/solar_winds/v3.rb
Constant Summary collapse
- OPTIONS =
[ {key: :alert_acknowledged, type: :boolean, default: false}, {key: :server_url, type: :string, default: nil}, {key: :server_username, type: :string, default: nil}, {key: :server_password, type: :string, default: nil}, {key: :proxy_url, type: :string, default: nil} ]
Instance Method Summary collapse
- #adapter_action ⇒ Object
- #adapter_incoming_can_defer? ⇒ Boolean
- #adapter_outgoing_interest?(event_name) ⇒ Boolean
- #adapter_process_create ⇒ Object
- #adapter_process_outgoing ⇒ Object
- #adapter_process_outgoing_alert_acknowledged ⇒ Object
- #adapter_show_outgoing_webhook_delivery? ⇒ Boolean
- #adapter_supports_incoming? ⇒ Boolean
- #adapter_supports_outgoing? ⇒ Boolean
- #adapter_thirdparty_id ⇒ Object
Instance Method Details
#adapter_action ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 89 def adapter_action case adapter_incoming_request_params.dig("ActionType").to_s.downcase when "create" :create when "resolve" :resolve else :other end end |
#adapter_incoming_can_defer? ⇒ Boolean
37 38 39 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 37 def adapter_incoming_can_defer? true end |
#adapter_outgoing_interest?(event_name) ⇒ Boolean
41 42 43 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 41 def adapter_outgoing_interest?(event_name) try("option_#{event_name}") || false end |
#adapter_process_create ⇒ Object
100 101 102 103 104 105 106 107 108 109 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 100 def adapter_process_create Alert.new( title: _title, description: _description, urgency: _urgency, thirdparty_id: adapter_thirdparty_id, dedup_keys: [], additional_data: _additional_datums ) end |
#adapter_process_outgoing ⇒ Object
45 46 47 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 45 def adapter_process_outgoing try("adapter_process_outgoing_#{adapter_outgoing_event.event_name}") end |
#adapter_process_outgoing_alert_acknowledged ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 49 def adapter_process_outgoing_alert_acknowledged return unless adapter_outgoing_event.alert.source == self ack_url = adapter_outgoing_event.alert&.source_log&.&.dig("params", "AcknowledgeUrl") ack_uri = URI.parse(ack_url) server_uri = URI.parse(option_server_url) object_id = Rack::Utils.parse_query(ack_uri.query).dig("ObjID") url = "#{server_uri.origin}/SolarWinds/InformationService/v3/Json/Invoke/Orion.AlertActive/Acknowledge" body = { alertObjectIds: [object_id], notes: "Acknowledged by #{adapter_outgoing_event.alert&.alert_responders&.where(role: :incident_commander)&.includes(account_user: :user)&.first&.account_user&.user&.name}" } auth = {} if option_server_username.present? && option_server_password.present? auth = { username: option_server_username, password: option_server_password } end outgoing_webhook_delivery = OutgoingWebhookDelivery.factory( resource: self, url: url, body: body, auth: auth, proxy_url: option_proxy_url.presence ) outgoing_webhook_delivery.save! outgoing_webhook_delivery.deliver_later outgoing_webhook_delivery rescue end |
#adapter_show_outgoing_webhook_delivery? ⇒ Boolean
33 34 35 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 33 def adapter_show_outgoing_webhook_delivery? true end |
#adapter_supports_incoming? ⇒ Boolean
25 26 27 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 25 def adapter_supports_incoming? true end |
#adapter_supports_outgoing? ⇒ Boolean
29 30 31 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 29 def adapter_supports_outgoing? true end |
#adapter_thirdparty_id ⇒ Object
85 86 87 |
# File 'app/models/pager_tree/integrations/solar_winds/v3.rb', line 85 def adapter_thirdparty_id adapter_incoming_request_params.dig("AlertID") end |