configpanel: Implement 'hidden' domain_action_run route

This commit is contained in:
Alexandre Aubin 2022-02-08 16:07:35 +01:00
parent c39f0ae3bc
commit 40ad8ce25e
3 changed files with 29 additions and 7 deletions

View file

@ -563,6 +563,20 @@ domain:
path: path:
help: The path to check (e.g. /coffee) 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/<domain>/actions/<action>
arguments:
domain:
help: Domain name
action:
help: action id
-a:
full: --args
help: Serialized arguments for action (i.e. "foo=bar&lorem=ipsum")
subcategories: subcategories:
config: config:

View file

@ -106,7 +106,6 @@ i18n = "domain_config"
style = "success" style = "success"
visible = "issuer != 'letsencrypt'" visible = "issuer != 'letsencrypt'"
enabled = "acme_eligible or cert_no_checks" enabled = "acme_eligible or cert_no_checks"
# ??? api = "PUT /domains/{domain}/cert?force&"
[cert.cert.cert_renew] [cert.cert.cert_renew]
ask = "Renew Let's Encrypt certificate" ask = "Renew Let's Encrypt certificate"

View file

@ -530,14 +530,23 @@ class DomainConfigPanel(ConfigPanel):
self.values["cert_issuer"] = self.cert_status["CA_type"] self.values["cert_issuer"] = self.cert_status["CA_type"]
self.values["acme_eligible"] = self.cert_status["ACME_eligible"] self.values["acme_eligible"] = self.cert_status["ACME_eligible"]
def _run_action(self, action):
if action == "cert_install": @is_unit_operation()
from yunohost.certificate import certificate_install as action_func def domain_action_run(
elif action == "cert_renew": operation_logger, domain, action, args=None
from yunohost.certificate import certificate_renew as action_func ):
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: def _get_domain_settings(domain: str) -> dict: