diff --git a/examples/aci_to_infrahub/aci/__init__.py b/examples/aci_to_infrahub/aci/__init__.py index 3b4c323..1b5f3be 100644 --- a/examples/aci_to_infrahub/aci/__init__.py +++ b/examples/aci_to_infrahub/aci/__init__.py @@ -1 +1 @@ -"""ACI sync adapter module.""" \ No newline at end of file +"""ACI sync adapter module.""" diff --git a/examples/aci_to_infrahub/aci/sync_models.py b/examples/aci_to_infrahub/aci/sync_models.py index 45e2e64..6246772 100644 --- a/examples/aci_to_infrahub/aci/sync_models.py +++ b/examples/aci_to_infrahub/aci/sync_models.py @@ -1,22 +1,23 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: - _loader = PluginLoader.from_env_and_args() - _spec = "aci" _ModelBaseClass = _loader.resolve(_spec, default_class_candidates=("Model",)) except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -36,6 +37,7 @@ class DcimPhysicalDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class DcimPhysicalInterface(_ModelBaseClass): _modelname = "DcimPhysicalInterface" _identifiers = ("device", "name") @@ -47,6 +49,7 @@ class DcimPhysicalInterface(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationBuilding(_ModelBaseClass): _modelname = "LocationBuilding" _identifiers = ("name",) @@ -58,6 +61,7 @@ class LocationBuilding(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationMetro(_ModelBaseClass): _modelname = "LocationMetro" _identifiers = ("name",) @@ -68,6 +72,7 @@ class LocationMetro(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationCustomer(_ModelBaseClass): _modelname = "OrganizationCustomer" _identifiers = ("name", "customer_id") diff --git a/examples/aci_to_infrahub/infrahub/__init__.py b/examples/aci_to_infrahub/infrahub/__init__.py index 7f25443..d50a46d 100644 --- a/examples/aci_to_infrahub/infrahub/__init__.py +++ b/examples/aci_to_infrahub/infrahub/__init__.py @@ -1 +1 @@ -"""Infrahub sync adapter module.""" \ No newline at end of file +"""Infrahub sync adapter module.""" diff --git a/examples/aci_to_infrahub/infrahub/sync_models.py b/examples/aci_to_infrahub/infrahub/sync_models.py index f32592a..e89dbd8 100644 --- a/examples/aci_to_infrahub/infrahub/sync_models.py +++ b/examples/aci_to_infrahub/infrahub/sync_models.py @@ -1,22 +1,23 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: - _loader = PluginLoader.from_env_and_args() - _spec = "infrahub" _ModelBaseClass = _loader.resolve(_spec, default_class_candidates=("Model",)) except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -36,6 +37,7 @@ class DcimPhysicalDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class DcimPhysicalInterface(_ModelBaseClass): _modelname = "DcimPhysicalInterface" _identifiers = ("device", "name") @@ -47,6 +49,7 @@ class DcimPhysicalInterface(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationBuilding(_ModelBaseClass): _modelname = "LocationBuilding" _identifiers = ("name",) @@ -58,6 +61,7 @@ class LocationBuilding(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationMetro(_ModelBaseClass): _modelname = "LocationMetro" _identifiers = ("name",) @@ -68,6 +72,7 @@ class LocationMetro(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationCustomer(_ModelBaseClass): _modelname = "OrganizationCustomer" _identifiers = ("name", "customer_id") diff --git a/examples/custom_adapter/custom_adapter_src/custom_adapter.py b/examples/custom_adapter/custom_adapter_src/custom_adapter.py index dfa8a3f..35ba527 100644 --- a/examples/custom_adapter/custom_adapter_src/custom_adapter.py +++ b/examples/custom_adapter/custom_adapter_src/custom_adapter.py @@ -48,6 +48,7 @@ def __init__(self, filepath: str | None = None) -> None: print(f"DEBUG: Loaded mock database from {filepath}") except (FileNotFoundError, json.JSONDecodeError) as e: print(f"DEBUG: Failed to load mock database from {filepath}: {e}") + def get_all_nodes(self, model: str) -> list[dict[str, Any]]: """Get all nodes of a specific model from the mock database. diff --git a/examples/custom_adapter/infrahub/sync_models.py b/examples/custom_adapter/infrahub/sync_models.py index 4740186..7bbd418 100644 --- a/examples/custom_adapter/infrahub/sync_models.py +++ b/examples/custom_adapter/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` diff --git a/examples/custom_adapter/mockdb/sync_models.py b/examples/custom_adapter/mockdb/sync_models.py index e96c554..22b7a22 100644 --- a/examples/custom_adapter/mockdb/sync_models.py +++ b/examples/custom_adapter/mockdb/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` diff --git a/examples/device42_to_infrahub/genericrestapi/sync_models.py b/examples/device42_to_infrahub/genericrestapi/sync_models.py index 7646f48..856da79 100644 --- a/examples/device42_to_infrahub/genericrestapi/sync_models.py +++ b/examples/device42_to_infrahub/genericrestapi/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -29,6 +32,7 @@ class BuiltinTag(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationSite(_ModelBaseClass): _modelname = "LocationSite" _identifiers = ("name",) @@ -39,6 +43,7 @@ class LocationSite(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationTenant(_ModelBaseClass): _modelname = "OrganizationTenant" _identifiers = ("name",) diff --git a/examples/device42_to_infrahub/infrahub/sync_models.py b/examples/device42_to_infrahub/infrahub/sync_models.py index 0a9115a..bb3c730 100644 --- a/examples/device42_to_infrahub/infrahub/sync_models.py +++ b/examples/device42_to_infrahub/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -29,6 +32,7 @@ class BuiltinTag(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationSite(_ModelBaseClass): _modelname = "LocationSite" _identifiers = ("name",) @@ -39,6 +43,7 @@ class LocationSite(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationTenant(_ModelBaseClass): _modelname = "OrganizationTenant" _identifiers = ("name",) diff --git a/examples/infrahub_to_peering-manager/infrahub/sync_models.py b/examples/infrahub_to_peering-manager/infrahub/sync_models.py index 895298b..fd71475 100644 --- a/examples/infrahub_to_peering-manager/infrahub/sync_models.py +++ b/examples/infrahub_to_peering-manager/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -35,6 +38,7 @@ class InfraAutonomousSystem(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPPeerGroup(_ModelBaseClass): _modelname = "InfraBGPPeerGroup" _identifiers = ("name",) @@ -49,6 +53,7 @@ class InfraBGPPeerGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPCommunity(_ModelBaseClass): _modelname = "InfraBGPCommunity" _identifiers = ("name",) @@ -62,6 +67,7 @@ class InfraBGPCommunity(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPRoutingPolicy(_ModelBaseClass): _modelname = "InfraBGPRoutingPolicy" _identifiers = ("name",) @@ -77,6 +83,7 @@ class InfraBGPRoutingPolicy(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIXP(_ModelBaseClass): _modelname = "InfraIXP" _identifiers = ("name",) @@ -91,6 +98,7 @@ class InfraIXP(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIXPConnection(_ModelBaseClass): _modelname = "InfraIXPConnection" _identifiers = ("name",) diff --git a/examples/infrahub_to_peering-manager/peeringmanager/sync_models.py b/examples/infrahub_to_peering-manager/peeringmanager/sync_models.py index 60d3991..f10bc73 100644 --- a/examples/infrahub_to_peering-manager/peeringmanager/sync_models.py +++ b/examples/infrahub_to_peering-manager/peeringmanager/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -35,6 +38,7 @@ class InfraAutonomousSystem(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPPeerGroup(_ModelBaseClass): _modelname = "InfraBGPPeerGroup" _identifiers = ("name",) @@ -49,6 +53,7 @@ class InfraBGPPeerGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPCommunity(_ModelBaseClass): _modelname = "InfraBGPCommunity" _identifiers = ("name",) @@ -62,6 +67,7 @@ class InfraBGPCommunity(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPRoutingPolicy(_ModelBaseClass): _modelname = "InfraBGPRoutingPolicy" _identifiers = ("name",) @@ -77,6 +83,7 @@ class InfraBGPRoutingPolicy(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIXP(_ModelBaseClass): _modelname = "InfraIXP" _identifiers = ("name",) @@ -91,6 +98,7 @@ class InfraIXP(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIXPConnection(_ModelBaseClass): _modelname = "InfraIXPConnection" _identifiers = ("name",) diff --git a/examples/librenms_to_infrahub/genericrestapi/sync_models.py b/examples/librenms_to_infrahub/genericrestapi/sync_models.py index 53e50ec..badd81d 100644 --- a/examples/librenms_to_infrahub/genericrestapi/sync_models.py +++ b/examples/librenms_to_infrahub/genericrestapi/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class CoreStandardGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraDevice(_ModelBaseClass): _modelname = "InfraDevice" _identifiers = ("name",) @@ -41,6 +45,7 @@ class InfraDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class IpamIPAddress(_ModelBaseClass): _modelname = "IpamIPAddress" _identifiers = ("address",) @@ -51,6 +56,7 @@ class IpamIPAddress(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationSite(_ModelBaseClass): _modelname = "LocationSite" _identifiers = ("name",) diff --git a/examples/librenms_to_infrahub/infrahub/sync_models.py b/examples/librenms_to_infrahub/infrahub/sync_models.py index c600e45..0669898 100644 --- a/examples/librenms_to_infrahub/infrahub/sync_models.py +++ b/examples/librenms_to_infrahub/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class CoreStandardGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraDevice(_ModelBaseClass): _modelname = "InfraDevice" _identifiers = ("name",) @@ -41,6 +45,7 @@ class InfraDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class IpamIPAddress(_ModelBaseClass): _modelname = "IpamIPAddress" _identifiers = ("address",) @@ -51,6 +56,7 @@ class IpamIPAddress(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationSite(_ModelBaseClass): _modelname = "LocationSite" _identifiers = ("name",) diff --git a/examples/nautobot-v2_to_infrahub/infrahub/sync_adapter.py b/examples/nautobot-v2_to_infrahub/infrahub/sync_adapter.py index a204caf..a4c3960 100644 --- a/examples/nautobot-v2_to_infrahub/infrahub/sync_adapter.py +++ b/examples/nautobot-v2_to_infrahub/infrahub/sync_adapter.py @@ -12,8 +12,8 @@ InfraCircuit, InfraDevice, InfraFrontPort, - InfraIPAddress, InfraInterfaceL2L3, + InfraIPAddress, InfraPlatform, InfraPrefix, InfraProviderNetwork, diff --git a/examples/nautobot-v2_to_infrahub/infrahub/sync_models.py b/examples/nautobot-v2_to_infrahub/infrahub/sync_models.py index e95bee7..7e1f2fc 100644 --- a/examples/nautobot-v2_to_infrahub/infrahub/sync_models.py +++ b/examples/nautobot-v2_to_infrahub/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class CoreStandardGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class BuiltinTag(_ModelBaseClass): _modelname = "BuiltinTag" _identifiers = ("name",) @@ -40,6 +44,7 @@ class BuiltinTag(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraAutonomousSystem(_ModelBaseClass): _modelname = "InfraAutonomousSystem" _identifiers = ("name",) @@ -52,6 +57,7 @@ class InfraAutonomousSystem(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraCircuit(_ModelBaseClass): _modelname = "InfraCircuit" _identifiers = ("circuit_id",) @@ -67,6 +73,7 @@ class InfraCircuit(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceCircuitType(_ModelBaseClass): _modelname = "ChoiceCircuitType" _identifiers = ("name",) @@ -77,6 +84,7 @@ class ChoiceCircuitType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraDevice(_ModelBaseClass): _modelname = "InfraDevice" _identifiers = ("location", "organization", "name") @@ -96,6 +104,7 @@ class InfraDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceDeviceType(_ModelBaseClass): _modelname = "ChoiceDeviceType" _identifiers = ("name", "manufacturer") @@ -110,6 +119,7 @@ class ChoiceDeviceType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraFrontPort(_ModelBaseClass): _modelname = "InfraFrontPort" _identifiers = ("name", "device") @@ -123,10 +133,20 @@ class InfraFrontPort(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraInterfaceL2L3(_ModelBaseClass): _modelname = "InfraInterfaceL2L3" _identifiers = ("name", "device") - _attributes = ("tagged_vlan", "tags", "status", "l2_mode", "description", "mac_address", "mgmt_only", "interface_type") + _attributes = ( + "tagged_vlan", + "tags", + "status", + "l2_mode", + "description", + "mac_address", + "mgmt_only", + "interface_type", + ) l2_mode: str | None = None description: str | None = None name: str @@ -142,6 +162,7 @@ class InfraInterfaceL2L3(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIPAddress(_ModelBaseClass): _modelname = "InfraIPAddress" _identifiers = ("address", "ip_prefix") @@ -157,6 +178,7 @@ class InfraIPAddress(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceLocationType(_ModelBaseClass): _modelname = "ChoiceLocationType" _identifiers = ("name",) @@ -167,6 +189,7 @@ class ChoiceLocationType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class NautobotNamespace(_ModelBaseClass): _modelname = "NautobotNamespace" _identifiers = ("name",) @@ -177,6 +200,7 @@ class NautobotNamespace(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraPlatform(_ModelBaseClass): _modelname = "InfraPlatform" _identifiers = ("name", "manufacturer") @@ -189,6 +213,7 @@ class InfraPlatform(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraProviderNetwork(_ModelBaseClass): _modelname = "InfraProviderNetwork" _identifiers = ("name",) @@ -203,6 +228,7 @@ class InfraProviderNetwork(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraPrefix(_ModelBaseClass): _modelname = "InfraPrefix" _identifiers = ("prefix", "ip_namespace") @@ -219,6 +245,7 @@ class InfraPrefix(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRack(_ModelBaseClass): _modelname = "InfraRack" _identifiers = ("name",) @@ -235,6 +262,7 @@ class InfraRack(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRearPort(_ModelBaseClass): _modelname = "InfraRearPort" _identifiers = ("name", "device") @@ -247,6 +275,7 @@ class InfraRearPort(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRouteTarget(_ModelBaseClass): _modelname = "InfraRouteTarget" _identifiers = ("name", "organization") @@ -258,6 +287,7 @@ class InfraRouteTarget(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraVLAN(_ModelBaseClass): _modelname = "InfraVLAN" _identifiers = ("name",) @@ -274,6 +304,7 @@ class InfraVLAN(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraVRF(_ModelBaseClass): _modelname = "InfraVRF" _identifiers = ("name", "ip_namespace") @@ -289,6 +320,7 @@ class InfraVRF(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationGeneric(_ModelBaseClass): _modelname = "OrganizationGeneric" _identifiers = ("name",) @@ -301,6 +333,7 @@ class OrganizationGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class StatusGeneric(_ModelBaseClass): _modelname = "StatusGeneric" _identifiers = ("name",) @@ -312,6 +345,7 @@ class StatusGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class RoleGeneric(_ModelBaseClass): _modelname = "RoleGeneric" _identifiers = ("name",) @@ -323,6 +357,7 @@ class RoleGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationGeneric(_ModelBaseClass): _modelname = "LocationGeneric" _identifiers = ("name",) diff --git a/examples/nautobot-v2_to_infrahub/nautobot/sync_adapter.py b/examples/nautobot-v2_to_infrahub/nautobot/sync_adapter.py index 7be26d0..f58be65 100644 --- a/examples/nautobot-v2_to_infrahub/nautobot/sync_adapter.py +++ b/examples/nautobot-v2_to_infrahub/nautobot/sync_adapter.py @@ -12,8 +12,8 @@ InfraCircuit, InfraDevice, InfraFrontPort, - InfraIPAddress, InfraInterfaceL2L3, + InfraIPAddress, InfraPlatform, InfraPrefix, InfraProviderNetwork, diff --git a/examples/nautobot-v2_to_infrahub/nautobot/sync_models.py b/examples/nautobot-v2_to_infrahub/nautobot/sync_models.py index aa9a50e..5b78d88 100644 --- a/examples/nautobot-v2_to_infrahub/nautobot/sync_models.py +++ b/examples/nautobot-v2_to_infrahub/nautobot/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class CoreStandardGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class BuiltinTag(_ModelBaseClass): _modelname = "BuiltinTag" _identifiers = ("name",) @@ -40,6 +44,7 @@ class BuiltinTag(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraAutonomousSystem(_ModelBaseClass): _modelname = "InfraAutonomousSystem" _identifiers = ("name",) @@ -52,6 +57,7 @@ class InfraAutonomousSystem(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraCircuit(_ModelBaseClass): _modelname = "InfraCircuit" _identifiers = ("circuit_id",) @@ -67,6 +73,7 @@ class InfraCircuit(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceCircuitType(_ModelBaseClass): _modelname = "ChoiceCircuitType" _identifiers = ("name",) @@ -77,6 +84,7 @@ class ChoiceCircuitType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraDevice(_ModelBaseClass): _modelname = "InfraDevice" _identifiers = ("location", "organization", "name") @@ -96,6 +104,7 @@ class InfraDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceDeviceType(_ModelBaseClass): _modelname = "ChoiceDeviceType" _identifiers = ("name", "manufacturer") @@ -110,6 +119,7 @@ class ChoiceDeviceType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraFrontPort(_ModelBaseClass): _modelname = "InfraFrontPort" _identifiers = ("name", "device") @@ -123,10 +133,20 @@ class InfraFrontPort(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraInterfaceL2L3(_ModelBaseClass): _modelname = "InfraInterfaceL2L3" _identifiers = ("name", "device") - _attributes = ("tagged_vlan", "tags", "status", "l2_mode", "description", "mac_address", "mgmt_only", "interface_type") + _attributes = ( + "tagged_vlan", + "tags", + "status", + "l2_mode", + "description", + "mac_address", + "mgmt_only", + "interface_type", + ) l2_mode: str | None = None description: str | None = None name: str @@ -142,6 +162,7 @@ class InfraInterfaceL2L3(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIPAddress(_ModelBaseClass): _modelname = "InfraIPAddress" _identifiers = ("address", "ip_prefix") @@ -157,6 +178,7 @@ class InfraIPAddress(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceLocationType(_ModelBaseClass): _modelname = "ChoiceLocationType" _identifiers = ("name",) @@ -167,6 +189,7 @@ class ChoiceLocationType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class NautobotNamespace(_ModelBaseClass): _modelname = "NautobotNamespace" _identifiers = ("name",) @@ -177,6 +200,7 @@ class NautobotNamespace(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraPlatform(_ModelBaseClass): _modelname = "InfraPlatform" _identifiers = ("name", "manufacturer") @@ -189,6 +213,7 @@ class InfraPlatform(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraProviderNetwork(_ModelBaseClass): _modelname = "InfraProviderNetwork" _identifiers = ("name",) @@ -203,6 +228,7 @@ class InfraProviderNetwork(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraPrefix(_ModelBaseClass): _modelname = "InfraPrefix" _identifiers = ("prefix", "ip_namespace") @@ -219,6 +245,7 @@ class InfraPrefix(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRack(_ModelBaseClass): _modelname = "InfraRack" _identifiers = ("name",) @@ -235,6 +262,7 @@ class InfraRack(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRearPort(_ModelBaseClass): _modelname = "InfraRearPort" _identifiers = ("name", "device") @@ -247,6 +275,7 @@ class InfraRearPort(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRouteTarget(_ModelBaseClass): _modelname = "InfraRouteTarget" _identifiers = ("name", "organization") @@ -258,6 +287,7 @@ class InfraRouteTarget(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraVLAN(_ModelBaseClass): _modelname = "InfraVLAN" _identifiers = ("name",) @@ -274,6 +304,7 @@ class InfraVLAN(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraVRF(_ModelBaseClass): _modelname = "InfraVRF" _identifiers = ("name", "ip_namespace") @@ -289,6 +320,7 @@ class InfraVRF(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationGeneric(_ModelBaseClass): _modelname = "OrganizationGeneric" _identifiers = ("name",) @@ -301,6 +333,7 @@ class OrganizationGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class StatusGeneric(_ModelBaseClass): _modelname = "StatusGeneric" _identifiers = ("name",) @@ -312,6 +345,7 @@ class StatusGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class RoleGeneric(_ModelBaseClass): _modelname = "RoleGeneric" _identifiers = ("name",) @@ -323,6 +357,7 @@ class RoleGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationGeneric(_ModelBaseClass): _modelname = "LocationGeneric" _identifiers = ("name",) diff --git a/examples/netbox_to_infrahub/infrahub/sync_adapter.py b/examples/netbox_to_infrahub/infrahub/sync_adapter.py index 2b68a6a..ee6a0ea 100644 --- a/examples/netbox_to_infrahub/infrahub/sync_adapter.py +++ b/examples/netbox_to_infrahub/infrahub/sync_adapter.py @@ -9,8 +9,8 @@ CoreStandardGroup, InfraCircuit, InfraDevice, - InfraIPAddress, InfraInterfaceL2L3, + InfraIPAddress, InfraPrefix, InfraProviderNetwork, InfraRack, diff --git a/examples/netbox_to_infrahub/infrahub/sync_models.py b/examples/netbox_to_infrahub/infrahub/sync_models.py index 47b2370..ba60020 100644 --- a/examples/netbox_to_infrahub/infrahub/sync_models.py +++ b/examples/netbox_to_infrahub/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class CoreStandardGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class BuiltinTag(_ModelBaseClass): _modelname = "BuiltinTag" _identifiers = ("name",) @@ -40,6 +44,7 @@ class BuiltinTag(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceCircuitType(_ModelBaseClass): _modelname = "ChoiceCircuitType" _identifiers = ("name",) @@ -51,6 +56,7 @@ class ChoiceCircuitType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceDeviceType(_ModelBaseClass): _modelname = "ChoiceDeviceType" _identifiers = ("name", "manufacturer") @@ -65,6 +71,7 @@ class ChoiceDeviceType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraCircuit(_ModelBaseClass): _modelname = "InfraCircuit" _identifiers = ("circuit_id",) @@ -79,6 +86,7 @@ class InfraCircuit(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraDevice(_ModelBaseClass): _modelname = "InfraDevice" _identifiers = ("location", "rack", "organization", "name") @@ -97,6 +105,7 @@ class InfraDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIPAddress(_ModelBaseClass): _modelname = "InfraIPAddress" _identifiers = ("address", "vrf") @@ -109,6 +118,7 @@ class InfraIPAddress(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraInterfaceL2L3(_ModelBaseClass): _modelname = "InfraInterfaceL2L3" _identifiers = ("device", "name") @@ -127,6 +137,7 @@ class InfraInterfaceL2L3(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraPrefix(_ModelBaseClass): _modelname = "InfraPrefix" _identifiers = ("prefix", "vrf") @@ -141,6 +152,7 @@ class InfraPrefix(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraProviderNetwork(_ModelBaseClass): _modelname = "InfraProviderNetwork" _identifiers = ("name",) @@ -154,6 +166,7 @@ class InfraProviderNetwork(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRack(_ModelBaseClass): _modelname = "InfraRack" _identifiers = ("name", "location") @@ -170,6 +183,7 @@ class InfraRack(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRouteTarget(_ModelBaseClass): _modelname = "InfraRouteTarget" _identifiers = ("name", "organization") @@ -181,6 +195,7 @@ class InfraRouteTarget(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraVLAN(_ModelBaseClass): _modelname = "InfraVLAN" _identifiers = ("name", "vlan_id", "location", "vlan_group") @@ -195,6 +210,7 @@ class InfraVLAN(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraVRF(_ModelBaseClass): _modelname = "InfraVRF" _identifiers = ("name",) @@ -209,6 +225,7 @@ class InfraVRF(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationGeneric(_ModelBaseClass): _modelname = "LocationGeneric" _identifiers = ("name",) @@ -223,6 +240,7 @@ class LocationGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationGeneric(_ModelBaseClass): _modelname = "OrganizationGeneric" _identifiers = ("name",) @@ -234,6 +252,7 @@ class OrganizationGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class RoleGeneric(_ModelBaseClass): _modelname = "RoleGeneric" _identifiers = ("name",) diff --git a/examples/netbox_to_infrahub/netbox/sync_adapter.py b/examples/netbox_to_infrahub/netbox/sync_adapter.py index 2e5971f..7489de0 100644 --- a/examples/netbox_to_infrahub/netbox/sync_adapter.py +++ b/examples/netbox_to_infrahub/netbox/sync_adapter.py @@ -9,8 +9,8 @@ CoreStandardGroup, InfraCircuit, InfraDevice, - InfraIPAddress, InfraInterfaceL2L3, + InfraIPAddress, InfraPrefix, InfraProviderNetwork, InfraRack, diff --git a/examples/netbox_to_infrahub/netbox/sync_models.py b/examples/netbox_to_infrahub/netbox/sync_models.py index fddbc2e..daf58a2 100644 --- a/examples/netbox_to_infrahub/netbox/sync_models.py +++ b/examples/netbox_to_infrahub/netbox/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class CoreStandardGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class BuiltinTag(_ModelBaseClass): _modelname = "BuiltinTag" _identifiers = ("name",) @@ -40,6 +44,7 @@ class BuiltinTag(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceCircuitType(_ModelBaseClass): _modelname = "ChoiceCircuitType" _identifiers = ("name",) @@ -51,6 +56,7 @@ class ChoiceCircuitType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class ChoiceDeviceType(_ModelBaseClass): _modelname = "ChoiceDeviceType" _identifiers = ("name", "manufacturer") @@ -65,6 +71,7 @@ class ChoiceDeviceType(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraCircuit(_ModelBaseClass): _modelname = "InfraCircuit" _identifiers = ("circuit_id",) @@ -79,6 +86,7 @@ class InfraCircuit(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraDevice(_ModelBaseClass): _modelname = "InfraDevice" _identifiers = ("location", "rack", "organization", "name") @@ -97,6 +105,7 @@ class InfraDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIPAddress(_ModelBaseClass): _modelname = "InfraIPAddress" _identifiers = ("address", "vrf") @@ -109,6 +118,7 @@ class InfraIPAddress(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraInterfaceL2L3(_ModelBaseClass): _modelname = "InfraInterfaceL2L3" _identifiers = ("device", "name") @@ -127,6 +137,7 @@ class InfraInterfaceL2L3(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraPrefix(_ModelBaseClass): _modelname = "InfraPrefix" _identifiers = ("prefix", "vrf") @@ -141,6 +152,7 @@ class InfraPrefix(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraProviderNetwork(_ModelBaseClass): _modelname = "InfraProviderNetwork" _identifiers = ("name",) @@ -154,6 +166,7 @@ class InfraProviderNetwork(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRack(_ModelBaseClass): _modelname = "InfraRack" _identifiers = ("name", "location") @@ -170,6 +183,7 @@ class InfraRack(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraRouteTarget(_ModelBaseClass): _modelname = "InfraRouteTarget" _identifiers = ("name", "organization") @@ -181,6 +195,7 @@ class InfraRouteTarget(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraVLAN(_ModelBaseClass): _modelname = "InfraVLAN" _identifiers = ("name", "vlan_id", "location", "vlan_group") @@ -195,6 +210,7 @@ class InfraVLAN(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraVRF(_ModelBaseClass): _modelname = "InfraVRF" _identifiers = ("name",) @@ -209,6 +225,7 @@ class InfraVRF(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class LocationGeneric(_ModelBaseClass): _modelname = "LocationGeneric" _identifiers = ("name",) @@ -223,6 +240,7 @@ class LocationGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationGeneric(_ModelBaseClass): _modelname = "OrganizationGeneric" _identifiers = ("name",) @@ -234,6 +252,7 @@ class OrganizationGeneric(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class RoleGeneric(_ModelBaseClass): _modelname = "RoleGeneric" _identifiers = ("name",) diff --git a/examples/observium_to_infrahub/genericrestapi/sync_models.py b/examples/observium_to_infrahub/genericrestapi/sync_models.py index 50a7ab8..38e544d 100644 --- a/examples/observium_to_infrahub/genericrestapi/sync_models.py +++ b/examples/observium_to_infrahub/genericrestapi/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class CoreStandardGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraDevice(_ModelBaseClass): _modelname = "InfraDevice" _identifiers = ("name",) @@ -43,6 +47,7 @@ class InfraDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class IpamIPAddress(_ModelBaseClass): _modelname = "IpamIPAddress" _identifiers = ("address",) diff --git a/examples/observium_to_infrahub/infrahub/sync_models.py b/examples/observium_to_infrahub/infrahub/sync_models.py index 59d2348..012da3d 100644 --- a/examples/observium_to_infrahub/infrahub/sync_models.py +++ b/examples/observium_to_infrahub/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class CoreStandardGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraDevice(_ModelBaseClass): _modelname = "InfraDevice" _identifiers = ("name",) @@ -43,6 +47,7 @@ class InfraDevice(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class IpamIPAddress(_ModelBaseClass): _modelname = "IpamIPAddress" _identifiers = ("address",) diff --git a/examples/peering-manager_to_infrahub/infrahub/sync_models.py b/examples/peering-manager_to_infrahub/infrahub/sync_models.py index 8dd15c2..d6e87f2 100644 --- a/examples/peering-manager_to_infrahub/infrahub/sync_models.py +++ b/examples/peering-manager_to_infrahub/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class IpamIPAddress(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationProvider(_ModelBaseClass): _modelname = "OrganizationProvider" _identifiers = ("name",) @@ -39,10 +43,19 @@ class OrganizationProvider(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraAutonomousSystem(_ModelBaseClass): _modelname = "InfraAutonomousSystem" _identifiers = ("asn",) - _attributes = ("organization", "ipv4_max_prefixes", "ipv6_max_prefixes", "affiliated", "name", "irr_as_set", "description") + _attributes = ( + "organization", + "ipv4_max_prefixes", + "ipv6_max_prefixes", + "affiliated", + "name", + "irr_as_set", + "description", + ) ipv4_max_prefixes: int | None = None ipv6_max_prefixes: int | None = None affiliated: bool | None = None @@ -55,6 +68,7 @@ class InfraAutonomousSystem(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPPeerGroup(_ModelBaseClass): _modelname = "InfraBGPPeerGroup" _identifiers = ("name",) @@ -69,6 +83,7 @@ class InfraBGPPeerGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPCommunity(_ModelBaseClass): _modelname = "InfraBGPCommunity" _identifiers = ("name",) @@ -82,6 +97,7 @@ class InfraBGPCommunity(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPRoutingPolicy(_ModelBaseClass): _modelname = "InfraBGPRoutingPolicy" _identifiers = ("name",) @@ -97,6 +113,7 @@ class InfraBGPRoutingPolicy(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIXP(_ModelBaseClass): _modelname = "InfraIXP" _identifiers = ("name",) @@ -111,10 +128,19 @@ class InfraIXP(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIXPConnection(_ModelBaseClass): _modelname = "InfraIXPConnection" _identifiers = ("name",) - _attributes = ("ipv4_address", "ipv6_address", "internet_exchange_point", "peeringdb_netixlan", "vlan", "description", "status") + _attributes = ( + "ipv4_address", + "ipv6_address", + "internet_exchange_point", + "peeringdb_netixlan", + "vlan", + "description", + "status", + ) name: str peeringdb_netixlan: int | None = None vlan: int | None = None diff --git a/examples/peering-manager_to_infrahub/peeringmanager/sync_models.py b/examples/peering-manager_to_infrahub/peeringmanager/sync_models.py index 578287d..0b8cf58 100644 --- a/examples/peering-manager_to_infrahub/peeringmanager/sync_models.py +++ b/examples/peering-manager_to_infrahub/peeringmanager/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` @@ -30,6 +33,7 @@ class IpamIPAddress(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class OrganizationProvider(_ModelBaseClass): _modelname = "OrganizationProvider" _identifiers = ("name",) @@ -39,10 +43,19 @@ class OrganizationProvider(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraAutonomousSystem(_ModelBaseClass): _modelname = "InfraAutonomousSystem" _identifiers = ("asn",) - _attributes = ("organization", "ipv4_max_prefixes", "ipv6_max_prefixes", "affiliated", "name", "irr_as_set", "description") + _attributes = ( + "organization", + "ipv4_max_prefixes", + "ipv6_max_prefixes", + "affiliated", + "name", + "irr_as_set", + "description", + ) ipv4_max_prefixes: int | None = None ipv6_max_prefixes: int | None = None affiliated: bool | None = None @@ -55,6 +68,7 @@ class InfraAutonomousSystem(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPPeerGroup(_ModelBaseClass): _modelname = "InfraBGPPeerGroup" _identifiers = ("name",) @@ -69,6 +83,7 @@ class InfraBGPPeerGroup(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPCommunity(_ModelBaseClass): _modelname = "InfraBGPCommunity" _identifiers = ("name",) @@ -82,6 +97,7 @@ class InfraBGPCommunity(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraBGPRoutingPolicy(_ModelBaseClass): _modelname = "InfraBGPRoutingPolicy" _identifiers = ("name",) @@ -97,6 +113,7 @@ class InfraBGPRoutingPolicy(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIXP(_ModelBaseClass): _modelname = "InfraIXP" _identifiers = ("name",) @@ -111,10 +128,19 @@ class InfraIXP(_ModelBaseClass): local_id: str | None = None local_data: Any | None = None + class InfraIXPConnection(_ModelBaseClass): _modelname = "InfraIXPConnection" _identifiers = ("name",) - _attributes = ("ipv4_address", "ipv6_address", "internet_exchange_point", "peeringdb_netixlan", "vlan", "description", "status") + _attributes = ( + "ipv4_address", + "ipv6_address", + "internet_exchange_point", + "peeringdb_netixlan", + "vlan", + "description", + "status", + ) name: str peeringdb_netixlan: int | None = None vlan: int | None = None diff --git a/examples/peeringdb_to_infrahub/genericrestapi/sync_models.py b/examples/peeringdb_to_infrahub/genericrestapi/sync_models.py index ddc9e20..cef7e6c 100644 --- a/examples/peeringdb_to_infrahub/genericrestapi/sync_models.py +++ b/examples/peeringdb_to_infrahub/genericrestapi/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` diff --git a/examples/peeringdb_to_infrahub/infrahub/sync_models.py b/examples/peeringdb_to_infrahub/infrahub/sync_models.py index 5696bdc..2bc62a1 100644 --- a/examples/peeringdb_to_infrahub/infrahub/sync_models.py +++ b/examples/peeringdb_to_infrahub/infrahub/sync_models.py @@ -1,8 +1,9 @@ from __future__ import annotations -from typing import Any, List +from typing import Any from infrahub_sync.plugin_loader import PluginLoader + # Load model class dynamically at runtime (honor adapters_path, safe fallback) try: _loader = PluginLoader.from_env_and_args(adapter_paths=[]) @@ -13,8 +14,10 @@ except Exception: # Fallback: use DiffSyncModel to avoid import-time failure from diffsync import DiffSyncModel as _FallbackModel + _ModelBaseClass = _FallbackModel + # ------------------------------------------------------- # AUTO-GENERATED FILE, DO NOT MODIFY # This file has been generated with the command `infrahub-sync generate` diff --git a/infrahub_sync/__init__.py b/infrahub_sync/__init__.py index 709bb15..84b4adf 100644 --- a/infrahub_sync/__init__.py +++ b/infrahub_sync/__init__.py @@ -45,7 +45,7 @@ class SchemaMappingField(pydantic.BaseModel): class SchemaMappingModel(pydantic.BaseModel): name: str - mapping: str + mapping: str | None = pydantic.Field(default=None) identifiers: list[str] | None = pydantic.Field(default=None) filters: list[SchemaMappingFilter] | None = pydantic.Field(default=None) transforms: list[SchemaMappingTransform] | None = pydantic.Field(default=None) diff --git a/infrahub_sync/adapters/aci.py b/infrahub_sync/adapters/aci.py index 98c5a28..8ce53ca 100644 --- a/infrahub_sync/adapters/aci.py +++ b/infrahub_sync/adapters/aci.py @@ -248,6 +248,10 @@ def model_loader(self, model_name: str, model: builtins.type[AciModel]) -> None: logger.debug("No fields defined for schema mapping %s, skipping", element.name) continue + if not element.mapping: + print(f"No mapping defined for '{element.name}', skipping...") + continue + # Use the resource endpoint from the schema mapping resource_name = element.mapping diff --git a/infrahub_sync/adapters/genericrestapi.py b/infrahub_sync/adapters/genericrestapi.py index 58213d2..3fe7c22 100644 --- a/infrahub_sync/adapters/genericrestapi.py +++ b/infrahub_sync/adapters/genericrestapi.py @@ -141,6 +141,10 @@ def model_loader(self, model_name: str, model: GenericrestapiModel) -> None: if element.name != model_name: continue + if not element.mapping: + print(f"No mapping defined for '{element.name}', skipping...") + continue + # Use the resource endpoint from the schema mapping resource_name = element.mapping diff --git a/infrahub_sync/adapters/ipfabricsync.py b/infrahub_sync/adapters/ipfabricsync.py index 060ef82..040c918 100644 --- a/infrahub_sync/adapters/ipfabricsync.py +++ b/infrahub_sync/adapters/ipfabricsync.py @@ -74,11 +74,12 @@ def model_loader(self, model_name: str, model: IpfabricsyncModel) -> None: if element.name != model_name: continue + if not element.mapping: + print(f"No mapping defined for '{element.name}', skipping...") + continue table = self.client.fetch_all(element.mapping, filters=ipf_filters.get(element.mapping)) - print(f"{self.type}: Loading {len(table)} from `{element.mapping}`") total = len(table) - if self.config.source.name.title() == self.type.title(): # Filter records filtered_objs = model.filter_records(records=table, schema_mapping=element) @@ -90,9 +91,7 @@ def model_loader(self, model_name: str, model: IpfabricsyncModel) -> None: transformed_objs = table for obj in transformed_objs: - print(f"Object to load: {obj}") data = self.ipfabric_dict_to_diffsync(obj=obj, mapping=element, model=model) - print(f"Data to load: {data}") item = model(**data) self.update_or_add_model_instance(item) diff --git a/infrahub_sync/adapters/nautobot.py b/infrahub_sync/adapters/nautobot.py index 82c5c02..04a0741 100644 --- a/infrahub_sync/adapters/nautobot.py +++ b/infrahub_sync/adapters/nautobot.py @@ -61,6 +61,10 @@ def model_loader(self, model_name: str, model: NautobotModel) -> None: if element.name != model_name: continue + if not element.mapping: + print(f"No mapping defined for '{element.name}', skipping...") + continue + # Use the resource endpoint from the schema mapping app_name, resource_name = element.mapping.split(".") nautobot_app = getattr(self.client, app_name) diff --git a/infrahub_sync/adapters/netbox.py b/infrahub_sync/adapters/netbox.py index 4dc212b..a6cc91e 100644 --- a/infrahub_sync/adapters/netbox.py +++ b/infrahub_sync/adapters/netbox.py @@ -65,6 +65,10 @@ def model_loader(self, model_name: str, model: NetboxModel) -> None: if element.name != model_name: continue + if not element.mapping: + print(f"No mapping defined for '{element.name}', skipping...") + continue + # Use the resource endpoint from the schema mapping app_name, resource_name = element.mapping.split(".") netbox_app = getattr(self.client, app_name) diff --git a/infrahub_sync/adapters/prometheus.py b/infrahub_sync/adapters/prometheus.py index e4fc981..c5a2f44 100644 --- a/infrahub_sync/adapters/prometheus.py +++ b/infrahub_sync/adapters/prometheus.py @@ -470,6 +470,10 @@ def model_loader(self, model_name: str, model) -> None: if element.name != model_name: continue + if not element.mapping: + print(f"No mapping defined for '{element.name}', skipping...") + continue + metric_or_resource = element.mapping objs = samples_by_metric.get(metric_or_resource, []) total = len(objs) diff --git a/infrahub_sync/adapters/slurpitsync.py b/infrahub_sync/adapters/slurpitsync.py index 3627d52..a256966 100644 --- a/infrahub_sync/adapters/slurpitsync.py +++ b/infrahub_sync/adapters/slurpitsync.py @@ -175,6 +175,10 @@ def model_loader(self, model_name: str, model: SlurpitsyncModel) -> None: if element.name != model_name: continue + if not element.mapping: + print(f"No mapping defined for '{element.name}', skipping...") + continue + if element.mapping.startswith("planning_results"): planning_name = element.mapping.split(".")[1] nodes = self.planning_results(planning_name)