Passed
Push — master ( 41a424...f04d85 )
by Artem
01:57
created

DatabaseMySQL::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 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
18
/**
19
 * Managed MySQL Databases object.
20
 *
21
 * @property int             $id               A unique ID that can be used to identify and reference the Managed Database.
22
 * @property string          $label            A unique, user-defined string referring to the Managed Database.
23
 * @property string          $region           The Region ID for the Managed Database.
24
 * @property string          $type             The Linode Instance type used by the Managed Database for its nodes.
25
 * @property int             $cluster_size     The number of Linode Instance nodes deployed to the Managed Database. Defaults to
26
 *                                             `1`.
27
 *                                             Choosing 3 nodes creates a high availability cluster consisting of 1 primary node
28
 *                                             and 2 replica nodes.
29
 * @property string          $engine           The Managed Database engine type.
30
 * @property string          $version          The Managed Database engine version.
31
 * @property int             $port             The access port for this Managed Database.
32
 * @property string          $replication_type The replication method used for the Managed Database.
33
 *                                             Defaults to `none` for a single cluster and `semi_synch` for a high availability
34
 *                                             cluster.
35
 *                                             Must be `none` for a single node cluster.
36
 *                                             Must be `asynch` or `semi_synch` for a high availability cluster.
37
 * @property string          $status           The operating status of the Managed Database.
38
 * @property bool            $encrypted        Whether the Managed Databases is encrypted. Defaults to `false`.
39
 * @property string[]        $allow_list       A list of IP addresses that can access the Managed Database. Each item can be a
40
 *                                             single IP address or a range in CIDR format.
41
 *                                             By default, this is an empty array (`[]`), which blocks all connections (both
42
 *                                             public and private) to the Managed Database.
43
 * @property DatabaseHosts   $hosts            The primary and secondary hosts for the Managed Database. These are assigned after
44
 *                                             provisioning is complete.
45
 * @property bool            $ssl_connection   Whether to require SSL credentials to establish a connection to the Managed
46
 *                                             Database. Defaults to `false`.
47
 *                                             Use the **Managed MySQL Database Credentials View** (GET
48
 *                                             /databases/mysql/instances/{instanceId}/credentials) command for access
49
 *                                             information.
50
 * @property string          $created          When this Managed Database was created.
51
 * @property string          $updated          When this Managed Database was last updated.
52
 * @property DatabaseUpdates $updates          Configuration settings for automated patch update maintenance for the Managed
53
 *                                             Database.
54
 */
55
class DatabaseMySQL extends Entity
56
{
57
    // Available fields.
58
    public const FIELD_ID               = 'id';
59
    public const FIELD_LABEL            = 'label';
60
    public const FIELD_REGION           = 'region';
61
    public const FIELD_TYPE             = 'type';
62
    public const FIELD_CLUSTER_SIZE     = 'cluster_size';
63
    public const FIELD_ENGINE           = 'engine';
64
    public const FIELD_VERSION          = 'version';
65
    public const FIELD_PORT             = 'port';
66
    public const FIELD_REPLICATION_TYPE = 'replication_type';
67
    public const FIELD_STATUS           = 'status';
68
    public const FIELD_ENCRYPTED        = 'encrypted';
69
    public const FIELD_ALLOW_LIST       = 'allow_list';
70
    public const FIELD_HOSTS            = 'hosts';
71
    public const FIELD_SSL_CONNECTION   = 'ssl_connection';
72
    public const FIELD_CREATED          = 'created';
73
    public const FIELD_UPDATED          = 'updated';
74
    public const FIELD_UPDATES          = 'updates';
75
76
    // `FIELD_CLUSTER_SIZE` values.
77
    public const CLUSTER_SIZE_1 = 1;
78
    public const CLUSTER_SIZE_3 = 3;
79
80
    // `FIELD_REPLICATION_TYPE` values.
81
    public const REPLICATION_TYPE_NONE       = 'none';
82
    public const REPLICATION_TYPE_ASYNCH     = 'asynch';
83
    public const REPLICATION_TYPE_SEMI_SYNCH = 'semi_synch';
84
85
    // `FIELD_STATUS` values.
86
    public const STATUS_PROVISIONING = 'provisioning';
87
    public const STATUS_ACTIVE       = 'active';
88
    public const STATUS_SUSPENDING   = 'suspending';
89
    public const STATUS_SUSPENDED    = 'suspended';
90
    public const STATUS_RESUMING     = 'resuming';
91
    public const STATUS_RESTORING    = 'restoring';
92
    public const STATUS_FAILED       = 'failed';
93
    public const STATUS_DEGRADED     = 'degraded';
94
    public const STATUS_UPDATING     = 'updating';
95
96
    /**
97
     * @codeCoverageIgnore This method was autogenerated.
98
     */
99
    public function __get(string $name): mixed
100
    {
101
        return match ($name) {
102
            self::FIELD_HOSTS   => new DatabaseHosts($this->client, $this->data[$name]),
103
            self::FIELD_UPDATES => new DatabaseUpdates($this->client, $this->data[$name]),
104
            default             => parent::__get($name),
105
        };
106
    }
107
}
108