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(host_group) ⇒ Hash
disable hostgroup notifications.
-
#disable_service_notification(host) ⇒ Hash
disable service notifications.
-
#enable_host_notification(host) ⇒ Hash
enable host notifications.
-
#enable_hostgroup_notification(host_group) ⇒ 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(host_group) ⇒ Hash
disable hostgroup notifications
113 114 115 116 117 118 119 120 121 |
# File 'lib/icinga2/notifications.rb', line 113 def disable_hostgroup_notification( host_group ) raise ArgumentError.new(format('wrong type. \'host_group\' must be an String, given \'%s\'', host_group.class.to_s)) unless( host_group.is_a?(String) ) raise ArgumentError.new('missing \'host_group\'') if( host_group.size.zero? ) return { 'code' => 404, 'status' => 'Object not Found' } if( exists_hostgroup?( host_group ) == false ) hostgroup_notification( host_group: host_group, enable_notifications: false ) 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(host_group) ⇒ Hash
enable hostgroup notifications
94 95 96 97 98 99 100 101 102 |
# File 'lib/icinga2/notifications.rb', line 94 def enable_hostgroup_notification( host_group ) raise ArgumentError.new(format('wrong type. \'host_group\' must be an String, given \'%s\'', host_group.class.to_s)) unless( host_group.is_a?(String) ) raise ArgumentError.new('missing \'host_group\'') if( host_group.size.zero? ) return { 'code' => 404, 'status' => 'Object not Found' } unless( exists_hostgroup?( host_group ) ) 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
128 129 130 131 132 133 134 135 |
# File 'lib/icinga2/notifications.rb', line 128 def notifications api_data( url: format( '%s/objects/notifications', @icinga_api_url_base ), headers: @headers, options: @options ) end |