mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 02:00:46 +08:00
feat(UME): 网元与告警统一marker分页能力
将 marker 分页逻辑抽象为通用流程并同时应用于网元和告警同步,默认按 limit+marker 拉取全量数据,统一处理 is-end-of-reply、缺失marker和重复页保护。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
00afaaae3d
commit
037873423d
3 changed files with 178 additions and 53 deletions
|
|
@ -442,8 +442,23 @@ class UMEClient:
|
|||
walk(payload)
|
||||
return found
|
||||
|
||||
def get_network_elements(self) -> tuple[list[dict[str, Any]], RequestDiagnostics]:
|
||||
data, diag = self.request_json("GET", self.ne_path)
|
||||
def get_network_elements(
|
||||
self,
|
||||
*,
|
||||
limit: int | None = None,
|
||||
marker: str | None = None,
|
||||
) -> tuple[list[dict[str, Any]], RequestDiagnostics]:
|
||||
limit_max = int(getattr(settings, "ume_limit_max", 5000) or 5000)
|
||||
limit_max = max(1, limit_max)
|
||||
page_size = int(limit or settings.ume_page_size or 1000)
|
||||
page_size = max(1, min(page_size, limit_max))
|
||||
params: dict[str, Any] = {
|
||||
"limit": page_size,
|
||||
}
|
||||
marker_value = str(marker or "").strip()
|
||||
if marker_value:
|
||||
params["marker"] = marker_value
|
||||
data, diag = self.request_json("GET", self.ne_path, params=params)
|
||||
rows = self._extract_named_list(data, ["network-elements", "network-element", "ne", "network_elements"])
|
||||
if rows:
|
||||
return rows, diag
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue