mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-06-21 09:35:45 +02:00
Add regexp field to ip dns static (#142)
* Add regexp field to "ip dns static" * Change test_invalid_required_missing to use "ip dhcp-server" "ip dns static" requires name or regexp so it cannot be used in this test. * Add required_one_of attribute to APIData Used by "ip dns static" which requires either "name" or "regexp. * Add mutually_exclusive attribute to APIData Used by "ip dns static" where only one of "name" or "regexp" can be used. * Add changelog fragment
This commit is contained in:
parent
62da7dd4e3
commit
586edbc211
5 changed files with 98 additions and 4 deletions
|
@ -465,6 +465,24 @@ def polish_entry(entry, path_info, module, for_text):
|
|||
for key, field_info in path_info.fields.items():
|
||||
if field_info.required and key not in entry:
|
||||
module.fail_json(msg='Key "{key}" must be present{for_text}.'.format(key=key, for_text=for_text))
|
||||
for require_list in path_info.required_one_of:
|
||||
found_req_keys = [rk for rk in require_list if rk in entry]
|
||||
if len(require_list) > 0 and not found_req_keys:
|
||||
module.fail_json(
|
||||
msg='Every element in data must contain one of {required_keys}. For example, the element{for_text} does not provide it.'.format(
|
||||
required_keys=', '.join(['"{k}"'.format(k=k) for k in require_list]),
|
||||
for_text=for_text,
|
||||
)
|
||||
)
|
||||
for exclusive_list in path_info.mutually_exclusive:
|
||||
found_ex_keys = [ek for ek in exclusive_list if ek in entry]
|
||||
if len(found_ex_keys) > 1:
|
||||
module.fail_json(
|
||||
msg='Keys {exclusive_keys} cannot be used at the same time{for_text}.'.format(
|
||||
exclusive_keys=', '.join(['"{k}"'.format(k=k) for k in found_ex_keys]),
|
||||
for_text=for_text,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def remove_irrelevant_data(entry, path_info):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue