Add Device42 to Infrahub sync example with demo server integration#91
Add Device42 to Infrahub sync example with demo server integration#91BeArchiTek merged 6 commits intomainfrom
Conversation
Deploying infrahub-sync with
|
| Latest commit: |
f7b1061
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e5c1ad46.infrahub-sync.pages.dev |
| Branch Preview URL: | https://copilot-fix-87.infrahub-sync.pages.dev |
Co-authored-by: BeArchiTek <1334310+BeArchiTek@users.noreply.github.com>
|
@copilot based on the docs https://api.device42.com, add the authentication. use http://swaggerdemo.device42.com/ and use credentials guest:device42_rocks! in your example. Add anything you see fit in the GenericRestAPIAdapter to work with device42 |
Co-authored-by: BeArchiTek <1334310+BeArchiTek@users.noreply.github.com>
Updated the Device42 adapter with the demo server credentials and enhanced API handling: ✅ Demo Server Integration (commit e2bdbfb):
✅ Device42-Specific Enhancements:
✅ GenericRestAPIAdapter Improvements:
The adapter now properly handles Device42's API structure and includes a debug mode to help with API response analysis. Ready for testing with the demo server! |
This PR implements a complete Device42 to Infrahub synchronization example, addressing the gap in popular sync options mentioned in issue #87.
Overview
Device42 is a comprehensive IT asset management and documentation solution that was notably missing from the examples directory despite being a popular choice for infrastructure management. This implementation provides a production-ready sync adapter that leverages the existing GenericRestApiAdapter framework.
Changes Made
Core Adapter Implementation
infrahub_sync/adapters/device42.py): Extends GenericRestApiAdapter with Device42-specific configuration including basic authentication, API v2.0 endpoints, proper environment variable handling, and Device42-specific response format parsinginfrahub_sync/adapters/genericrestapi.py): Added missing aliases (GenericRestApiAdapter,GenericRestApiModel) to resolve import issues in existing adaptersComplete Example Structure
Created a comprehensive
device42_to_infrahubexample following the established pattern used by NetBox, LibreNMS, and other integrations:config.yml): Maps Device42 objects to Infrahub schema with proper field mappings, transforms, and dependency orderingdevice42/sync_models.py): Device42-specific data modelsinfrahub/sync_models.py): Corresponding Infrahub object modelsDevice42-Specific Features
{"objects": [...], "total_count": N}API response format_fetch_paginated_data()method for handling large datasets with automatic paginationhttp://swaggerdemo.device42.com) using credentialsguest:device42_rocks!Data Mapping Coverage
The example handles common Device42 objects:
Documentation
Includes comprehensive documentation (
README.md) covering:Usage Example
For production use:
For testing with demo server:
The implementation follows the same patterns as existing examples, ensuring consistency and maintainability while providing a robust foundation for Device42 integrations with enhanced API handling capabilities.
Fixes #87.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.