-
Notifications
You must be signed in to change notification settings - Fork 77
Add support for resource lock #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive support for resource lock functionality to the Linode API client, enabling users to prevent deletion or modification of resources (currently Linode instances).
Key Changes:
- Introduced
LockandLockEntitydata models with support for two lock types:cannot_deleteandcannot_delete_with_subresources - Added
LockGroupwith methods to list, create, and delete resource locks - Integrated lock support into the
LinodeClientand added alocksproperty to Linode instances
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| linode_api4/objects/lock.py | Defines Lock, LockEntity, and LockType models for representing resource locks |
| linode_api4/groups/lock.py | Implements LockGroup with create and list operations for resource locks |
| linode_api4/objects/init.py | Exports lock-related classes for public API access |
| linode_api4/groups/init.py | Exports LockGroup for public API access |
| linode_api4/linode_client.py | Integrates LockGroup into LinodeClient |
| linode_api4/objects/linode.py | Adds locks property to Instance model |
| test/unit/objects/lock_test.py | Unit tests for Lock object methods (get, delete) |
| test/unit/groups/lock_test.py | Unit tests for LockGroup methods (list, create with variations) |
| test/integration/models/lock/test_lock.py | End-to-end integration tests for lock functionality |
| test/integration/models/lock/init.py | Package initialization for lock integration tests |
| test/fixtures/locks_1.json | Mock response fixture for single lock retrieval |
| test/fixtures/locks.json | Mock response fixture for listing multiple locks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
|
|
||
| self.assertEqual(lock.id, 1) | ||
| self.assertEqual(lock.lock_type, "cannot_delete") |
Copilot
AI
Dec 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion on line 66 is incorrect. When creating a lock with lock_type=LockType.cannot_delete_with_subresources, the returned lock should have lock_type equal to "cannot_delete_with_subresources", not "cannot_delete". This test is validating the wrong expected behavior for the subresources lock type.
| self.assertEqual(lock.lock_type, "cannot_delete") | |
| self.assertEqual(lock.lock_type, "cannot_delete_with_subresources") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "cannot_delete" can just be unquoted here 👍
📝 Description
Add support for resource lock API changes.
✔️ How to Test