blob: 3f8093287cd02fd4ff672c039411d924431fa624 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<?php
/* Icinga Web 2 X.509 Module | (c) 2023 Icinga GmbH | GPLv2 */
namespace Icinga\Module\X509;
use Icinga\Module\X509\Model\X509Schedule;
use Icinga\Util\Json;
use stdClass;
class Schedule
{
/** @var int The database id of this schedule */
protected $id;
/** @var string The name of this job schedule */
protected $name;
/** @var object The config of this schedule */
protected $config;
public function __construct(string $name, int $id, object $config)
{
$this->id = $id;
$this->name = $name;
$this->config = $config;
}
public static function fromModel(X509Schedule $schedule): self
{
/** @var stdClass $config */
$config = Json::decode($schedule->config);
if (isset($config->rescan)) {
$config->rescan = $config->rescan === 'y';
}
if (isset($config->full_scan)) {
$config->full_scan = $config->full_scan === 'y';
}
return new static($schedule->name, $schedule->id, $config);
}
/**
* Get the name of this schedule
*
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* Set the name of this schedule
*
* @param string $name
*
* @return $this
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* Get the database id of this job
*
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* Set the database id of this job
*
* @param int $id
*
* @return $this
*/
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
/**
* Get the config of this schedule
*
* @return object
*/
public function getConfig(): object
{
return $this->config;
}
/**
* Set the config of this schedule
*
* @param object $config
*
* @return $this
*/
public function setConfig(object $config): self
{
$this->config = $config;
return $this;
}
/**
* Get the checksum of this schedule
*
* @return string
*/
public function getChecksum(): string
{
return md5($this->getName() . Json::encode($this->getConfig()), true);
}
}
|