1+ from typing import Any , Dict , Optional , Union
2+
13from linode_api4 .errors import UnexpectedResponseError
24from linode_api4 .groups import Group
35from linode_api4 .objects import (
46 VLAN ,
57 Base ,
68 Firewall ,
9+ FirewallCreateDevicesOptions ,
710 Instance ,
811 IPAddress ,
912 IPv6Pool ,
1013 IPv6Range ,
1114 NetworkTransferPrice ,
1215 Region ,
1316)
17+ from linode_api4 .objects .base import _flatten_request_body_recursive
18+ from linode_api4 .util import drop_null_keys
1419
1520
1621class NetworkingGroup (Group ):
@@ -33,7 +38,13 @@ def firewalls(self, *filters):
3338 """
3439 return self .client ._get_and_filter (Firewall , * filters )
3540
36- def firewall_create (self , label , rules , ** kwargs ):
41+ def firewall_create (
42+ self ,
43+ label : str ,
44+ rules : Dict [str , Any ],
45+ devices : Optional [Union [FirewallCreateDevicesOptions , Dict [str , Any ]]],
46+ ** kwargs ,
47+ ):
3748 """
3849 Creates a new Firewall, either in the given Region or
3950 attached to the given Instance.
@@ -44,6 +55,8 @@ def firewall_create(self, label, rules, **kwargs):
4455 :type label: str
4556 :param rules: The rules to apply to the new Firewall. For more information on Firewall rules, see our `Firewalls Documentation`_.
4657 :type rules: dict
58+ :param devices: Represents devices to create created alongside a Linode Firewall.
59+ :type devices: Optional[Union[FirewallCreateDevicesOptions, Dict[str, Any]]]
4760
4861 :returns: The new Firewall.
4962 :rtype: Firewall
@@ -81,10 +94,14 @@ def firewall_create(self, label, rules, **kwargs):
8194 params = {
8295 "label" : label ,
8396 "rules" : rules ,
97+ "devices" : devices ,
8498 }
8599 params .update (kwargs )
86100
87- result = self .client .post ("/networking/firewalls" , data = params )
101+ result = self .client .post (
102+ "/networking/firewalls" ,
103+ data = drop_null_keys (_flatten_request_body_recursive (params )),
104+ )
88105
89106 if not "id" in result :
90107 raise UnexpectedResponseError (
0 commit comments