Bladeren bron

feat(api,docs): expose RRset.touched

Peter Thomassen 5 jaren geleden
bovenliggende
commit
953b14f1b9
3 gewijzigde bestanden met toevoegingen van 13 en 2 verwijderingen
  1. 1 1
      api/desecapi/serializers.py
  2. 2 0
      api/desecapi/tests/test_rrsets.py
  3. 10 1
      docs/dns/rrsets.rst

+ 1 - 1
api/desecapi/serializers.py

@@ -208,7 +208,7 @@ class RRsetSerializer(ConditionalExistenceModelSerializer):
 
     class Meta:
         model = models.RRset
-        fields = ('created', 'domain', 'subname', 'name', 'records', 'ttl', 'type',)
+        fields = ('created', 'domain', 'subname', 'name', 'records', 'ttl', 'type', 'touched',)
         extra_kwargs = {
             'subname': {'required': False, 'default': NonBulkOnlyDefault('')}
         }

+ 2 - 0
api/desecapi/tests/test_rrsets.py

@@ -141,6 +141,8 @@ class AuthenticatedRRSetTestCase(AuthenticatedRRSetBaseTestCase):
 
                 with self.assertPdnsRequests(self.requests_desec_rr_sets_update(name=self.my_empty_domain.name)):
                     response = self.client.post_rr_set(domain_name=self.my_empty_domain.name, **data)
+                    self.assertTrue(all(field in response.data for field in
+                                        ['created', 'domain', 'subname', 'name', 'records', 'ttl', 'type', 'touched']))
                     self.assertStatus(response, status.HTTP_201_CREATED)
 
                 # Check for uniqueness on second attempt

+ 10 - 1
docs/dns/rrsets.rst

@@ -43,7 +43,8 @@ A JSON object representing an RRset has the following structure::
             "127.0.0.1",
             "127.0.0.2"
         ],
-        "ttl": 3600
+        "ttl": 3600,
+        "touched": "2020-04-06T09:24:09.987436Z"
     }
 
 Field details:
@@ -115,6 +116,14 @@ Field details:
 
 .. _RRset types supported by PowerDNS: https://doc.powerdns.com/md/types/
 
+``touched``
+    :Access mode: read-only
+
+    Timestamp of when the RRset was last touched (same format as ``created``).
+    This field reflects the most recent write request to the RRset. It is also
+    updated when the write request does not actually change anything (e.g.
+    overwriting a DNS record with identical values).
+
 
 Creating an RRset
 ~~~~~~~~~~~~~~~~~