1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
// --------------------------------------------------------------------- |
4
|
|
|
// |
5
|
|
|
// Copyright (C) 2018-2024 Artem Rodygin |
6
|
|
|
// |
7
|
|
|
// You should have received a copy of the MIT License along with |
8
|
|
|
// this file. If not, see <https://opensource.org/licenses/MIT>. |
9
|
|
|
// |
10
|
|
|
// --------------------------------------------------------------------- |
11
|
|
|
|
12
|
|
|
namespace Linode\Databases; |
13
|
|
|
|
14
|
|
|
use Linode\Entity; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* A general Managed Database instance object containing properties that are |
18
|
|
|
* identical for all database types. |
19
|
|
|
* |
20
|
|
|
* @property int $id A unique ID that can be used to identify and reference the Managed Database. |
21
|
|
|
* @property string $label A unique, user-defined string referring to the Managed Database. |
22
|
|
|
* @property string $region The Region ID for the Managed Database. |
23
|
|
|
* @property string $type The Linode Instance type used by the Managed Database for its nodes. |
24
|
|
|
* @property int $cluster_size The number of Linode Instance nodes deployed to the Managed Database. Defaults to |
25
|
|
|
* `1`. |
26
|
|
|
* Choosing 3 nodes creates a high availability cluster consisting of 1 primary node |
27
|
|
|
* and 2 replica nodes. |
28
|
|
|
* @property string $engine The Managed Database engine type. Currently, only MySQL is available. |
29
|
|
|
* @property string $version The Managed Database engine version. |
30
|
|
|
* @property string $status The operating status of the Managed Database. |
31
|
|
|
* @property bool $encrypted Whether the Managed Databases is encrypted. Defaults to `false`. |
32
|
|
|
* @property string[] $allow_list A list of IP addresses that can access the Managed Database. Each item can be a |
33
|
|
|
* single IP address or a range in CIDR format. |
34
|
|
|
* By default, this is an empty array (`[]`), which blocks all connections (both |
35
|
|
|
* public and private) to the Managed Database. |
36
|
|
|
* @property DatabaseHosts $hosts The primary and secondary hosts for the Managed Database. These are assigned after |
37
|
|
|
* provisioning is complete. |
38
|
|
|
* @property string $created When this Managed Database was created. |
39
|
|
|
* @property string $updated When this Managed Database was last updated. |
40
|
|
|
* @property string $instance_uri Append this to `https://api.linode.com` to run commands for the Managed Database. |
41
|
|
|
*/ |
42
|
|
|
class Database extends Entity |
43
|
|
|
{ |
44
|
|
|
// Available fields. |
45
|
|
|
public const FIELD_ID = 'id'; |
46
|
|
|
public const FIELD_LABEL = 'label'; |
47
|
|
|
public const FIELD_REGION = 'region'; |
48
|
|
|
public const FIELD_TYPE = 'type'; |
49
|
|
|
public const FIELD_CLUSTER_SIZE = 'cluster_size'; |
50
|
|
|
public const FIELD_ENGINE = 'engine'; |
51
|
|
|
public const FIELD_VERSION = 'version'; |
52
|
|
|
public const FIELD_STATUS = 'status'; |
53
|
|
|
public const FIELD_ENCRYPTED = 'encrypted'; |
54
|
|
|
public const FIELD_ALLOW_LIST = 'allow_list'; |
55
|
|
|
public const FIELD_HOSTS = 'hosts'; |
56
|
|
|
public const FIELD_CREATED = 'created'; |
57
|
|
|
public const FIELD_UPDATED = 'updated'; |
58
|
|
|
public const FIELD_INSTANCE_URI = 'instance_uri'; |
59
|
|
|
|
60
|
|
|
// `FIELD_CLUSTER_SIZE` values. |
61
|
|
|
public const CLUSTER_SIZE_1 = 1; |
62
|
|
|
public const CLUSTER_SIZE_3 = 3; |
63
|
|
|
|
64
|
|
|
// `FIELD_STATUS` values. |
65
|
|
|
public const STATUS_PROVISIONING = 'provisioning'; |
66
|
|
|
public const STATUS_ACTIVE = 'active'; |
67
|
|
|
public const STATUS_SUSPENDING = 'suspending'; |
68
|
|
|
public const STATUS_SUSPENDED = 'suspended'; |
69
|
|
|
public const STATUS_RESUMING = 'resuming'; |
70
|
|
|
public const STATUS_RESTORING = 'restoring'; |
71
|
|
|
public const STATUS_FAILED = 'failed'; |
72
|
|
|
public const STATUS_DEGRADED = 'degraded'; |
73
|
|
|
public const STATUS_UPDATING = 'updating'; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @codeCoverageIgnore This method was autogenerated. |
77
|
|
|
*/ |
78
|
|
|
public function __get(string $name): mixed |
79
|
|
|
{ |
80
|
|
|
return match ($name) { |
81
|
|
|
self::FIELD_HOSTS => new DatabaseHosts($this->client, $this->data[$name]), |
82
|
|
|
default => parent::__get($name), |
83
|
|
|
}; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|