diff options
author | John Estabrook <jestabro@vyos.io> | 2023-03-03 11:30:27 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-03-05 19:38:07 -0600 |
commit | 1e72e1c68a708518526b8e090f5d6482671cbd57 (patch) | |
tree | b1b040241ad157ba8cc165b42d47cf8d00fa5fc7 /src/op_mode/nat.py | |
parent | ae2db32a13d78c5014c7b770f2de28949a13a6c3 (diff) | |
download | vyos-1x-1e72e1c68a708518526b8e090f5d6482671cbd57.tar.gz vyos-1x-1e72e1c68a708518526b8e090f5d6482671cbd57.zip |
op-mode: T5051: use typing.Literal in op-mode scripts
Diffstat (limited to 'src/op_mode/nat.py')
-rwxr-xr-x | src/op_mode/nat.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/op_mode/nat.py b/src/op_mode/nat.py index cf06de0e9..c92795745 100755 --- a/src/op_mode/nat.py +++ b/src/op_mode/nat.py @@ -31,6 +31,8 @@ from vyos.util import dict_search base = 'nat' unconf_message = 'NAT is not configured' +ArgDirection = typing.Literal['source', 'destination'] +ArgFamily = typing.Literal['inet', 'inet6'] def _get_xml_translation(direction, family, address=None): """ @@ -298,7 +300,7 @@ def _verify(func): @_verify -def show_rules(raw: bool, direction: str, family: str): +def show_rules(raw: bool, direction: ArgDirection, family: ArgFamily): nat_rules = _get_raw_data_rules(direction, family) if raw: return nat_rules @@ -307,7 +309,7 @@ def show_rules(raw: bool, direction: str, family: str): @_verify -def show_statistics(raw: bool, direction: str, family: str): +def show_statistics(raw: bool, direction: ArgDirection, family: ArgFamily): nat_statistics = _get_raw_data_rules(direction, family) if raw: return nat_statistics @@ -316,8 +318,8 @@ def show_statistics(raw: bool, direction: str, family: str): @_verify -def show_translations(raw: bool, direction: - str, family: str, +def show_translations(raw: bool, direction: ArgDirection, + family: ArgFamily, address: typing.Optional[str], verbose: typing.Optional[bool]): family = 'ipv6' if family == 'inet6' else 'ipv4' |