]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Return record last modification time in API when known.
authorMiod Vallat <miod.vallat@powerdns.com>
Fri, 18 Jul 2025 07:07:18 +0000 (09:07 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Fri, 18 Jul 2025 07:07:18 +0000 (09:07 +0200)
Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
docs/http-api/swagger/authoritative-api-swagger.yaml
pdns/dns.hh
pdns/ws-auth.cc

index c80cbb21394eefb6734b42417cf37720abf6aa96..df1da4b79a54be5e1ca20af195e18a3efa2809b0 100644 (file)
@@ -1,6 +1,6 @@
 swagger: '2.0'
 info:
-  version: "0.0.16"
+  version: "0.0.17"
   title: PowerDNS Authoritative HTTP API
   license:
     name: MIT
@@ -1289,6 +1289,9 @@ definitions:
       disabled:
         type: boolean
         description: 'Whether or not this record is disabled. When unset, the record is not disabled'
+      modified_at:
+        type: integer
+        description: 'Timestamp of the last change to the record'
 
   Comment:
     title: Comment
index 1b55e859d01be924fb31ed196e97eb0410d5ad4e..e1be00222f14b1bd0a2431c8c71baae8cb34ecf6 100644 (file)
@@ -90,7 +90,7 @@ public:
 
   // Aligned on 8-byte boundaries on systems where time_t is 8 bytes and int
   // is 4 bytes, aka modern linux on x86_64
-  time_t last_modified{}; //!< For autocalculating SOA serial numbers - the backend needs to fill this in
+  time_t last_modified{}; //!< Timestamp of last update, if known by the backend
 
   uint32_t ttl{}; //!< Time To Live of this record
   uint32_t signttl{}; //!< If non-zero, use this TTL as original TTL in the RRSIG
index a72e5c057a117ad2422067ddf5d643ccc900b0ad..47ac61eecd1c5139c6b61c021a76f75442e828da 100644 (file)
@@ -525,9 +525,13 @@ static void fillZone(UeberBackend& backend, const ZoneName& zonename, HttpRespon
 
       while (rit != records.end() && rit->qname == current_qname && rit->qtype == current_qtype) {
         ttl = min(ttl, rit->ttl);
-        rrset_records.push_back(Json::object{
+        auto object = Json::object{
           {"disabled", rit->disabled},
-          {"content", makeApiRecordContent(rit->qtype, rit->content)}});
+          {"content", makeApiRecordContent(rit->qtype, rit->content)}};
+        if (rit->last_modified != 0) {
+          object["modified_at"] = (double)rit->last_modified;
+        }
+        rrset_records.push_back(object);
         rit++;
       }
       while (cit != comments.end() && cit->qname == current_qname && cit->qtype == current_qtype) {
@@ -2596,6 +2600,9 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp)
         {"ttl", (double)resourceRecord.ttl},
         {"disabled", resourceRecord.disabled},
         {"content", makeApiRecordContent(resourceRecord.qtype, resourceRecord.content)}};
+      if (resourceRecord.last_modified != 0) {
+        object["modified_at"] = (double)resourceRecord.last_modified;
+      }
 
       val = zoneIdZone.find(resourceRecord.domain_id);
       if (val != zoneIdZone.end()) {