Best Python code snippet using lisa_python
_api_data.py
Source:_api_data.py  
1# -*- coding: utf-8 -*-2# Copyright (c) 2022, Felix Fontein (@felixfontein) <felix@fontein.de>3# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)4# SPDX-License-Identifier: GPL-3.0-or-later5# The data inside here is private to this collection. If you use this from outside the collection,6# you are on your own. There can be random changes to its format even in bugfix releases!7from __future__ import absolute_import, division, print_function8__metaclass__ = type9class APIData(object):10    def __init__(self, primary_keys=None,11                 stratify_keys=None,12                 has_identifier=False,13                 single_value=False,14                 unknown_mechanism=False,15                 fully_understood=False,16                 fixed_entries=False,17                 fields=None):18        if sum([primary_keys is not None, stratify_keys is not None, has_identifier, single_value, unknown_mechanism]) > 1:19            raise ValueError('primary_keys, stratify_keys, has_identifier, single_value, and unknown_mechanism are mutually exclusive')20        if unknown_mechanism and fully_understood:21            raise ValueError('unknown_mechanism and fully_understood cannot be combined')22        self.primary_keys = primary_keys23        self.stratify_keys = stratify_keys24        self.has_identifier = has_identifier25        self.single_value = single_value26        self.unknown_mechanism = unknown_mechanism27        self.fully_understood = fully_understood28        self.fixed_entries = fixed_entries29        if fixed_entries and primary_keys is None:30            raise ValueError('fixed_entries can only be used with primary_keys')31        if fields is None:32            raise ValueError('fields must be provided')33        self.fields = fields34        if primary_keys:35            for pk in primary_keys:36                if pk not in fields:37                    raise ValueError('Primary key {pk} must be in fields!'.format(pk=pk))38        if stratify_keys:39            for sk in stratify_keys:40                if sk not in fields:41                    raise ValueError('Stratify key {sk} must be in fields!'.format(sk=sk))42class KeyInfo(object):43    def __init__(self, _dummy=None, can_disable=False, remove_value=None, absent_value=None, default=None, required=False, automatically_computed_from=None):44        if _dummy is not None:45            raise ValueError('KeyInfo() does not have positional arguments')46        if sum([required, default is not None, automatically_computed_from is not None, can_disable]) > 1:47            raise ValueError('required, default, automatically_computed_from, and can_disable are mutually exclusive')48        if not can_disable and remove_value is not None:49            raise ValueError('remove_value can only be specified if can_disable=True')50        if absent_value is not None and any([default is not None, automatically_computed_from is not None, can_disable]):51            raise ValueError('absent_value can not be combined with default, automatically_computed_from, can_disable=True, or absent_value')52        self.can_disable = can_disable53        self.remove_value = remove_value54        self.automatically_computed_from = automatically_computed_from55        self.default = default56        self.required = required57        self.absent_value = absent_value58def split_path(path):59    return path.split()60def join_path(path):61    return ' '.join(path)62# How to obtain this information:63# 1. Run `/export verbose` in the CLI;64# 2. All attributes listed there go into the `fields` list;65#    attributes which can have a `!` ahead should have `canDisable=True`66# 3. All bold attributes go into the `primary_keys` list -- this is not always true!67PATHS = {68    ('interface', 'bridge'): APIData(69        # fully_understood=True,70        primary_keys=('name', ),71        fields={72            'admin-mac': KeyInfo(),73            'ageing-time': KeyInfo(default='5m'),74            'arp': KeyInfo(default='enabled'),75            'arp-timeout': KeyInfo(default='auto'),76            'auto-mac': KeyInfo(default=False),77            'comment': KeyInfo(can_disable=True, remove_value=''),78            'dhcp-snooping': KeyInfo(default=False),79            'disabled': KeyInfo(default=False),80            'fast-forward': KeyInfo(default=True),81            'forward-delay': KeyInfo(default='15s'),82            'igmp-snooping': KeyInfo(default=False),83            'max-message-age': KeyInfo(default='20s'),84            'mtu': KeyInfo(default='auto'),85            'name': KeyInfo(),86            'priority': KeyInfo(default='0x8000'),87            'protocol-mode': KeyInfo(default='rstp'),88            'transmit-hold-count': KeyInfo(default=6),89            'vlan-filtering': KeyInfo(default=False),90        },91    ),92    ('interface', 'ethernet'): APIData(93        fixed_entries=True,94        fully_understood=True,95        primary_keys=('default-name', ),96        fields={97            'default-name': KeyInfo(),98            'advertise': KeyInfo(),99            'arp': KeyInfo(default='enabled'),100            'arp-timeout': KeyInfo(default='auto'),101            'auto-negotiation': KeyInfo(default=True),102            'bandwidth': KeyInfo(default='unlimited/unlimited'),103            'disabled': KeyInfo(default=False),104            'full-duplex': KeyInfo(default=True),105            'l2mtu': KeyInfo(default=1598),106            'loop-protect': KeyInfo(default='default'),107            'loop-protect-disable-time': KeyInfo(default='5m'),108            'loop-protect-send-interval': KeyInfo(default='5s'),109            'mac-address': KeyInfo(),110            'mtu': KeyInfo(default=1500),111            'name': KeyInfo(),112            'orig-mac-address': KeyInfo(),113            'rx-flow-control': KeyInfo(default='off'),114            'sfp-rate-select': KeyInfo(default='high'),115            'sfp-shutdown-temperature': KeyInfo(default='95C'),116            'speed': KeyInfo(),117            'tx-flow-control': KeyInfo(default='off'),118        },119    ),120    ('interface', 'list'): APIData(121        primary_keys=('name', ),122        fields={123            'comment': KeyInfo(can_disable=True, remove_value=''),124            'exclude': KeyInfo(),125            'include': KeyInfo(),126            'name': KeyInfo(),127        },128    ),129    ('interface', 'lte', 'apn'): APIData(130        unknown_mechanism=True,131        # primary_keys=('default', ),132        fields={133            'default': KeyInfo(),134            'add-default-route': KeyInfo(),135            'apn': KeyInfo(),136            'default-route-distance': KeyInfo(),137            'name': KeyInfo(),138            'use-peer-dns': KeyInfo(),139        },140    ),141    ('interface', 'wireless', 'security-profiles'): APIData(142        unknown_mechanism=True,143        # primary_keys=('default', ),144        fields={145            'default': KeyInfo(),146            'authentication-types': KeyInfo(),147            'disable-pmkid': KeyInfo(),148            'eap-methods': KeyInfo(),149            'group-ciphers': KeyInfo(),150            'group-key-update': KeyInfo(),151            'interim-update': KeyInfo(),152            'management-protection': KeyInfo(),153            'management-protection-key': KeyInfo(),154            'mode': KeyInfo(),155            'mschapv2-password': KeyInfo(),156            'mschapv2-username': KeyInfo(),157            'name': KeyInfo(),158            'radius-called-format': KeyInfo(),159            'radius-eap-accounting': KeyInfo(),160            'radius-mac-accounting': KeyInfo(),161            'radius-mac-authentication': KeyInfo(),162            'radius-mac-caching': KeyInfo(),163            'radius-mac-format': KeyInfo(),164            'radius-mac-mode': KeyInfo(),165            'static-algo-0': KeyInfo(),166            'static-algo-1': KeyInfo(),167            'static-algo-2': KeyInfo(),168            'static-algo-3': KeyInfo(),169            'static-key-0': KeyInfo(),170            'static-key-1': KeyInfo(),171            'static-key-2': KeyInfo(),172            'static-key-3': KeyInfo(),173            'static-sta-private-algo': KeyInfo(),174            'static-sta-private-key': KeyInfo(),175            'static-transmit-key': KeyInfo(),176            'supplicant-identity': KeyInfo(),177            'tls-certificate': KeyInfo(),178            'tls-mode': KeyInfo(),179            'unicast-ciphers': KeyInfo(),180            'wpa-pre-shared-key': KeyInfo(),181            'wpa2-pre-shared-key': KeyInfo(),182        },183    ),184    ('ip', 'hotspot', 'profile'): APIData(185        unknown_mechanism=True,186        # primary_keys=('default', ),187        fields={188            'default': KeyInfo(),189            'dns-name': KeyInfo(),190            'hotspot-address': KeyInfo(),191            'html-directory': KeyInfo(),192            'html-directory-override': KeyInfo(),193            'http-cookie-lifetime': KeyInfo(),194            'http-proxy': KeyInfo(),195            'login-by': KeyInfo(),196            'name': KeyInfo(),197            'rate-limit': KeyInfo(),198            'smtp-server': KeyInfo(),199            'split-user-domain': KeyInfo(),200            'use-radius': KeyInfo(),201        },202    ),203    ('ip', 'hotspot', 'user', 'profile'): APIData(204        unknown_mechanism=True,205        # primary_keys=('default', ),206        fields={207            'default': KeyInfo(),208            'add-mac-cookie': KeyInfo(),209            'address-list': KeyInfo(),210            'idle-timeout': KeyInfo(),211            'insert-queue-before': KeyInfo(can_disable=True),212            'keepalive-timeout': KeyInfo(),213            'mac-cookie-timeout': KeyInfo(),214            'name': KeyInfo(),215            'parent-queue': KeyInfo(can_disable=True),216            'queue-type': KeyInfo(can_disable=True),217            'shared-users': KeyInfo(),218            'status-autorefresh': KeyInfo(),219            'transparent-proxy': KeyInfo(),220        },221    ),222    ('ip', 'ipsec', 'mode-config'): APIData(223        unknown_mechanism=True,224        # primary_keys=('default', ),225        fields={226            'default': KeyInfo(),227            'name': KeyInfo(),228            'responder': KeyInfo(),229            'use-responder-dns': KeyInfo(),230        },231    ),232    ('ip', 'ipsec', 'policy', 'group'): APIData(233        unknown_mechanism=True,234        # primary_keys=('default', ),235        fields={236            'default': KeyInfo(),237            'name': KeyInfo(),238        },239    ),240    ('ip', 'ipsec', 'profile'): APIData(241        unknown_mechanism=True,242        # primary_keys=('default', ),243        fields={244            'default': KeyInfo(),245            'dh-group': KeyInfo(),246            'dpd-interval': KeyInfo(),247            'dpd-maximum-failures': KeyInfo(),248            'enc-algorithm': KeyInfo(),249            'hash-algorithm': KeyInfo(),250            'lifetime': KeyInfo(),251            'name': KeyInfo(),252            'nat-traversal': KeyInfo(),253            'proposal-check': KeyInfo(),254        },255    ),256    ('ip', 'ipsec', 'proposal'): APIData(257        unknown_mechanism=True,258        # primary_keys=('default', ),259        fields={260            'default': KeyInfo(),261            'auth-algorithms': KeyInfo(),262            'disabled': KeyInfo(),263            'enc-algorithms': KeyInfo(),264            'lifetime': KeyInfo(),265            'name': KeyInfo(),266            'pfs-group': KeyInfo(),267        },268    ),269    ('ip', 'pool'): APIData(270        fully_understood=True,271        primary_keys=('name', ),272        fields={273            'name': KeyInfo(),274            'ranges': KeyInfo(),275        },276    ),277    ('ip', 'dhcp-server'): APIData(278        fully_understood=True,279        primary_keys=('name', ),280        fields={281            'address-pool': KeyInfo(required=True),282            'authoritative': KeyInfo(default=True),283            'disabled': KeyInfo(default=False),284            'interface': KeyInfo(required=True),285            'lease-script': KeyInfo(default=''),286            'lease-time': KeyInfo(default='10m'),287            'name': KeyInfo(),288            'use-radius': KeyInfo(default=False),289        },290    ),291    ('routing', 'ospf', 'instance'): APIData(292        unknown_mechanism=True,293        # primary_keys=('default', ),294        fields={295            'default': KeyInfo(),296            'disabled': KeyInfo(),297            'distribute-default': KeyInfo(),298            'domain-id': KeyInfo(can_disable=True),299            'domain-tag': KeyInfo(can_disable=True),300            'in-filter': KeyInfo(),301            'metric-bgp': KeyInfo(),302            'metric-connected': KeyInfo(),303            'metric-default': KeyInfo(),304            'metric-other-ospf': KeyInfo(),305            'metric-rip': KeyInfo(),306            'metric-static': KeyInfo(),307            'mpls-te-area': KeyInfo(can_disable=True),308            'mpls-te-router-id': KeyInfo(can_disable=True),309            'name': KeyInfo(),310            'out-filter': KeyInfo(),311            'redistribute-bgp': KeyInfo(),312            'redistribute-connected': KeyInfo(),313            'redistribute-other-ospf': KeyInfo(),314            'redistribute-rip': KeyInfo(),315            'redistribute-static': KeyInfo(),316            'router-id': KeyInfo(),317            'routing-table': KeyInfo(can_disable=True),318            'use-dn': KeyInfo(can_disable=True),319        },320    ),321    ('routing', 'ospf', 'area'): APIData(322        unknown_mechanism=True,323        # primary_keys=('default', ),324        fields={325            'default': KeyInfo(),326            'area-id': KeyInfo(),327            'disabled': KeyInfo(),328            'instance': KeyInfo(),329            'name': KeyInfo(),330            'type': KeyInfo(),331        },332    ),333    ('routing', 'ospf-v3', 'instance'): APIData(334        unknown_mechanism=True,335        # primary_keys=('default', ),336        fields={337            'default': KeyInfo(),338            'disabled': KeyInfo(),339            'distribute-default': KeyInfo(),340            'metric-bgp': KeyInfo(),341            'metric-connected': KeyInfo(),342            'metric-default': KeyInfo(),343            'metric-other-ospf': KeyInfo(),344            'metric-rip': KeyInfo(),345            'metric-static': KeyInfo(),346            'name': KeyInfo(),347            'redistribute-bgp': KeyInfo(),348            'redistribute-connected': KeyInfo(),349            'redistribute-other-ospf': KeyInfo(),350            'redistribute-rip': KeyInfo(),351            'redistribute-static': KeyInfo(),352            'router-id': KeyInfo(),353        },354    ),355    ('routing', 'ospf-v3', 'area'): APIData(356        unknown_mechanism=True,357        # primary_keys=('default', ),358        fields={359            'default': KeyInfo(),360            'area-id': KeyInfo(),361            'disabled': KeyInfo(),362            'instance': KeyInfo(),363            'name': KeyInfo(),364            'type': KeyInfo(),365        },366    ),367    ('snmp', 'community'): APIData(368        unknown_mechanism=True,369        # primary_keys=('default', ),370        fields={371            'default': KeyInfo(),372            'addresses': KeyInfo(),373            'authentication-password': KeyInfo(),374            'authentication-protocol': KeyInfo(),375            'disabled': KeyInfo(),376            'encryption-password': KeyInfo(),377            'encryption-protocol': KeyInfo(),378            'name': KeyInfo(),379            'read-access': KeyInfo(),380            'security': KeyInfo(),381            'write-access': KeyInfo(),382        },383    ),384    ('caps-man', 'aaa'): APIData(385        single_value=True,386        fully_understood=True,387        fields={388            'called-format': KeyInfo(default='mac:ssid'),389            'interim-update': KeyInfo(default='disabled'),390            'mac-caching': KeyInfo(default='disabled'),391            'mac-format': KeyInfo(default='XX:XX:XX:XX:XX:XX'),392            'mac-mode': KeyInfo(default='as-username'),393        },394    ),395    ('caps-man', 'manager', 'interface'): APIData(396        unknown_mechanism=True,397        # primary_keys=('default', ),398        fields={399            'default': KeyInfo(),400            'disabled': KeyInfo(),401            'forbid': KeyInfo(),402            'interface': KeyInfo(),403        },404    ),405    ('certificate', 'settings'): APIData(406        single_value=True,407        fully_understood=True,408        fields={409            'crl-download': KeyInfo(default=False),410            'crl-store': KeyInfo(default='ram'),411            'crl-use': KeyInfo(default=False),412        },413    ),414    ('interface', 'bridge', 'port'): APIData(415        fully_understood=True,416        primary_keys=('interface', ),417        fields={418            'auto-isolate': KeyInfo(default=False),419            'bpdu-guard': KeyInfo(default=False),420            'bridge': KeyInfo(required=True),421            'broadcast-flood': KeyInfo(default=True),422            'comment': KeyInfo(can_disable=True, remove_value=''),423            'disabled': KeyInfo(default=False),424            'edge': KeyInfo(default='auto'),425            'fast-leave': KeyInfo(default=False),426            'frame-types': KeyInfo(default='admit-all'),427            'horizon': KeyInfo(default='none'),428            'hw': KeyInfo(default=True),429            'ingress-filtering': KeyInfo(default=False),430            'interface': KeyInfo(),431            'internal-path-cost': KeyInfo(default=10),432            'learn': KeyInfo(default='auto'),433            'multicast-router': KeyInfo(default='temporary-query'),434            'path-cost': KeyInfo(default=10),435            'point-to-point': KeyInfo(default='auto'),436            'priority': KeyInfo(default='0x80'),437            'pvid': KeyInfo(default=1),438            'restricted-role': KeyInfo(default=False),439            'restricted-tcn': KeyInfo(default=False),440            'tag-stacking': KeyInfo(default=False),441            'trusted': KeyInfo(default=False),442            'unknown-multicast-flood': KeyInfo(default=True),443            'unknown-unicast-flood': KeyInfo(default=True),444        },445    ),446    ('interface', 'bridge', 'port-controller'): APIData(447        single_value=True,448        fully_understood=True,449        fields={450            'bridge': KeyInfo(default='none'),451            'cascade-ports': KeyInfo(default=''),452            'switch': KeyInfo(default='none'),453        },454    ),455    ('interface', 'bridge', 'port-extender'): APIData(456        single_value=True,457        fully_understood=True,458        fields={459            'control-ports': KeyInfo(default=''),460            'excluded-ports': KeyInfo(default=''),461            'switch': KeyInfo(default='none'),462        },463    ),464    ('interface', 'bridge', 'settings'): APIData(465        single_value=True,466        fully_understood=True,467        fields={468            'allow-fast-path': KeyInfo(default=True),469            'use-ip-firewall': KeyInfo(default=False),470            'use-ip-firewall-for-pppoe': KeyInfo(default=False),471            'use-ip-firewall-for-vlan': KeyInfo(default=False),472        },473    ),474    ('ip', 'firewall', 'connection', 'tracking'): APIData(475        single_value=True,476        fully_understood=True,477        fields={478            'enabled': KeyInfo(default='auto'),479            'generic-timeout': KeyInfo(default='10m'),480            'icmp-timeout': KeyInfo(default='10s'),481            'loose-tcp-tracking': KeyInfo(default=True),482            'tcp-close-timeout': KeyInfo(default='10s'),483            'tcp-close-wait-timeout': KeyInfo(default='10s'),484            'tcp-established-timeout': KeyInfo(default='1d'),485            'tcp-fin-wait-timeout': KeyInfo(default='10s'),486            'tcp-last-ack-timeout': KeyInfo(default='10s'),487            'tcp-max-retrans-timeout': KeyInfo(default='5m'),488            'tcp-syn-received-timeout': KeyInfo(default='5s'),489            'tcp-syn-sent-timeout': KeyInfo(default='5s'),490            'tcp-time-wait-timeout': KeyInfo(default='10s'),491            'tcp-unacked-timeout': KeyInfo(default='5m'),492            'udp-stream-timeout': KeyInfo(default='3m'),493            'udp-timeout': KeyInfo(default='10s'),494        },495    ),496    ('ip', 'neighbor', 'discovery-settings'): APIData(497        single_value=True,498        fully_understood=True,499        fields={500            'discover-interface-list': KeyInfo(),501            'lldp-med-net-policy-vlan': KeyInfo(default='disabled'),502            'protocol': KeyInfo(default='cdp,lldp,mndp'),503        },504    ),505    ('ip', 'settings'): APIData(506        single_value=True,507        fully_understood=True,508        fields={509            'accept-redirects': KeyInfo(default=False),510            'accept-source-route': KeyInfo(default=False),511            'allow-fast-path': KeyInfo(default=True),512            'arp-timeout': KeyInfo(default='30s'),513            'icmp-rate-limit': KeyInfo(default=10),514            'icmp-rate-mask': KeyInfo(default='0x1818'),515            'ip-forward': KeyInfo(default=True),516            'max-neighbor-entries': KeyInfo(default=8192),517            'route-cache': KeyInfo(default=True),518            'rp-filter': KeyInfo(default=False),519            'secure-redirects': KeyInfo(default=True),520            'send-redirects': KeyInfo(default=True),521            'tcp-syncookies': KeyInfo(default=False),522        },523    ),524    ('ipv6', 'settings'): APIData(525        single_value=True,526        fully_understood=True,527        fields={528            'accept-redirects': KeyInfo(default='yes-if-forwarding-disabled'),529            'accept-router-advertisements': KeyInfo(default='yes-if-forwarding-disabled'),530            'forward': KeyInfo(default=True),531            'max-neighbor-entries': KeyInfo(default=8192),532        },533    ),534    ('interface', 'detect-internet'): APIData(535        single_value=True,536        fully_understood=True,537        fields={538            'detect-interface-list': KeyInfo(default='none'),539            'internet-interface-list': KeyInfo(default='none'),540            'lan-interface-list': KeyInfo(default='none'),541            'wan-interface-list': KeyInfo(default='none'),542        },543    ),544    ('interface', 'l2tp-server', 'server'): APIData(545        single_value=True,546        fully_understood=True,547        fields={548            'allow-fast-path': KeyInfo(default=False),549            'authentication': KeyInfo(default='pap,chap,mschap1,mschap2'),550            'caller-id-type': KeyInfo(default='ip-address'),551            'default-profile': KeyInfo(default='default-encryption'),552            'enabled': KeyInfo(default=False),553            'ipsec-secret': KeyInfo(default=''),554            'keepalive-timeout': KeyInfo(default=30),555            'max-mru': KeyInfo(default=1450),556            'max-mtu': KeyInfo(default=1450),557            'max-sessions': KeyInfo(default='unlimited'),558            'mrru': KeyInfo(default='disabled'),559            'one-session-per-host': KeyInfo(default=False),560            'use-ipsec': KeyInfo(default=False),561        },562    ),563    ('interface', 'ovpn-server', 'server'): APIData(564        single_value=True,565        fully_understood=True,566        fields={567            'auth': KeyInfo(),568            'cipher': KeyInfo(),569            'default-profile': KeyInfo(default='default'),570            'enabled': KeyInfo(default=False),571            'keepalive-timeout': KeyInfo(default=60),572            'mac-address': KeyInfo(),573            'max-mtu': KeyInfo(default=1500),574            'mode': KeyInfo(default='ip'),575            'netmask': KeyInfo(default=24),576            'port': KeyInfo(default=1194),577            'require-client-certificate': KeyInfo(default=False),578        },579    ),580    ('interface', 'pptp-server', 'server'): APIData(581        single_value=True,582        fully_understood=True,583        fields={584            'authentication': KeyInfo(default='mschap1,mschap2'),585            'default-profile': KeyInfo(default='default-encryption'),586            'enabled': KeyInfo(default=False),587            'keepalive-timeout': KeyInfo(default=30),588            'max-mru': KeyInfo(default=1450),589            'max-mtu': KeyInfo(default=1450),590            'mrru': KeyInfo(default='disabled'),591        },592    ),593    ('interface', 'sstp-server', 'server'): APIData(594        single_value=True,595        fully_understood=True,596        fields={597            'authentication': KeyInfo(default='pap,chap,mschap1,mschap2'),598            'certificate': KeyInfo(default='none'),599            'default-profile': KeyInfo(default='default'),600            'enabled': KeyInfo(default=False),601            'force-aes': KeyInfo(default=False),602            'keepalive-timeout': KeyInfo(default=60),603            'max-mru': KeyInfo(default=1500),604            'max-mtu': KeyInfo(default=1500),605            'mrru': KeyInfo(default='disabled'),606            'pfs': KeyInfo(default=False),607            'port': KeyInfo(default=443),608            'tls-version': KeyInfo(default='any'),609            'verify-client-certificate': KeyInfo(default='no'),610        },611    ),612    ('interface', 'wireless', 'align'): APIData(613        single_value=True,614        fully_understood=True,615        fields={616            'active-mode': KeyInfo(default=True),617            'audio-max': KeyInfo(default=-20),618            'audio-min': KeyInfo(default=-100),619            'audio-monitor': KeyInfo(default='00:00:00:00:00:00'),620            'filter-mac': KeyInfo(default='00:00:00:00:00:00'),621            'frame-size': KeyInfo(default=300),622            'frames-per-second': KeyInfo(default=25),623            'receive-all': KeyInfo(default=False),624            'ssid-all': KeyInfo(default=False),625        },626    ),627    ('interface', 'wireless', 'cap'): APIData(628        single_value=True,629        fully_understood=True,630        fields={631            'bridge': KeyInfo(default='none'),632            'caps-man-addresses': KeyInfo(default=''),633            'caps-man-certificate-common-names': KeyInfo(default=''),634            'caps-man-names': KeyInfo(default=''),635            'certificate': KeyInfo(default='none'),636            'discovery-interfaces': KeyInfo(default=''),637            'enabled': KeyInfo(default=False),638            'interfaces': KeyInfo(default=''),639            'lock-to-caps-man': KeyInfo(default=False),640            'static-virtual': KeyInfo(default=False),641        },642    ),643    ('interface', 'wireless', 'sniffer'): APIData(644        single_value=True,645        fully_understood=True,646        fields={647            'channel-time': KeyInfo(default='200ms'),648            'file-limit': KeyInfo(default=10),649            'file-name': KeyInfo(default=''),650            'memory-limit': KeyInfo(default=10),651            'multiple-channels': KeyInfo(default=False),652            'only-headers': KeyInfo(default=False),653            'receive-errors': KeyInfo(default=False),654            'streaming-enabled': KeyInfo(default=False),655            'streaming-max-rate': KeyInfo(default=0),656            'streaming-server': KeyInfo(default='0.0.0.0'),657        },658    ),659    ('interface', 'wireless', 'snooper'): APIData(660        single_value=True,661        fully_understood=True,662        fields={663            'channel-time': KeyInfo(default='200ms'),664            'multiple-channels': KeyInfo(default=True),665            'receive-errors': KeyInfo(default=False),666        },667    ),668    ('ip', 'accounting'): APIData(669        single_value=True,670        fully_understood=True,671        fields={672            'account-local-traffic': KeyInfo(default=False),673            'enabled': KeyInfo(default=False),674            'threshold': KeyInfo(default=256),675        },676    ),677    ('ip', 'accounting', 'web-access'): APIData(678        single_value=True,679        fully_understood=True,680        fields={681            'accessible-via-web': KeyInfo(default=False),682            'address': KeyInfo(default='0.0.0.0/0'),683        },684    ),685    ('ip', 'address'): APIData(686        fully_understood=True,687        primary_keys=('address', 'interface', ),688        fields={689            'address': KeyInfo(),690            'comment': KeyInfo(can_disable=True, remove_value=''),691            'disabled': KeyInfo(default=False),692            'interface': KeyInfo(),693            'network': KeyInfo(automatically_computed_from=('address', )),694        },695    ),696    ('ip', 'cloud'): APIData(697        single_value=True,698        fully_understood=True,699        fields={700            'ddns-enabled': KeyInfo(default=False),701            'ddns-update-interval': KeyInfo(default='none'),702            'update-time': KeyInfo(default=True),703        },704    ),705    ('ip', 'cloud', 'advanced'): APIData(706        single_value=True,707        fully_understood=True,708        fields={709            'use-local-address': KeyInfo(default=False),710        },711    ),712    ('ip', 'dhcp-client'): APIData(713        fully_understood=True,714        primary_keys=('interface', ),715        fields={716            'add-default-route': KeyInfo(default=True),717            'comment': KeyInfo(can_disable=True, remove_value=''),718            'default-route-distance': KeyInfo(default=1),719            'dhcp-options': KeyInfo(default='hostname,clientid'),720            'disabled': KeyInfo(default=False),721            'interface': KeyInfo(),722            'script': KeyInfo(can_disable=True),723            'use-peer-dns': KeyInfo(default=True),724            'use-peer-ntp': KeyInfo(default=True),725        },726    ),727    ('ip', 'dhcp-server', 'config'): APIData(728        single_value=True,729        fully_understood=True,730        fields={731            'accounting': KeyInfo(default=True),732            'interim-update': KeyInfo(default='0s'),733            'store-leases-disk': KeyInfo(default='5m'),734        },735    ),736    ('ip', 'dhcp-server', 'lease'): APIData(737        fully_understood=True,738        primary_keys=('server', 'address', ),739        fields={740            'address': KeyInfo(),741            'address-lists': KeyInfo(default=''),742            'always-broadcast': KeyInfo(),743            'client-id': KeyInfo(can_disable=True, remove_value=''),744            'comment': KeyInfo(can_disable=True, remove_value=''),745            'dhcp-option': KeyInfo(default=''),746            'disabled': KeyInfo(default=False),747            'insert-queue-before': KeyInfo(can_disable=True),748            'mac-address': KeyInfo(can_disable=True, remove_value=''),749            'server': KeyInfo(absent_value='all'),750        },751    ),752    ('ip', 'dhcp-server', 'network'): APIData(753        fully_understood=True,754        primary_keys=('address', ),755        fields={756            'address': KeyInfo(),757            'boot-file-name': KeyInfo(default=''),758            'caps-manager': KeyInfo(default=''),759            'comment': KeyInfo(can_disable=True, remove_value=''),760            'dhcp-option': KeyInfo(default=''),761            'dhcp-option-set': KeyInfo(default=''),762            'dns-none': KeyInfo(default=''),763            'dns-server': KeyInfo(default=''),764            'domain': KeyInfo(default=''),765            'gateway': KeyInfo(automatically_computed_from=('address', )),766            'netmask': KeyInfo(automatically_computed_from=('address', )),767            'next-server': KeyInfo(default=''),768            'ntp-server': KeyInfo(default=''),769            'wins-server': KeyInfo(default=''),770        },771    ),772    ('ip', 'dns'): APIData(773        single_value=True,774        fully_understood=True,775        fields={776            'allow-remote-requests': KeyInfo(),777            'cache-max-ttl': KeyInfo(default='1w'),778            'cache-size': KeyInfo(default='2048KiB'),779            'max-concurrent-queries': KeyInfo(default=100),780            'max-concurrent-tcp-sessions': KeyInfo(default=20),781            'max-udp-packet-size': KeyInfo(default=4096),782            'query-server-timeout': KeyInfo(default='2s'),783            'query-total-timeout': KeyInfo(default='10s'),784            'servers': KeyInfo(default=''),785            'use-doh-server': KeyInfo(default=''),786            'verify-doh-cert': KeyInfo(default=False),787        },788    ),789    ('ip', 'dns', 'static'): APIData(790        fully_understood=True,791        stratify_keys=('name', ),792        fields={793            'address': KeyInfo(),794            'cname': KeyInfo(),795            'comment': KeyInfo(can_disable=True, remove_value=''),796            'disabled': KeyInfo(default=False),797            'forward-to': KeyInfo(),798            'mx-exchange': KeyInfo(),799            'mx-preference': KeyInfo(),800            'name': KeyInfo(required=True),801            'ns': KeyInfo(),802            'srv-port': KeyInfo(),803            'srv-priority': KeyInfo(),804            'srv-target': KeyInfo(),805            'srv-weight': KeyInfo(),806            'text': KeyInfo(),807            'ttl': KeyInfo(default='1d'),808            'type': KeyInfo(),809        },810    ),811    ('ip', 'firewall', 'address-list'): APIData(812        fully_understood=True,813        primary_keys=('address', 'list', ),814        fields={815            'address': KeyInfo(),816            'disabled': KeyInfo(default=False),817            'list': KeyInfo(),818        },819    ),820    ('ip', 'firewall', 'filter'): APIData(821        fully_understood=True,822        stratify_keys=('chain', ),823        fields={824            'action': KeyInfo(),825            'chain': KeyInfo(),826            'comment': KeyInfo(can_disable=True, remove_value=''),827            'connection-bytes': KeyInfo(can_disable=True),828            'connection-limit': KeyInfo(can_disable=True),829            'connection-mark': KeyInfo(can_disable=True),830            'connection-nat-state': KeyInfo(can_disable=True),831            'connection-rate': KeyInfo(can_disable=True),832            'connection-state': KeyInfo(can_disable=True),833            'connection-type': KeyInfo(can_disable=True),834            'content': KeyInfo(can_disable=True),835            'disabled': KeyInfo(),836            'dscp': KeyInfo(can_disable=True),837            'dst-address': KeyInfo(can_disable=True),838            'dst-address-list': KeyInfo(can_disable=True),839            'dst-address-type': KeyInfo(can_disable=True),840            'dst-limit': KeyInfo(can_disable=True),841            'dst-port': KeyInfo(can_disable=True),842            'fragment': KeyInfo(can_disable=True),843            'hotspot': KeyInfo(can_disable=True),844            'icmp-options': KeyInfo(can_disable=True),845            'in-bridge-port': KeyInfo(can_disable=True),846            'in-bridge-port-list': KeyInfo(can_disable=True),847            'in-interface': KeyInfo(can_disable=True),848            'in-interface-list': KeyInfo(can_disable=True),849            'ingress-priority': KeyInfo(can_disable=True),850            'ipsec-policy': KeyInfo(can_disable=True),851            'ipv4-options': KeyInfo(can_disable=True),852            'layer7-protocol': KeyInfo(can_disable=True),853            'limit': KeyInfo(can_disable=True),854            'log': KeyInfo(),855            'log-prefix': KeyInfo(),856            'nth': KeyInfo(can_disable=True),857            'out-bridge-port': KeyInfo(can_disable=True),858            'out-bridge-port-list': KeyInfo(can_disable=True),859            'out-interface': KeyInfo(can_disable=True),860            'out-interface-list': KeyInfo(can_disable=True),861            'p2p': KeyInfo(can_disable=True),862            'packet-mark': KeyInfo(can_disable=True),863            'packet-size': KeyInfo(can_disable=True),864            'per-connection-classifier': KeyInfo(can_disable=True),865            'port': KeyInfo(can_disable=True),866            'priority': KeyInfo(can_disable=True),867            'protocol': KeyInfo(can_disable=True),868            'psd': KeyInfo(can_disable=True),869            'random': KeyInfo(can_disable=True),870            'routing-mark': KeyInfo(can_disable=True),871            'routing-table': KeyInfo(can_disable=True),872            'src-address': KeyInfo(can_disable=True),873            'src-address-list': KeyInfo(can_disable=True),874            'src-address-type': KeyInfo(can_disable=True),875            'src-mac-address': KeyInfo(can_disable=True),876            'src-port': KeyInfo(can_disable=True),877            'tcp-flags': KeyInfo(can_disable=True),878            'tcp-mss': KeyInfo(can_disable=True),879            'time': KeyInfo(can_disable=True),880            'tls-host': KeyInfo(can_disable=True),881            'ttl': KeyInfo(can_disable=True),882        },883    ),884    ('ip', 'firewall', 'mangle'): APIData(885        fully_understood=True,886        stratify_keys=('chain', ),887        fields={888            'action': KeyInfo(),889            'chain': KeyInfo(),890            'comment': KeyInfo(can_disable=True, remove_value=''),891            'connection-bytes': KeyInfo(can_disable=True),892            'connection-limit': KeyInfo(can_disable=True),893            'connection-mark': KeyInfo(can_disable=True),894            'connection-nat-state': KeyInfo(can_disable=True),895            'connection-rate': KeyInfo(can_disable=True),896            'connection-state': KeyInfo(can_disable=True),897            'connection-type': KeyInfo(can_disable=True),898            'content': KeyInfo(can_disable=True),899            'disabled': KeyInfo(),900            'dscp': KeyInfo(can_disable=True),901            'dst-address': KeyInfo(can_disable=True),902            'dst-address-list': KeyInfo(can_disable=True),903            'dst-address-type': KeyInfo(can_disable=True),904            'dst-limit': KeyInfo(can_disable=True),905            'dst-port': KeyInfo(can_disable=True),906            'fragment': KeyInfo(can_disable=True),907            'hotspot': KeyInfo(can_disable=True),908            'icmp-options': KeyInfo(can_disable=True),909            'in-bridge-port': KeyInfo(can_disable=True),910            'in-bridge-port-list': KeyInfo(can_disable=True),911            'in-interface': KeyInfo(can_disable=True),912            'in-interface-list': KeyInfo(can_disable=True),913            'ingress-priority': KeyInfo(can_disable=True),914            'ipsec-policy': KeyInfo(can_disable=True),915            'ipv4-options': KeyInfo(can_disable=True),916            'layer7-protocol': KeyInfo(can_disable=True),917            'limit': KeyInfo(can_disable=True),918            'log': KeyInfo(),919            'log-prefix': KeyInfo(),920            'new-connection-mark': KeyInfo(can_disable=True),921            'new-dscp': KeyInfo(can_disable=True),922            'new-mss': KeyInfo(can_disable=True),923            'new-packet-mark': KeyInfo(can_disable=True),924            'new-priority': KeyInfo(can_disable=True),925            'new-routing-mark': KeyInfo(can_disable=True),926            'new-ttl': KeyInfo(can_disable=True),927            'nth': KeyInfo(can_disable=True),928            'out-bridge-port': KeyInfo(can_disable=True),929            'out-bridge-port-list': KeyInfo(can_disable=True),930            'out-interface': KeyInfo(can_disable=True),931            'out-interface-list': KeyInfo(can_disable=True),932            'p2p': KeyInfo(can_disable=True),933            'packet-mark': KeyInfo(can_disable=True),934            'packet-size': KeyInfo(can_disable=True),935            'passthrough': KeyInfo(can_disable=True),936            'per-connection-classifier': KeyInfo(can_disable=True),937            'port': KeyInfo(can_disable=True),938            'priority': KeyInfo(can_disable=True),939            'protocol': KeyInfo(can_disable=True),940            'psd': KeyInfo(can_disable=True),941            'random': KeyInfo(can_disable=True),942            'route-dst': KeyInfo(can_disable=True),943            'routing-mark': KeyInfo(can_disable=True),944            'routing-table': KeyInfo(can_disable=True),945            'sniff-id': KeyInfo(can_disable=True),946            'sniff-target': KeyInfo(can_disable=True),947            'sniff-target-port': KeyInfo(can_disable=True),948            'src-address': KeyInfo(can_disable=True),949            'src-address-list': KeyInfo(can_disable=True),950            'src-address-type': KeyInfo(can_disable=True),951            'src-mac-address': KeyInfo(can_disable=True),952            'src-port': KeyInfo(can_disable=True),953            'tcp-flags': KeyInfo(can_disable=True),954            'tcp-mss': KeyInfo(can_disable=True),955            'time': KeyInfo(can_disable=True),956            'tls-host': KeyInfo(can_disable=True),957            'ttl': KeyInfo(can_disable=True),958        },959    ),960    ('ip', 'firewall', 'nat'): APIData(961        fully_understood=True,962        stratify_keys=('chain', ),963        fields={964            'action': KeyInfo(),965            'chain': KeyInfo(),966            'comment': KeyInfo(can_disable=True, remove_value=''),967            'dst-address': KeyInfo(can_disable=True),968            'dst-port': KeyInfo(can_disable=True),969            'in-interface': KeyInfo(can_disable=True),970            'in-interface-list': KeyInfo(can_disable=True),971            'out-interface': KeyInfo(can_disable=True),972            'out-interface-list': KeyInfo(can_disable=True),973            'protocol': KeyInfo(can_disable=True),974            'to-addresses': KeyInfo(can_disable=True),975            'to-ports': KeyInfo(can_disable=True),976        },977    ),978    ('ip', 'hotspot', 'user'): APIData(979        unknown_mechanism=True,980        # primary_keys=('default', ),981        fields={982            'default': KeyInfo(),983            'comment': KeyInfo(can_disable=True, remove_value=''),984            'disabled': KeyInfo(),985            'name': KeyInfo(),986        },987    ),988    ('ip', 'ipsec', 'settings'): APIData(989        single_value=True,990        fully_understood=True,991        fields={992            'accounting': KeyInfo(default=True),993            'interim-update': KeyInfo(default='0s'),994            'xauth-use-radius': KeyInfo(default=False),995        },996    ),997    ('ip', 'proxy'): APIData(998        single_value=True,999        fully_understood=True,1000        fields={1001            'always-from-cache': KeyInfo(default=False),1002            'anonymous': KeyInfo(default=False),1003            'cache-administrator': KeyInfo(default='webmaster'),1004            'cache-hit-dscp': KeyInfo(default=4),1005            'cache-on-disk': KeyInfo(default=False),1006            'cache-path': KeyInfo(default='web-proxy'),1007            'enabled': KeyInfo(default=False),1008            'max-cache-object-size': KeyInfo(default='2048KiB'),1009            'max-cache-size': KeyInfo(default='unlimited'),1010            'max-client-connections': KeyInfo(default=600),1011            'max-fresh-time': KeyInfo(default='3d'),1012            'max-server-connections': KeyInfo(default=600),1013            'parent-proxy': KeyInfo(default='::'),1014            'parent-proxy-port': KeyInfo(default=0),1015            'port': KeyInfo(default=8080),1016            'serialize-connections': KeyInfo(default=False),1017            'src-address': KeyInfo(default='::'),1018        },1019    ),1020    ('ip', 'smb'): APIData(1021        single_value=True,1022        fully_understood=True,1023        fields={1024            'allow-guests': KeyInfo(default=True),1025            'comment': KeyInfo(default='MikrotikSMB'),1026            'domain': KeyInfo(default='MSHOME'),1027            'enabled': KeyInfo(default=False),1028            'interfaces': KeyInfo(default='all'),1029        },1030    ),1031    ('ip', 'smb', 'shares'): APIData(1032        unknown_mechanism=True,1033        # primary_keys=('default', ),1034        fields={1035            'default': KeyInfo(),1036            'comment': KeyInfo(can_disable=True, remove_value=''),1037            'directory': KeyInfo(),1038            'disabled': KeyInfo(),1039            'max-sessions': KeyInfo(),1040            'name': KeyInfo(),1041        },1042    ),1043    ('ip', 'smb', 'users'): APIData(1044        unknown_mechanism=True,1045        # primary_keys=('default', ),1046        fields={1047            'default': KeyInfo(),1048            'disabled': KeyInfo(),1049            'name': KeyInfo(),1050            'password': KeyInfo(),1051            'read-only': KeyInfo(),1052        },1053    ),1054    ('ip', 'socks'): APIData(1055        single_value=True,1056        fully_understood=True,1057        fields={1058            'auth-method': KeyInfo(default='none'),1059            'connection-idle-timeout': KeyInfo(default='2m'),1060            'enabled': KeyInfo(default=False),1061            'max-connections': KeyInfo(default=200),1062            'port': KeyInfo(default=1080),1063            'version': KeyInfo(default=4),1064        },1065    ),1066    ('ip', 'ssh'): APIData(1067        single_value=True,1068        fully_understood=True,1069        fields={1070            'allow-none-crypto': KeyInfo(default=False),1071            'always-allow-password-login': KeyInfo(default=False),1072            'forwarding-enabled': KeyInfo(default=False),1073            'host-key-size': KeyInfo(default=2048),1074            'strong-crypto': KeyInfo(default=False),1075        },1076    ),1077    ('ip', 'tftp', 'settings'): APIData(1078        single_value=True,1079        fully_understood=True,1080        fields={1081            'max-block-size': KeyInfo(default=4096),1082        },1083    ),1084    ('ip', 'traffic-flow'): APIData(1085        single_value=True,1086        fully_understood=True,1087        fields={1088            'active-flow-timeout': KeyInfo(default='30m'),1089            'cache-entries': KeyInfo(default='32k'),1090            'enabled': KeyInfo(default=False),1091            'inactive-flow-timeout': KeyInfo(default='15s'),1092            'interfaces': KeyInfo(default='all'),1093            'packet-sampling': KeyInfo(default=False),1094            'sampling-interval': KeyInfo(default=0),1095            'sampling-space': KeyInfo(default=0),1096        },1097    ),1098    ('ip', 'traffic-flow', 'ipfix'): APIData(1099        single_value=True,1100        fully_understood=True,1101        fields={1102            'bytes': KeyInfo(default=True),1103            'dst-address': KeyInfo(default=True),1104            'dst-address-mask': KeyInfo(default=True),1105            'dst-mac-address': KeyInfo(default=True),1106            'dst-port': KeyInfo(default=True),1107            'first-forwarded': KeyInfo(default=True),1108            'gateway': KeyInfo(default=True),1109            'icmp-code': KeyInfo(default=True),1110            'icmp-type': KeyInfo(default=True),1111            'igmp-type': KeyInfo(default=True),1112            'in-interface': KeyInfo(default=True),1113            'ip-header-length': KeyInfo(default=True),1114            'ip-total-length': KeyInfo(default=True),1115            'ipv6-flow-label': KeyInfo(default=True),1116            'is-multicast': KeyInfo(default=True),1117            'last-forwarded': KeyInfo(default=True),1118            'nat-dst-address': KeyInfo(default=True),1119            'nat-dst-port': KeyInfo(default=True),1120            'nat-events': KeyInfo(default=False),1121            'nat-src-address': KeyInfo(default=True),1122            'nat-src-port': KeyInfo(default=True),1123            'out-interface': KeyInfo(default=True),1124            'packets': KeyInfo(default=True),1125            'protocol': KeyInfo(default=True),1126            'src-address': KeyInfo(default=True),1127            'src-address-mask': KeyInfo(default=True),1128            'src-mac-address': KeyInfo(default=True),1129            'src-port': KeyInfo(default=True),1130            'sys-init-time': KeyInfo(default=True),1131            'tcp-ack-num': KeyInfo(default=True),1132            'tcp-flags': KeyInfo(default=True),1133            'tcp-seq-num': KeyInfo(default=True),1134            'tcp-window-size': KeyInfo(default=True),1135            'tos': KeyInfo(default=True),1136            'ttl': KeyInfo(default=True),1137            'udp-length': KeyInfo(default=True),1138        },1139    ),1140    ('ip', 'upnp'): APIData(1141        single_value=True,1142        fully_understood=True,1143        fields={1144            'allow-disable-external-interface': KeyInfo(default=False),1145            'enabled': KeyInfo(default=False),1146            'show-dummy-rule': KeyInfo(default=True),1147        },1148    ),1149    ('ipv6', 'dhcp-client'): APIData(1150        fully_understood=True,1151        primary_keys=('interface', 'request'),1152        fields={1153            'add-default-route': KeyInfo(default=False),1154            'comment': KeyInfo(can_disable=True, remove_value=''),1155            'default-route-distance': KeyInfo(default=1),1156            'dhcp-options': KeyInfo(default=''),1157            'disabled': KeyInfo(default=False),1158            'interface': KeyInfo(),1159            'pool-name': KeyInfo(required=True),1160            'pool-prefix-length': KeyInfo(default=64),1161            'prefix-hint': KeyInfo(default='::/0'),1162            'request': KeyInfo(),1163            'use-peer-dns': KeyInfo(default=True),1164        },1165    ),1166    ('ipv6', 'firewall', 'address-list'): APIData(1167        fully_understood=True,1168        primary_keys=('address', 'list', ),1169        fields={1170            'address': KeyInfo(),1171            'disabled': KeyInfo(default=False),1172            'dynamic': KeyInfo(default=False),1173            'list': KeyInfo(),1174        },1175    ),1176    ('ipv6', 'firewall', 'filter'): APIData(1177        fully_understood=True,1178        stratify_keys=('chain', ),1179        fields={1180            'action': KeyInfo(),1181            'chain': KeyInfo(),1182            'comment': KeyInfo(can_disable=True, remove_value=''),1183            'connection-bytes': KeyInfo(can_disable=True),1184            'connection-limit': KeyInfo(can_disable=True),1185            'connection-mark': KeyInfo(can_disable=True),1186            'connection-rate': KeyInfo(can_disable=True),1187            'connection-state': KeyInfo(can_disable=True),1188            'connection-type': KeyInfo(can_disable=True),1189            'content': KeyInfo(can_disable=True),1190            'disabled': KeyInfo(),1191            'dscp': KeyInfo(can_disable=True),1192            'dst-address': KeyInfo(can_disable=True),1193            'dst-address-list': KeyInfo(can_disable=True),1194            'dst-address-type': KeyInfo(can_disable=True),1195            'dst-limit': KeyInfo(can_disable=True),1196            'dst-port': KeyInfo(can_disable=True),1197            'headers': KeyInfo(can_disable=True),1198            'hop-limit': KeyInfo(can_disable=True),1199            'icmp-options': KeyInfo(can_disable=True),1200            'in-bridge-port': KeyInfo(can_disable=True),1201            'in-bridge-port-list': KeyInfo(can_disable=True),1202            'in-interface': KeyInfo(can_disable=True),1203            'in-interface-list': KeyInfo(can_disable=True),1204            'ingress-priority': KeyInfo(can_disable=True),1205            'ipsec-policy': KeyInfo(can_disable=True),1206            'limit': KeyInfo(can_disable=True),1207            'log': KeyInfo(),1208            'log-prefix': KeyInfo(),1209            'nth': KeyInfo(can_disable=True),1210            'out-bridge-port': KeyInfo(can_disable=True),1211            'out-bridge-port-list': KeyInfo(can_disable=True),1212            'out-interface': KeyInfo(can_disable=True),1213            'out-interface-list': KeyInfo(can_disable=True),1214            'packet-mark': KeyInfo(can_disable=True),1215            'packet-size': KeyInfo(can_disable=True),1216            'per-connection-classifier': KeyInfo(can_disable=True),1217            'port': KeyInfo(can_disable=True),1218            'priority': KeyInfo(can_disable=True),1219            'protocol': KeyInfo(can_disable=True),1220            'random': KeyInfo(can_disable=True),1221            'src-address': KeyInfo(can_disable=True),1222            'src-address-list': KeyInfo(can_disable=True),1223            'src-address-type': KeyInfo(can_disable=True),1224            'src-mac-address': KeyInfo(can_disable=True),1225            'src-port': KeyInfo(can_disable=True),1226            'tcp-flags': KeyInfo(can_disable=True),1227            'tcp-mss': KeyInfo(can_disable=True),1228            'time': KeyInfo(can_disable=True),1229        },1230    ),1231    ('ipv6', 'nd'): APIData(1232        unknown_mechanism=True,1233        # primary_keys=('default', ),1234        fields={1235            'default': KeyInfo(),1236            'advertise-dns': KeyInfo(),1237            'advertise-mac-address': KeyInfo(),1238            'disabled': KeyInfo(),1239            'hop-limit': KeyInfo(),1240            'interface': KeyInfo(),1241            'managed-address-configuration': KeyInfo(),1242            'mtu': KeyInfo(),1243            'other-configuration': KeyInfo(),1244            'ra-delay': KeyInfo(),1245            'ra-interval': KeyInfo(),1246            'ra-lifetime': KeyInfo(),1247            'reachable-time': KeyInfo(),1248            'retransmit-interval': KeyInfo(),1249        },1250    ),1251    ('ipv6', 'nd', 'prefix', 'default'): APIData(1252        single_value=True,1253        fully_understood=True,1254        fields={1255            'autonomous': KeyInfo(default=True),1256            'preferred-lifetime': KeyInfo(default='1w'),1257            'valid-lifetime': KeyInfo(default='4w2d'),1258        },1259    ),1260    ('ipv6', 'route'): APIData(1261        fields={1262            'bgp-as-path': KeyInfo(can_disable=True),1263            'bgp-atomic-aggregate': KeyInfo(can_disable=True),1264            'bgp-communities': KeyInfo(can_disable=True),1265            'bgp-local-pref': KeyInfo(can_disable=True),1266            'bgp-med': KeyInfo(can_disable=True),1267            'bgp-origin': KeyInfo(can_disable=True),1268            'bgp-prepend': KeyInfo(can_disable=True),1269            'check-gateway': KeyInfo(can_disable=True),1270            'disabled': KeyInfo(),1271            'distance': KeyInfo(),1272            'dst-address': KeyInfo(),1273            'gateway': KeyInfo(),1274            'route-tag': KeyInfo(can_disable=True),1275            'scope': KeyInfo(),1276            'target-scope': KeyInfo(),1277        },1278    ),1279    ('mpls', ): APIData(1280        single_value=True,1281        fully_understood=True,1282        fields={1283            'allow-fast-path': KeyInfo(default=True),1284            'dynamic-label-range': KeyInfo(default='16-1048575'),1285            'propagate-ttl': KeyInfo(default=True),1286        },1287    ),1288    ('mpls', 'interface'): APIData(1289        unknown_mechanism=True,1290        # primary_keys=('default', ),1291        fields={1292            'default': KeyInfo(),1293            'disabled': KeyInfo(),1294            'interface': KeyInfo(),1295            'mpls-mtu': KeyInfo(),1296        },1297    ),1298    ('mpls', 'ldp'): APIData(1299        single_value=True,1300        fully_understood=True,1301        fields={1302            'distribute-for-default-route': KeyInfo(default=False),1303            'enabled': KeyInfo(default=False),1304            'hop-limit': KeyInfo(default=255),1305            'loop-detect': KeyInfo(default=False),1306            'lsr-id': KeyInfo(default='0.0.0.0'),1307            'path-vector-limit': KeyInfo(default=255),1308            'transport-address': KeyInfo(default='0.0.0.0'),1309            'use-explicit-null': KeyInfo(default=False),1310        },1311    ),1312    ('port', 'firmware'): APIData(1313        single_value=True,1314        fully_understood=True,1315        fields={1316            'directory': KeyInfo(default='firmware'),1317            'ignore-directip-modem': KeyInfo(default=False),1318        },1319    ),1320    ('ppp', 'aaa'): APIData(1321        single_value=True,1322        fully_understood=True,1323        fields={1324            'accounting': KeyInfo(default=True),1325            'interim-update': KeyInfo(default='0s'),1326            'use-circuit-id-in-nas-port-id': KeyInfo(default=False),1327            'use-radius': KeyInfo(default=False),1328        },1329    ),1330    ('radius', 'incoming'): APIData(1331        single_value=True,1332        fully_understood=True,1333        fields={1334            'accept': KeyInfo(default=False),1335            'port': KeyInfo(default=3799),1336        },1337    ),1338    ('routing', 'bfd', 'interface'): APIData(1339        unknown_mechanism=True,1340        # primary_keys=('default', ),1341        fields={1342            'default': KeyInfo(),1343            'disabled': KeyInfo(),1344            'interface': KeyInfo(),1345            'interval': KeyInfo(),1346            'min-rx': KeyInfo(),1347            'multiplier': KeyInfo(),1348        },1349    ),1350    ('routing', 'mme'): APIData(1351        single_value=True,1352        fully_understood=True,1353        fields={1354            'bidirectional-timeout': KeyInfo(default=2),1355            'gateway-class': KeyInfo(default='none'),1356            'gateway-keepalive': KeyInfo(default='1m'),1357            'gateway-selection': KeyInfo(default='no-gateway'),1358            'origination-interval': KeyInfo(default='5s'),1359            'preferred-gateway': KeyInfo(default='0.0.0.0'),1360            'timeout': KeyInfo(default='1m'),1361            'ttl': KeyInfo(default=50),1362        },1363    ),1364    ('routing', 'rip'): APIData(1365        single_value=True,1366        fully_understood=True,1367        fields={1368            'distribute-default': KeyInfo(default='never'),1369            'garbage-timer': KeyInfo(default='2m'),1370            'metric-bgp': KeyInfo(default=1),1371            'metric-connected': KeyInfo(default=1),1372            'metric-default': KeyInfo(default=1),1373            'metric-ospf': KeyInfo(default=1),1374            'metric-static': KeyInfo(default=1),1375            'redistribute-bgp': KeyInfo(default=False),1376            'redistribute-connected': KeyInfo(default=False),1377            'redistribute-ospf': KeyInfo(default=False),1378            'redistribute-static': KeyInfo(default=False),1379            'routing-table': KeyInfo(default='main'),1380            'timeout-timer': KeyInfo(default='3m'),1381            'update-timer': KeyInfo(default='30s'),1382        },1383    ),1384    ('routing', 'ripng'): APIData(1385        single_value=True,1386        fully_understood=True,1387        fields={1388            'distribute-default': KeyInfo(default='never'),1389            'garbage-timer': KeyInfo(default='2m'),1390            'metric-bgp': KeyInfo(default=1),1391            'metric-connected': KeyInfo(default=1),1392            'metric-default': KeyInfo(default=1),1393            'metric-ospf': KeyInfo(default=1),1394            'metric-static': KeyInfo(default=1),1395            'redistribute-bgp': KeyInfo(default=False),1396            'redistribute-connected': KeyInfo(default=False),1397            'redistribute-ospf': KeyInfo(default=False),1398            'redistribute-static': KeyInfo(default=False),1399            'timeout-timer': KeyInfo(default='3m'),1400            'update-timer': KeyInfo(default='30s'),1401        },1402    ),1403    ('snmp', ): APIData(1404        single_value=True,1405        fully_understood=True,1406        fields={1407            'contact': KeyInfo(default=''),1408            'enabled': KeyInfo(default=False),1409            'engine-id': KeyInfo(default=''),1410            'location': KeyInfo(default=''),1411            'src-address': KeyInfo(default='::'),1412            'trap-community': KeyInfo(default='public'),1413            'trap-generators': KeyInfo(default='temp-exception'),1414            'trap-target': KeyInfo(default=''),1415            'trap-version': KeyInfo(default=1),1416        },1417    ),1418    ('system', 'clock'): APIData(1419        single_value=True,1420        fully_understood=True,1421        fields={1422            'time-zone-autodetect': KeyInfo(default=True),1423            'time-zone-name': KeyInfo(default='manual'),1424        },1425    ),1426    ('system', 'clock', 'manual'): APIData(1427        single_value=True,1428        fully_understood=True,1429        fields={1430            'dst-delta': KeyInfo(default='00:00'),1431            'dst-end': KeyInfo(default='jan/01/1970 00:00:00'),1432            'dst-start': KeyInfo(default='jan/01/1970 00:00:00'),1433            'time-zone': KeyInfo(default='+00:00'),1434        },1435    ),1436    ('system', 'identity'): APIData(1437        single_value=True,1438        fully_understood=True,1439        fields={1440            'name': KeyInfo(default='Mikrotik'),1441        },1442    ),1443    ('system', 'leds', 'settings'): APIData(1444        single_value=True,1445        fully_understood=True,1446        fields={1447            'all-leds-off': KeyInfo(default='never'),1448        },1449    ),1450    ('system', 'note'): APIData(1451        single_value=True,1452        fully_understood=True,1453        fields={1454            'note': KeyInfo(default=''),1455            'show-at-login': KeyInfo(default=True),1456        },1457    ),1458    ('system', 'ntp', 'client'): APIData(1459        single_value=True,1460        fully_understood=True,1461        fields={1462            'enabled': KeyInfo(default=False),1463            'primary-ntp': KeyInfo(default='0.0.0.0'),1464            'secondary-ntp': KeyInfo(default='0.0.0.0'),1465            'server-dns-names': KeyInfo(default=''),1466        },1467    ),1468    ('system', 'package', 'update'): APIData(1469        single_value=True,1470        fully_understood=True,1471        fields={1472            'channel': KeyInfo(default='stable'),1473        },1474    ),1475    ('system', 'routerboard', 'settings'): APIData(1476        single_value=True,1477        fully_understood=True,1478        fields={1479            'auto-upgrade': KeyInfo(default=False),1480            'baud-rate': KeyInfo(default=115200),1481            'boot-delay': KeyInfo(default='2s'),1482            'boot-device': KeyInfo(default='nand-if-fail-then-ethernet'),1483            'boot-protocol': KeyInfo(default='bootp'),1484            'enable-jumper-reset': KeyInfo(default=True),1485            'enter-setup-on': KeyInfo(default='any-key'),1486            'force-backup-booter': KeyInfo(default=False),1487            'protected-routerboot': KeyInfo(default='disabled'),1488            'reformat-hold-button': KeyInfo(default='20s'),1489            'reformat-hold-button-max': KeyInfo(default='10m'),1490            'silent-boot': KeyInfo(default=False),1491        },1492    ),1493    ('system', 'upgrade', 'mirror'): APIData(1494        single_value=True,1495        fully_understood=True,1496        fields={1497            'check-interval': KeyInfo(default='1d'),1498            'enabled': KeyInfo(default=False),1499            'primary-server': KeyInfo(default='0.0.0.0'),1500            'secondary-server': KeyInfo(default='0.0.0.0'),1501            'user': KeyInfo(default=''),1502        },1503    ),1504    ('system', 'watchdog'): APIData(1505        single_value=True,1506        fully_understood=True,1507        fields={1508            'auto-send-supout': KeyInfo(default=False),1509            'automatic-supout': KeyInfo(default=True),1510            'ping-start-after-boot': KeyInfo(default='5m'),1511            'ping-timeout': KeyInfo(default='1m'),1512            'watch-address': KeyInfo(default='none'),1513            'watchdog-timer': KeyInfo(default=True),1514        },1515    ),1516    ('tool', 'bandwidth-server'): APIData(1517        single_value=True,1518        fully_understood=True,1519        fields={1520            'allocate-udp-ports-from': KeyInfo(default=2000),1521            'authenticate': KeyInfo(default=True),1522            'enabled': KeyInfo(default=True),1523            'max-sessions': KeyInfo(default=100),1524        },1525    ),1526    ('tool', 'e-mail'): APIData(1527        single_value=True,1528        fully_understood=True,1529        fields={1530            'address': KeyInfo(default='0.0.0.0'),1531            'from': KeyInfo(default='<>'),1532            'password': KeyInfo(default=''),1533            'port': KeyInfo(default=25),1534            'start-tls': KeyInfo(default=False),1535            'user': KeyInfo(default=''),1536        },1537    ),1538    ('tool', 'graphing'): APIData(1539        single_value=True,1540        fully_understood=True,1541        fields={1542            'page-refresh': KeyInfo(default=300),1543            'store-every': KeyInfo(default='5min'),1544        },1545    ),1546    ('tool', 'mac-server'): APIData(1547        single_value=True,1548        fully_understood=True,1549        fields={1550            'allowed-interface-list': KeyInfo(),1551        },1552    ),1553    ('tool', 'mac-server', 'mac-winbox'): APIData(1554        single_value=True,1555        fully_understood=True,1556        fields={1557            'allowed-interface-list': KeyInfo(),1558        },1559    ),1560    ('tool', 'mac-server', 'ping'): APIData(1561        single_value=True,1562        fully_understood=True,1563        fields={1564            'enabled': KeyInfo(default=True),1565        },1566    ),1567    ('tool', 'romon'): APIData(1568        single_value=True,1569        fully_understood=True,1570        fields={1571            'enabled': KeyInfo(default=False),1572            'id': KeyInfo(default='00:00:00:00:00:00'),1573            'secrets': KeyInfo(default=''),1574        },1575    ),1576    ('tool', 'romon', 'port'): APIData(1577        fields={1578            'cost': KeyInfo(),1579            'disabled': KeyInfo(),1580            'forbid': KeyInfo(),1581            'interface': KeyInfo(),1582            'secrets': KeyInfo(),1583        },1584    ),1585    ('tool', 'sms'): APIData(1586        single_value=True,1587        fully_understood=True,1588        fields={1589            'allowed-number': KeyInfo(default=''),1590            'auto-erase': KeyInfo(default=False),1591            'channel': KeyInfo(default=0),1592            'port': KeyInfo(default='none'),1593            'receive-enabled': KeyInfo(default=False),1594            'secret': KeyInfo(default=''),1595            'sim-pin': KeyInfo(default=''),1596        },1597    ),1598    ('tool', 'sniffer'): APIData(1599        single_value=True,1600        fully_understood=True,1601        fields={1602            'file-limit': KeyInfo(default='1000KiB'),1603            'file-name': KeyInfo(default=''),1604            'filter-cpu': KeyInfo(default=''),1605            'filter-direction': KeyInfo(default='any'),1606            'filter-interface': KeyInfo(default=''),1607            'filter-ip-address': KeyInfo(default=''),1608            'filter-ip-protocol': KeyInfo(default=''),1609            'filter-ipv6-address': KeyInfo(default=''),1610            'filter-mac-address': KeyInfo(default=''),1611            'filter-mac-protocol': KeyInfo(default=''),1612            'filter-operator-between-entries': KeyInfo(default='or'),1613            'filter-port': KeyInfo(default=''),1614            'filter-size': KeyInfo(default=''),1615            'filter-stream': KeyInfo(default=False),1616            'memory-limit': KeyInfo(default='100KiB'),1617            'memory-scroll': KeyInfo(default=True),1618            'only-headers': KeyInfo(default=False),1619            'streaming-enabled': KeyInfo(default=False),1620            'streaming-server': KeyInfo(default='0.0.0.0:37008'),1621        },1622    ),1623    ('tool', 'traffic-generator'): APIData(1624        single_value=True,1625        fully_understood=True,1626        fields={1627            'latency-distribution-max': KeyInfo(default='100us'),1628            'measure-out-of-order': KeyInfo(default=True),1629            'stats-samples-to-keep': KeyInfo(default=100),1630            'test-id': KeyInfo(default=0),1631        },1632    ),1633    ('user', 'aaa'): APIData(1634        single_value=True,1635        fully_understood=True,1636        fields={1637            'accounting': KeyInfo(default=True),1638            'default-group': KeyInfo(default='read'),1639            'exclude-groups': KeyInfo(default=''),1640            'interim-update': KeyInfo(default='0s'),1641            'use-radius': KeyInfo(default=False),1642        },1643    ),1644    ('queue', 'interface'): APIData(1645        primary_keys=('name', ),1646        fully_understood=True,1647        fields={1648            'name': KeyInfo(required=True),1649            'queue': KeyInfo(required=True),1650        },1651    ),1652    ('interface', 'ethernet', 'switch'): APIData(1653        fixed_entries=True,1654        primary_keys=('name', ),1655        fully_understood=True,1656        fields={1657            'cpu-flow-control': KeyInfo(default=True),1658            'mirror-source': KeyInfo(default='none'),1659            'mirror-target': KeyInfo(default='none'),1660            'name': KeyInfo(),1661        },1662    ),1663    ('interface', 'ethernet', 'switch', 'port'): APIData(1664        fixed_entries=True,1665        primary_keys=('name', ),1666        fully_understood=True,1667        fields={1668            'default-vlan-id': KeyInfo(),1669            'name': KeyInfo(),1670            'vlan-header': KeyInfo(default='leave-as-is'),1671            'vlan-mode': KeyInfo(default='disabled'),1672        },1673    ),1674    ('ip', 'dhcp-client', 'option'): APIData(1675        fixed_entries=True,1676        primary_keys=('name', ),1677        fully_understood=True,1678        fields={1679            'code': KeyInfo(),1680            'name': KeyInfo(),1681            'value': KeyInfo(),1682        },1683    ),1684    ('ppp', 'profile'): APIData(1685        has_identifier=True,1686        fields={1687            'address-list': KeyInfo(),1688            'bridge': KeyInfo(can_disable=True),1689            'bridge-horizon': KeyInfo(can_disable=True),1690            'bridge-learning': KeyInfo(),1691            'bridge-path-cost': KeyInfo(can_disable=True),1692            'bridge-port-priority': KeyInfo(can_disable=True),1693            'change-tcp-mss': KeyInfo(),1694            'dns-server': KeyInfo(can_disable=True),1695            'idle-timeout': KeyInfo(can_disable=True),1696            'incoming-filter': KeyInfo(can_disable=True),1697            'insert-queue-before': KeyInfo(can_disable=True),1698            'interface-list': KeyInfo(can_disable=True),1699            'local-address': KeyInfo(can_disable=True),1700            'name': KeyInfo(),1701            'on-down': KeyInfo(),1702            'on-up': KeyInfo(),1703            'only-one': KeyInfo(),1704            'outgoing-filter': KeyInfo(can_disable=True),1705            'parent-queue': KeyInfo(can_disable=True),1706            'queue-type': KeyInfo(can_disable=True),1707            'rate-limit': KeyInfo(can_disable=True),1708            'remote-address': KeyInfo(can_disable=True),1709            'session-timeout': KeyInfo(can_disable=True),1710            'use-compression': KeyInfo(),1711            'use-encryption': KeyInfo(),1712            'use-ipv6': KeyInfo(),1713            'use-mpls': KeyInfo(),1714            'use-upnp': KeyInfo(),1715            'wins-server': KeyInfo(can_disable=True),1716        },1717    ),1718    ('queue', 'type'): APIData(1719        has_identifier=True,1720        fields={1721            'kind': KeyInfo(),1722            'mq-pfifo-limit': KeyInfo(),1723            'name': KeyInfo(),1724            'pcq-burst-rate': KeyInfo(),1725            'pcq-burst-threshold': KeyInfo(),1726            'pcq-burst-time': KeyInfo(),1727            'pcq-classifier': KeyInfo(),1728            'pcq-dst-address-mask': KeyInfo(),1729            'pcq-dst-address6-mask': KeyInfo(),1730            'pcq-limit': KeyInfo(),1731            'pcq-rate': KeyInfo(),1732            'pcq-src-address-mask': KeyInfo(),1733            'pcq-src-address6-mask': KeyInfo(),1734            'pcq-total-limit': KeyInfo(),1735            'pfifo-limit': KeyInfo(),1736            'red-avg-packet': KeyInfo(),1737            'red-burst': KeyInfo(),1738            'red-limit': KeyInfo(),1739            'red-max-threshold': KeyInfo(),1740            'red-min-threshold': KeyInfo(),1741            'sfq-allot': KeyInfo(),1742            'sfq-perturb': KeyInfo(),1743        },1744    ),1745    ('routing', 'bgp', 'instance'): APIData(1746        fixed_entries=True,1747        primary_keys=('name', ),1748        fully_understood=True,1749        fields={1750            'as': KeyInfo(),1751            'client-to-client-reflection': KeyInfo(),1752            'cluster-id': KeyInfo(can_disable=True),1753            'confederation': KeyInfo(can_disable=True),1754            'disabled': KeyInfo(),1755            'ignore-as-path-len': KeyInfo(),1756            'name': KeyInfo(),1757            'out-filter': KeyInfo(),1758            'redistribute-connected': KeyInfo(),1759            'redistribute-ospf': KeyInfo(),1760            'redistribute-other-bgp': KeyInfo(),1761            'redistribute-rip': KeyInfo(),1762            'redistribute-static': KeyInfo(),1763            'router-id': KeyInfo(),1764            'routing-table': KeyInfo(),1765        },1766    ),1767    ('system', 'logging', 'action'): APIData(1768        has_identifier=True,1769        fields={1770            'bsd-syslog': KeyInfo(),1771            'disk-file-count': KeyInfo(),1772            'disk-file-name': KeyInfo(),1773            'disk-lines-per-file': KeyInfo(),1774            'disk-stop-on-full': KeyInfo(),1775            'memory-lines': KeyInfo(),1776            'memory-stop-on-full': KeyInfo(),1777            'name': KeyInfo(),1778            'remember': KeyInfo(),1779            'remote': KeyInfo(),1780            'remote-port': KeyInfo(),1781            'src-address': KeyInfo(),1782            'syslog-facility': KeyInfo(),1783            'syslog-severity': KeyInfo(),1784            'syslog-time-format': KeyInfo(),1785            'target': KeyInfo(),1786        },1787    ),1788    ('user', 'group'): APIData(1789        fixed_entries=True,1790        primary_keys=('name', ),1791        fully_understood=True,1792        fields={1793            'name': KeyInfo(),1794            'policy': KeyInfo(),1795            'skin': KeyInfo(default='default'),1796        },1797    ),1798    ('caps-man', 'manager'): APIData(1799        single_value=True,1800        fields={1801            'ca-certificate': KeyInfo(default='none'),1802            'certificate': KeyInfo(default='none'),1803            'enabled': KeyInfo(default=False),1804            'package-path': KeyInfo(default=''),1805            'require-peer-certificate': KeyInfo(default=False),1806            'upgrade-policy': KeyInfo(default='none'),1807        },1808    ),1809    ('ip', 'firewall', 'service-port'): APIData(1810        primary_keys=('name', ),1811        fully_understood=True,1812        fields={1813            'disabled': KeyInfo(default=False),1814            'name': KeyInfo(),1815            'ports': KeyInfo(),1816            'sip-direct-media': KeyInfo(),1817            'sip-timeout': KeyInfo(),1818        },1819    ),1820    ('ip', 'hotspot', 'service-port'): APIData(1821        fixed_entries=True,1822        primary_keys=('name', ),1823        fully_understood=True,1824        fields={1825            'disabled': KeyInfo(default=False),1826            'name': KeyInfo(),1827            'ports': KeyInfo(),1828        },1829    ),1830    ('ip', 'ipsec', 'policy'): APIData(1831        has_identifier=True,1832        fields={1833            'disabled': KeyInfo(),1834            'dst-address': KeyInfo(),1835            'group': KeyInfo(),1836            'proposal': KeyInfo(),1837            'protocol': KeyInfo(),1838            'src-address': KeyInfo(),1839            'template': KeyInfo(),1840        },1841    ),1842    ('ip', 'service'): APIData(1843        fixed_entries=True,1844        primary_keys=('name', ),1845        fully_understood=True,1846        fields={1847            'address': KeyInfo(),1848            'certificate': KeyInfo(),1849            'disabled': KeyInfo(default=False),1850            'name': KeyInfo(),1851            'port': KeyInfo(),1852            'tls-version': KeyInfo(),1853        },1854    ),1855    ('system', 'logging'): APIData(1856        has_identifier=True,1857        fields={1858            'action': KeyInfo(),1859            'disabled': KeyInfo(),1860            'prefix': KeyInfo(),1861            'topics': KeyInfo(),1862        },1863    ),1864    ('system', 'resource', 'irq'): APIData(1865        has_identifier=True,1866        fields={1867            'cpu': KeyInfo(),1868        },1869    ),...decorators.py
Source:decorators.py  
1from PrimeMega.modules.disable import (2    DisableAbleCommandHandler,3    DisableAbleMessageHandler,4)5from telegram.ext import (6    CommandHandler,7    MessageHandler,8    CallbackQueryHandler,9    InlineQueryHandler,10)11from telegram.ext.filters import BaseFilter12from PrimeMega import dispatcher as d, LOGGER13from typing import Optional, Union, List14class PrimeHandler:15    def __init__(self, d):16        self._dispatcher = d17    def command(18        self,19        command: str,20        filters: Optional[BaseFilter] = None,21        admin_ok: bool = False,22        pass_args: bool = False,23        pass_chat_data: bool = False,24        run_async: bool = True,25        can_disable: bool = True,26        group: Optional[Union[int]] = 40,27    ):28        def _command(func):29            try:30                if can_disable:31                    self._dispatcher.add_handler(32                        DisableAbleCommandHandler(33                            command,34                            func,35                            filters=filters,36                            run_async=run_async,37                            pass_args=pass_args,38                            admin_ok=admin_ok,39                        ),40                        group,41                    )42                else:43                    self._dispatcher.add_handler(44                        CommandHandler(45                            command,46                            func,47                            filters=filters,48                            run_async=run_async,49                            pass_args=pass_args,50                        ),51                        group,52                    )53                LOGGER.debug(54                    f"[PrimeCMD] Loaded handler {command} for function {func.__name__} in group {group}"55                )56            except TypeError:57                if can_disable:58                    self._dispatcher.add_handler(59                        DisableAbleCommandHandler(60                            command,61                            func,62                            filters=filters,63                            run_async=run_async,64                            pass_args=pass_args,65                            admin_ok=admin_ok,66                            pass_chat_data=pass_chat_data,67                        )68                    )69                else:70                    self._dispatcher.add_handler(71                        CommandHandler(72                            command,73                            func,74                            filters=filters,75                            run_async=run_async,76                            pass_args=pass_args,77                            pass_chat_data=pass_chat_data,78                        )79                    )80                LOGGER.debug(81                    f"[PrimeCMD] Loaded handler {command} for function {func.__name__}"82                )83            return func84        return _command85    def message(86        self,87        pattern: Optional[str] = None,88        can_disable: bool = True,89        run_async: bool = True,90        group: Optional[Union[int]] = 60,91        friendly=None,92    ):93        def _message(func):94            try:95                if can_disable:96                    self._dispatcher.add_handler(97                        DisableAbleMessageHandler(98                            pattern, func, friendly=friendly, run_async=run_async99                        ),100                        group,101                    )102                else:103                    self._dispatcher.add_handler(104                        MessageHandler(pattern, func, run_async=run_async), group105                    )106                LOGGER.debug(107                    f"[PrimeMSG] Loaded filter pattern {pattern} for function {func.__name__} in group {group}"108                )109            except TypeError:110                if can_disable:111                    self._dispatcher.add_handler(112                        DisableAbleMessageHandler(113                            pattern, func, friendly=friendly, run_async=run_async114                        )115                    )116                else:117                    self._dispatcher.add_handler(118                        MessageHandler(pattern, func, run_async=run_async)119                    )120                LOGGER.debug(121                    f"[PrimeMSG] Loaded filter pattern {pattern} for function {func.__name__}"122                )123            return func124        return _message125    def callbackquery(self, pattern: str = None, run_async: bool = True):126        def _callbackquery(func):127            self._dispatcher.add_handler(128                CallbackQueryHandler(129                    pattern=pattern, callback=func, run_async=run_async130                )131            )132            LOGGER.debug(133                f"[PrimeCALLBACK] Loaded callbackquery handler with pattern {pattern} for function {func.__name__}"134            )135            return func136        return _callbackquery137    def inlinequery(138        self,139        pattern: Optional[str] = None,140        run_async: bool = True,141        pass_user_data: bool = True,142        pass_chat_data: bool = True,143        chat_types: List[str] = None,144    ):145        def _inlinequery(func):146            self._dispatcher.add_handler(147                InlineQueryHandler(148                    pattern=pattern,149                    callback=func,150                    run_async=run_async,151                    pass_user_data=pass_user_data,152                    pass_chat_data=pass_chat_data,153                    chat_types=chat_types,154                )155            )156            LOGGER.debug(157                f"[PrimeINLINE] Loaded inlinequery handler with pattern {pattern} for function {func.__name__} | PASSES USER DATA: {pass_user_data} | PASSES CHAT DATA: {pass_chat_data} | CHAT TYPES: {chat_types}"158            )159            return func160        return _inlinequery161Primecmd = PrimeHandler(d).command162Primemsg = PrimeHandler(d).message163Primecallback = PrimeHandler(d).callbackquery...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
