@@ -888,7 +888,12 @@ async def update(
888
888
await self ._process_mutation_result (mutation_name = mutation_name , response = response , timeout = timeout )
889
889
890
890
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 ,
892
897
) -> None :
893
898
"""Processes the Relationships of a InfrahubNode and add Related Nodes to a list.
894
899
@@ -907,6 +912,10 @@ async def _process_relationships(
907
912
client = self ._client , branch = branch , data = relation , timeout = timeout
908
913
)
909
914
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
+ )
910
919
elif rel and isinstance (rel , RelationshipManager ):
911
920
peers = node_data ["node" ].get (rel_name , None )
912
921
if peers and peers ["edges" ]:
@@ -915,6 +924,10 @@ async def _process_relationships(
915
924
client = self ._client , branch = branch , data = peer , timeout = timeout
916
925
)
917
926
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
+ )
918
931
919
932
async def get_pool_allocated_resources (self , resource : InfrahubNode ) -> list [InfrahubNode ]:
920
933
"""Fetch all nodes that were allocated for the pool and a given resource.
@@ -1416,6 +1429,7 @@ def _process_relationships(
1416
1429
branch : str ,
1417
1430
related_nodes : list [InfrahubNodeSync ],
1418
1431
timeout : int | None = None ,
1432
+ recursive : bool = False ,
1419
1433
) -> None :
1420
1434
"""Processes the Relationships of a InfrahubNodeSync and add Related Nodes to a list.
1421
1435
@@ -1435,6 +1449,10 @@ def _process_relationships(
1435
1449
client = self ._client , branch = branch , data = relation , timeout = timeout
1436
1450
)
1437
1451
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
+ )
1438
1456
elif rel and isinstance (rel , RelationshipManagerSync ):
1439
1457
peers = node_data ["node" ].get (rel_name )
1440
1458
if peers :
@@ -1443,6 +1461,10 @@ def _process_relationships(
1443
1461
client = self ._client , branch = branch , data = peer , timeout = timeout
1444
1462
)
1445
1463
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
+ )
1446
1468
1447
1469
def get_pool_allocated_resources (self , resource : InfrahubNodeSync ) -> list [InfrahubNodeSync ]:
1448
1470
"""Fetch all nodes that were allocated for the pool and a given resource.
0 commit comments