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:
Felix Fontein 2023-09-01 22:27:18 +02:00 committed by GitHub
parent 1ed4690240
commit 4b0995135c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 3158 additions and 2710 deletions

View file

@ -97,6 +97,7 @@ def _ros_api_connect(module, username, password, host, port, use_tls, force_no_c
def create_api(module):
"""Create an API object."""
return _ros_api_connect(
module,
module.params['username'],
@ -111,3 +112,9 @@ def create_api(module):
module.params['encoding'],
module.params['timeout'],
)
def get_api_version(api):
"""Given an API object, query the system's version."""
system_info = list(api.path().join('system', 'resource'))[0]
return system_info['version'].split(' ', 1)[0]