Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions linode_api4/objects/linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,22 @@ def firewalls(self):
for firewall in result["data"]
]

def apply_firewalls(self):
"""
Reapply assigned firewalls to a Linode in case they were not applied successfully.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-apply-firewalls

:returns: Returns True if the operation was successful
:rtype: bool
"""

self._client.post(
"{}/firewalls/apply".format(Instance.api_endpoint), model=self
)

return True

def nodebalancers(self):
"""
View a list of NodeBalancers that are assigned to this Linode and readable by the requesting User.
Expand Down
8 changes: 8 additions & 0 deletions test/integration/models/linode/test_linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ def test_linode_firewalls(linode_with_volume_firewall):
assert "firewall" in firewalls[0].label


def test_linode_apply_firewalls(linode_with_volume_firewall):
linode = linode_with_volume_firewall

result = linode.apply_firewalls()

assert result


def test_linode_volumes(linode_with_volume_firewall):
linode = linode_with_volume_firewall

Expand Down
13 changes: 13 additions & 0 deletions test/unit/objects/linode_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,19 @@ def test_firewalls(self):
self.assertEqual(m.call_url, "/linode/instances/123/firewalls")
self.assertEqual(len(result), 1)

def test_apply_firewalls(self):
"""
Tests that you can submit a correct apply firewalls api request
"""
linode = Instance(self.client, 123)

with self.mock_post({}) as m:
result = linode.apply_firewalls()
self.assertEqual(
m.call_url, "/linode/instances/123/firewalls/apply"
)
self.assertEqual(result, True)

def test_volumes(self):
"""
Tests that you can submit a correct volumes api request
Expand Down
Loading