Skip to content

Commit 8ae0ebf

Browse files
Progress
1 parent 5cf4440 commit 8ae0ebf

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

linode_api4/groups/networking.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Base,
88
Firewall,
99
FirewallCreateDevicesOptions,
10+
FirewallSettings,
1011
Instance,
1112
IPAddress,
1213
IPv6Pool,
@@ -111,6 +112,25 @@ def firewall_create(
111112
f = Firewall(self.client, result["id"], result)
112113
return f
113114

115+
def firewall_settings(self) -> FirewallSettings:
116+
"""
117+
Returns an object representing the Linode Firewall settings for the current user.
118+
119+
API Documentation: Not yet available.
120+
121+
:returns: An object representing the Linode Firewall settings for the current user.
122+
:rtype: FirewallSettings
123+
"""
124+
result = self.client.get("/networking/firewalls/settings")
125+
126+
if "default_firewall_ids" not in result:
127+
raise UnexpectedResponseError(
128+
"Unexpected response when getting firewall settings!",
129+
json=result,
130+
)
131+
132+
return FirewallSettings(self.client, None, result)
133+
114134
def ips(self, *filters):
115135
"""
116136
Returns a list of IP addresses on this account, excluding private addresses.

linode_api4/objects/networking.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,38 @@ class FirewallCreateDevicesOptions(JSONObject):
186186
interfaces: List[int] = field(default_factory=list)
187187

188188

189+
class FirewallSettingsDefaultFirewallIDs(JSONObject):
190+
"""
191+
Contains the IDs of Linode Firewalls that should be used by default
192+
when creating various interface types.
193+
"""
194+
195+
vpc_interface: int = 0
196+
public_interface: int = 0
197+
linode: int = 0
198+
nodebalancer: int = 0
199+
200+
201+
class FirewallSettings(Base):
202+
"""
203+
Represents the Firewall settings for the current user.
204+
205+
API Documentation: Not yet available.
206+
"""
207+
208+
api_endpoint = "/networking/firewalls/settings"
209+
210+
# NOTE: This isn't used but is necessary when deriving from Base
211+
id_attributes = "default_firewall_ids"
212+
213+
properties = {
214+
"default_firewall_ids": Property(
215+
json_object=FirewallSettingsDefaultFirewallIDs,
216+
mutable=True,
217+
),
218+
}
219+
220+
189221
class FirewallDevice(DerivedBase):
190222
"""
191223
An object representing the assignment between a Linode Firewall and another Linode resource.

0 commit comments

Comments
 (0)