@@ -888,7 +888,12 @@ async def update(
888888 await self ._process_mutation_result (mutation_name = mutation_name , response = response , timeout = timeout )
889889
890890 async def _process_relationships (
891- self , node_data : dict [str , Any ], branch : str , related_nodes : list [InfrahubNode ], timeout : int | None = None
891+ self ,
892+ node_data : dict [str , Any ],
893+ branch : str ,
894+ related_nodes : list [InfrahubNode ],
895+ timeout : int | None = None ,
896+ recursive : bool = False ,
892897 ) -> None :
893898 """Processes the Relationships of a InfrahubNode and add Related Nodes to a list.
894899
@@ -907,6 +912,10 @@ async def _process_relationships(
907912 client = self ._client , branch = branch , data = relation , timeout = timeout
908913 )
909914 related_nodes .append (related_node )
915+ if recursive :
916+ await related_node ._process_relationships (
917+ node_data = relation , branch = branch , related_nodes = related_nodes , recursive = recursive
918+ )
910919 elif rel and isinstance (rel , RelationshipManager ):
911920 peers = node_data ["node" ].get (rel_name , None )
912921 if peers and peers ["edges" ]:
@@ -915,6 +924,10 @@ async def _process_relationships(
915924 client = self ._client , branch = branch , data = peer , timeout = timeout
916925 )
917926 related_nodes .append (related_node )
927+ if recursive :
928+ await related_node ._process_relationships (
929+ node_data = peer , branch = branch , related_nodes = related_nodes , recursive = recursive
930+ )
918931
919932 async def get_pool_allocated_resources (self , resource : InfrahubNode ) -> list [InfrahubNode ]:
920933 """Fetch all nodes that were allocated for the pool and a given resource.
@@ -1416,6 +1429,7 @@ def _process_relationships(
14161429 branch : str ,
14171430 related_nodes : list [InfrahubNodeSync ],
14181431 timeout : int | None = None ,
1432+ recursive : bool = False ,
14191433 ) -> None :
14201434 """Processes the Relationships of a InfrahubNodeSync and add Related Nodes to a list.
14211435
@@ -1435,6 +1449,10 @@ def _process_relationships(
14351449 client = self ._client , branch = branch , data = relation , timeout = timeout
14361450 )
14371451 related_nodes .append (related_node )
1452+ if recursive :
1453+ related_node ._process_relationships (
1454+ node_data = relation , branch = branch , related_nodes = related_nodes , recursive = recursive
1455+ )
14381456 elif rel and isinstance (rel , RelationshipManagerSync ):
14391457 peers = node_data ["node" ].get (rel_name )
14401458 if peers :
@@ -1443,6 +1461,10 @@ def _process_relationships(
14431461 client = self ._client , branch = branch , data = peer , timeout = timeout
14441462 )
14451463 related_nodes .append (related_node )
1464+ if recursive :
1465+ related_node ._process_relationships (
1466+ node_data = peer , branch = branch , related_nodes = related_nodes , recursive = recursive
1467+ )
14461468
14471469 def get_pool_allocated_resources (self , resource : InfrahubNodeSync ) -> list [InfrahubNodeSync ]:
14481470 """Fetch all nodes that were allocated for the pool and a given resource.
0 commit comments