NodeBalancer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 17
dl 0
loc 27
c 0
b 0
f 0
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\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, beginning with its IP address and ending with
29
 *                                                                       _.ip.linodeusercontent.com_.
30
 * @property string                                $ipv4                 This NodeBalancer's public IPv4 address.
31
 * @property null|string                           $ipv6                 This NodeBalancer's public IPv6 address.
32
 * @property int                                   $client_conn_throttle Throttle connections per second. Set to 0 (zero) to disable throttling.
33
 * @property string                                $created              When this NodeBalancer was created.
34
 * @property string                                $updated              When this NodeBalancer was last updated.
35
 * @property string[]                              $tags                 An array of Tags applied to this object. Tags are for organizational purposes
36
 *                                                                       only.
37
 * @property NodeTransfer                          $transfer             Information about the amount of transfer this NodeBalancer has had so far this
38
 *                                                                       month.
39
 * @property NodeBalancerConfigRepositoryInterface $configs              NodeBalancer configs.
40
 */
41
class NodeBalancer extends Entity
42
{
43
    // Available fields.
44
    public const FIELD_ID                   = 'id';
45
    public const FIELD_LABEL                = 'label';
46
    public const FIELD_REGION               = 'region';
47
    public const FIELD_HOSTNAME             = 'hostname';
48
    public const FIELD_IPV4                 = 'ipv4';
49
    public const FIELD_IPV6                 = 'ipv6';
50
    public const FIELD_CLIENT_CONN_THROTTLE = 'client_conn_throttle';
51
    public const FIELD_CREATED              = 'created';
52
    public const FIELD_UPDATED              = 'updated';
53
    public const FIELD_TAGS                 = 'tags';
54
    public const FIELD_TRANSFER             = 'transfer';
55
56
    // Extra fields for POST/PUT requests.
57
    public const FIELD_CONFIGS = 'configs';
58
59
    /**
60
     * @codeCoverageIgnore This method was autogenerated.
61
     */
62
    public function __get(string $name): mixed
63
    {
64
        return match ($name) {
65
            self::FIELD_TRANSFER => new NodeTransfer($this->client, $this->data[$name]),
66
            self::FIELD_CONFIGS  => new NodeBalancerConfigRepository($this->client, $this->id),
67
            default              => parent::__get($name),
68
        };
69
    }
70
}
71