Add alias support to Property class and related tests#619
Add alias support to Property class and related tests#619zliang-akamai merged 5 commits intolinode:devfrom
Conversation
- Introduced `alias_of` parameter in Property to allow aliasing of API attributes. - Implemented `properties_with_alias` method in Base class to retrieve aliased properties. - Updated BetaProgram to include an aliased property for "class". - Added comprehensive tests for alias functionality in PropertyAliasTest.
There was a problem hiding this comment.
Pull request overview
This PR adds support for property aliasing in the Property class, allowing Python-friendly names for API attributes that are reserved words (like "class"). The implementation includes a new alias_of parameter, a properties_with_alias cached property for efficient lookup, and updates to serialization/deserialization logic to handle the mapping between aliased and original attribute names.
Key Changes:
- Added
alias_ofparameter toPropertyclass for mapping Python-safe names to original API attributes - Implemented
properties_with_aliascached property inBaseclass for retrieving aliased properties - Updated
_populateand_serializemethods to correctly handle aliased properties during JSON deserialization and serialization
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| linode_api4/objects/base.py | Added alias support infrastructure including the alias_of parameter, properties_with_alias cached property, and updated serialization/population logic |
| linode_api4/objects/beta.py | Added example usage with beta_class property aliasing the reserved word "class" |
| test/unit/objects/property_alias_test.py | Comprehensive test suite covering alias functionality including population, serialization, multiple aliases, and edge cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 Description
alias_ofparameter in Property to allow aliasing of API attributes.properties_with_aliasmethod in Base class to retrieve aliased properties.BetaProgramto include an aliased property for "class".PropertyAliasTest.✔️ How to Test