2021-02-04 09:02:19 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/* Icinga DB Web | (c) 2021 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Icingadb\Command\Object;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable or disable a feature of an Icinga object, i.e. host or service
|
|
|
|
|
*/
|
2023-03-01 05:28:18 -05:00
|
|
|
class ToggleObjectFeatureCommand extends ObjectsCommand
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Feature for enabling or disabling active checks of a host or service
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const FEATURE_ACTIVE_CHECKS = 'active_checks_enabled';
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Feature for enabling or disabling passive checks of a host or service
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const FEATURE_PASSIVE_CHECKS = 'passive_checks_enabled';
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Feature for enabling or disabling notifications for a host or service
|
|
|
|
|
*
|
|
|
|
|
* Notifications will be sent out only if notifications are enabled on a program-wide basis as well.
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const FEATURE_NOTIFICATIONS = 'notifications_enabled';
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Feature for enabling or disabling event handler for a host or service
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const FEATURE_EVENT_HANDLER = 'event_handler_enabled';
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Feature for enabling or disabling flap detection for a host or service.
|
|
|
|
|
*
|
|
|
|
|
* In order to enable flap detection flap detection must be enabled on a program-wide basis as well.
|
|
|
|
|
*/
|
2025-10-12 16:45:40 -04:00
|
|
|
public const FEATURE_FLAP_DETECTION = 'flapping_enabled';
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Feature that is to be enabled or disabled
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $feature;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether the feature should be enabled or disabled
|
|
|
|
|
*
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
protected $enabled;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the feature that is to be enabled or disabled
|
|
|
|
|
*
|
|
|
|
|
* @param string $feature
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function setFeature(string $feature): self
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
$this->feature = $feature;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the feature that is to be enabled or disabled
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function getFeature(): string
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
if ($this->feature === null) {
|
|
|
|
|
throw new \LogicException(
|
|
|
|
|
'You are accessing an unset property. Please make sure to set it beforehand.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 09:02:19 -05:00
|
|
|
return $this->feature;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set whether the feature should be enabled or disabled
|
|
|
|
|
*
|
|
|
|
|
* @param bool $enabled
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
2021-09-22 04:21:15 -04:00
|
|
|
public function setEnabled(bool $enabled = true): self
|
2021-02-04 09:02:19 -05:00
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
$this->enabled = $enabled;
|
2021-02-04 09:02:19 -05:00
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get whether the feature should be enabled or disabled
|
|
|
|
|
*
|
2021-09-22 04:21:15 -04:00
|
|
|
* @return ?bool
|
2021-02-04 09:02:19 -05:00
|
|
|
*/
|
|
|
|
|
public function getEnabled()
|
|
|
|
|
{
|
|
|
|
|
return $this->enabled;
|
|
|
|
|
}
|
|
|
|
|
}
|