forked from DigitalOceanPHP/Client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseCluster.php
More file actions
88 lines (65 loc) · 2.07 KB
/
DatabaseCluster.php
File metadata and controls
88 lines (65 loc) · 2.07 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
<?php
declare(strict_types=1);
/*
* This file is part of the DigitalOcean API library.
*
* (c) Antoine Kirk <contact@sbin.dk>
* (c) Graham Campbell <hello@gjcampbell.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace DigitalOceanV2\Entity;
/**
* @author Filippo Fortino <filippofortino@gmail.com>
*/
final class DatabaseCluster extends AbstractEntity
{
public string $id;
public string $name;
public string $engine;
public string $version;
public DatabaseConnection $connection;
public DatabaseConnection $privateConnection;
/**
* @var DatabaseUser[]
*/
public array $users = [];
/**
* @var string[]
*/
public ?array $dbNames = [];
public int $numNodes;
public string $size;
public string $region;
public string $status;
public DatabaseMaintenanceWindow $maintenanceWindow;
public string $createdAt;
/**
* @var string[]
*/
public array $tags = [];
public string $privateNetworkUuid;
public ?int $storageSizeMib;
public function build(array $parameters): void
{
foreach ($parameters as $property => $value) {
$property = static::convertToCamelCase($property);
if ('connection' === $property) {
$this->connection = new DatabaseConnection($value);
} elseif ('privateConnection' === $property) {
$this->privateConnection = new DatabaseConnection($value);
} elseif ('users' === $property) {
$this->users = \array_map(fn ($v) => new DatabaseUser($v), $value ?? []);
} elseif ('maintenanceWindow' === $property) {
$this->maintenanceWindow = new DatabaseMaintenanceWindow($value);
} elseif (\property_exists($this, $property)) {
$this->$property = $value;
}
}
}
public function setCreatedAt(string $createdAt): void
{
$this->createdAt = static::convertToIso8601($createdAt);
}
}