mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
IcingaApiUser: introduce a new object type
This commit is contained in:
parent
b73806d69c
commit
08c3614620
19
library/Director/Objects/IcingaApiUser.php
Normal file
19
library/Director/Objects/IcingaApiUser.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Objects;
|
||||
|
||||
class IcingaApiUser extends IcingaObject
|
||||
{
|
||||
protected $table = 'icinga_apiuser';
|
||||
|
||||
protected $supportsImports = true;
|
||||
|
||||
protected $defaultProperties = array(
|
||||
'id' => null,
|
||||
'object_name' => null,
|
||||
'object_type' => null,
|
||||
'password' => null,
|
||||
'client_dn' => null,
|
||||
'permissions' => null,
|
||||
);
|
||||
}
|
@ -16,14 +16,21 @@ class IcingaEndpoint extends IcingaObject
|
||||
'port' => null,
|
||||
'log_duration' => null,
|
||||
'object_type' => null,
|
||||
'apiuser_id' => null,
|
||||
);
|
||||
|
||||
protected $relations = array(
|
||||
'zone' => 'IcingaZone',
|
||||
'zone' => 'IcingaZone',
|
||||
'apiuser' => 'IcingaApiUser',
|
||||
);
|
||||
|
||||
protected function renderLog_duration()
|
||||
{
|
||||
return $this->renderPropertyAsSeconds('log_duration');
|
||||
}
|
||||
|
||||
protected function renderApiuser_id()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
20
schema/mysql-changes/upgrade_57.sql
Normal file
20
schema/mysql-changes/upgrade_57.sql
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
CREATE TABLE icinga_apiuser (
|
||||
id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
|
||||
object_name VARCHAR(255) NOT NULL,
|
||||
object_type ENUM('object', 'template', 'external_object') NOT NULL,
|
||||
password VARCHAR(255) DEFAULT NULL,
|
||||
client_dn VARCHAR(64) DEFAULT NULL,
|
||||
permissions TEXT DEFAULT NULL COMMENT 'JSON-encoded permissions',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE icinga_endpoint
|
||||
ADD COLUMN apiuser_id INT(10) UNSIGNED DEFAULT NULL,
|
||||
ADD CONSTRAINT icinga_apiuser
|
||||
FOREIGN KEY apiuser (apiuser_id)
|
||||
REFERENCES icinga_apiuser (id)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
||||
|
||||
|
@ -320,6 +320,16 @@ CREATE TABLE icinga_command_var (
|
||||
ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE icinga_apiuser (
|
||||
id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
|
||||
object_name VARCHAR(255) NOT NULL,
|
||||
object_type ENUM('object', 'template', 'external_object') NOT NULL,
|
||||
password VARCHAR(255) DEFAULT NULL,
|
||||
client_dn VARCHAR(64) DEFAULT NULL,
|
||||
permissions TEXT DEFAULT NULL COMMENT 'JSON-encoded permissions',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE icinga_endpoint (
|
||||
id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
|
||||
zone_id INT(10) UNSIGNED DEFAULT NULL,
|
||||
@ -328,12 +338,18 @@ CREATE TABLE icinga_endpoint (
|
||||
port SMALLINT UNSIGNED DEFAULT NULL COMMENT '5665 if not set',
|
||||
log_duration VARCHAR(32) DEFAULT NULL COMMENT '1d if not set',
|
||||
object_type ENUM('object', 'template', 'external_object') NOT NULL,
|
||||
apiuser_id INT(10) UNSIGNED DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE INDEX object_name (object_name),
|
||||
CONSTRAINT icinga_endpoint_zone
|
||||
FOREIGN KEY zone (zone_id)
|
||||
REFERENCES icinga_zone (id)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE,
|
||||
CONSTRAINT icinga_apiuser
|
||||
FOREIGN KEY apiuser (apiuser_id)
|
||||
REFERENCES icinga_apiuser (id)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user