|
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\Networking; |
|
13
|
|
|
|
|
14
|
|
|
use Linode\Entity; |
|
15
|
|
|
use Linode\Networking\Repository\FirewallDevicesRepository; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* A resource that controls incoming and outgoing network traffic to a Linode |
|
19
|
|
|
* service. A Firewall can be assigned to multiple Linode services, and up to three |
|
20
|
|
|
* active Firewalls can be assigned to a single Linode service. Create a Firewall |
|
21
|
|
|
* Device to assign a Firewall to a Linode service. Currently, Firewalls can only be |
|
22
|
|
|
* assigned to Linode instances. |
|
23
|
|
|
* |
|
24
|
|
|
* @property int $id The Firewall's unique ID. |
|
25
|
|
|
* @property string $label The Firewall's label, for display purposes only. If no label is provided for a |
|
26
|
|
|
* Firewall, a default will be assigned. |
|
27
|
|
|
* Firewall labels have the following constraints: |
|
28
|
|
|
* * Must begin and end with an alphanumeric character. |
|
29
|
|
|
* * May only consist of alphanumeric characters, dashes (`-`), underscores (`_`) |
|
30
|
|
|
* or periods (`.`). |
|
31
|
|
|
* * Cannot have two dashes (`--`), underscores (`__`) or periods (`..`) in a row. |
|
32
|
|
|
* * Must be between 3 and 32 characters. |
|
33
|
|
|
* @property string $status The status of this Firewall. |
|
34
|
|
|
* * When a Firewall is first created its status is `enabled`. |
|
35
|
|
|
* * Use the Update Firewall endpoint to set a Firewall's status to `enbaled` or |
|
36
|
|
|
* `disabled`. |
|
37
|
|
|
* * Use the Delete Firewall endpoint to delete a Firewall. |
|
38
|
|
|
* @property string $created When this Firewall was created. |
|
39
|
|
|
* @property string $updated When this Firewall was last updated. |
|
40
|
|
|
* @property FirewallRules $rules The inbound and outbound access rules to apply to the Firewall. |
|
41
|
|
|
* * A minimum of one open inbound rule is required. Any inbound |
|
42
|
|
|
* traffic that is not permitted by your rules will be blocked. |
|
43
|
|
|
* * Outbound rules are optional. When no outbound rules are specified, |
|
44
|
|
|
* all outbound traffic is allowed. If one or more outbound rules are |
|
45
|
|
|
* specified, all outbound traffic that is not permitted by your rules |
|
46
|
|
|
* will be blocked. |
|
47
|
|
|
* A Firewall may have up to 25 rules across its inbound and outbound rulesets. |
|
48
|
|
|
* @property string[] $tags An array of tags applied to this object. Tags are for organizational purposes |
|
49
|
|
|
* only. |
|
50
|
|
|
* @property FirewallDevicesRepositoryInterface $devices Firewall devices. |
|
51
|
|
|
*/ |
|
52
|
|
|
class Firewall extends Entity |
|
53
|
|
|
{ |
|
54
|
|
|
// Available fields. |
|
55
|
|
|
public const FIELD_ID = 'id'; |
|
56
|
|
|
public const FIELD_LABEL = 'label'; |
|
57
|
|
|
public const FIELD_STATUS = 'status'; |
|
58
|
|
|
public const FIELD_CREATED = 'created'; |
|
59
|
|
|
public const FIELD_UPDATED = 'updated'; |
|
60
|
|
|
public const FIELD_RULES = 'rules'; |
|
61
|
|
|
public const FIELD_TAGS = 'tags'; |
|
62
|
|
|
|
|
63
|
|
|
// Extra fields for POST/PUT requests. |
|
64
|
|
|
public const FIELD_DEVICES = 'devices'; |
|
65
|
|
|
public const FIELD_INBOUND = 'inbound'; |
|
66
|
|
|
public const FIELD_OUTBOUND = 'outbound'; |
|
67
|
|
|
|
|
68
|
|
|
// `FIELD_STATUS` values. |
|
69
|
|
|
public const STATUS_ENABLED = 'enabled'; |
|
70
|
|
|
public const STATUS_DISABLED = 'disabled'; |
|
71
|
|
|
public const STATUS_DELETED = 'deleted'; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @codeCoverageIgnore This method was autogenerated. |
|
75
|
|
|
*/ |
|
76
|
|
|
public function __get(string $name): mixed |
|
77
|
|
|
{ |
|
78
|
|
|
return match ($name) { |
|
79
|
|
|
self::FIELD_DEVICES => new FirewallDevicesRepository($this->client, $this->id), |
|
80
|
|
|
default => parent::__get($name), |
|
81
|
|
|
}; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|