Passed
Push — master ( f0f514...a1b81d )
by Artem
01:46
created

LinodeConfigInterface   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __get() 0 5 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\LinodeInstances;
13
14
use Linode\Entity;
15
16
/**
17
 * The Network Interface to apply to this Linode's configuration profile.
18
 *
19
 * @property int           $id           The unique ID representing this Interface.
20
 * @property null|string   $label        The name of this Interface.
21
 *                                       For `vlan` purpose Interfaces:
22
 *                                       * Required.
23
 *                                       * Must be unique among the Linode's Interfaces (a Linode cannot be attached to the
24
 *                                       same VLAN multiple times).
25
 *                                       * Can only contain ASCII letters, numbers, and hyphens (`-`). You can't use two
26
 *                                       consecutive hyphens (`--`).
27
 *                                       * If the VLAN label is new, a VLAN is created. Up to 10 VLANs can be created in
28
 *                                       each data center region. To view your active VLANs, use the VLANs List endpoint.
29
 *                                       For `public` purpose Interfaces:
30
 *                                       * In requests, must be an empty string (`""`) or `null` if included.
31
 *                                       * In responses, always returns `null`.
32
 *                                       For `vpc` purpose Interfaces:
33
 *                                       * In requests, must be an empty string (`""`) or `null` if included.
34
 *                                       * In responses, always returns `null`.
35
 * @property string        $purpose      The type of Interface.
36
 *                                       * `public`
37
 *                                       * Only one `public` Interface per Linode can be defined.
38
 *                                       * The Linode's default public IPv4 address is assigned to the `public`
39
 *                                       Interface.
40
 *                                       * A Linode must have a public Interface in the first/eth0 position to be
41
 *                                       reachable via the public internet upon boot without additional system
42
 *                                       configuration. If no `public` Interface is configured, the Linode is not directly
43
 *                                       reachable via the public internet. In this case, access can only be established
44
 *                                       via LISH or other Linodes connected to the same VLAN or VPC.
45
 *                                       * `vlan`
46
 *                                       * Configuring a `vlan` purpose Interface attaches this Linode to the VLAN with
47
 *                                       the specified `label`.
48
 *                                       * The Linode is configured to use the specified `ipam_address`, if any.
49
 *                                       * `vpc`
50
 *                                       * Configuring a `vpc` purpose Interface attaches this Linode to the existing VPC
51
 *                                       Subnet with the specified `subnet_id`.
52
 *                                       * When the Interface is activated, the Linode is configured to use an IP address
53
 *                                       from the range in the assigned VPC Subnet. See `ipv4.vpc` for more information.
54
 * @property null|string   $ipam_address This Network Interface's private IP address in Classless Inter-Domain Routing
55
 *                                       (CIDR) notation.
56
 *                                       For `vlan` purpose Interfaces:
57
 *                                       * Must be unique among the Linode's Interfaces to avoid conflicting addresses.
58
 *                                       * Should be unique among devices attached to the VLAN to avoid conflict.
59
 *                                       * The Linode is configured to use this address for the associated Interface upon
60
 *                                       reboot if Network Helper is enabled. If Network Helper is disabled, the address
61
 *                                       can be enabled with manual static IP configuration.
62
 *                                       For `public` purpose Interfaces:
63
 *                                       * In requests, must be an empty string (`""`) or `null` if included.
64
 *                                       * In responses, always returns `null`.
65
 *                                       For `vpc` purpose Interfaces:
66
 *                                       * In requests, must be an empty string (`""`) or `null` if included.
67
 *                                       * In responses, always returns `null`.
68
 * @property bool          $active       Returns `true` if the Interface is in use, meaning that Compute Instance has been
69
 *                                       booted using the Configuration Profile to which the Interface belongs. Otherwise
70
 *                                       returns `false`.
71
 * @property bool          $primary      The primary Interface is configured as the default route to the Linode.
72
 *                                       Each Configuration Profile can have up to one `"primary": true` Interface at a
73
 *                                       time.
74
 *                                       Must be `false` for `vlan` type Interfaces.
75
 *                                       If no Interface is configured as the primary, the first non-`vlan` type Interface
76
 *                                       in the `interfaces` array is automatically treated as the primary Interface.
77
 * @property null|int      $vpc_id       The `id` of the VPC configured for this Interface. Returns `null` for non-`vpc`
78
 *                                       type Interfaces.
79
 * @property null|int      $subnet_id    The `id` of the VPC Subnet for this Interface.
80
 *                                       In requests, this value is used to assign a Linode to a VPC Subnet.
81
 *                                       * Required for `vpc` type Interfaces.
82
 *                                       * Returns `null` for non-`vpc` type Interfaces.
83
 *                                       * Once a VPC Subnet is assigned to an Interface, it cannot be updated.
84
 *                                       * The Linode must be rebooted with the Interface's Configuration Profile to
85
 *                                       complete assignment to a VPC Subnet.
86
 * @property IPv4Config    $ipv4         IPv4 addresses configured for this Interface. Only allowed for `vpc` type
87
 *                                       Interfaces. Returns `null` if no `vpc` Interface is assigned.
88
 * @property null|string[] $ip_ranges    An array of IPv4 CIDR VPC Subnet ranges that are routed to this Interface. **IPv6
89
 *                                       ranges are also available to select participants in the Beta program.**
90
 *                                       * Array items are only allowed for `vpc` type Interfaces.
91
 *                                       * This must be empty for non-`vpc` type Interfaces.
92
 *                                       For requests:
93
 *                                       * Addresses in submitted ranges must not already be actively assigned.
94
 *                                       * Submitting values replaces any existing values.
95
 *                                       * Submitting an empty array removes any existing values.
96
 *                                       * Omitting this property results in no change to existing values.
97
 */
98
class LinodeConfigInterface extends Entity
99
{
100
    // Available fields.
101
    public const FIELD_ID           = 'id';
102
    public const FIELD_LABEL        = 'label';
103
    public const FIELD_PURPOSE      = 'purpose';
104
    public const FIELD_IPAM_ADDRESS = 'ipam_address';
105
    public const FIELD_ACTIVE       = 'active';
106
    public const FIELD_PRIMARY      = 'primary';
107
    public const FIELD_VPC_ID       = 'vpc_id';
108
    public const FIELD_SUBNET_ID    = 'subnet_id';
109
    public const FIELD_IPV4         = 'ipv4';
110
    public const FIELD_IP_RANGES    = 'ip_ranges';
111
112
    // `FIELD_PURPOSE` values.
113
    public const PURPOSE_PUBLIC = 'public';
114
    public const PURPOSE_VLAN   = 'vlan';
115
    public const PURPOSE_VPC    = 'vpc';
116
117
    /**
118
     * @codeCoverageIgnore This method was autogenerated.
119
     */
120
    public function __get(string $name): mixed
121
    {
122
        return match ($name) {
123
            self::FIELD_IPV4 => new IPv4Config($this->client, $this->data[$name]),
124
            default          => parent::__get($name),
125
        };
126
    }
127
}
128