From f66ab8dae2f3d0418759f81a3a64dc9517a62449 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:31 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- library/Director/Objects/IcingaObjectGroup.php | 76 ++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 library/Director/Objects/IcingaObjectGroup.php (limited to 'library/Director/Objects/IcingaObjectGroup.php') diff --git a/library/Director/Objects/IcingaObjectGroup.php b/library/Director/Objects/IcingaObjectGroup.php new file mode 100644 index 0000000..c0bec54 --- /dev/null +++ b/library/Director/Objects/IcingaObjectGroup.php @@ -0,0 +1,76 @@ + null, + 'uuid' => null, + 'object_name' => null, + 'object_type' => null, + 'disabled' => 'n', + 'display_name' => null, + 'assign_filter' => null, + ]; + + public function getUniqueIdentifier() + { + return $this->getObjectName(); + } + + /** + * @return object + * @deprecated please use \Icinga\Module\Director\Data\Exporter + * @throws \Icinga\Exception\NotFoundError + */ + public function export() + { + return $this->toPlainObject(); + } + + /** + * @param $plain + * @param Db $db + * @param bool $replace + * @return IcingaObjectGroup + * @throws DuplicateKeyException + * @throws \Icinga\Exception\NotFoundError + */ + public static function import($plain, Db $db, $replace = false) + { + $properties = (array) $plain; + $name = $properties['object_name']; + $key = $name; + + if ($replace && static::exists($key, $db)) { + $object = static::load($key, $db); + } elseif (static::exists($key, $db)) { + throw new DuplicateKeyException( + 'Group "%s" already exists', + $name + ); + } else { + $object = static::create([], $db); + } + + $object->setProperties($properties); + + return $object; + } + + protected function prefersGlobalZone() + { + return true; + } +} -- cgit v1.2.3