Skip to content

Commit c1b0c8d

Browse files
committed
Cleanup
1 parent c2cf0c9 commit c1b0c8d

File tree

2 files changed

+2
-87
lines changed

2 files changed

+2
-87
lines changed

linode_api4/groups/account.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
ChildAccount,
1212
Event,
1313
Invoice,
14-
Lock,
1514
Login,
1615
MappedObject,
1716
OAuthClient,
@@ -511,58 +510,3 @@ def child_accounts(self, *filters):
511510
:rtype: PaginatedList of ChildAccount
512511
"""
513512
return self.client._get_and_filter(ChildAccount, *filters)
514-
515-
def locks(self, *filters):
516-
"""
517-
Returns a list of all resource locks on the account.
518-
519-
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-locks
520-
521-
:param filters: Any number of filters to apply to this query.
522-
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
523-
for more details on filtering.
524-
525-
:returns: A list of resource locks on the account.
526-
:rtype: PaginatedList of Lock
527-
"""
528-
return self.client._get_and_filter(Lock, *filters)
529-
530-
def lock_create(self, entity_type, entity_id, lock_type, **kwargs):
531-
"""
532-
Creates a resource lock to prevent deletion or modification.
533-
534-
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-lock
535-
536-
:param entity_type: The type of entity to lock (e.g., "linode").
537-
:type entity_type: str
538-
:param entity_id: The ID of the entity to lock.
539-
:type entity_id: int
540-
:param lock_type: The type of lock (e.g., "cannot_delete").
541-
:type lock_type: str or LockType
542-
543-
:returns: The created resource lock.
544-
:rtype: Lock
545-
"""
546-
from linode_api4.objects.lock import ( # pylint: disable=import-outside-toplevel
547-
LockType,
548-
)
549-
550-
params = {
551-
"entity_type": entity_type,
552-
"entity_id": entity_id,
553-
"lock_type": (
554-
lock_type.value
555-
if isinstance(lock_type, LockType)
556-
else lock_type
557-
),
558-
}
559-
params.update(kwargs)
560-
561-
result = self.client.post("/locks", data=params)
562-
563-
if "id" not in result:
564-
raise UnexpectedResponseError(
565-
"Unexpected response when creating lock!", json=result
566-
)
567-
568-
return Lock(self.client, result["id"], result)

test/unit/objects/lock_test.py

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from test.unit.base import ClientBaseCase
22

3-
from linode_api4.objects.lock import Lock, LockEntity, LockType
3+
from linode_api4.objects.lock import Lock, LockEntity
44

55

66
class LockTest(ClientBaseCase):
@@ -22,38 +22,9 @@ def test_get_lock(self):
2222
self.assertEqual(lock.entity.label, "test-linode")
2323
self.assertEqual(lock.entity.url, "/v4/linode/instances/123")
2424

25-
def test_get_locks(self):
26-
"""
27-
Tests that locks can be retrieved
28-
"""
29-
locks = self.client.account.locks()
30-
31-
self.assertEqual(len(locks), 2)
32-
self.assertEqual(locks[0].id, 1)
33-
self.assertEqual(locks[0].lock_type, "cannot_delete")
34-
self.assertEqual(locks[1].id, 2)
35-
self.assertEqual(locks[1].lock_type, "cannot_delete_with_subresources")
36-
37-
def test_create_lock(self):
38-
"""
39-
Tests that a lock can be created
40-
"""
41-
with self.mock_post("/locks/1") as m:
42-
lock = self.client.account.lock_create(
43-
"linode", 123, LockType.cannot_delete
44-
)
45-
46-
self.assertEqual(m.call_url, "/locks")
47-
self.assertEqual(m.call_data["entity_type"], "linode")
48-
self.assertEqual(m.call_data["entity_id"], 123)
49-
self.assertEqual(m.call_data["lock_type"], "cannot_delete")
50-
51-
self.assertEqual(lock.id, 1)
52-
self.assertEqual(lock.lock_type, "cannot_delete")
53-
5425
def test_delete_lock(self):
5526
"""
56-
Tests that a lock can be deleted
27+
Tests that a lock can be deleted using the Lock object's delete method
5728
"""
5829
lock = Lock(self.client, 1)
5930

0 commit comments

Comments
 (0)