diff --git a/changelogs/fragments/133-api.yml b/changelogs/fragments/133-api.yml new file mode 100644 index 0000000..ecd8a62 --- /dev/null +++ b/changelogs/fragments/133-api.yml @@ -0,0 +1,11 @@ +minor_changes: + - api_modify, api_info - support API paths - ``interface bonding``, ``interface bridge mlag``, ``ipv6 firewall mangle``, ``ipv6 nd``, ``system scheduler``, ``system script``, ``system ups`` + (https://github.com/ansible-collections/community.routeros/pull/133). + - api_modify, api_info - support fields ``jump-target``, ``reject-with`` in ``ip firewall filter`` API path, field ``comment`` in ``ip firwall address-list`` API path, field ``jump-target`` in ``ip firewall mangle`` API path, field ``comment`` in ``ipv6 firewall address-list`` API path, fields ``jump-target``, ``reject-with`` in ``ipv6 firewall filter`` API path + (https://github.com/ansible-collections/community.routeros/pull/133). + - api_modify, api_info - support fields ``address-list``, ``address-list-timeout``, ``connection-bytes``, ``connection-limit``, ``connection-mark``, ``connection-rate``, ``connection-type``, ``content``, ``disabled``, ``dscp``, ``dst-address-list``, ``dst-address-type``, ``dst-limit``, ``fragment``, ``hotspot``, ``icmp-options``, ``in-bridge-port``, ``in-bridge-port-list``, ``ingress-priority``, ``ipsec-policy``, ``ipv4-options``, ``jump-target``, ``layer7-protocol``, ``limit``, ``log``, ``log-prefix``, ``nth``, ``out-bridge-port``, ``out-bridge-port-list``, ``packet-mark``, ``packet-size``, ``per-connection-classifier``, ``port``, ``priority``, ``psd``, ``random``, ``realm``, ``routing-mark``, ``same-not-by-dst``, ``src-address``, ``src-address-list``, ``src-address-type``, ``src-mac-address``, ``src-port``, ``tcp-mss``, ``time``, ``tls-host``, ``ttl`` in ``ip firewall nat`` path + (https://github.com/ansible-collections/community.routeros/pull/133). + +bugfixes: + - api_modify, api_info - removed wrong field ``dynamic`` from API path ``ipv6 firewall address-list`` + (https://github.com/ansible-collections/community.routeros/pull/133). diff --git a/plugins/module_utils/_api_data.py b/plugins/module_utils/_api_data.py index c094821..133048c 100644 --- a/plugins/module_utils/_api_data.py +++ b/plugins/module_utils/_api_data.py @@ -80,6 +80,33 @@ def join_path(path): # 3. All bold attributes go into the `primary_keys` list -- this is not always true! PATHS = { + ('interface', 'bonding'): APIData( + fully_understood=True, + primary_keys=('name', ), + fields={ + 'arp': KeyInfo(default='enabled'), + 'arp-interval': KeyInfo(default='100ms'), + 'arp-ip-targets': KeyInfo(default=''), + 'arp-timeout': KeyInfo(default='auto'), + 'comment': KeyInfo(can_disable=True, remove_value=''), + 'disabled': KeyInfo(default=False), + 'down-delay': KeyInfo(default='0ms'), + 'forced-mac-address': KeyInfo(can_disable=True), + 'lacp-rate': KeyInfo(default='30secs'), + 'lacp-user-key': KeyInfo(can_disable=True, remove_value=0), + 'link-monitoring': KeyInfo(default='mii'), + 'mii-interval': KeyInfo(default='100ms'), + 'min-links': KeyInfo(default=0), + 'mlag-id': KeyInfo(can_disable=True, remove_value=0), + 'mode': KeyInfo(default='balance-rr'), + 'mtu': KeyInfo(default=1500), + 'name': KeyInfo(), + 'primary': KeyInfo(default='none'), + 'slaves': KeyInfo(required=True), + 'transmit-hash-policy': KeyInfo(default='layer-2'), + 'up-delay': KeyInfo(default='0ms'), + } + ), ('interface', 'bridge'): APIData( fully_understood=True, primary_keys=('name', ), @@ -852,6 +879,14 @@ PATHS = { 'unknown-unicast-flood': KeyInfo(default=True), }, ), + ('interface', 'bridge', 'mlag'): APIData( + single_value=True, + fully_understood=True, + fields={ + 'bridge': KeyInfo(default='none'), + 'peer-port': KeyInfo(default='none'), + } + ), ('interface', 'bridge', 'port-controller'): APIData( single_value=True, fully_understood=True, @@ -1247,6 +1282,7 @@ PATHS = { primary_keys=('address', 'list', ), fields={ 'address': KeyInfo(), + 'comment': KeyInfo(can_disable=True, remove_value=''), 'disabled': KeyInfo(default=False), 'list': KeyInfo(), }, @@ -1284,6 +1320,7 @@ PATHS = { 'ingress-priority': KeyInfo(can_disable=True), 'ipsec-policy': KeyInfo(can_disable=True), 'ipv4-options': KeyInfo(can_disable=True), + 'jump-target': KeyInfo(), 'layer7-protocol': KeyInfo(can_disable=True), 'limit': KeyInfo(can_disable=True), 'log': KeyInfo(), @@ -1302,6 +1339,7 @@ PATHS = { 'protocol': KeyInfo(can_disable=True), 'psd': KeyInfo(can_disable=True), 'random': KeyInfo(can_disable=True), + 'reject-with': KeyInfo(), 'routing-mark': KeyInfo(can_disable=True), 'routing-table': KeyInfo(can_disable=True), 'src-address': KeyInfo(can_disable=True), @@ -1348,6 +1386,7 @@ PATHS = { 'ingress-priority': KeyInfo(can_disable=True), 'ipsec-policy': KeyInfo(can_disable=True), 'ipv4-options': KeyInfo(can_disable=True), + 'jump-target': KeyInfo(), 'layer7-protocol': KeyInfo(can_disable=True), 'limit': KeyInfo(can_disable=True), 'log': KeyInfo(), @@ -1397,17 +1436,65 @@ PATHS = { stratify_keys=('chain', ), fields={ 'action': KeyInfo(), + 'address-list': KeyInfo(), + 'address-list-timeout': KeyInfo(), 'chain': KeyInfo(), 'comment': KeyInfo(can_disable=True, remove_value=''), + 'connection-bytes': KeyInfo(can_disable=True), + 'connection-limit': KeyInfo(can_disable=True), + 'connection-mark': KeyInfo(can_disable=True), + 'connection-rate': KeyInfo(can_disable=True), + 'connection-type': KeyInfo(can_disable=True), + 'content': KeyInfo(can_disable=True), + 'disabled': KeyInfo(), + 'dscp': KeyInfo(can_disable=True), 'dst-address': KeyInfo(can_disable=True), + 'dst-address-list': KeyInfo(can_disable=True), + 'dst-address-type': KeyInfo(can_disable=True), + 'dst-limit': KeyInfo(can_disable=True), 'dst-port': KeyInfo(can_disable=True), + 'fragment': KeyInfo(can_disable=True), + 'hotspot': KeyInfo(can_disable=True), + 'icmp-options': KeyInfo(can_disable=True), + 'in-bridge-port': KeyInfo(can_disable=True), + 'in-bridge-port-list': KeyInfo(can_disable=True), 'in-interface': KeyInfo(can_disable=True), 'in-interface-list': KeyInfo(can_disable=True), + 'ingress-priority': KeyInfo(can_disable=True), + 'ipsec-policy': KeyInfo(can_disable=True), + 'ipv4-options': KeyInfo(can_disable=True), + 'jump-target': KeyInfo(), + 'layer7-protocol': KeyInfo(can_disable=True), + 'limit': KeyInfo(can_disable=True), + 'log': KeyInfo(), + 'log-prefix': KeyInfo(), + 'nth': KeyInfo(can_disable=True), + 'out-bridge-port': KeyInfo(can_disable=True), + 'out-bridge-port-list': KeyInfo(can_disable=True), 'out-interface': KeyInfo(can_disable=True), 'out-interface-list': KeyInfo(can_disable=True), + 'packet-mark': KeyInfo(can_disable=True), + 'packet-size': KeyInfo(can_disable=True), + 'per-connection-classifier': KeyInfo(can_disable=True), + 'port': KeyInfo(can_disable=True), + 'priority': KeyInfo(can_disable=True), 'protocol': KeyInfo(can_disable=True), + 'psd': KeyInfo(can_disable=True), + 'random': KeyInfo(can_disable=True), + 'realm': KeyInfo(can_disable=True), + 'routing-mark': KeyInfo(can_disable=True), + 'same-not-by-dst': KeyInfo(), + 'src-address': KeyInfo(can_disable=True), + 'src-address-list': KeyInfo(can_disable=True), + 'src-address-type': KeyInfo(can_disable=True), + 'src-mac-address': KeyInfo(can_disable=True), + 'src-port': KeyInfo(can_disable=True), + 'tcp-mss': KeyInfo(can_disable=True), + 'time': KeyInfo(can_disable=True), + 'tls-host': KeyInfo(can_disable=True), 'to-addresses': KeyInfo(can_disable=True), 'to-ports': KeyInfo(can_disable=True), + 'ttl': KeyInfo(can_disable=True), }, ), ('ip', 'hotspot', 'user'): APIData( @@ -1633,8 +1720,8 @@ PATHS = { primary_keys=('address', 'list', ), fields={ 'address': KeyInfo(), + 'comment': KeyInfo(can_disable=True, remove_value=''), 'disabled': KeyInfo(default=False), - 'dynamic': KeyInfo(default=False), 'list': KeyInfo(), }, ), @@ -1668,6 +1755,7 @@ PATHS = { 'in-interface-list': KeyInfo(can_disable=True), 'ingress-priority': KeyInfo(can_disable=True), 'ipsec-policy': KeyInfo(can_disable=True), + 'jump-target': KeyInfo(), 'limit': KeyInfo(can_disable=True), 'log': KeyInfo(), 'log-prefix': KeyInfo(), @@ -1683,6 +1771,7 @@ PATHS = { 'priority': KeyInfo(can_disable=True), 'protocol': KeyInfo(can_disable=True), 'random': KeyInfo(can_disable=True), + 'reject-with': KeyInfo(), 'src-address': KeyInfo(can_disable=True), 'src-address-list': KeyInfo(can_disable=True), 'src-address-type': KeyInfo(can_disable=True), @@ -1693,24 +1782,97 @@ PATHS = { 'time': KeyInfo(can_disable=True), }, ), - ('ipv6', 'nd'): APIData( - unknown_mechanism=True, - # primary_keys=('default', ), + ('ipv6', 'firewall', 'mangle'): APIData( + fully_understood=True, + stratify_keys=('chain', ), fields={ - 'default': KeyInfo(), - 'advertise-dns': KeyInfo(), - 'advertise-mac-address': KeyInfo(), + 'action': KeyInfo(), + 'address-list': KeyInfo(), + 'address-list-timeout': KeyInfo(), + 'chain': KeyInfo(), + 'comment': KeyInfo(can_disable=True, remove_value=''), + 'connection-bytes': KeyInfo(can_disable=True), + 'connection-limit': KeyInfo(can_disable=True), + 'connection-mark': KeyInfo(can_disable=True), + 'connection-rate': KeyInfo(can_disable=True), + 'connection-state': KeyInfo(can_disable=True), + 'connection-type': KeyInfo(can_disable=True), + 'content': KeyInfo(can_disable=True), 'disabled': KeyInfo(), - 'hop-limit': KeyInfo(), + 'dscp': KeyInfo(can_disable=True), + 'dst-address': KeyInfo(can_disable=True), + 'dst-address-list': KeyInfo(can_disable=True), + 'dst-address-type': KeyInfo(can_disable=True), + 'dst-limit': KeyInfo(can_disable=True), + 'dst-port': KeyInfo(can_disable=True), + 'dst-prefix': KeyInfo(), + 'headers': KeyInfo(can_disable=True), + 'hop-limit': KeyInfo(can_disable=True), + 'icmp-options': KeyInfo(can_disable=True), + 'in-bridge-port': KeyInfo(can_disable=True), + 'in-bridge-port-list': KeyInfo(can_disable=True), + 'in-interface': KeyInfo(can_disable=True), + 'in-interface-list': KeyInfo(can_disable=True), + 'ingress-priority': KeyInfo(can_disable=True), + 'ipsec-policy': KeyInfo(can_disable=True), + 'jump-target': KeyInfo(), + 'limit': KeyInfo(can_disable=True), + 'log': KeyInfo(), + 'log-prefix': KeyInfo(), + 'new-connection-mark': KeyInfo(), + 'new-dscp': KeyInfo(), + 'new-hop-limit': KeyInfo(), + 'new-mss': KeyInfo(), + 'new-packet-mark': KeyInfo(), + 'new-routing-mark': KeyInfo(), + 'nth': KeyInfo(can_disable=True), + 'out-bridge-port': KeyInfo(can_disable=True), + 'out-bridge-port-list': KeyInfo(can_disable=True), + 'out-interface': KeyInfo(can_disable=True), + 'out-interface-list': KeyInfo(can_disable=True), + 'packet-mark': KeyInfo(can_disable=True), + 'packet-size': KeyInfo(can_disable=True), + 'passthrough': KeyInfo(), + 'per-connection-classifier': KeyInfo(can_disable=True), + 'port': KeyInfo(can_disable=True), + 'priority': KeyInfo(can_disable=True), + 'protocol': KeyInfo(can_disable=True), + 'random': KeyInfo(can_disable=True), + 'routing-mark': KeyInfo(can_disable=True), + 'sniff-id': KeyInfo(), + 'sniff-target': KeyInfo(), + 'sniff-target-port': KeyInfo(), + 'src-address': KeyInfo(can_disable=True), + 'src-address-list': KeyInfo(can_disable=True), + 'src-address-type': KeyInfo(can_disable=True), + 'src-mac-address': KeyInfo(can_disable=True), + 'src-port': KeyInfo(can_disable=True), + 'src-prefix': KeyInfo(), + 'tcp-flags': KeyInfo(can_disable=True), + 'tcp-mss': KeyInfo(can_disable=True), + 'time': KeyInfo(can_disable=True), + 'tls-host': KeyInfo(can_disable=True), + } + ), + ('ipv6', 'nd'): APIData( + fully_understood=True, + primary_keys=('interface', ), + fields={ + 'advertise-dns': KeyInfo(default=True), + 'advertise-mac-address': KeyInfo(default=True), + 'disabled': KeyInfo(default=False), + 'dns': KeyInfo(default=''), + 'hop-limit': KeyInfo(default='unspecified'), 'interface': KeyInfo(), - 'managed-address-configuration': KeyInfo(), - 'mtu': KeyInfo(), - 'other-configuration': KeyInfo(), - 'ra-delay': KeyInfo(), - 'ra-interval': KeyInfo(), - 'ra-lifetime': KeyInfo(), - 'reachable-time': KeyInfo(), - 'retransmit-interval': KeyInfo(), + 'managed-address-configuration': KeyInfo(default=False), + 'mtu': KeyInfo(default='unspecified'), + 'other-configuration': KeyInfo(default=False), + 'ra-delay': KeyInfo(default='3s'), + 'ra-interval': KeyInfo(default='3m20s-10m'), + 'ra-lifetime': KeyInfo(default='30m'), + 'ra-preference': KeyInfo(default='medium'), + 'reachable-time': KeyInfo(default='unspecified'), + 'retransmit-interval': KeyInfo(default='unspecified'), }, ), ('ipv6', 'nd', 'prefix', 'default'): APIData( @@ -2003,6 +2165,20 @@ PATHS = { 'user': KeyInfo(default=''), }, ), + ('system', 'ups'): APIData( + fully_understood=True, + primary_keys=('name', ), + fields={ + 'alarm-setting': KeyInfo(default='immediate'), + 'check-capabilities': KeyInfo(can_disable=True, remove_value=True), + 'comment': KeyInfo(can_disable=True, remove_value=''), + 'disabled': KeyInfo(default=True), + 'min-runtime': KeyInfo(default='never'), + 'name': KeyInfo(), + 'offline-time': KeyInfo(default='0s'), + 'port': KeyInfo(required=True), + }, + ), ('system', 'watchdog'): APIData( single_value=True, fully_understood=True, @@ -2404,4 +2580,30 @@ PATHS = { 'cpu': KeyInfo(), }, ), + ('system', 'scheduler'): APIData( + fully_understood=True, + primary_keys=('name', ), + fields={ + 'comment': KeyInfo(can_disable=True, remove_value=''), + 'disabled': KeyInfo(default=False), + 'interval': KeyInfo(default='0s'), + 'name': KeyInfo(), + 'on-event': KeyInfo(default=''), + 'policy': KeyInfo(default='ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon'), + 'start-date': KeyInfo(), + 'start-time': KeyInfo(), + }, + ), + ('system', 'script'): APIData( + fully_understood=True, + primary_keys=('name',), + fields={ + 'comment': KeyInfo(can_disable=True, remove_value=''), + 'dont-require-permissions': KeyInfo(default=False), + 'name': KeyInfo(), + 'owner': KeyInfo(), + 'policy': KeyInfo(default='ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon'), + 'source': KeyInfo(default=''), + }, + ), } diff --git a/plugins/modules/api_info.py b/plugins/modules/api_info.py index f8e9337..958d5dc 100644 --- a/plugins/modules/api_info.py +++ b/plugins/modules/api_info.py @@ -50,7 +50,9 @@ options: - caps-man provisioning - caps-man security - certificate settings + - interface bonding - interface bridge + - interface bridge mlag - interface bridge port - interface bridge port-controller - interface bridge port-extender @@ -120,6 +122,8 @@ options: - ipv6 dhcp-server option - ipv6 firewall address-list - ipv6 firewall filter + - ipv6 firewall mangle + - ipv6 nd - ipv6 nd prefix default - ipv6 route - ipv6 settings @@ -153,7 +157,10 @@ options: - system ntp server - system package update - system routerboard settings + - system scheduler + - system script - system upgrade mirror + - system ups - system watchdog - tool bandwidth-server - tool e-mail diff --git a/plugins/modules/api_modify.py b/plugins/modules/api_modify.py index fc57ee0..c8f0d74 100644 --- a/plugins/modules/api_modify.py +++ b/plugins/modules/api_modify.py @@ -55,7 +55,9 @@ options: - caps-man provisioning - caps-man security - certificate settings + - interface bonding - interface bridge + - interface bridge mlag - interface bridge port - interface bridge port-controller - interface bridge port-extender @@ -125,6 +127,8 @@ options: - ipv6 dhcp-server option - ipv6 firewall address-list - ipv6 firewall filter + - ipv6 firewall mangle + - ipv6 nd - ipv6 nd prefix default - ipv6 route - ipv6 settings @@ -158,7 +162,10 @@ options: - system ntp server - system package update - system routerboard settings + - system scheduler + - system script - system upgrade mirror + - system ups - system watchdog - tool bandwidth-server - tool e-mail diff --git a/tests/unit/plugins/modules/test_api_info.py b/tests/unit/plugins/modules/test_api_info.py index 70a5ab6..8478daa 100644 --- a/tests/unit/plugins/modules/test_api_info.py +++ b/tests/unit/plugins/modules/test_api_info.py @@ -220,6 +220,7 @@ class TestRouterosApiInfoModule(ModuleTestCase): '!ingress-priority': None, '!ipsec-policy': None, '!ipv4-options': None, + '!jump-target': None, '!layer7-protocol': None, '!limit': None, '!log': None, @@ -238,6 +239,7 @@ class TestRouterosApiInfoModule(ModuleTestCase): '!protocol': None, '!psd': None, '!random': None, + '!reject-with': None, '!routing-mark': None, '!routing-table': None, '!src-address': None, @@ -304,6 +306,7 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'ingress-priority': None, 'ipsec-policy': None, 'ipv4-options': None, + 'jump-target': None, 'layer7-protocol': None, 'limit': None, 'log': None, @@ -322,6 +325,7 @@ class TestRouterosApiInfoModule(ModuleTestCase): 'protocol': None, 'psd': None, 'random': None, + 'reject-with': None, 'routing-mark': None, 'routing-table': None, 'src-address': None,