@@ -547,16 +547,21 @@ async def count(
547547 at : Timestamp | None = None ,
548548 branch : str | None = None ,
549549 timeout : int | None = None ,
550+ ** kwargs : Any ,
550551 ) -> int :
551552 """Return the number of nodes of a given kind."""
553+ filters = kwargs
552554 schema = await self .schema .get (kind = kind , branch = branch )
553555
554556 branch = branch or self .default_branch
555557 if at :
556558 at = Timestamp (at )
557559
558560 response = await self .execute_graphql (
559- query = Query (query = {schema .kind : {"count" : None }}).render (), branch_name = branch , at = at , timeout = timeout
561+ query = Query (query = {schema .kind : {"count" : None , "@filters" : filters }}).render (),
562+ branch_name = branch ,
563+ at = at ,
564+ timeout = timeout ,
560565 )
561566 return int (response .get (schema .kind , {}).get ("count" , 0 ))
562567
@@ -781,7 +786,7 @@ async def process_batch() -> tuple[list[InfrahubNode], list[InfrahubNode]]:
781786 nodes = []
782787 related_nodes = []
783788 batch_process = await self .create_batch ()
784- count = await self .count (kind = schema .kind )
789+ count = await self .count (kind = schema .kind , ** filters )
785790 total_pages = (count + pagination_size - 1 ) // pagination_size
786791
787792 for page_number in range (1 , total_pages + 1 ):
@@ -1181,7 +1186,7 @@ async def allocate_next_ip_address(
11811186 async def allocate_next_ip_address (
11821187 self ,
11831188 resource_pool : CoreNode ,
1184- kind : Literal [ None ] = ...,
1189+ kind : None = ...,
11851190 identifier : str | None = ...,
11861191 prefix_length : int | None = ...,
11871192 address_type : str | None = ...,
@@ -1196,7 +1201,7 @@ async def allocate_next_ip_address(
11961201 async def allocate_next_ip_address (
11971202 self ,
11981203 resource_pool : CoreNode ,
1199- kind : Literal [ None ] = ...,
1204+ kind : None = ...,
12001205 identifier : str | None = ...,
12011206 prefix_length : int | None = ...,
12021207 address_type : str | None = ...,
@@ -1211,7 +1216,7 @@ async def allocate_next_ip_address(
12111216 async def allocate_next_ip_address (
12121217 self ,
12131218 resource_pool : CoreNode ,
1214- kind : Literal [ None ] = ...,
1219+ kind : None = ...,
12151220 identifier : str | None = ...,
12161221 prefix_length : int | None = ...,
12171222 address_type : str | None = ...,
@@ -1328,7 +1333,7 @@ async def allocate_next_ip_prefix(
13281333 async def allocate_next_ip_prefix (
13291334 self ,
13301335 resource_pool : CoreNode ,
1331- kind : Literal [ None ] = ...,
1336+ kind : None = ...,
13321337 identifier : str | None = ...,
13331338 prefix_length : int | None = ...,
13341339 member_type : str | None = ...,
@@ -1344,7 +1349,7 @@ async def allocate_next_ip_prefix(
13441349 async def allocate_next_ip_prefix (
13451350 self ,
13461351 resource_pool : CoreNode ,
1347- kind : Literal [ None ] = ...,
1352+ kind : None = ...,
13481353 identifier : str | None = ...,
13491354 prefix_length : int | None = ...,
13501355 member_type : str | None = ...,
@@ -1360,7 +1365,7 @@ async def allocate_next_ip_prefix(
13601365 async def allocate_next_ip_prefix (
13611366 self ,
13621367 resource_pool : CoreNode ,
1363- kind : Literal [ None ] = ...,
1368+ kind : None = ...,
13641369 identifier : str | None = ...,
13651370 prefix_length : int | None = ...,
13661371 member_type : str | None = ...,
@@ -1651,16 +1656,21 @@ def count(
16511656 at : Timestamp | None = None ,
16521657 branch : str | None = None ,
16531658 timeout : int | None = None ,
1659+ ** kwargs : Any ,
16541660 ) -> int :
16551661 """Return the number of nodes of a given kind."""
1662+ filters = kwargs
16561663 schema = self .schema .get (kind = kind , branch = branch )
16571664
16581665 branch = branch or self .default_branch
16591666 if at :
16601667 at = Timestamp (at )
16611668
16621669 response = self .execute_graphql (
1663- query = Query (query = {schema .kind : {"count" : None }}).render (), branch_name = branch , at = at , timeout = timeout
1670+ query = Query (query = {schema .kind : {"count" : None , "@filters" : filters }}).render (),
1671+ branch_name = branch ,
1672+ at = at ,
1673+ timeout = timeout ,
16641674 )
16651675 return int (response .get (schema .kind , {}).get ("count" , 0 ))
16661676
@@ -1920,7 +1930,7 @@ def process_batch() -> tuple[list[InfrahubNodeSync], list[InfrahubNodeSync]]:
19201930 related_nodes = []
19211931 batch_process = self .create_batch ()
19221932
1923- count = self .count (kind = schema .kind )
1933+ count = self .count (kind = schema .kind , ** filters )
19241934 total_pages = (count + pagination_size - 1 ) // pagination_size
19251935
19261936 for page_number in range (1 , total_pages + 1 ):
@@ -2296,7 +2306,7 @@ def allocate_next_ip_address(
22962306 def allocate_next_ip_address (
22972307 self ,
22982308 resource_pool : CoreNodeSync ,
2299- kind : Literal [ None ] = ...,
2309+ kind : None = ...,
23002310 identifier : str | None = ...,
23012311 prefix_length : int | None = ...,
23022312 address_type : str | None = ...,
@@ -2311,7 +2321,7 @@ def allocate_next_ip_address(
23112321 def allocate_next_ip_address (
23122322 self ,
23132323 resource_pool : CoreNodeSync ,
2314- kind : Literal [ None ] = ...,
2324+ kind : None = ...,
23152325 identifier : str | None = ...,
23162326 prefix_length : int | None = ...,
23172327 address_type : str | None = ...,
@@ -2326,7 +2336,7 @@ def allocate_next_ip_address(
23262336 def allocate_next_ip_address (
23272337 self ,
23282338 resource_pool : CoreNodeSync ,
2329- kind : Literal [ None ] = ...,
2339+ kind : None = ...,
23302340 identifier : str | None = ...,
23312341 prefix_length : int | None = ...,
23322342 address_type : str | None = ...,
@@ -2439,7 +2449,7 @@ def allocate_next_ip_prefix(
24392449 def allocate_next_ip_prefix (
24402450 self ,
24412451 resource_pool : CoreNodeSync ,
2442- kind : Literal [ None ] = ...,
2452+ kind : None = ...,
24432453 identifier : str | None = ...,
24442454 prefix_length : int | None = ...,
24452455 member_type : str | None = ...,
@@ -2455,7 +2465,7 @@ def allocate_next_ip_prefix(
24552465 def allocate_next_ip_prefix (
24562466 self ,
24572467 resource_pool : CoreNodeSync ,
2458- kind : Literal [ None ] = ...,
2468+ kind : None = ...,
24592469 identifier : str | None = ...,
24602470 prefix_length : int | None = ...,
24612471 member_type : str | None = ...,
@@ -2471,7 +2481,7 @@ def allocate_next_ip_prefix(
24712481 def allocate_next_ip_prefix (
24722482 self ,
24732483 resource_pool : CoreNodeSync ,
2474- kind : Literal [ None ] = ...,
2484+ kind : None = ...,
24752485 identifier : str | None = ...,
24762486 prefix_length : int | None = ...,
24772487 member_type : str | None = ...,
0 commit comments