Refactor endpoints for DRY and SOLID principles#675
Conversation
- Add `_get_client` to `GenericEndpoint` to unify client retrieval. - Remove duplicated `_build_path` from `EdcEndpointMixin`. - Update `GenericListEndpoint` and `GenericListPathGetEndpoint` to use `_get_client`. - Refactor `RecordsEndpoint` to consolidate `create` and `async_create` logic into `_create_impl`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This PR refactors the endpoint architecture to reduce code duplication and enforce SOLID principles.
Key changes:
GenericEndpointRefactoring: Added a_get_client(is_async: bool)helper method toGenericEndpoint. This centralizes the logic for retrieving the appropriate client (sync or async) based on the execution context, adhering to the DRY principle and simplifying subclasses.EdcEndpointMixinCleanup: Removed the_build_pathmethod fromEdcEndpointMixin. The implementation was identical (in behavior) toGenericEndpoint._build_path, so removing it eliminates redundancy.EdcEndpointMixinnow relies on the base implementation, which correctly handles theBASE_PATHdefined in the mixin.GenericListEndpoint&GenericListPathGetEndpointUpdate: Updated these mixins to use the new_get_clienthelper, making the client retrieval logic consistent across the codebase.RecordsEndpointConsolidation: RefactoredRecordsEndpointto introduce a_create_implmethod. This method encapsulates the common logic for creating records, which was previously duplicated increateandasync_create. The public methods now delegate to this implementation, ensuring consistent behavior and reducing maintenance overhead.These changes are structural only and do not alter the runtime behavior of the SDK. Tests have been run to verify no regressions were introduced.
PR created automatically by Jules for task 18318603622383437127 started by @fderuiter