Module: Icinga2::Notifications
- Included in:
- Client
- Defined in:
- lib/icinga2/notifications.rb
Overview
namespace for servicegroup handling
Instance Method Summary collapse
-
#disable_host_notification(host) ⇒ Hash
disable host notifications.
-
#disable_hostgroup_notification(params) ⇒ Hash
disable hostgroup notifications.
-
#disable_service_notification(host) ⇒ Hash
disable service notifications.
-
#enable_host_notification(host) ⇒ Hash
enable host notifications.
-
#enable_hostgroup_notification(params) ⇒ Hash
enable hostgroup notifications.
-
#enable_service_notification(host) ⇒ Hash
enable service notifications.
-
#notifications ⇒ Array
return all notifications.
Instance Method Details
#disable_host_notification(host) ⇒ Hash
disable host notifications
35 36 37 38 39 40 41 |
# File 'lib/icinga2/notifications.rb', line 35 def disable_host_notification( host ) raise ArgumentError.new('only String are allowed') unless( host.is_a?(String) ) raise ArgumentError.new('missing host') if( host.size.zero? ) host_notification( name: host, enable_notifications: false ) end |
#disable_hostgroup_notification(params) ⇒ Hash
disable hostgroup notifications
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/icinga2/notifications.rb', line 113 def disable_hostgroup_notification( params ) raise ArgumentError.new('only Hash are allowed') unless( params.is_a?(Hash) ) raise ArgumentError.new('missing params') if( params.size.zero? ) host = params.dig(:host) host_group = params.dig(:host_group) raise ArgumentError.new('Missing host') if( host.nil? ) raise ArgumentError.new('Missing host_group') if( host_group.nil? ) hostgroup_notification( host: host, host_group: host_group, enable_notifications: false ) end |
#disable_service_notification(host) ⇒ Hash
disable service notifications
69 70 71 72 73 74 75 |
# File 'lib/icinga2/notifications.rb', line 69 def disable_service_notification( host ) raise ArgumentError.new('only String are allowed') unless( host.is_a?(String) ) raise ArgumentError.new('missing host') if( host.size.zero? ) service_notification( name: host, enable_notifications: false ) end |
#enable_host_notification(host) ⇒ Hash
enable host notifications
18 19 20 21 22 23 24 |
# File 'lib/icinga2/notifications.rb', line 18 def enable_host_notification( host ) raise ArgumentError.new('only String are allowed') unless( host.is_a?(String) ) raise ArgumentError.new('missing host') if( host.size.zero? ) host_notification( name: host, enable_notifications: true ) end |
#enable_hostgroup_notification(params) ⇒ Hash
enable hostgroup notifications
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/icinga2/notifications.rb', line 88 def enable_hostgroup_notification( params ) raise ArgumentError.new('only Hash are allowed') unless( params.is_a?(Hash) ) raise ArgumentError.new('missing params') if( params.size.zero? ) host = params.dig(:host) host_group = params.dig(:host_group) raise ArgumentError.new('Missing host') if( host.nil? ) raise ArgumentError.new('Missing host_group') if( host_group.nil? ) hostgroup_notification( host: host, host_group: host_group, enable_notifications: true ) end |
#enable_service_notification(host) ⇒ Hash
enable service notifications
52 53 54 55 56 57 58 |
# File 'lib/icinga2/notifications.rb', line 52 def enable_service_notification( host ) raise ArgumentError.new('only String are allowed') unless( host.is_a?(String) ) raise ArgumentError.new('missing host') if( host.size.zero? ) service_notification( name: host, enable_notifications: true ) end |
#notifications ⇒ Array
return all notifications
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/icinga2/notifications.rb', line 132 def notifications data = Network.api_data( url: format( '%s/objects/notifications', @icinga_api_url_base ), headers: @headers, options: @options ) return data.dig('results') if( data.dig(:status).nil? ) nil end |