1818
1919from netpalm .backend .core .cache .store import CacheStore
2020from netpalm .backend .core .confload .confload import NetpalmSettings , get_settings
21+ from pydantic import BaseModel
22+
2123from netpalm .backend .core .models .models import (
22- GetConfig ,
2324 QueueStrategy ,
24- Script ,
25- SetConfig ,
2625)
2726from netpalm .backend .core .queue .broker import QueueBroker
2827from netpalm .backend .core .queue .broker import TaskResponse as BrokerTaskResponse
@@ -51,7 +50,7 @@ def __init__(
5150
5251 # ── task operations ───────────────────────────────────────────────────────
5352
54- async def get_config (self , request : GetConfig ) -> dict [str , Any ]:
53+ async def get_config (self , request : BaseModel ) -> dict [str , Any ]:
5554 """
5655 Enqueue a getconfig job.
5756 If cache is enabled and a result exists, return it without enqueuing.
@@ -66,7 +65,7 @@ async def get_config(self, request: GetConfig) -> dict[str, Any]:
6665 cached = self ._cache .get (cache_key )
6766 if cached is not None :
6867 log .debug (f"NetpalmManager.get_config: cache hit for { cache_key } " )
69- return cached
68+ return cached # type: ignore[no-any-return]
7069
7170 strategy = req_data .get ("queue_strategy" , QueueStrategy .fifo )
7271 pinned_host = host if strategy == QueueStrategy .pinned else None
@@ -79,7 +78,7 @@ async def get_config(self, request: GetConfig) -> dict[str, Any]:
7978 )
8079 return _task_to_response (task )
8180
82- async def set_config (self , request : SetConfig ) -> dict [str , Any ]:
81+ async def set_config (self , request : BaseModel ) -> dict [str , Any ]:
8382 req_data = request .model_dump (exclude_none = True )
8483 conn = req_data .get ("connection_args" , {})
8584 host = conn .get ("host" , "" )
@@ -98,7 +97,7 @@ async def set_config(self, request: SetConfig) -> dict[str, Any]:
9897 )
9998 return _task_to_response (task )
10099
101- async def execute_script (self , request : Script ) -> dict [str , Any ]:
100+ async def execute_script (self , request : BaseModel ) -> dict [str , Any ]:
102101 req_data = request .model_dump (exclude_none = True )
103102 strategy = req_data .get ("queue_strategy" , QueueStrategy .fifo )
104103 pinned_host = req_data .get ("script" ) if strategy == QueueStrategy .pinned else None
0 commit comments