LKECluster::__get()   A
last analyzed

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\LKE;
13
14
use Linode\Entity;
15
use Linode\LKE\Repository\LKENodePoolRepository;
16
17
/**
18
 * A Kubernetes cluster.
19
 *
20
 * @property int                            $id            This Kubernetes cluster's unique ID.
21
 * @property string                         $label         This Kubernetes cluster's unique label for display purposes only. If no label is
22
 *                                                         provided, one will be assigned automatically.
23
 * @property string                         $region        This Kubernetes cluster's location.
24
 * @property string                         $created       When this Kubernetes cluster was created.
25
 * @property string                         $updated       When this Kubernetes cluster was updated.
26
 * @property string                         $k8s_version   The desired Kubernetes version for this Kubernetes cluster in the format of
27
 *                                                         <major>.<minor>, and the latest supported patch version will be deployed.
28
 * @property string[]                       $tags          An array of tags applied to the Kubernetes cluster. Tags are for organizational
29
 *                                                         purposes only.
30
 * @property KubernetesControlPlane         $control_plane Defines settings for the Kubernetes Control Plane. Allows for the enabling of High
31
 *                                                         Availability (HA) for Control Plane Components. Enabling High Avaialability for
32
 *                                                         LKE is an **irreversible** change.
33
 * @property LKENodePoolRepositoryInterface $nodePools     Node pools.
34
 */
35
class LKECluster extends Entity
36
{
37
    // Available fields.
38
    public const FIELD_ID            = 'id';
39
    public const FIELD_LABEL         = 'label';
40
    public const FIELD_REGION        = 'region';
41
    public const FIELD_CREATED       = 'created';
42
    public const FIELD_UPDATED       = 'updated';
43
    public const FIELD_K8S_VERSION   = 'k8s_version';
44
    public const FIELD_TAGS          = 'tags';
45
    public const FIELD_CONTROL_PLANE = 'control_plane';
46
47
    // Extra fields for POST/PUT requests.
48
    public const FIELD_NODE_POOLS = 'node_pools';
49
50
    /**
51
     * @codeCoverageIgnore This method was autogenerated.
52
     */
53
    public function __get(string $name): mixed
54
    {
55
        return match ($name) {
56
            self::FIELD_CONTROL_PLANE => new KubernetesControlPlane($this->client, $this->data[$name]),
57
            'nodePools'               => new LKENodePoolRepository($this->client, $this->id),
58
            default                   => parent::__get($name),
59
        };
60
    }
61
}
62