mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-08-17 16:21:21 +02:00
Support absent values. Support absent value 'all' for 'server' in /ip dhcp-server lease. (#107)
This commit is contained in:
parent
a2ace3fb79
commit
f797b4a231
7 changed files with 232 additions and 10 deletions
|
@ -46,18 +46,21 @@ class APIData(object):
|
|||
|
||||
|
||||
class KeyInfo(object):
|
||||
def __init__(self, _dummy=None, can_disable=False, remove_value=None, default=None, required=False, automatically_computed_from=None):
|
||||
def __init__(self, _dummy=None, can_disable=False, remove_value=None, absent_value=None, default=None, required=False, automatically_computed_from=None):
|
||||
if _dummy is not None:
|
||||
raise ValueError('KeyInfo() does not have positional arguments')
|
||||
if sum([required, default is not None, automatically_computed_from is not None, can_disable]) > 1:
|
||||
raise ValueError('required, default, automatically_computed_from, and can_disable are mutually exclusive')
|
||||
if not can_disable and remove_value is not None:
|
||||
raise ValueError('remove_value can only be specified if can_disable=True')
|
||||
if absent_value is not None and any([default is not None, automatically_computed_from is not None, can_disable]):
|
||||
raise ValueError('absent_value can not be combined with default, automatically_computed_from, can_disable=True, or absent_value')
|
||||
self.can_disable = can_disable
|
||||
self.remove_value = remove_value
|
||||
self.automatically_computed_from = automatically_computed_from
|
||||
self.default = default
|
||||
self.required = required
|
||||
self.absent_value = absent_value
|
||||
|
||||
|
||||
def split_path(path):
|
||||
|
@ -755,7 +758,7 @@ PATHS = {
|
|||
'disabled': KeyInfo(default=False),
|
||||
'insert-queue-before': KeyInfo(can_disable=True),
|
||||
'mac-address': KeyInfo(can_disable=True, remove_value=''),
|
||||
'server': KeyInfo(),
|
||||
'server': KeyInfo(absent_value='all'),
|
||||
},
|
||||
),
|
||||
('ip', 'dhcp-server', 'network'): APIData(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue