Skip to content

Conversation

@zliang-akamai
Copy link
Member

📝 Description

Add support for resource lock API changes.

✔️ How to Test

python -m pytest test/unit/objects/lock_test.py -v

@zliang-akamai zliang-akamai marked this pull request as ready for review December 7, 2025 02:26
@zliang-akamai zliang-akamai requested a review from a team as a code owner December 7, 2025 02:26
@zliang-akamai zliang-akamai requested review from jriddle-linode and lgarber-akamai and removed request for a team December 7, 2025 02:26
Copy link
Contributor

Copilot AI left a 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 Lock and LockEntity data models with support for two lock types: cannot_delete and cannot_delete_with_subresources
  • Added LockGroup with methods to list, create, and delete resource locks
  • Integrated lock support into the LinodeClient and added a locks property 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")
Copy link

Copilot AI Dec 8, 2025

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.

Suggested change
self.assertEqual(lock.lock_type, "cannot_delete")
self.assertEqual(lock.lock_type, "cannot_delete_with_subresources")

Copilot uses AI. Check for mistakes.
Copy link
Contributor

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants