diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:36:40 +0000 |
commit | a0901c4b7f2db488cb4fb3be2dd921a0308f4659 (patch) | |
tree | fafb393cf330a60df129ff10d0059eb7b14052a7 /library/Icingadb/Model/Notification.php | |
parent | Initial commit. (diff) | |
download | icingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.tar.xz icingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Icingadb/Model/Notification.php')
-rw-r--r-- | library/Icingadb/Model/Notification.php | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/library/Icingadb/Model/Notification.php b/library/Icingadb/Model/Notification.php new file mode 100644 index 0000000..8d42301 --- /dev/null +++ b/library/Icingadb/Model/Notification.php @@ -0,0 +1,130 @@ +<?php + +/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */ + +namespace Icinga\Module\Icingadb\Model; + +use Icinga\Module\Icingadb\Model\Behavior\Bitmask; +use Icinga\Module\Icingadb\Model\Behavior\ReRoute; +use ipl\Orm\Behavior\Binary; +use ipl\Orm\Behaviors; +use ipl\Orm\Model; +use ipl\Orm\Relations; + +class Notification extends Model +{ + public function getTableName() + { + return 'notification'; + } + + public function getKeyName() + { + return 'id'; + } + + public function getColumns() + { + return [ + 'environment_id', + 'name_checksum', + 'properties_checksum', + 'name', + 'name_ci', + 'host_id', + 'service_id', + 'notificationcommand_id', + 'times_begin', + 'times_end', + 'notification_interval', + 'timeperiod_id', + 'states', + 'types', + 'zone_id' + ]; + } + + public function getColumnDefinitions() + { + return [ + 'environment_id' => t('Environment Id'), + 'name_checksum' => t('Notification Name Checksum'), + 'properties_checksum' => t('Notification Properties Checksum'), + 'name' => t('Notification Name'), + 'name_ci' => t('Notification Name (CI)'), + 'host_id' => t('Host Id'), + 'service_id' => t('Service Id'), + 'notificationcommand_id' => t('Notificationcommand Id'), + 'times_begin' => t('Notification Escalate After'), + 'times_end' => t('Notification Escalate Until'), + 'notification_interval' => t('Notification Interval'), + 'timeperiod_id' => t('Timeperiod Id'), + 'states' => t('Notification State Filter'), + 'types' => t('Notification Type Filter'), + 'zone_id' => t('Zone Id') + ]; + } + + public function createBehaviors(Behaviors $behaviors) + { + $behaviors->add(new ReRoute([ + 'hostgroup' => 'host.hostgroup', + 'servicegroup' => 'service.servicegroup' + ])); + + $behaviors->add(new Bitmask([ + 'states' => [ + 'ok' => 1, + 'warning' => 2, + 'critical' => 4, + 'unknown' => 8, + 'up' => 16, + 'down' => 32 + ], + 'types' => [ + 'downtime_start' => 1, + 'downtime_end' => 2, + 'downtime_removed' => 4, + 'custom' => 8, + 'ack' => 16, + 'problem' => 32, + 'recovery' => 64, + 'flapping_start' => 128, + 'flapping_end' => 256 + ] + ])); + + $behaviors->add(new Binary([ + 'id', + 'environment_id', + 'name_checksum', + 'properties_checksum', + 'host_id', + 'service_id', + 'notificationcommand_id', + 'timeperiod_id', + 'zone_id' + ])); + } + + public function createRelations(Relations $relations) + { + $relations->belongsTo('environment', Environment::class); + $relations->belongsTo('host', Host::class); + $relations->belongsTo('service', Service::class); + $relations->belongsTo('notificationcommand', Notificationcommand::class); + $relations->belongsTo('timeperiod', Timeperiod::class); + $relations->belongsTo('zone', Zone::class); + + $relations->belongsToMany('customvar', Customvar::class) + ->through(NotificationCustomvar::class); + $relations->belongsToMany('customvar_flat', CustomvarFlat::class) + ->through(NotificationCustomvar::class); + $relations->belongsToMany('vars', Vars::class) + ->through(NotificationCustomvar::class); + $relations->belongsToMany('user', User::class) + ->through('notification_recipient'); + $relations->belongsToMany('usergroup', Usergroup::class) + ->through('notification_recipient'); + } +} |