Database   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 34
c 1
b 0
f 0
dl 0
loc 48
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __get() 0 6 1
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.
25
 *                                         Choosing 3 nodes creates a high availability cluster consisting of 1 primary node
26
 *                                         and 2 replica nodes.
27
 * @property string          $engine       The Managed Database engine type.
28
 * @property string          $version      The Managed Database engine version.
29
 * @property string          $status       The operating status of the Managed Database.
30
 * @property bool            $encrypted    Whether the Managed Databases is encrypted.
31
 * @property string[]        $allow_list   A list of IP addresses that can access the Managed Database. Each item can be a
32
 *                                         single IP address or a range in CIDR format.
33
 *                                         By default, this is an empty array (`[]`), which blocks all connections (both
34
 *                                         public and private) to the Managed Database.
35
 *                                         If `0.0.0.0/0` is a value in this list, then all IP addresses can access the
36
 *                                         Managed Database.
37
 * @property DatabaseHosts   $hosts        The primary and secondary hosts for the Managed Database. These are assigned after
38
 *                                         provisioning is complete.
39
 * @property string          $created      When this Managed Database was created.
40
 * @property string          $updated      When this Managed Database was last updated.
41
 * @property DatabaseUpdates $updates      Configuration settings for automated patch update maintenance for the Managed
42
 *                                         Database.
43
 * @property string          $instance_uri Append this to `https://api.linode.com` to run commands for the Managed Database.
44
 */
45
class Database extends Entity
46
{
47
    // Available fields.
48
    public const FIELD_ID           = 'id';
49
    public const FIELD_LABEL        = 'label';
50
    public const FIELD_REGION       = 'region';
51
    public const FIELD_TYPE         = 'type';
52
    public const FIELD_CLUSTER_SIZE = 'cluster_size';
53
    public const FIELD_ENGINE       = 'engine';
54
    public const FIELD_VERSION      = 'version';
55
    public const FIELD_STATUS       = 'status';
56
    public const FIELD_ENCRYPTED    = 'encrypted';
57
    public const FIELD_ALLOW_LIST   = 'allow_list';
58
    public const FIELD_HOSTS        = 'hosts';
59
    public const FIELD_CREATED      = 'created';
60
    public const FIELD_UPDATED      = 'updated';
61
    public const FIELD_UPDATES      = 'updates';
62
    public const FIELD_INSTANCE_URI = 'instance_uri';
63
64
    // `FIELD_CLUSTER_SIZE` values.
65
    public const CLUSTER_SIZE_1 = 1;
66
    public const CLUSTER_SIZE_3 = 3;
67
68
    // `FIELD_ENGINE` values.
69
    public const ENGINE_MYSQL      = 'mysql';
70
    public const ENGINE_POSTGRESQL = 'postgresql';
71
72
    // `FIELD_STATUS` values.
73
    public const STATUS_PROVISIONING = 'provisioning';
74
    public const STATUS_ACTIVE       = 'active';
75
    public const STATUS_SUSPENDING   = 'suspending';
76
    public const STATUS_SUSPENDED    = 'suspended';
77
    public const STATUS_RESUMING     = 'resuming';
78
    public const STATUS_RESTORING    = 'restoring';
79
    public const STATUS_FAILED       = 'failed';
80
    public const STATUS_DEGRADED     = 'degraded';
81
    public const STATUS_UPDATING     = 'updating';
82
    public const STATUS_BACKING_UP   = 'backing_up';
83
84
    /**
85
     * @codeCoverageIgnore This method was autogenerated.
86
     */
87
    public function __get(string $name): mixed
88
    {
89
        return match ($name) {
90
            self::FIELD_HOSTS   => new DatabaseHosts($this->client, $this->data[$name]),
91
            self::FIELD_UPDATES => new DatabaseUpdates($this->client, $this->data[$name]),
92
            default             => parent::__get($name),
93
        };
94
    }
95
}
96