mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Change API naming etc. Expect a new change to come!
This commit is contained in:
parent
f295dffd00
commit
fa818a476a
2 changed files with 92 additions and 69 deletions
|
@ -460,31 +460,6 @@ domain:
|
|||
help: Do not ask confirmation to remove apps
|
||||
action: store_true
|
||||
|
||||
settings:
|
||||
action_help: Get settings for a domain
|
||||
api: GET /domains/<domain>/settings
|
||||
arguments:
|
||||
domain:
|
||||
help: Target domain
|
||||
|
||||
set-settings:
|
||||
action_help: Set settings of a domain
|
||||
api: POST /domains/<domain>/settings
|
||||
arguments:
|
||||
domain:
|
||||
help: Target domain
|
||||
-t:
|
||||
full: --ttl
|
||||
help: Time To Live of this domain's DNS records
|
||||
-x:
|
||||
full: --xmpp
|
||||
help: Configure XMPP in this domain's DNS records? True or False
|
||||
-m:
|
||||
full: --mail
|
||||
help: Configure mail in this domain's DNS records? True or False
|
||||
-o:
|
||||
full: --owned-dns-zone
|
||||
help: Is this domain owned as a DNS zone? Is it a full domain, i.e not a subdomain? True or False
|
||||
|
||||
### domain_dns_conf()
|
||||
dns-conf:
|
||||
|
@ -493,6 +468,8 @@ domain:
|
|||
arguments:
|
||||
domain:
|
||||
help: Target domain
|
||||
extra:
|
||||
pattern: *pattern_domain
|
||||
|
||||
### domain_maindomain()
|
||||
main-domain:
|
||||
|
@ -575,6 +552,62 @@ domain:
|
|||
path:
|
||||
help: The path to check (e.g. /coffee)
|
||||
|
||||
subcategories:
|
||||
config:
|
||||
subcategory_help: Domains DNS settings
|
||||
actions:
|
||||
# domain_config_list
|
||||
list:
|
||||
action_help: Get settings for all domains
|
||||
api: GET /domains/list
|
||||
arguments:
|
||||
domain:
|
||||
help: Target domain
|
||||
extra:
|
||||
pattern: *pattern_domain
|
||||
|
||||
# domain_config_show
|
||||
show:
|
||||
action_help: Get settings for all domains
|
||||
api: GET /domains/<domain>/show
|
||||
arguments:
|
||||
domain:
|
||||
help: Target domain
|
||||
extra:
|
||||
pattern: *pattern_domain
|
||||
|
||||
# domain_config_get
|
||||
get:
|
||||
action_help: Get specific setting of a domain
|
||||
api: GET /domains/<domain>/<key>
|
||||
arguments:
|
||||
domain:
|
||||
help: Target domain
|
||||
extra:
|
||||
pattern: *pattern_domain
|
||||
key:
|
||||
help: Setting requested. One of ttl, xmpp, mail, owned_dns_zone
|
||||
extra:
|
||||
pattern: &pattern_domain_key
|
||||
- !!str ^(ttl)|(xmpp)|(mail)|(owned_dns_zone)|$
|
||||
- "pattern_domain_key"
|
||||
|
||||
# domain_config_set
|
||||
set:
|
||||
action_help: Set a setting of a domain
|
||||
api: POST /domains/<domain>/<key>
|
||||
arguments:
|
||||
domain:
|
||||
help: Target domain
|
||||
extra:
|
||||
pattern: *pattern_domain
|
||||
key:
|
||||
help: Setting requested. One of ttl (Time To Live of this domain's DNS records), xmpp (Configure XMPP in this domain's DNS records?), mail (Configure mail in this domain's DNS records?), owned_dns_zone (Is it a full domain, i.e not a subdomain?)
|
||||
extra:
|
||||
pattern: *pattern_domain_key
|
||||
value:
|
||||
help: Value of the setting. Must be a positive integer number for "ttl", or one of ("True", "False", "true", "false", "1", "0") for other settings
|
||||
|
||||
|
||||
### domain_info()
|
||||
# info:
|
||||
|
|
|
@ -705,10 +705,8 @@ def _load_domain_settings():
|
|||
is_maindomain = domain == maindomain
|
||||
domain_in_old_domains = domain in old_domains.keys()
|
||||
# Update each setting if not present
|
||||
new_domains[domain] = {
|
||||
# Set "main" value
|
||||
"main": is_maindomain
|
||||
}
|
||||
new_domains[domain] = {}
|
||||
# new_domains[domain] = { "main": is_maindomain }
|
||||
# Set other values (default value if missing)
|
||||
for setting, default in [ ("xmpp", is_maindomain), ("mail", is_maindomain), ("owned_dns_zone", True), ("ttl", 3600) ]:
|
||||
if domain_in_old_domains and setting in old_domains[domain].keys():
|
||||
|
@ -719,9 +717,9 @@ def _load_domain_settings():
|
|||
return new_domains
|
||||
|
||||
|
||||
def domain_settings(domain):
|
||||
def domain_config_show(domain):
|
||||
"""
|
||||
Get settings of a domain
|
||||
Show settings of a domain
|
||||
|
||||
Keyword arguments:
|
||||
domain -- The domain name
|
||||
|
@ -729,6 +727,18 @@ def domain_settings(domain):
|
|||
return _get_domain_settings(domain, False)
|
||||
|
||||
|
||||
def domain_config_get(domain, key):
|
||||
"""
|
||||
Show a setting of a domain
|
||||
|
||||
Keyword arguments:
|
||||
domain -- The domain name
|
||||
key -- ttl, xmpp, mail, owned_dns_zone
|
||||
"""
|
||||
settings = _get_domain_settings(domain, False)
|
||||
return settings[domain][key]
|
||||
|
||||
|
||||
def _get_domain_settings(domain, subdomains):
|
||||
"""
|
||||
Get settings of a domain
|
||||
|
@ -740,7 +750,7 @@ def _get_domain_settings(domain, subdomains):
|
|||
"""
|
||||
domains = _load_domain_settings()
|
||||
if not domain in domains.keys():
|
||||
return {}
|
||||
raise YunohostError("domain_name_unknown", domain=domain)
|
||||
|
||||
only_wanted_domains = dict()
|
||||
for entry in domains.keys():
|
||||
|
@ -754,16 +764,19 @@ def _get_domain_settings(domain, subdomains):
|
|||
return only_wanted_domains
|
||||
|
||||
|
||||
def domain_set_settings(domain, ttl=None, xmpp=None, mail=None, owned_dns_zone=None):
|
||||
def domain_config_set(domain, key, value):
|
||||
#(domain, ttl=None, xmpp=None, mail=None, owned_dns_zone=None):
|
||||
"""
|
||||
Set some settings of a domain, for DNS generation.
|
||||
|
||||
Keyword arguments:
|
||||
domain -- The domain name
|
||||
--ttl -- the Time To Live for this domains DNS record
|
||||
--xmpp -- configure XMPP DNS records for this domain
|
||||
--mail -- configure mail DNS records for this domain
|
||||
--owned_dns_zone -- is this domain DNS zone owned? (is it a full domain or a subdomain?)
|
||||
key must be one of this strings:
|
||||
ttl -- the Time To Live for this domains DNS record
|
||||
xmpp -- configure XMPP DNS records for this domain
|
||||
mail -- configure mail DNS records for this domain
|
||||
owned_dns_zone -- is this domain DNS zone owned? (is it a full domain or a subdomain?)
|
||||
value must be set according to the key
|
||||
"""
|
||||
domains = _load_domain_settings()
|
||||
|
||||
|
@ -771,11 +784,9 @@ def domain_set_settings(domain, ttl=None, xmpp=None, mail=None, owned_dns_zone=N
|
|||
# TODO add locales
|
||||
raise YunohostError("domain_name_unknown", domain=domain)
|
||||
|
||||
setting_set = False
|
||||
|
||||
if ttl is not None:
|
||||
if "ttl" == key:
|
||||
try:
|
||||
ttl = int(ttl)
|
||||
ttl = int(value)
|
||||
except:
|
||||
# TODO add locales
|
||||
raise YunohostError("bad_value_type", value_type=type(ttl))
|
||||
|
@ -785,38 +796,17 @@ def domain_set_settings(domain, ttl=None, xmpp=None, mail=None, owned_dns_zone=N
|
|||
raise YunohostError("must_be_positive", value_type=type(ttl))
|
||||
|
||||
domains[domain]["ttl"] = ttl
|
||||
setting_set = True
|
||||
|
||||
if xmpp is not None:
|
||||
try:
|
||||
xmpp = xmpp in ["True", "true", "1"]
|
||||
except:
|
||||
# TODO add locales
|
||||
raise YunohostError("bad_value_type", value_type=type(xmpp))
|
||||
domains[domain]["xmpp"] = xmpp
|
||||
setting_set = True
|
||||
elif "xmpp" == key:
|
||||
domains[domain]["xmpp"] = value in ["True", "true", "1"]
|
||||
|
||||
if mail is not None:
|
||||
try:
|
||||
mail = mail in ["True", "true", "1"]
|
||||
except:
|
||||
# TODO add locales
|
||||
raise YunohostError("bad_value_type", value_type=type(mail))
|
||||
elif "mail" == key:
|
||||
domains[domain]["mail"] = value in ["True", "true", "1"]
|
||||
|
||||
domains[domain]["mail"] = mail
|
||||
setting_set = True
|
||||
elif "owned_dns_zone" == key:
|
||||
domains[domain]["owned_dns_zone"] = value in ["True", "true", "1"]
|
||||
|
||||
if owned_dns_zone is not None:
|
||||
try:
|
||||
owned_dns_zone = owned_dns_zone in ["True", "true", "1"]
|
||||
except:
|
||||
# TODO add locales
|
||||
raise YunohostError("bad_value_type", value_type=type(owned_dns_zone))
|
||||
|
||||
domains[domain]["owned_dns_zone"] = owned_dns_zone
|
||||
setting_set = True
|
||||
|
||||
if not setting_set:
|
||||
else:
|
||||
# TODO add locales
|
||||
raise YunohostError("no_setting_given")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue