move rule

This commit is contained in:
2026-02-28 15:29:50 +01:00
parent 2c6cb2b7d9
commit 60fd926fc6
4 changed files with 467 additions and 141 deletions

View File

@@ -45,9 +45,83 @@ export interface CmdResult {
cmd: string;
out?: ExecResult;
err?: string;
};
}
export interface TableProp {
family: string;
name: string;
};
}
/**
* Types derived from Python Pydantic models:
* - MoveRequest
* - MoveSubResult
* - MoveResult
*
* Field names intentionally match the Python/JSON names (snake_case) so they work
* directly with your backend API.
*/
/**
* ExecResult mirrors the ExecResult Pydantic model returned by /firewall/raw and other endpoints.
*/
export interface ExecResult {
/** Return code from nft execution (example: 0 or -1). */
rc: number;
/** Standard output from nft (may be null/undefined). */
stdout?: string | null;
/** Standard error from nft (may be null/undefined). */
stderr?: string | null;
}
/**
* Request body for moving a rule.
* Exactly one of position / before_handle / to_top / to_bottom is typically provided.
*
* Examples:
* - Move to top: { family: "bridge", table: "filter", chain: "forward", to_top: true }
* - Move before handle: { family: "inet", table: "filter", chain: "input", before_handle: 42 }
* - Insert at position: { family: "ip", table: "filter", chain: "forward", position: 0 }
*/
export interface MoveRequest {
/** Table family, e.g. "bridge", "inet", "ip", "ip6". */
family: string;
/** Table name, e.g. "filter". */
table: string;
/** Chain name, e.g. "forward". */
chain: string;
/** Zero-based position to insert at (0 = top). Optional. */
position?: number | null;
/** Insert before this existing handle in the same chain. Optional. */
before_handle?: number | null;
/** Move to top (equivalent to position=0). Optional; default false on server. */
to_top?: boolean;
/** Move to bottom (append). Optional; default false on server. */
to_bottom?: boolean;
}
/**
* Sub-result for the move action (what was added / what was deleted).
* Mirrors MoveSubResult(BaseModel).
*/
export interface MoveSubResult {
/** Executed command as text (e.g. "add rule ..."). */
cmd: string;
/** Exec result if command was executed (may be null/undefined). */
out?: ExecResult | null;
/** Error string if the operation failed (may be null/undefined). */
err?: string | null;
}
/**
* Overall move result: what was added and what was deleted.
* Mirrors MoveResult(BaseModel).
*/
export interface MoveResult {
added: MoveSubResult;
deleted: MoveSubResult;
}