#!/usr/bin/env python3 from cmk.gui.i18n import _ from cmk.gui.plugins.wato.special_agents.common import RulespecGroupDatasourceProgramsApps from cmk.gui.plugins.wato.utils import ( HostRulespec, Rulespec, IndividualOrStoredPassword, rulespec_registry, ) from cmk.gui.valuespec import ( Dictionary, ListChoice, Checkbox, TextAscii, Password, ) def _factory_default_special_agent_nextcloud(): return Rulespec.FACTORY_DEFAULT_UNUSED def _valuespec_special_agent_nextcloud(): return Dictionary( title=_("Nextcloud Server Information"), help = _("Checking Nextcloud servers via API"), elements=[ ("hostname", TextAscii(title=_("Hostname"), allow_empty=False, size = 40, help=_("Hostname of Nextcloud server (bare FQDN or IP), mandatory, eg. nextcloud.yourdomain.tld"))), ("username", TextAscii(title=_("Username"), size = 40, allow_empty=False, help=_("Username with administrative rights, mandatory"))), ("password", IndividualOrStoredPassword(title=_("App Password"), size = 40, allow_empty=False, help=_("Specify app password, mandatory, use Personal Settings|Security|Devices and Sessions within the NC UI to create one for the given user"))), ("port", TextAscii(title=_("Port"), allow_empty=True, help=_("Specify port if not listening to HTTP(S), optional"))), ("folder", TextAscii(title=_("Folder"), allow_empty=True, help=_("Specify subfolder if your Nextcloud instance is not installed in the web root, no trailing/leading slashes, optional"))), ("no_https", Checkbox(title=_("Disable HTTPS"), help=_("Activate to disable encryption (not recommended), optional"))), ("no_cert_check", Checkbox(title=_("Disable certificate validation"), help=_("Activate to disable certificate validation (not recommended), optional"))), ], optional_keys=[], ) rulespec_registry.register( HostRulespec( factory_default = _factory_default_special_agent_nextcloud(), group = RulespecGroupDatasourceProgramsApps, name = "special_agents:nextcloud", valuespec = _valuespec_special_agent_nextcloud, ) )