diff --git a/share/actionsmap.yml b/share/actionsmap.yml index 86ef3848a..969a2e07c 100644 --- a/share/actionsmap.yml +++ b/share/actionsmap.yml @@ -563,6 +563,20 @@ domain: path: help: The path to check (e.g. /coffee) + ### domain_action_run() + action-run: + hide_in_help: True + action_help: Run domain action + api: PUT /domain//actions/ + arguments: + domain: + help: Domain name + action: + help: action id + -a: + full: --args + help: Serialized arguments for action (i.e. "foo=bar&lorem=ipsum") + subcategories: config: diff --git a/share/config_domain.toml b/share/config_domain.toml index e7f43f84d..14bb72a67 100644 --- a/share/config_domain.toml +++ b/share/config_domain.toml @@ -106,7 +106,6 @@ i18n = "domain_config" style = "success" visible = "issuer != 'letsencrypt'" enabled = "acme_eligible or cert_no_checks" - # ??? api = "PUT /domains/{domain}/cert?force&" [cert.cert.cert_renew] ask = "Renew Let's Encrypt certificate" diff --git a/src/domain.py b/src/domain.py index 4456d972c..45a516f7d 100644 --- a/src/domain.py +++ b/src/domain.py @@ -530,14 +530,23 @@ class DomainConfigPanel(ConfigPanel): self.values["cert_issuer"] = self.cert_status["CA_type"] self.values["acme_eligible"] = self.cert_status["ACME_eligible"] - def _run_action(self, action): - if action == "cert_install": - from yunohost.certificate import certificate_install as action_func - elif action == "cert_renew": - from yunohost.certificate import certificate_renew as action_func +@is_unit_operation() +def domain_action_run( + operation_logger, domain, action, args=None +): - action_func([self.entity], force=True, no_checks=self.new_values["cert_no_checks"]) + import urllib.parse + + if action == "cert.cert.cert_install": + from yunohost.certificate import certificate_install as action_func + elif action == "cert.cert.cert_renew": + from yunohost.certificate import certificate_renew as action_func + + args = dict(urllib.parse.parse_qsl(args or "", keep_blank_values=True)) + no_checks = bool(args["cert_no_checks"]) + + action_func([domain], force=True, no_checks=no_checks) def _get_domain_settings(domain: str) -> dict: