1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the CwdPowerDNS Client |
5
|
|
|
* |
6
|
|
|
* (c) 2018 cwd.at GmbH <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Cwd\PowerDNSClient\Model; |
15
|
|
|
|
16
|
|
|
use Cwd\PowerDNSClient\Model\Zone\RRSet; |
17
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
18
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
19
|
|
|
use Cwd\PowerDNSClient\Validator\Constraints as DNSAssert; |
20
|
|
|
|
21
|
|
|
class Zone |
22
|
|
|
{ |
23
|
|
|
protected const TYPE = 'Zone'; |
24
|
|
|
public const KIND_MASTER = 'Master'; |
25
|
|
|
public const KIND_SLAVE = 'Slave'; |
26
|
|
|
public const KIND_NATIVE = 'Native'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string|null |
30
|
|
|
* @Groups({"CREATE", "DELETE"}) |
31
|
|
|
*/ |
32
|
|
|
protected $id; |
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
* @Assert\NotBlank(groups={"CREATE"}) |
36
|
|
|
* @DNSAssert\HasDotPostfix(groups={"CREATE"}) |
37
|
|
|
* @Groups({"CREATE", "DELETE"}) |
38
|
|
|
*/ |
39
|
|
|
protected $name; |
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
* @Assert\NotBlank() |
43
|
|
|
* @Assert\Choice( |
44
|
|
|
* choices= {"Zone"}, |
45
|
|
|
* groups={"CREATE", "UPDATE"} |
46
|
|
|
* ) |
47
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
48
|
|
|
*/ |
49
|
|
|
protected $type = self::TYPE; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string|null |
53
|
|
|
* @Groups({"CREATE", "DELETE"}) |
54
|
|
|
*/ |
55
|
|
|
protected $url; |
56
|
|
|
/** |
57
|
|
|
* @var string|null |
58
|
|
|
* @Assert\Choice( |
59
|
|
|
* choices = {"Master", "Slave", "Native"}, |
60
|
|
|
* groups={"CREATE", "UPDATE"} |
61
|
|
|
* ) |
62
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
63
|
|
|
*/ |
64
|
|
|
protected $kind; |
65
|
|
|
/** |
66
|
|
|
* @var array |
67
|
|
|
* @Assert\Valid(groups={"CREATE", "UPDATE"}) |
68
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
69
|
|
|
*/ |
70
|
|
|
protected $rrsets = []; |
71
|
|
|
|
72
|
|
|
/** @var int|null */ |
73
|
|
|
protected $serial; |
74
|
|
|
/** @var int|null */ |
75
|
|
|
protected $notifiedSerial; |
76
|
|
|
/** |
77
|
|
|
* @var string[] |
78
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
79
|
|
|
*/ |
80
|
|
|
protected $masters = []; |
81
|
|
|
/** |
82
|
|
|
* @var bool |
83
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
84
|
|
|
*/ |
85
|
|
|
protected $dnssec = false; |
86
|
|
|
/** |
87
|
|
|
* @var string|null |
88
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
89
|
|
|
*/ |
90
|
|
|
protected $nsec3param; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @var bool |
94
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
95
|
|
|
*/ |
96
|
|
|
protected $nsec3narrow = false; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @var bool |
100
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
101
|
|
|
*/ |
102
|
|
|
protected $predisgned = false; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @var string|null |
106
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
107
|
|
|
*/ |
108
|
|
|
protected $soaEdit; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @var string|null |
112
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
113
|
|
|
*/ |
114
|
|
|
protected $soaEditApi; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @var bool |
118
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
119
|
|
|
*/ |
120
|
|
|
protected $apiRectify = false; |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @var string|null |
124
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
125
|
|
|
*/ |
126
|
|
|
protected $zone; |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @var string|null |
130
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
131
|
|
|
*/ |
132
|
|
|
protected $account; |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @var string[] |
136
|
|
|
* @Groups({"REPLACE", "CREATE", "DELETE"}) |
137
|
|
|
*/ |
138
|
|
|
protected $nameservers = []; |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return null|string |
142
|
|
|
*/ |
143
|
|
|
public function getId(): ?string |
144
|
|
|
{ |
145
|
|
|
return $this->id; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param null|string $id |
150
|
|
|
* |
151
|
|
|
* @return Zone |
152
|
|
|
*/ |
153
|
|
|
public function setId(?string $id): Zone |
154
|
|
|
{ |
155
|
|
|
$this->id = $id; |
156
|
|
|
|
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @return string |
162
|
|
|
*/ |
163
|
|
|
public function getName(): ?string |
164
|
|
|
{ |
165
|
|
|
return $this->name; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @param string $name |
170
|
|
|
* |
171
|
|
|
* @return Zone |
172
|
|
|
*/ |
173
|
|
|
public function setName(?string $name): Zone |
174
|
|
|
{ |
175
|
|
|
$this->name = $name; |
176
|
|
|
|
177
|
|
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @return string |
182
|
|
|
*/ |
183
|
|
|
public function getType(): ?string |
184
|
|
|
{ |
185
|
|
|
return $this->type; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @param string $type |
190
|
|
|
* |
191
|
|
|
* @return Zone |
192
|
|
|
*/ |
193
|
|
|
public function setType(?string $type): Zone |
194
|
|
|
{ |
195
|
|
|
$this->type = $type; |
196
|
|
|
|
197
|
|
|
return $this; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @return null|string |
202
|
|
|
*/ |
203
|
|
|
public function getUrl(): ?string |
204
|
|
|
{ |
205
|
|
|
return $this->url; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @param null|string $url |
210
|
|
|
* |
211
|
|
|
* @return Zone |
212
|
|
|
*/ |
213
|
|
|
public function setUrl(?string $url): Zone |
214
|
|
|
{ |
215
|
|
|
$this->url = $url; |
216
|
|
|
|
217
|
|
|
return $this; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return null|string |
222
|
|
|
*/ |
223
|
|
|
public function getKind(): ?string |
224
|
|
|
{ |
225
|
|
|
return $this->kind; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param null|string $kind |
230
|
|
|
* |
231
|
|
|
* @return Zone |
232
|
|
|
*/ |
233
|
|
|
public function setKind(?string $kind): Zone |
234
|
|
|
{ |
235
|
|
|
$this->kind = $kind; |
236
|
|
|
|
237
|
|
|
return $this; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* @return array<RRSet> |
242
|
|
|
*/ |
243
|
|
|
public function getRrsets(): array |
244
|
|
|
{ |
245
|
|
|
return $this->rrsets; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* @param array $rrsets |
250
|
|
|
* |
251
|
|
|
* @return Zone |
252
|
|
|
*/ |
253
|
|
|
public function setRrsets(array $rrsets): Zone |
254
|
|
|
{ |
255
|
|
|
$this->rrsets = $rrsets; |
256
|
|
|
|
257
|
|
|
return $this; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
public function addRrset(RRSet $rrset): Zone |
261
|
|
|
{ |
262
|
|
|
$this->rrsets[] = $rrset; |
263
|
|
|
|
264
|
|
|
return $this; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @return int|null |
269
|
|
|
*/ |
270
|
|
|
public function getSerial(): ?int |
271
|
|
|
{ |
272
|
|
|
return $this->serial; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @param int|null $serial |
277
|
|
|
* |
278
|
|
|
* @return Zone |
279
|
|
|
*/ |
280
|
|
|
public function setSerial(?int $serial): Zone |
281
|
|
|
{ |
282
|
|
|
$this->serial = $serial; |
283
|
|
|
|
284
|
|
|
return $this; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @return int|null |
289
|
|
|
*/ |
290
|
|
|
public function getNotifiedSerial(): ?int |
291
|
|
|
{ |
292
|
|
|
return $this->notifiedSerial; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @param int|null $notifiedSerial |
297
|
|
|
* |
298
|
|
|
* @return Zone |
299
|
|
|
*/ |
300
|
|
|
public function setNotifiedSerial(?int $notifiedSerial): Zone |
301
|
|
|
{ |
302
|
|
|
$this->notifiedSerial = $notifiedSerial; |
303
|
|
|
|
304
|
|
|
return $this; |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @return string[] |
309
|
|
|
*/ |
310
|
|
|
public function getMasters(): array |
311
|
|
|
{ |
312
|
|
|
return $this->masters; |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @param string[] $masters |
317
|
|
|
* |
318
|
|
|
* @return Zone |
319
|
|
|
*/ |
320
|
|
|
public function setMasters(array $masters): Zone |
321
|
|
|
{ |
322
|
|
|
$this->masters = $masters; |
323
|
|
|
|
324
|
|
|
return $this; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* @return bool |
329
|
|
|
*/ |
330
|
|
|
public function isDnssec(): bool |
331
|
|
|
{ |
332
|
|
|
return $this->dnssec; |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* @param bool $dnssec |
337
|
|
|
* |
338
|
|
|
* @return Zone |
339
|
|
|
*/ |
340
|
|
|
public function setDnssec(bool $dnssec): Zone |
341
|
|
|
{ |
342
|
|
|
$this->dnssec = $dnssec; |
343
|
|
|
|
344
|
|
|
return $this; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* @return null|string |
349
|
|
|
*/ |
350
|
|
|
public function getNsec3param(): ?string |
351
|
|
|
{ |
352
|
|
|
return $this->nsec3param; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* @param null|string $nsec3param |
357
|
|
|
* |
358
|
|
|
* @return Zone |
359
|
|
|
*/ |
360
|
|
|
public function setNsec3param(?string $nsec3param): Zone |
361
|
|
|
{ |
362
|
|
|
$this->nsec3param = $nsec3param; |
363
|
|
|
|
364
|
|
|
return $this; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* @return bool |
369
|
|
|
*/ |
370
|
|
|
public function isNsec3narrow(): bool |
371
|
|
|
{ |
372
|
|
|
return $this->nsec3narrow; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* @param bool $nsec3narrow |
377
|
|
|
* |
378
|
|
|
* @return Zone |
379
|
|
|
*/ |
380
|
|
|
public function setNsec3narrow(bool $nsec3narrow): Zone |
381
|
|
|
{ |
382
|
|
|
$this->nsec3narrow = $nsec3narrow; |
383
|
|
|
|
384
|
|
|
return $this; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @return bool |
389
|
|
|
*/ |
390
|
|
|
public function isPredisgned(): bool |
391
|
|
|
{ |
392
|
|
|
return $this->predisgned; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* @param bool $predisgned |
397
|
|
|
* |
398
|
|
|
* @return Zone |
399
|
|
|
*/ |
400
|
|
|
public function setPredisgned(bool $predisgned): Zone |
401
|
|
|
{ |
402
|
|
|
$this->predisgned = $predisgned; |
403
|
|
|
|
404
|
|
|
return $this; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* @return null|string |
409
|
|
|
*/ |
410
|
|
|
public function getSoaEdit(): ?string |
411
|
|
|
{ |
412
|
|
|
return $this->soaEdit; |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
/** |
416
|
|
|
* @param null|string $soaEdit |
417
|
|
|
* |
418
|
|
|
* @return Zone |
419
|
|
|
*/ |
420
|
|
|
public function setSoaEdit(?string $soaEdit): Zone |
421
|
|
|
{ |
422
|
|
|
$this->soaEdit = $soaEdit; |
423
|
|
|
|
424
|
|
|
return $this; |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* @return null|string |
429
|
|
|
*/ |
430
|
|
|
public function getSoaEditApi(): ?string |
431
|
|
|
{ |
432
|
|
|
return $this->soaEditApi; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* @param null|string $soaEditApi |
437
|
|
|
* |
438
|
|
|
* @return Zone |
439
|
|
|
*/ |
440
|
|
|
public function setSoaEditApi(?string $soaEditApi): Zone |
441
|
|
|
{ |
442
|
|
|
$this->soaEditApi = $soaEditApi; |
443
|
|
|
|
444
|
|
|
return $this; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* @return bool |
449
|
|
|
*/ |
450
|
|
|
public function isApiRectify(): bool |
451
|
|
|
{ |
452
|
|
|
return $this->apiRectify; |
453
|
|
|
} |
454
|
|
|
|
455
|
|
|
/** |
456
|
|
|
* @param bool $apiRectify |
457
|
|
|
* |
458
|
|
|
* @return Zone |
459
|
|
|
*/ |
460
|
|
|
public function setApiRectify(bool $apiRectify): Zone |
461
|
|
|
{ |
462
|
|
|
$this->apiRectify = $apiRectify; |
463
|
|
|
|
464
|
|
|
return $this; |
465
|
|
|
} |
466
|
|
|
|
467
|
|
|
/** |
468
|
|
|
* @return null|string |
469
|
|
|
*/ |
470
|
|
|
public function getZone(): ?string |
471
|
|
|
{ |
472
|
|
|
return $this->zone; |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* @param null|string $zone |
477
|
|
|
* |
478
|
|
|
* @return Zone |
479
|
|
|
*/ |
480
|
|
|
public function setZone(?string $zone): Zone |
481
|
|
|
{ |
482
|
|
|
$this->zone = $zone; |
483
|
|
|
|
484
|
|
|
return $this; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* @return null|string |
489
|
|
|
*/ |
490
|
|
|
public function getAccount(): ?string |
491
|
|
|
{ |
492
|
|
|
return $this->account; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
/** |
496
|
|
|
* @param null|string $account |
497
|
|
|
* |
498
|
|
|
* @return Zone |
499
|
|
|
*/ |
500
|
|
|
public function setAccount(?string $account): Zone |
501
|
|
|
{ |
502
|
|
|
$this->account = $account; |
503
|
|
|
|
504
|
|
|
return $this; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* @return string[] |
509
|
|
|
*/ |
510
|
|
|
public function getNameservers(): array |
511
|
|
|
{ |
512
|
|
|
return $this->nameservers; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* @param string[] $nameservers |
517
|
|
|
* |
518
|
|
|
* @return Zone |
519
|
|
|
*/ |
520
|
|
|
public function setNameservers(array $nameservers): Zone |
521
|
|
|
{ |
522
|
|
|
$this->nameservers = $nameservers; |
523
|
|
|
|
524
|
|
|
return $this; |
525
|
|
|
} |
526
|
|
|
} |
527
|
|
|
|