mirror of
https://github.com/ansible-collections/community.routeros.git
synced 2025-06-21 09:35:45 +02:00
Allow to differ on API paths based on RouterOS version (1/2) (#209)
* Allow to provide definition for path based on API version.
* The paths added in 343c4883c0
are RouterOS 7+.
This commit is contained in:
parent
1ed4690240
commit
4b0995135c
7 changed files with 3158 additions and 2710 deletions
|
@ -282,6 +282,7 @@ from ansible_collections.community.routeros.plugins.module_utils.api import (
|
|||
api_argument_spec,
|
||||
check_has_library,
|
||||
create_api,
|
||||
get_api_version,
|
||||
)
|
||||
|
||||
from ansible_collections.community.routeros.plugins.module_utils._api_data import (
|
||||
|
@ -324,9 +325,14 @@ def main():
|
|||
api = create_api(module)
|
||||
|
||||
path = split_path(module.params['path'])
|
||||
path_info = PATHS.get(tuple(path))
|
||||
if path_info is None:
|
||||
versioned_path_info = PATHS.get(tuple(path))
|
||||
if versioned_path_info is None:
|
||||
module.fail_json(msg='Path /{path} is not yet supported'.format(path='/'.join(path)))
|
||||
if versioned_path_info.needs_version:
|
||||
api_version = get_api_version(api)
|
||||
if not versioned_path_info.provide_version(api_version):
|
||||
module.fail_json(msg='Path /{path} is not supported for API version {api_version}'.format(path='/'.join(path), api_version=api_version))
|
||||
path_info = versioned_path_info.get_data()
|
||||
|
||||
handle_disabled = module.params['handle_disabled']
|
||||
hide_defaults = module.params['hide_defaults']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue