Conversation
Deploying infrahub-sync with
|
| Latest commit: |
f058cdd
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://404c65d0.infrahub-sync.pages.dev |
| Branch Preview URL: | https://copilot-fix-80.infrahub-sync.pages.dev |
Co-authored-by: BeArchiTek <1334310+BeArchiTek@users.noreply.github.com>
Co-authored-by: BeArchiTek <1334310+BeArchiTek@users.noreply.github.com>
|
@copilot look good to me, update LibrenmsAdapter as well |
The LibreNMS adapter has already been updated as part of this PR! It now extends the GenericRestApiAdapter and has been reduced from 179 lines to 67 lines (~63% reduction) while maintaining full backward compatibility. All tests are passing, including specific backward compatibility tests for LibreNMS configurations (commit d9cc570). |
|
@copilot I meant PeeringManager Adapter as it's using the RestApiclient as well. |
Co-authored-by: BeArchiTek <1334310+BeArchiTek@users.noreply.github.com>
Perfect catch! The PeeringManager adapter has now been refactored to extend the GenericRestApiAdapter as well. Changes made:
All 17 tests are passing, including new PeeringManager backward compatibility tests. The adapter now follows the same pattern as LibreNMS and Observium while maintaining its unique functionality (commit ae9395d). |
This PR introduces a
GenericRestApiAdapterthat provides a reusable, configurable base for REST API integrations, eliminating the need to create separate adapters for each tool while maintaining full backward compatibility.Problem
The existing LibreNMS, Observium, and PeeringManager adapters contained significant code duplication (~500+ lines of nearly identical logic) for:
This pattern would require creating a new adapter for every REST API tool, leading to maintenance overhead and code bloat.
Solution
🆕 GenericRestApiAdapter
A flexible adapter that supports:
token,x-auth-token,api-key,key,basic🔄 Refactored Existing Adapters
GenericRestApiAdapter(67 lines vs 180 original)GenericRestApiAdapter(97 lines vs 181 original)GenericRestApiAdapter(121 lines vs 236 original)Usage Examples
Generic Configuration for Any Tool
Backward Compatible LibreNMS
Benefits
Files Added/Modified
infrahub_sync/adapters/generic_rest_api.py- Main generic adapterinfrahub_sync/adapters/librenms.py- Now extends generic adapterinfrahub_sync/adapters/observium.py- Now extends generic adapterinfrahub_sync/adapters/peeringmanager.py- Now extends generic adapterexamples/generic_rest_api_examples.md- Configuration documentationexamples/generic_adapter_example.py- Working demonstration scripttests/adapters/test_generic_rest_api.py- Comprehensive test suitetests/adapters/test_backward_compatibility.py- Compatibility verification including PeeringManagerTesting
All tests pass including:
Fixes #80.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.