]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Rename type to object_type 7326/head
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 8 Feb 2019 11:24:59 +0000 (12:24 +0100)
committerChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Fri, 8 Feb 2019 11:24:59 +0000 (12:24 +0100)
docs/http-api/swagger/authoritative-api-swagger.yaml
pdns/ws-auth.cc
regression-tests.api/test_Zones.py

index ce9918adeeb0e8c0fdba3368bb695c9ff18d5c07..0c4570e69bb46f3685b945a6fcf5f535773c9a2a 100644 (file)
@@ -436,7 +436,7 @@ paths:
           required: true
           description: 'Maximum number of entries to return'
           type: integer
-        - name: type
+        - name: object_type
           in: query
           required: false
           description: 'Type of data to search for, one of “all”, “zone”, “record”, “comment”'
index fbd5cb506f80dcddaf642114aedfc34f85aaa0ac..e97a379937680b0def394e2e97bbf8b0979f49c2 100644 (file)
@@ -2041,19 +2041,19 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
 
   string q = req->getvars["q"];
   string sMax = req->getvars["max"];
-  string sType = req->getvars["type"];
+  string sObjectType = req->getvars["object_type"];
 
   int maxEnts = 100;
   int ents = 0;
 
   // the following types of data can be searched for using the api
-  enum class Type
+  enum class ObjectType
   {
     ALL,
     ZONE,
     RECORD,
     COMMENT
-  } type;
+  } objectType;
 
   if (q.empty())
     throw ApiException("Query q can't be blank");
@@ -2062,18 +2062,18 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
   if (maxEnts < 1)
     throw ApiException("Maximum entries must be larger than 0");
 
-  if (sType.empty())
-    type = Type::ALL;
-  else if (sType == "all")
-    type = Type::ALL;
-  else if (sType == "zone")
-    type = Type::ZONE;
-  else if (sType == "record")
-    type = Type::RECORD;
-  else if (sType == "comment")
-    type = Type::COMMENT;
+  if (sObjectType.empty())
+    objectType = ObjectType::ALL;
+  else if (sObjectType == "all")
+    objectType = ObjectType::ALL;
+  else if (sObjectType == "zone")
+    objectType = ObjectType::ZONE;
+  else if (sObjectType == "record")
+    objectType = ObjectType::RECORD;
+  else if (sObjectType == "comment")
+    objectType = ObjectType::COMMENT;
   else
-    throw ApiException("Type must be one of the following options: all, zone, record, comment");
+    throw ApiException("object_type must be one of the following options: all, zone, record, comment");
 
   SimpleMatch sm(q,true);
   UeberBackend B;
@@ -2088,7 +2088,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
 
   for(const DomainInfo di: domains)
   {
-    if ((type == Type::ALL || type == Type::ZONE) && ents < maxEnts && sm.match(di.zone)) {
+    if ((objectType == ObjectType::ALL || objectType == ObjectType::ZONE) && ents < maxEnts && sm.match(di.zone)) {
       doc.push_back(Json::object {
         { "object_type", "zone" },
         { "zone_id", apiZoneNameToId(di.zone) },
@@ -2099,7 +2099,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
     zoneIdZone[di.id] = di; // populate cache
   }
 
-  if ((type == Type::ALL || type == Type::RECORD) && B.searchRecords(q, maxEnts, result_rr))
+  if ((objectType == ObjectType::ALL || objectType == ObjectType::RECORD) && B.searchRecords(q, maxEnts, result_rr))
   {
     for(const DNSResourceRecord& rr: result_rr)
     {
@@ -2122,7 +2122,7 @@ static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
     }
   }
 
-  if ((type == Type::ALL || type == Type::COMMENT) && B.searchComments(q, maxEnts, result_c))
+  if ((objectType == ObjectType::ALL || objectType == ObjectType::COMMENT) && B.searchComments(q, maxEnts, result_c))
   {
     for(const Comment &c: result_c)
     {
index 636ea439ea93fae021e125d7a44ac582bf59b793..ae9cf4b9177a1196305910011bbb0c88fb352a19 100644 (file)
@@ -1621,7 +1621,7 @@ fred   IN  A      192.168.0.4
         name = unique_zone_name()
         data_type = "zone"
         self.create_zone(name=name, serial=22, soa_edit_api='')
-        r = self.session.get(self.url("/api/v1/servers/localhost/search-data?q=" + name.rstrip('.') + "&type=" + data_type))
+        r = self.session.get(self.url("/api/v1/servers/localhost/search-data?q=" + name.rstrip('.') + "&object_type=" + data_type))
         self.assert_success_json(r)
         print(r.json())
         self.assertEquals(r.json(), [
@@ -1632,7 +1632,7 @@ fred   IN  A      192.168.0.4
         name = unique_zone_name()
         data_type = "record"
         self.create_zone(name=name, serial=22, soa_edit_api='')
-        r = self.session.get(self.url("/api/v1/servers/localhost/search-data?q=" + name.rstrip('.') + "&type=" + data_type))
+        r = self.session.get(self.url("/api/v1/servers/localhost/search-data?q=" + name.rstrip('.') + "&object_type=" + data_type))
         self.assert_success_json(r)
         print(r.json())
         self.assertEquals(r.json(), [