diff options
author | Daniil Baturin <daniil@vyos.io> | 2023-03-07 19:51:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-07 19:51:18 +0000 |
commit | 06e810ffc398366f7d4cc00241e0692e6fe81620 (patch) | |
tree | a1e2d444b83eadbb8f0e7f43b6493a03c6f90c8a /src/op_mode/nat.py | |
parent | 9f0857c2e7821ea22d5132d6352ee8cbcb64b738 (diff) | |
parent | 1e72e1c68a708518526b8e090f5d6482671cbd57 (diff) | |
download | vyos-1x-06e810ffc398366f7d4cc00241e0692e6fe81620.tar.gz vyos-1x-06e810ffc398366f7d4cc00241e0692e6fe81620.zip |
Merge pull request #1868 from jestabro/literal
op-mode: T5051: use Literal types to provide op-mode CLI choices and API enums
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' |