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
37 38 39 40 41 42 43 44 45 |
# File 'lib/icinga2/notifications.rb', line 37 def disable_host_notification( host ) raise ArgumentError.new(format('wrong type. \'host\' must be an String, given \'%s\'', host.class.to_s)) unless( host.is_a?(String) ) raise ArgumentError.new('missing \'host\'') if( host.size.zero? ) return { 'code' => 404, 'status' => 'Object not Found' } if( exists_host?( host ) == false ) host_notification( name: host, enable_notifications: false ) end |
#disable_hostgroup_notification(params) ⇒ Hash
disable hostgroup notifications
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/icinga2/notifications.rb', line 120 def disable_hostgroup_notification( params ) raise ArgumentError.new(format('wrong type. \'params\' must be an Hash, given \'%s\'', params.class.to_s)) unless( params.is_a?(Hash) ) raise ArgumentError.new('missing \'params\'') if( params.size.zero? ) host_group = params.dig(:host_group) raise ArgumentError.new('Missing host_group') if( host_group.nil? ) return { 'code' => 404, 'status' => 'Object not Found' } if( exists_hostgroup?( host_group ) == false ) hostgroup_notification( host_group: host_group, enable_notifications: true ) end |
#disable_service_notification(host) ⇒ Hash
disable service notifications
75 76 77 78 79 80 81 82 83 |
# File 'lib/icinga2/notifications.rb', line 75 def disable_service_notification( host ) raise ArgumentError.new(format('wrong type. \'host\' must be an String, given \'%s\'', host.class.to_s)) unless( host.is_a?(String) ) raise ArgumentError.new('missing \'host\'') if( host.size.zero? ) return { 'code' => 404, 'status' => 'Object not Found' } if( exists_host?( host ) == false ) service_notification( name: host, enable_notifications: false ) end |
#enable_host_notification(host) ⇒ Hash
enable host notifications
18 19 20 21 22 23 24 25 26 |
# File 'lib/icinga2/notifications.rb', line 18 def enable_host_notification( host ) raise ArgumentError.new(format('wrong type. \'host\' must be an String, given \'%s\'', host.class.to_s)) unless( host.is_a?(String) ) raise ArgumentError.new('missing \'host\'') if( host.size.zero? ) return { 'code' => 404, 'status' => 'Object not Found' } if( exists_host?( host ) == false ) host_notification( name: host, enable_notifications: true ) end |
#enable_hostgroup_notification(params) ⇒ Hash
enable hostgroup notifications
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/icinga2/notifications.rb', line 96 def enable_hostgroup_notification( params ) raise ArgumentError.new(format('wrong type. \'params\' must be an Hash, given \'%s\'', params.class.to_s)) unless( params.is_a?(Hash) ) raise ArgumentError.new('missing \'params\'') if( params.size.zero? ) host_group = params.dig(:host_group) raise ArgumentError.new('Missing host_group') if( host_group.nil? ) return { 'code' => 404, 'status' => 'Object not Found' } if( exists_hostgroup?( host_group ) == false ) hostgroup_notification( host_group: host_group, enable_notifications: true ) end |
#enable_service_notification(host) ⇒ Hash
enable service notifications
56 57 58 59 60 61 62 63 64 |
# File 'lib/icinga2/notifications.rb', line 56 def enable_service_notification( host ) raise ArgumentError.new(format('wrong type. \'host\' must be an String, given \'%s\'', host.class.to_s)) unless( host.is_a?(String) ) raise ArgumentError.new('missing \'host\'') if( host.size.zero? ) return { 'code' => 404, 'status' => 'Object not Found' } if( exists_host?( host ) == false ) service_notification( name: host, enable_notifications: true ) end |
#notifications ⇒ Array
return all notifications
138 139 140 141 142 143 144 145 |
# File 'lib/icinga2/notifications.rb', line 138 def notifications api_data( url: format( '%s/objects/notifications', @icinga_api_url_base ), headers: @headers, options: @options ) end |