Passed
Push — master ( 0676a7...01ab94 )
by Artem
11:54
created

NodeBalancer::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
c 0
b 0
f 0
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\NodeBalancers;
13
14
use Linode\Entity;
15
use Linode\NodeBalancers\Repository\NodeBalancerConfigRepository;
16
17
/**
18
 * Linode's load balancing solution. Can handle multiple ports, SSL termination, and
19
 * any number of backends. NodeBalancer ports are configured with NodeBalancer
20
 * Configs, and each config is given one or more NodeBalancer Node that accepts
21
 * traffic. The traffic should be routed to the  NodeBalancer's ip address, the
22
 * NodeBalancer will handle routing individual requests to backends.
23
 *
24
 * @property int                                   $id                   This NodeBalancer's unique ID.
25
 * @property string                                $label                This NodeBalancer's label. These must be unique on your Account.
26
 * @property string                                $region               The Region where this NodeBalancer is located. NodeBalancers only support backends
27
 *                                                                       in the same Region.
28
 * @property string                                $hostname             This NodeBalancer's hostname, ending with _.nodebalancer.linode.com_
29
 * @property string                                $ipv4                 This NodeBalancer's public IPv4 address.
30
 * @property null|string                           $ipv6                 This NodeBalancer's public IPv6 address.
31
 * @property int                                   $client_conn_throttle Throttle connections per second. Set to 0 (zero) to disable throttling.
32
 * @property string                                $created              When this NodeBalancer was created.
33
 * @property string                                $updated              When this NodeBalancer was last updated.
34
 * @property string[]                              $tags                 An array of Tags applied to this object. Tags are for organizational purposes
35
 *                                                                       only.
36
 * @property NodeTransfer                          $transfer             Information about the amount of transfer this NodeBalancer has had so far this
37
 *                                                                       month.
38
 * @property NodeBalancerConfigRepositoryInterface $configs              NodeBalancer configs.
39
 */
40
class NodeBalancer extends Entity
41
{
42
    // Available fields.
43
    public const FIELD_ID                   = 'id';
44
    public const FIELD_LABEL                = 'label';
45
    public const FIELD_REGION               = 'region';
46
    public const FIELD_HOSTNAME             = 'hostname';
47
    public const FIELD_IPV4                 = 'ipv4';
48
    public const FIELD_IPV6                 = 'ipv6';
49
    public const FIELD_CLIENT_CONN_THROTTLE = 'client_conn_throttle';
50
    public const FIELD_CREATED              = 'created';
51
    public const FIELD_UPDATED              = 'updated';
52
    public const FIELD_TAGS                 = 'tags';
53
    public const FIELD_TRANSFER             = 'transfer';
54
55
    // Extra fields for POST/PUT requests.
56
    public const FIELD_CONFIGS = 'configs';
57
58
    /**
59
     * @codeCoverageIgnore This method was autogenerated.
60
     */
61
    public function __get(string $name): mixed
62
    {
63
        return match ($name) {
64
            self::FIELD_TRANSFER => new NodeTransfer($this->client, $this->data[$name]),
65
            self::FIELD_CONFIGS  => new NodeBalancerConfigRepository($this->client, $this->id),
66
            default              => parent::__get($name),
67
        };
68
    }
69
}
70