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
|
|
|
use Linode\LinodeInstances\Repository\BackupRepository; |
16
|
|
|
use Linode\LinodeInstances\Repository\DiskRepository; |
17
|
|
|
use Linode\LinodeInstances\Repository\LinodeConfigRepository; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* A Linode instance. |
21
|
|
|
* |
22
|
|
|
* @property int $id This Linode's ID which must be provided for all operations impacting this Linode. |
23
|
|
|
* @property string $label The Linode's label is for display purposes only. If no label is provided for a |
24
|
|
|
* Linode, a default will be assigned. |
25
|
|
|
* Linode labels have the following constraints: |
26
|
|
|
* * Must start with an alpha character. |
27
|
|
|
* * May only consist of alphanumeric characters, dashes (`-`), underscores (`_`) |
28
|
|
|
* or periods (`.`). |
29
|
|
|
* * Cannot have two dashes (`--`), underscores (`__`) or periods (`..`) in a row. |
30
|
|
|
* @property string $group A deprecated property denoting a group label for this Linode. |
31
|
|
|
* @property string[] $tags An array of tags applied to this object. Tags are for organizational purposes |
32
|
|
|
* only. |
33
|
|
|
* @property string $region This is the location where the Linode was deployed. This cannot be changed without |
34
|
|
|
* opening a support ticket. |
35
|
|
|
* @property string $type This is the Linode Type that this Linode was deployed with. |
36
|
|
|
* To change a Linode's Type, use POST /linode/instances/{linodeId}/resize. |
37
|
|
|
* @property null|string $image An Image ID to deploy the Disk from. Official Linode Images start with `linode/ `, |
38
|
|
|
* while your Images start with `private/`. |
39
|
|
|
* @property string $status A brief description of this Linode's current state. This field may change without |
40
|
|
|
* direct action from you. For instance, the status will change to "running" |
41
|
|
|
* when the boot process completes. |
42
|
|
|
* @property string $hypervisor The virtualization software powering this Linode. |
43
|
|
|
* @property string $created When this Linode was created. |
44
|
|
|
* @property string $updated When this Linode was last updated. |
45
|
|
|
* @property bool $watchdog_enabled The watchdog, named Lassie, is a Shutdown Watchdog that monitors your Linode and |
46
|
|
|
* will reboot it if it powers off unexpectedly. It works by issuing a boot job when |
47
|
|
|
* your Linode powers off without a shutdown job being responsible. |
48
|
|
|
* To prevent a loop, Lassie will give up if there have been more than 5 boot jobs |
49
|
|
|
* issued within 15 minutes. |
50
|
|
|
* @property string[] $ipv4 This Linode's IPv4 Addresses. Each Linode is assigned a single public IPv4 address |
51
|
|
|
* upon creation, and may get a single private IPv4 address if needed. You may need |
52
|
|
|
* to |
53
|
|
|
* open a support ticket |
54
|
|
|
* to get additional IPv4 addresses. |
55
|
|
|
* IPv4 addresses may be reassigned between your Linodes, or shared with other |
56
|
|
|
* Linodes. |
57
|
|
|
* See the /networking endpoints for details. |
58
|
|
|
* @property string $ipv6 This Linode's IPv6 SLAAC addresses. This address is specific to a Linode, and may |
59
|
|
|
* not be shared. If the Linode has not been assigned an IPv6 address, the return |
60
|
|
|
* value will be `null`. |
61
|
|
|
* @property LinodeSpecs $specs Information about the resources available to this Linode. |
62
|
|
|
* @property LinodeAlerts $alerts Information about this Linode's notification thresholds. |
63
|
|
|
* @property LinodeBackups $backups Information about this Linode's backups status. For information about available |
64
|
|
|
* backups, see /linode/instances/{linodeId}/backups. |
65
|
|
|
* @property BackupRepositoryInterface $linodeBackups Linode backups. |
66
|
|
|
* @property DiskRepositoryInterface $linodeDisks Linode disks. |
67
|
|
|
* @property LinodeConfigRepositoryInterface $linodeConfigs Linode configs. |
68
|
|
|
*/ |
69
|
|
|
class Linode extends Entity |
70
|
|
|
{ |
71
|
|
|
// Available fields. |
72
|
|
|
public const FIELD_ID = 'id'; |
73
|
|
|
public const FIELD_LABEL = 'label'; |
74
|
|
|
public const FIELD_GROUP = 'group'; |
75
|
|
|
public const FIELD_TAGS = 'tags'; |
76
|
|
|
public const FIELD_REGION = 'region'; |
77
|
|
|
public const FIELD_TYPE = 'type'; |
78
|
|
|
public const FIELD_IMAGE = 'image'; |
79
|
|
|
public const FIELD_STATUS = 'status'; |
80
|
|
|
public const FIELD_HYPERVISOR = 'hypervisor'; |
81
|
|
|
public const FIELD_CREATED = 'created'; |
82
|
|
|
public const FIELD_UPDATED = 'updated'; |
83
|
|
|
public const FIELD_WATCHDOG_ENABLED = 'watchdog_enabled'; |
84
|
|
|
public const FIELD_IPV4 = 'ipv4'; |
85
|
|
|
public const FIELD_IPV6 = 'ipv6'; |
86
|
|
|
public const FIELD_SPECS = 'specs'; |
87
|
|
|
public const FIELD_ALERTS = 'alerts'; |
88
|
|
|
public const FIELD_BACKUPS = 'backups'; |
89
|
|
|
|
90
|
|
|
// Extra fields for POST/PUT requests. |
91
|
|
|
public const FIELD_ALLOW_AUTO_DISK_RESIZE = 'allow_auto_disk_resize'; |
92
|
|
|
public const FIELD_BACKUPS_ENABLED = 'backups_enabled'; |
93
|
|
|
public const FIELD_BOOTED = 'booted'; |
94
|
|
|
public const FIELD_PRIVATE_IP = 'private_ip'; |
95
|
|
|
public const FIELD_ROOT_PASS = 'root_pass'; |
96
|
|
|
public const FIELD_SWAP_SIZE = 'swap_size'; |
97
|
|
|
public const FIELD_AUTHORIZED_KEYS = 'authorized_keys'; |
98
|
|
|
public const FIELD_AUTHORIZED_USERS = 'authorized_users'; |
99
|
|
|
public const FIELD_STACKSCRIPT_ID = 'stackscript_id'; |
100
|
|
|
public const FIELD_STACKSCRIPT_DATA = 'stackscript_data'; |
101
|
|
|
public const FIELD_BACKUP_ID = 'backup_id'; |
102
|
|
|
public const FIELD_CONFIG_ID = 'config_id'; |
103
|
|
|
public const FIELD_LINODE_ID = 'linode_id'; |
104
|
|
|
public const FIELD_CONFIGS = 'configs'; |
105
|
|
|
public const FIELD_DEVICES = 'devices'; |
106
|
|
|
public const FIELD_DISKS = 'disks'; |
107
|
|
|
|
108
|
|
|
// `FIELD_STATUS` values. |
109
|
|
|
public const STATUS_RUNNING = 'running'; |
110
|
|
|
public const STATUS_OFFLINE = 'offline'; |
111
|
|
|
public const STATUS_BOOTING = 'booting'; |
112
|
|
|
public const STATUS_REBOOTING = 'rebooting'; |
113
|
|
|
public const STATUS_SHUTTING_DOWN = 'shutting_down'; |
114
|
|
|
public const STATUS_PROVISIONING = 'provisioning'; |
115
|
|
|
public const STATUS_DELETING = 'deleting'; |
116
|
|
|
public const STATUS_MIGRATING = 'migrating'; |
117
|
|
|
public const STATUS_REBUILDING = 'rebuilding'; |
118
|
|
|
public const STATUS_CLONING = 'cloning'; |
119
|
|
|
public const STATUS_RESTORING = 'restoring'; |
120
|
|
|
|
121
|
|
|
// `FIELD_HYPERVISOR` values. |
122
|
|
|
public const HYPERVISOR_KVM = 'kvm'; |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @codeCoverageIgnore This method was autogenerated. |
126
|
|
|
*/ |
127
|
|
|
public function __get(string $name): mixed |
128
|
|
|
{ |
129
|
|
|
return match ($name) { |
130
|
|
|
self::FIELD_SPECS => new LinodeSpecs($this->client, $this->data[$name]), |
131
|
|
|
self::FIELD_ALERTS => new LinodeAlerts($this->client, $this->data[$name]), |
132
|
|
|
self::FIELD_BACKUPS => new LinodeBackups($this->client, $this->data[$name]), |
133
|
|
|
'linodeBackups' => new BackupRepository($this->client, $this->id), |
134
|
|
|
'linodeDisks' => new DiskRepository($this->client, $this->id), |
135
|
|
|
'linodeConfigs' => new LinodeConfigRepository($this->client, $this->id), |
136
|
|
|
default => parent::__get($name), |
137
|
|
|
}; |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|