-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerDNSClient.php
More file actions
98 lines (75 loc) · 2.29 KB
/
PowerDNSClient.php
File metadata and controls
98 lines (75 loc) · 2.29 KB
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
<?php
/*
* This file is part of the CwdPowerDNS Client
*
* (c) 2024 cwd.at GmbH <office@cwd.at>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cwd\PowerDNSClient;
use Cwd\PowerDNSClient\Endpoints\CryptokeysEndpoint;
use Cwd\PowerDNSClient\Endpoints\MetadataEndpoint;
use Cwd\PowerDNSClient\Endpoints\ServersEndpoint;
use Cwd\PowerDNSClient\Endpoints\ZonesEndpoint;
use Cwd\PowerDNSClient\Model\Zone;
class PowerDNSClient
{
/** @var Client */
private $client;
/** @var ServersEndpoint */
private $serversEndpoint;
/** @var ZonesEndpoint */
private $zonesEndpoint;
/** @var CryptokeysEndpoint */
private $cryptokeysEndpoint;
/** @var string */
private $defaultServerId = 'localhost';
public function __construct(Client $client)
{
$this->client = $client;
}
public function metadata($zone): MetadataEndpoint
{
$zoneId = $zone;
if ($zone instanceof Zone) {
$zoneId = $zone->getId();
}
return new MetadataEndpoint($this->getClient(), $this->getDefaultServerId(), $zoneId);
}
public function servers(): ServersEndpoint
{
if (null === $this->serversEndpoint) {
$this->serversEndpoint = new ServersEndpoint($this->getClient(), $this->getDefaultServerId());
}
return $this->serversEndpoint;
}
public function zones(): ZonesEndpoint
{
if (null === $this->zonesEndpoint) {
$this->zonesEndpoint = new ZonesEndpoint($this->getClient(), $this->getDefaultServerId());
}
return $this->zonesEndpoint;
}
public function cryptokeys($zone): CryptokeysEndpoint
{
$zoneId = $zone;
if ($zone instanceof Zone) {
$zoneId = $zone->getId();
}
return new CryptokeysEndpoint($this->getClient(), $this->getDefaultServerId(), $zoneId);
}
public function getClient(): Client
{
return $this->client;
}
public function getDefaultServerId(): string
{
return $this->defaultServerId;
}
public function setDefaultServerId(string $defaultServerId): void
{
$this->defaultServerId = $defaultServerId;
}
}