put:
summary: Modifies basic zone data.
- description: 'The only fields in the zone structure which can be modified are: kind, masters, account, soa_edit, soa_edit_api, api_rectify, dnssec, and nsec3param. All other fields are ignored.'
+ description: 'The only fields in the zone structure which can be modified are: kind, masters, catalog, account, soa_edit, soa_edit_api, api_rectify, dnssec, and nsec3param. All other fields are ignored.'
operationId: putZone
tags:
- zones
- 'Native'
- 'Master'
- 'Slave'
- description: 'Zone kind, one of “Native”, “Master”, “Slave”'
+ - 'Producer'
+ - 'Consumer'
+ description: 'Zone kind, one of “Native”, “Master”, “Slave”, “Producer”, “Consumer”'
rrsets:
type: array
items:
description: 'The SOA-EDIT-API metadata item'
api_rectify:
type: boolean
- description: ' Whether or not the zone will be rectified on data changes via the API'
+ description: 'Whether or not the zone will be rectified on data changes via the API'
zone:
type: string
description: 'MAY contain a BIND-style zone file when creating a zone'
+ catalog:
+ type: string
+ description: 'The catalog this zone is a member of'
account:
type: string
description: 'MAY be set. Its value is defined by local policy'
declare(suffix, "update-master-query", "", "update domains set master=:master where name=:domain");
declare(suffix, "update-kind-query", "", "update domains set type=:kind where name=:domain");
declare(suffix, "update-options-query", "", "update domains set options=:options where name=:domain");
- declare(suffix, "update-catalog-query", "", "update domains set catalog=:options where name=:domain");
+ declare(suffix, "update-catalog-query", "", "update domains set catalog=:catalog where name=:domain");
declare(suffix, "update-account-query", "", "update domains set account=:account where name=:domain");
declare(suffix, "update-serial-query", "", "update domains set notified_serial=:serial where id=:domain_id");
declare(suffix, "update-lastcheck-query", "", "update domains set last_check=:last_check where id=:domain_id");
masters.push_back(m.toStringWithPortExcept(53));
}
- auto obj = Json::object {
+ auto obj = Json::object{
// id is the canonical lookup key, which doesn't actually match the name (in some cases)
- { "id", zoneId },
- { "url", "/api/v1/servers/localhost/zones/" + zoneId },
- { "name", di.zone.toString() },
- { "kind", di.getKindString() },
- { "account", di.account },
- { "masters", std::move(masters) },
- { "serial", (double)di.serial },
- { "notified_serial", (double)di.notified_serial },
- { "last_check", (double)di.last_check }
- };
+ {"id", zoneId},
+ {"url", "/api/v1/servers/localhost/zones/" + zoneId},
+ {"name", di.zone.toString()},
+ {"kind", di.getKindString()},
+ {"catalog", (!di.catalog.empty() ? di.catalog.toString() : "")},
+ {"account", di.account},
+ {"masters", std::move(masters)},
+ {"serial", (double)di.serial},
+ {"notified_serial", (double)di.notified_serial},
+ {"last_check", (double)di.last_check}};
if (dk) {
obj["dnssec"] = dk->isSecuredZone(di.zone);
string soa_edit;
+ "capable backends are loaded, or because the backends have DNSSEC disabled. Check your configuration.");
}
-
-static void extractDomainInfoFromDocument(const Json& document, boost::optional<DomainInfo::DomainKind>& kind, boost::optional<vector<ComboAddress>>& masters, boost::optional<string>& account) {
+static void extractDomainInfoFromDocument(const Json& document, boost::optional<DomainInfo::DomainKind>& kind, boost::optional<vector<ComboAddress>>& masters, boost::optional<DNSName>& catalog, boost::optional<string>& account)
+{
if (document["kind"].is_string()) {
kind = DomainInfo::stringToKind(stringFromJson(document, "kind"));
} else {
masters = boost::none;
}
+ if (document["catalog"].is_string()) {
+ string catstring = document["catalog"].string_value();
+ catalog = (!catstring.empty() ? DNSName(catstring) : DNSName());
+ }
+ else {
+ catalog = boost::none;
+ }
+
if (document["account"].is_string()) {
account = document["account"].string_value();
} else {
static void updateDomainSettingsFromDocument(UeberBackend& B, const DomainInfo& di, const DNSName& zonename, const Json& document, bool rectifyTransaction=true) {
boost::optional<DomainInfo::DomainKind> kind;
boost::optional<vector<ComboAddress>> masters;
+ boost::optional<DNSName> catalog;
boost::optional<string> account;
- extractDomainInfoFromDocument(document, kind, masters, account);
+ extractDomainInfoFromDocument(document, kind, masters, catalog, account);
if (kind) {
di.backend->setKind(zonename, *kind);
if (masters) {
di.backend->setMasters(zonename, *masters);
}
+ if (catalog) {
+ di.backend->setCatalog(zonename, *catalog);
+ }
if (account) {
di.backend->setAccount(zonename, *account);
}
boost::optional<DomainInfo::DomainKind> kind;
boost::optional<vector<ComboAddress>> masters;
+ boost::optional<DNSName> catalog;
boost::optional<string> account;
- extractDomainInfoFromDocument(document, kind, masters, account);
+ extractDomainInfoFromDocument(document, kind, masters, catalog, account);
// no going back after this
if(!B.createDomain(zonename, kind.get_value_or(DomainInfo::Native), masters.get_value_or(vector<ComboAddress>()), account.get_value_or("")))
self.assertGreater(soa_serial, payload['serial'])
self.assertEqual(soa_serial, data['serial'])
+ def test_create_zone_with_catalog(self):
+ # soa_edit_api wins over serial
+ name, payload, data = self.create_zone(catalog='catalog.invalid.', serial=10)
+ print(data)
+ for k in ('catalog', ):
+ self.assertIn(k, data)
+ if k in payload:
+ self.assertEqual(data[k], payload[k])
+
def test_create_zone_with_account(self):
# soa_edit_api wins over serial
name, payload, data = self.create_zone(account='anaccount', serial=10)
payload = {
'kind': 'Master',
'masters': ['192.0.2.1', '192.0.2.2'],
+ 'catalog': 'catalog.invalid.',
'soa_edit_api': 'EPOCH',
'soa_edit': 'EPOCH'
}
# update, back to Native and empty(off)
payload = {
'kind': 'Native',
+ 'catalog': '',
'soa_edit_api': '',
'soa_edit': ''
}