icingaweb2-module-director/application/forms/SyncRuleForm.php

83 lines
3.4 KiB
PHP
Raw Normal View History

2015-07-23 16:40:32 +02:00
<?php
namespace Icinga\Module\Director\Forms;
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
class SyncRuleForm extends DirectorObjectForm
{
public function setup()
{
2016-02-26 12:42:21 +01:00
$availableTypes = array(
2015-12-03 16:13:49 +01:00
'host' => $this->translate('Host'),
'hostgroup' => $this->translate('Host group'),
2015-12-03 16:13:49 +01:00
'service' => $this->translate('Service'),
'servicegroup' => $this->translate('Service group'),
'serviceSet' => $this->translate('Service Set'),
2015-12-03 16:13:49 +01:00
'user' => $this->translate('User'),
'usergroup' => $this->translate('User group'),
2015-12-03 16:13:49 +01:00
'datalistEntry' => $this->translate('Datalist entry'),
'command' => $this->translate('Command'),
'timePeriod' => $this->translate('Time period'),
'endpoint' => $this->translate('Endpoint'),
2015-12-03 16:13:49 +01:00
'zone' => $this->translate('Zone'),
);
2015-07-23 16:40:32 +02:00
$this->addElement('text', 'rule_name', array(
2015-11-02 10:36:10 +01:00
'label' => $this->translate('Rule name'),
'description' => $this->translate('Please provide a rule name'),
2015-07-23 16:40:32 +02:00
'required' => true,
));
$this->addElement('select', 'object_type', array(
2015-11-02 10:36:10 +01:00
'label' => $this->translate('Object Type'),
2016-04-12 20:32:30 +02:00
'description' => $this->translate('Choose an object type'),
2015-11-02 10:36:10 +01:00
'required' => true,
2015-12-03 16:13:49 +01:00
'multiOptions' => $this->optionalEnum($availableTypes)
2015-07-23 16:40:32 +02:00
));
$this->addElement('select', 'update_policy', array(
2016-08-23 18:11:46 +02:00
'label' => $this->translate('Update Policy'),
2016-04-12 20:32:30 +02:00
'description' => $this->translate(
'Define what should happen when an object with a matching key'
. " already exists. You could merge its properties (import source"
2016-04-12 21:06:15 +02:00
. ' wins), replace it completely with the imported object or ignore'
. ' it (helpful for one-time imports)'
2016-04-12 20:32:30 +02:00
),
2015-11-02 10:36:10 +01:00
'required' => true,
2016-02-26 12:42:21 +01:00
'multiOptions' => $this->optionalEnum(array(
2016-04-12 20:32:30 +02:00
'merge' => $this->translate('Merge'),
'override' => $this->translate('Replace'),
'ignore' => $this->translate('Ignore'),
2015-11-02 10:36:10 +01:00
))
2015-07-23 16:40:32 +02:00
));
$this->addElement('select', 'purge_existing', array(
'label' => $this->translate('Purge'),
2016-04-12 20:32:30 +02:00
'description' => $this->translate(
'Whether to purge existing objects. This means that objects of'
2016-04-12 21:06:15 +02:00
. ' the same type will be removed from Director in case they no'
. ' longer exist at your import source.'
2016-04-12 20:32:30 +02:00
),
'required' => true,
2016-02-26 12:42:21 +01:00
'multiOptions' => $this->optionalEnum(array(
2016-04-12 20:32:30 +02:00
'y' => $this->translate('Yes'),
'n' => $this->translate('No')
2015-11-02 10:36:10 +01:00
))
2015-07-23 16:40:32 +02:00
));
$this->addElement('text', 'filter_expression', array(
2015-11-02 10:36:10 +01:00
'label' => $this->translate('Filter Expression'),
2016-04-12 20:32:30 +02:00
'description' => sprintf(
$this->translate(
'Sync only part of your imported objects with this rule. Icinga Web 2'
2016-04-12 21:06:15 +02:00
. ' filter syntax is allowed, so this could look as follows: %s'
2016-04-12 20:32:30 +02:00
),
'(host=a|host=b)&!ip=127.*'
),
2015-07-23 16:40:32 +02:00
));
$this->setButtons();
2015-07-23 16:40:32 +02:00
}
}