]
}
-Valid values for `<metadata_kind>` are specified in
+##### Parameters:
+
+`kind`: valid values for `<metadata_kind>` are specified in
[the `domainmetadata` documentation](../authoritative/domainmetadata.md).
-Clients MUST NOT modify `NSEC3PARAM`, `NSEC3NARROW` or `PRESIGNED`
-through this interface. The server SHOULD reject updates to these
-metadata.
+`metadata`: an array with all values for this metadata kind.
+
+Clients MUST NOT modify `NSEC3PARAM`, `NSEC3NARROW`, `PRESIGNED` and
+`LUA-AXFR-SCRIPT` through this interface. The server rejects updates to
+these metadata. Modifications to custom metadata kinds are rejected
+through this interface.
URL: /api/v1/servers/:server\_id/zones/:zone\_name/metadata
Allowed methods: `GET`, `POST`
-**TODO**: Not yet implemented.
+#### GET
+
+Returns all metadata entries for the zone.
+
+
+#### POST
+
+Creates a set of metadata entries of given kind for the zone.
+
+* existing metadata entries for the zone with the same kind are not overwritten.
+
URL: /api/v1/servers/:server\_id/zones/:zone\_name/metadata/:metadata\_kind
---------------------------------------------------------------------------
Allowed methods: `GET`, `PUT`, `DELETE`
-**TODO**: Not yet implemented.
+#### GET
+
+Returns all metadata entries of a given kind for the zone.
+
+
+#### DELETE
+
+Deletes all metadata entries of a given kind for the zone.
+
+
+#### PUT
+
+Modifies the metadata entries of a given kind for the zone.
+
+This returns `200 OK` on success.
+
CryptoKeys
==========
throw ApiException("Unsupported metadata kind '" + kind + "'");
vector<string> vecMetadata;
+
+ if (!B.getDomainMetadata(zonename, kind, vecMetadata))
+ throw ApiException("Could not retrieve metadata entries for domain '" +
+ zonename.toString() + "'");
+
auto& metadata = document["metadata"];
if (!metadata.is_array())
throw ApiException("metadata is not specified or not an array");
for (const auto& i : metadata.array_items()) {
if (!i.is_string())
throw ApiException("metadata must be strings");
- vecMetadata.push_back(i.string_value());
+ else if (std::find(vecMetadata.cbegin(),
+ vecMetadata.cend(),
+ i.string_value()) == vecMetadata.cend()) {
+ vecMetadata.push_back(i.string_value());
+ }
}
if (!B.setDomainMetadata(zonename, kind, vecMetadata))
- throw ApiException("Could not update metadata entries for domain '" + zonename.toString() + "'");
+ throw ApiException("Could not update metadata entries for domain '" +
+ zonename.toString() + "'");
+
+ Json::array respMetadata;
+ for (const string& s : vecMetadata)
+ respMetadata.push_back(s);
+
+ Json::object key {
+ { "type", "Metadata" },
+ { "kind", document["kind"] },
+ { "metadata", respMetadata }
+ };
resp->status = 201;
+ resp->setBody(key);
} else
throw HttpMethodNotAllowedException();
}