File: authoritative-api-swagger.yaml

package info (click to toggle)
pdns 5.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,824 kB
  • sloc: cpp: 101,247; sh: 5,616; makefile: 2,318; sql: 860; ansic: 675; python: 635; yacc: 245; perl: 161; lex: 131
file content (1613 lines) | stat: -rw-r--r-- 47,914 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
swagger: '2.0'
info:
  version: "0.0.17"
  title: PowerDNS Authoritative HTTP API
  license:
    name: MIT
basePath: /api/v1
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  # X-API-Key: abcdef12345
  APIKeyHeader:
    type: apiKey
    in: header
    name: X-API-Key
security:
  - APIKeyHeader: []

# Overall TODOS:
# TODO: Return types are not consistent across documentation
#       We need to look at the code and figure out the default HTTP response
#       codes and adjust docs accordingly.
paths:
  '/error':
    get:
      summary: Will always generate an error
      operationId: error
      responses: &commonErrors
        '400':
          description: The supplied request was not valid
          schema:
            $ref: '#/definitions/Error'
        '404':
          description: Requested item was not found
          schema:
            $ref: '#/definitions/Error'
        '422':
          description: The input to the operation was not valid
          schema:
            $ref: '#/definitions/Error'
        '500':
          description: Internal server error
          schema:
            $ref: '#/definitions/Error'

  '/servers':
    get:
      summary: List all servers
      operationId: listServers
      tags:
        - servers
      responses:
        '200':
          description: An array of servers
          schema:
            type: array
            items:
              $ref: '#/definitions/Server'
        <<: *commonErrors

  '/servers/{server_id}':
    get:
      summary: List a server
      operationId: listServer
      tags:
        - servers
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
      responses:
        '200':
          description: An server
          schema:
            $ref: '#/definitions/Server'
        <<: *commonErrors

  '/servers/{server_id}/cache/flush':
    put:
      summary: Flush a cache-entry by name
      operationId: cacheFlushByName
      tags:
        - servers
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: domain
          in: query
          required: true
          description: The domain name to flush from the cache
          type: string
      responses:
        '200':
          description: Flush successful
          schema:
            $ref: '#/definitions/CacheFlushResult'
        <<: *commonErrors

  '/servers/{server_id}/zones':
    get:
      summary: List all Zones in a server
      operationId: listZones
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone
          in: query
          required: false
          type: string
          description: |
            When set to the name of a zone, only this zone is returned.
            If no zone with that name exists, the response is an empty array.
            This can e.g. be used to check if a zone exists in the database without having to guess/encode the zone's id or to check if a zone exists.
        - name: dnssec
          in: query
          required: false
          type: boolean
          default: true
          description: '“true” (default) or “false”, whether to include the “dnssec” and “edited_serial” fields in the Zone objects. Setting this to ”false” will make the query a lot faster.'
      responses:
        '200':
          description: An array of Zones
          schema:
            type: array
            items:
              $ref: '#/definitions/Zone'
        <<: *commonErrors
    post:
      summary: Creates a new domain, returns the Zone on creation.
      operationId: createZone
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: rrsets
          in: query
          description: '“true” (default) or “false”, whether to include the “rrsets” in the response Zone object.'
          type: boolean
          default: true
        - name: zone_struct
          description: The zone struct to patch with
          required: true
          in: body
          schema:
            $ref: '#/definitions/Zone'
      responses:
        '201':
          description: A zone
          schema:
              $ref: '#/definitions/Zone'
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}':
    get:
      summary: zone managed by a server
      operationId: listZone
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
        - name: rrsets
          in: query
          description: '“true” (default) or “false”, whether to include the “rrsets” in the response Zone object.'
          type: boolean
          default: true
        - name: rrset_name
          in: query
          description: Limit output to RRsets for this name.
          type: string
        - name: rrset_type
          in: query
          description: Limit output to the RRset of this type. Can only be used together with rrset_name.
          type: string
        - name: include_disabled
          in: query
          description: '“true” (default) or “false”, whether to include disabled RRsets in the response.'
          type: boolean
      responses:
        '200':
          description: A Zone
          schema:
            $ref: '#/definitions/Zone'
        <<: *commonErrors
    delete:
      summary: Deletes this zone, all attached metadata and rrsets.
      operationId: deleteZone
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
      responses:
        '204':
          description: 'Returns 204 No Content on success.'
        <<: *commonErrors
    patch:
      summary: 'Creates/modifies/deletes RRsets present in the payload and their comments. Returns 204 No Content on success.'
      operationId: patchZone
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
        - name: zone_struct
          description: The zone struct to patch with
          required: true
          in: body
          schema:
            $ref: '#/definitions/Zone'
      responses:
        '204':
          description: 'Returns 204 No Content on success.'
        <<: *commonErrors

    put:
      summary: Modifies basic zone data.
      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
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
        - name: zone_struct
          description: The zone struct to patch with
          required: true
          in: body
          schema:
            $ref: '#/definitions/Zone'
      responses:
        '204':
          description: 'Returns 204 No Content on success.'
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}/notify':
    put:
      summary: Send a DNS NOTIFY to all slaves.
      description: 'Fails when zone kind is not Master or Slave, or master and slave are disabled in the configuration. Only works for Slave if renotify is on. Clients MUST NOT send a body.'
      operationId: notifyZone
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
      responses:
        '200':
          description: OK
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}/axfr-retrieve':
    put:
      summary: Retrieve slave zone from its master.
      description: 'Fails when zone kind is not Slave, or slave is disabled in the configuration. Clients MUST NOT send a body.'
      operationId: axfrRetrieveZone
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
      responses:
        '200':
          description: OK
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}/export':
    get:
      summary: 'Returns the zone in AXFR format.'
      operationId: axfrExportZone
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
      responses:
        '200':
          description: OK
          schema:
            type: string
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}/rectify':
    put:
      summary: 'Rectify the zone data.'
      description: 'This does not take into account the API-RECTIFY metadata. Fails on slave zones and zones that do not have DNSSEC.'
      operationId: rectifyZone
      tags:
        - zones
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
      responses:
        '200':
          description: OK
          schema:
            type: string
        <<: *commonErrors

  '/servers/{server_id}/config':
    get:
      summary: 'Returns all ConfigSettings for a single server'
      operationId: getConfig
      tags:
        - config
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
      responses:
        '200':
          description: List of config values
          schema:
            type: array
            items:
              $ref: '#/definitions/ConfigSetting'
        <<: *commonErrors

  '/servers/{server_id}/config/{config_setting_name}':
    get:
      summary: 'Returns a specific ConfigSetting for a single server'
      description: 'NOT IMPLEMENTED'
      operationId: getConfigSetting
      tags:
        - config
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: config_setting_name
          in: path
          required: true
          description: The name of the setting to retrieve
          type: string
      responses:
        '200':
          description: List of config values
          schema:
            $ref: '#/definitions/ConfigSetting'
        <<: *commonErrors

  '/servers/{server_id}/statistics':
    get:
      summary: 'Query statistics.'
      description: 'Query PowerDNS internal statistics.'
      operationId: getStats
      tags:
        - stats
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: statistic
          in: query
          required: false
          type: string
          description: |
            When set to the name of a specific statistic, only this value is returned.
            If no statistic with that name exists, the response has a 422 status and an error message.
        - name: includerings
          in: query
          required: false
          type: boolean
          default: true
          description: '“true” (default) or “false”, whether to include the Ring items, which can contain thousands of log messages or queried domains. Setting this to ”false” may make the response a lot smaller.'
      responses:
        '200':
          description: List of Statistic Items
          schema:
            type: array
            items:
              - $ref: '#/definitions/StatisticItem'
              - $ref: '#/definitions/MapStatisticItem'
              - $ref: '#/definitions/RingStatisticItem'
        '422':
          description: 'Returned when a non-existing statistic name has been requested. Contains an error message'
        <<: *commonErrors

  '/servers/{server_id}/search-data':
    get:
      summary: 'Search the data inside PowerDNS'
      description: 'Search the data inside PowerDNS for search_term and return at most max_results. This includes zones, records and comments. The * character can be used in search_term as a wildcard character and the ? character can be used as a wildcard for a single character.'
      operationId: searchData
      tags:
        - search
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: q
          in: query
          required: true
          description: 'The string to search for'
          type: string
        - name: max
          in: query
          required: true
          description: 'Maximum number of entries to return'
          type: integer
        - name: object_type
          in: query
          required: false
          description: 'Type of data to search for, one of “all”, “zone”, “record”, “comment”'
          type: string
      responses:
        '200':
          description: Returns a JSON array with results
          schema:
            $ref: '#/definitions/SearchResults'
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}/metadata':
    get:
      summary: 'Get all the Metadata associated with the zone.'
      operationId: listMetadata
      tags:
        - zonemetadata
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
      responses:
        '200':
          description: List of Metadata objects
          schema:
            type: array
            items:
              $ref: '#/definitions/Metadata'
        <<: *commonErrors
    post:
      summary: 'Creates a set of metadata entries'
      description: '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.'
      operationId: createMetadata
      tags:
        - zonemetadata
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
        - name: metadata
          description: Metadata object with list of values to create
          required: true
          in: body
          schema:
            $ref: '#/definitions/Metadata'
      responses:
        '204':
          description: OK
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}/metadata/{metadata_kind}':
    get:
      summary: 'Get the content of a single kind of domain metadata as a Metadata object.'
      operationId: getMetadata
      tags:
        - zonemetadata
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
        - name: metadata_kind
          type: string
          in: path
          required: true
          description: The kind of metadata
      responses:
        '200':
          description: Metadata object with list of values
          schema:
            $ref: '#/definitions/Metadata'
        <<: *commonErrors
    put:
      summary: 'Replace the content of a single kind of domain metadata.'
      description: 'Creates a set of metadata entries of given kind for the zone. Existing metadata entries for the zone with the same kind are removed.'
      operationId: modifyMetadata
      tags:
        - zonemetadata
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
        - name: metadata_kind
          description: The kind of metadata
          required: true
          type: string
          in: path
        - name: metadata
          description: metadata to add/create
          required: true
          in: body
          schema:
            $ref: '#/definitions/Metadata'
      responses:
        '200':
          description: Metadata object with list of values
          schema:
            $ref: '#/definitions/Metadata'
        <<: *commonErrors
    delete:
      summary: 'Delete all items of a single kind of domain metadata.'
      operationId: deleteMetadata
      tags:
        - zonemetadata
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
        - name: metadata_kind
          type: string
          in: path
          required: true
          description: The kind of metadata
      responses:
        '204':
          description: OK
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}/cryptokeys':
    get:
      summary: 'Get all CryptoKeys for a zone, except the privatekey'
      operationId: listCryptokeys
      tags:
        - zonecryptokey
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
      responses:
        '200':
          description: List of Cryptokey objects
          schema:
            type: array
            items:
              $ref: '#/definitions/Cryptokey'
        <<: *commonErrors
    post:
      summary: 'Creates a Cryptokey'
      description: 'This method adds a new key to a zone. The key can either be generated or imported by supplying the content parameter. if content, bits and algo are null, a key will be generated based on the default-ksk-algorithm and default-ksk-size settings for a KSK and the default-zsk-algorithm and default-zsk-size options for a ZSK.'
      operationId: createCryptokey
      tags:
        - zonecryptokey
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
        - name: cryptokey
          description: Add a Cryptokey
          required: true
          in: body
          schema:
            $ref: '#/definitions/Cryptokey'
      responses:
        '201':
          description: Created
          schema:
            $ref: '#/definitions/Cryptokey'
        <<: *commonErrors

  '/servers/{server_id}/zones/{zone_id}/cryptokeys/{cryptokey_id}':
    get:
      summary: 'Returns all data about the CryptoKey, including the privatekey.'
      operationId: getCryptokey
      tags:
        - zonecryptokey
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
        - name: cryptokey_id
          type: string
          in: path
          required: true
          description: 'The id value of the CryptoKey'
      responses:
        '200':
          description: Cryptokey
          schema:
            $ref: '#/definitions/Cryptokey'
        <<: *commonErrors
    put:
      summary: 'This method (de)activates a key from zone_name specified by cryptokey_id'
      operationId: modifyCryptokey
      tags:
        - zonecryptokey
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
        - name: cryptokey_id
          description: Cryptokey to manipulate
          required: true
          in: path
          type: string
        - name: cryptokey
          description: the Cryptokey
          required: true
          in: body
          schema:
            $ref: '#/definitions/Cryptokey'
      responses:
        '204':
          description: OK
        <<: *commonErrors
    delete:
      summary: 'This method deletes a key specified by cryptokey_id.'
      operationId: deleteCryptokey
      tags:
        - zonecryptokey
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: zone_id
          type: string
          in: path
          required: true
          description: The id of the zone to retrieve
        - name: cryptokey_id
          type: string
          in: path
          required: true
          description: 'The id value of the Cryptokey'
      responses:
        '204':
          description: OK
        <<: *commonErrors

  '/servers/{server_id}/tsigkeys':
    parameters:
      - name: server_id
        in: path
        required: true
        description: 'The id of the server'
        type: string
    get:
      summary: 'Get all TSIGKeys on the server, except the actual key'
      operationId: listTSIGKeys
      tags:
        - tsigkey
      responses:
        '200':
          description: List of TSIGKey objects
          schema:
            type: array
            items:
              $ref: '#/definitions/TSIGKey'
        <<: *commonErrors
    post:
      summary: 'Add a TSIG key'
      description: 'This methods add a new TSIGKey. The actual key can be generated by the server or be provided by the client'
      operationId: createTSIGKey
      tags:
        - tsigkey
      parameters:
        - name: tsigkey
          description: The TSIGKey to add
          required: true
          in: body
          schema:
            $ref: '#/definitions/TSIGKey'
      responses:
        '201':
          description: Created
          schema:
            $ref: '#/definitions/TSIGKey'
        '409':
          description: An item with this name already exists
          schema:
            $ref: '#/definitions/Error'
        <<: *commonErrors

  '/servers/{server_id}/tsigkeys/{tsigkey_id}':
    parameters:
      - name: server_id
        in: path
        required: true
        description: 'The id of the server to retrieve the key from'
        type: string
      - name: tsigkey_id
        in: path
        required: true
        description: 'The id of the TSIGkey. Should match the "id" field in the TSIGKey object'
        type: string
    get:
      summary: 'Get a specific TSIGKeys on the server, including the actual key'
      operationId: getTSIGKey
      tags:
        - tsigkey
      responses:
        '200':
          description: OK.
          schema:
            $ref: '#/definitions/TSIGKey'
        <<: *commonErrors
    put:
      description: |
        The TSIGKey at tsigkey_id can be changed in multiple ways:
         * Changing the Name, this will remove the key with tsigkey_id after adding.
         * Changing the Algorithm
         * Changing the Key

        Only the relevant fields have to be provided in the request body.
      operationId: putTSIGKey
      tags:
        - tsigkey
      parameters:
        - name: tsigkey
          description: A (possibly stripped down) TSIGKey object with the new values
          schema:
            $ref: '#/definitions/TSIGKey'
          in: body
          required: true
      responses:
        '200':
          description: OK. TSIGKey is changed.
          schema:
            $ref: '#/definitions/TSIGKey'
        '409':
          description: An item with this name already exists
          schema:
            $ref: '#/definitions/Error'
        <<: *commonErrors
    delete:
      summary: 'Delete the TSIGKey with tsigkey_id'
      operationId: deleteTSIGKey
      tags:
        - tsigkey
      responses:
        '204':
          description: 'OK, key was deleted'
        <<: *commonErrors

  '/servers/{server_id}/autoprimaries':
    parameters:
      - name: server_id
        in: path
        required: true
        description: 'The id of the server to manage the list of autoprimaries on'
        type: string
    get:
      summary: 'Get a list of autoprimaries'
      operationId: getAutoprimaries
      tags:
        - autoprimary
      responses:
        '200':
          description: OK.
          schema:
            $ref: '#/definitions/Autoprimary'
        <<: *commonErrors
    post:
      summary: 'Add an autoprimary'
      description: 'This methods add a new autoprimary server.'
      operationId: createAutoprimary
      tags:
        - autoprimary
      parameters:
        - name: autoprimary
          description: autoprimary entry to add
          required: true
          in: body
          schema:
            $ref: '#/definitions/Autoprimary'
      responses:
        '201':
          description: Created
        <<: *commonErrors

  '/servers/{server_id}/autoprimaries/{ip}/{nameserver}':
    parameters:
      - name: server_id
        in: path
        required: true
        description: 'The id of the server to delete the autoprimary from'
        type: string
      - name: ip
        in: path
        required: true
        description: 'IP address of autoprimary'
        type: string
      - name: nameserver
        in: path
        required: true
        description: 'DNS name of the autoprimary'
        type: string
    delete:
      summary: 'Delete the autoprimary entry'
      operationId: deleteAutoprimary
      tags:
        - autoprimary
      responses:
        '204':
          description: 'OK, key was deleted'
        <<: *commonErrors

  '/servers/{server_id}/views':
    get:
      summary: List all views in a server
      operationId: listViews
      tags:
        - views
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
      responses:
        '200':
          description: An array of view names
          schema:
            $ref: '#/definitions/Views'
        <<: *commonErrors

  '/servers/{server_id}/views/{view}':
    get:
      summary: List the contents of a given view
      operationId: listView
      tags:
        - views
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: view
          type: string
          in: path
          required: true
          description: The name of the view to retrieve
      responses:
        '200':
          description: An array of zone names
          schema:
            $ref: '#/definitions/View'
        <<: *commonErrors
    post:
      summary: Adds a zone to a given view, creating it if needed
      operationId: addToView
      tags:
        - views
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: view
          type: string
          in: path
          required: true
          description: The name of the view to update
        - name: name
          description: The zone to add to the view
          required: true
          in: body
          schema:
            type: string
      responses:
        '204':
          description: 'Returns 204 No Content on success.'
        <<: *commonErrors

  '/servers/{server_id}/views/{view}/{id}':
    delete:
      summary: Removes the given zone from the given view
      operationId: deleteFromView
      tags:
        - views
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: view
          type: string
          in: path
          required: true
          description: The name of the view to update
        - name: id
          description: The zone to remove from the view
          required: true
          in: path
          type: string
      responses:
        '204':
          description: 'Returns 204 No Content on success.'
        <<: *commonErrors

  '/servers/{server_id}/networks':
    get:
      summary: List all registered networks and views in a server
      operationId: listNetworks
      tags:
        - networks
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
      responses:
        '200':
          description: An array of networks
          schema:
            $ref: '#/definitions/Networks'
        <<: *commonErrors

  '/servers/{server_id}/networks/{ip}/{prefixlen}':
    get:
      summary: Return the view associated to the given network
      operationId: getNetwork
      tags:
        - networks
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: ip
          type: string
          in: path
          required: true
          description: The base address of the network
        - name: prefixlen
          type: string
          in: path
          required: true
          description: The length of the network prefix
      responses:
        '200':
          description: A network
          schema:
            $ref: '#/definitions/Network'
        <<: *commonErrors
    put:
      summary: Sets the view associated to the given network
      operationId: setNetwork
      tags:
        - networks
      parameters:
        - name: server_id
          in: path
          required: true
          description: The id of the server to retrieve
          type: string
        - name: ip
          type: string
          in: path
          required: true
          description: The base address of the network
        - name: prefixlen
          type: string
          in: path
          required: true
          description: The length of the network prefix
        - name: view
          required: true
          description: The name of the view to use for this network
          in: body
          schema:
            type: string
      responses:
        '204':
          description: 'Returns 204 No Content on success.'
        <<: *commonErrors

definitions:
  Server:
    title: Server
    properties:
      type:
        type: string
        description: 'Set to “Server”'
      id:
        type: string
        description: 'The id of the server, “localhost”'
      daemon_type:
        type: string
        description: '“recursor” for the PowerDNS Recursor and “authoritative” for the Authoritative Server'
      version:
        type: string
        description: 'The version of the server software'
      url:
        type: string
        description: 'The API endpoint for this server'
      config_url:
        type: string
        description: 'The API endpoint for this server’s configuration'
      zones_url:
        type: string
        description: 'The API endpoint for this server’s zones'

  Servers:
    type: array
    items:
      $ref: '#/definitions/Server'

  Zone:
    title: Zone
    description: This represents an authoritative DNS Zone.
    properties:
      id:
        type: string
        description: 'Opaque zone id (string), assigned by the server, should not be interpreted by the application. Guaranteed to be safe for embedding in URLs.'
      name:
        type: string
        description: 'Name of the zone (e.g. “example.com.”) MUST have a trailing dot'
      type:
        type: string
        description: 'Set to “Zone”'
      url:
        type: string
        description: 'API endpoint for this zone'
      kind:
        type: string
        enum:
          - 'Native'
          - 'Master'
          - 'Slave'
          - 'Producer'
          - 'Consumer'
        description: 'Zone kind, one of “Native”, “Master”, “Slave”, “Producer”, “Consumer”'
      rrsets:
        type: array
        items:
          $ref: '#/definitions/RRSet'
        description: 'RRSets in this zone (for zones/{zone_id} endpoint only; omitted during GET on the .../zones list endpoint)'
      serial:
        type: integer
        description: 'The SOA serial number'
      notified_serial:
        type: integer
        description: 'The SOA serial notifications have been sent out for'
      edited_serial:
        type: integer
        description: 'The SOA serial as seen in query responses. Calculated using the SOA-EDIT metadata, default-soa-edit and default-soa-edit-signed settings'
      masters:
        type: array
        items:
          type: string
        description: ' List of IP addresses configured as a master for this zone (“Slave” type zones only)'
      dnssec:
        type: boolean
        description: 'Whether or not this zone is DNSSEC signed (inferred from presigned being true XOR presence of at least one cryptokey with active being true)'
      nsec3param:
        type: string
        description: 'The NSEC3PARAM record'
      nsec3narrow:
        type: boolean
        description: 'Whether or not the zone uses NSEC3 narrow'
      presigned:
        type: boolean
        description: 'Whether or not the zone is pre-signed'
      soa_edit:
        type: string
        description: 'The SOA-EDIT metadata item'
      soa_edit_api:
        type: string
        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'
      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'
      nameservers:
        type: array
        items:
          type: string
        description: 'MAY be sent in client bodies during creation, and MUST NOT be sent by the server. Simple list of strings of nameserver names, including the trailing dot. Not required for slave zones.'
      master_tsig_key_ids:
        type: array
        items:
          type: string
        description: 'The id of the TSIG keys used for master operation in this zone'
        externalDocs:
          url: 'https://doc.powerdns.com/authoritative/tsig.html#provisioning-outbound-axfr-access'
      slave_tsig_key_ids:
        type: array
        items:
          type: string
        description: 'The id of the TSIG keys used for slave operation in this zone'
        externalDocs:
          url: 'https://doc.powerdns.com/authoritative/tsig.html#provisioning-signed-notification-and-axfr-requests'

  Zones:
    type: array
    items:
      $ref: '#/definitions/Zone'

  RRSet:
    title: RRSet
    description: This represents a Resource Record Set (all records with the same name and type).
    required:
      - name
      - type
      - ttl
      - changetype
      - records
    properties:
      name:
        type: string
        description: 'Name for record set (e.g. “www.powerdns.com.”)'
      type:
        type: string
        description: 'Type of this record (e.g. “A”, “PTR”, “MX”)'
      ttl:
        type: integer
        description: 'DNS TTL of the records, in seconds. MUST NOT be included when changetype is set to “DELETE”.'
      changetype:
        type: string
        description: 'MUST be added when updating the RRSet. Must be one of DELETE, EXTEND, PRUNE or REPLACE. With DELETE, all existing RRs matching name and type will be deleted, including all comments. With EXTEND, only a single record shall be present, and it will be added to the RRSet if not already present. With PRUNE, only a single record shall be present, and it will be deleted from the RRSet if present. With REPLACE, when records is present, all existing RRs matching name and type will be deleted, and then new records given in records will be created. If no records are left, any existing comments will be deleted as well. When comments is present, all existing comments for the RRs matching name and type will be deleted, and then new comments given in comments will be created.'
      records:
        type: array
        description: 'All records in this RRSet. When updating Records, this is the list of new records (replacing the old ones). Must be empty when changetype is set to DELETE, and must contain only one element when changetype is set to EXTEND or PRUNE. An empty list results in deletion of all records (and comments).'
        items:
          $ref: '#/definitions/Record'
      comments:
        type: array
        description: 'List of Comment. Must be empty when changetype is set to DELETE, EXTEND or PRUNE. An empty list results in deletion of all comments. modified_at is optional and defaults to the current server time.'
        items:
          $ref: '#/definitions/Comment'

  Record:
    title: Record
    description: The RREntry object represents a single record.
    required:
      - content
    properties:
      content:
        type: string
        description: 'The content of this record'
      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
    description: A comment about an RRSet.
    properties:
      content:
        type: string
        description: 'The actual comment'
      account:
        type: string
        description: 'Name of an account that added the comment'
      modified_at:
        type: integer
        description: 'Timestamp of the last change to the comment'

  TSIGKey:
    title: TSIGKey
    description: A TSIG key that can be used to authenticate NOTIFY, AXFR, and DNSUPDATE queries.
    properties:
      name:
        type: string
        description: 'The name of the key'
      id:
        type: string
        description: 'The ID for this key, used in the TSIGkey URL endpoint.'
        readOnly: true
      algorithm:
        type: string
        description: 'The algorithm of the TSIG key'
      key:
        type: string
        description: 'The Base64 encoded secret key, empty when listing keys. MAY be empty when POSTing to have the server generate the key material'
      type:
        type: string
        description: 'Set to "TSIGKey"'
        readOnly: true

  Autoprimary:
     title: Autoprimary server
     description: An autoprimary server that can provision new domains.
     properties:
       ip:
         type: string
         description: "IP address of the autoprimary server"
       nameserver:
         type: string
         description: "DNS name of the autoprimary server"
       account:
         type: string
         description: "Account name for the autoprimary server"

  ConfigSetting:
    title: ConfigSetting
    properties:
      name:
        type: string
        description: 'set to "ConfigSetting"'
      type:
        type: string
        description: 'The name of this setting (e.g. ‘webserver-port’)'
      value:
        type: string
        description: 'The value of setting name'

  SimpleStatisticItem:
    title: SimpleStatisticItem
    type: object
    properties:
      name:
          type: string
          description: 'Item name'
      value:
          type: string
          description: 'Item value'

  StatisticItem:
    title: StatisticItem
    properties:
      name:
        type: string
        description: 'Item name'
      type:
        type: string
        description: 'set to "StatisticItem"'
      value:
        type: string
        description: 'Item value'

  MapStatisticItem:
    title: MapStatisticItem
    properties:
      name:
        type: string
        description: 'Item name'
      type:
        type: string
        description: 'Set to "MapStatisticItem"'
      value:
        type: array
        description: 'Named values'
        items:
          $ref: '#/definitions/SimpleStatisticItem'

  RingStatisticItem:
    title: RingStatisticItem
    properties:
      name:
        type: string
        description: 'Item name'
      type:
        type: string
        description: 'Set to "RingStatisticItem"'
      size:
        type: integer
        description: 'Ring size'
      value:
        type: array
        description: 'Named values'
        items:
          $ref: '#/definitions/SimpleStatisticItem'

  SearchResultZone:
    title: SearchResultZone
    properties:
      name:
        type: string
      object_type:
        type: string
        description: 'set to "zone"'
      zone_id:
        type: string

  SearchResultRecord:
    title: SearchResultRecord
    properties:
      content:
        type: string
      disabled:
        type: boolean
      name:
        type: string
      object_type:
        type: string
        description: 'set to "record"'
      zone_id:
        type: string
      zone:
        type: string
      type:
        type: string
      ttl:
        type: integer

  SearchResultComment:
    title: SearchResultComment
    properties:
      content:
        type: string
      name:
        type: string
      object_type:
        type: string
        description: 'set to "comment"'
      zone_id:
        type: string
      zone:
        type: string

# FIXME: This is problematic at the moment, because swagger doesn't support this type of mixed response
#  SearchResult:
#    anyOf:
#      - $ref: '#/definitions/SearchResultZone'
#      - $ref: '#/definitions/SearchResultRecord'
#      - $ref: '#/definitions/SearchResultComment'

# Since we can't do 'anyOf' at the moment, we create a 'superset object'
  SearchResult:
    title: SearchResult
    properties:
      content:
        type: string
      disabled:
        type: boolean
      name:
        type: string
      object_type:
        type: string
        description: 'set to one of "record, zone, comment"'
      zone_id:
        type: string
      zone:
        type: string
      type:
        type: string
      ttl:
        type: integer

  SearchResults:
    type: array
    items:
      $ref: '#/definitions/SearchResult'

  Metadata:
    title: Metadata
    description: Represents zone metadata
    properties:
      kind:
        type: string
        description: 'Name of the metadata'
      metadata:
        type: array
        items:
          type: string
        description: 'Array with all values for this metadata kind.'

  Cryptokey:
    title: Cryptokey
    description: 'Describes a DNSSEC cryptographic key'
    properties:
      type:
        type: string
        description: 'set to "Cryptokey"'
      id:
        type: integer
        description: 'The internal identifier, read only'
      keytype:
        type: string
        enum: [ksk, zsk, csk]
      active:
        type: boolean
        description: 'Whether or not the key is in active use'
      published:
        type: boolean
        description: 'Whether or not the DNSKEY record is published in the zone'
      dnskey:
        type: string
        description: 'The DNSKEY record for this key'
      ds:
        type: array
        items:
          type: string
        description: 'An array of DS records for this key'
      cds:
        type: array
        items:
          type: string
        description: 'An array of DS records for this key, filtered by CDS publication settings'
      privatekey:
        type: string
        description: 'The private key in ISC format'
      algorithm:
        type: string
        description: 'The name of the algorithm of the key, should be a mnemonic'
      bits:
        type: integer
        description: 'The size of the key'

  Error:
    title: Error
    description: 'Returned when the server encounters an error, either in client input or internally'
    properties:
      error:
        type: string
        description: 'A human readable error message'
      errors:
        type: array
        items:
          type: string
        description: 'Optional array of multiple errors encountered during processing'
    required:
      - error

  CacheFlushResult:
    title: CacheFlushResult
    description: 'The result of a cache-flush'
    properties:
      count:
        type: number
        description: 'Amount of entries flushed'
      result:
        type: string
        description: 'A message about the result like "Flushed cache"'

  View:
    title: View
    properties:
      zones:
        type: array
        items:
          type: string
        description: 'An array of zone names'

  Views:
    title: Views
    properties:
      views:
        type: array
        items:
          type: string
        description: 'An array of view names'

  Network:
    title: Network
    properties:
      network:
        type: string
        description: 'Network specification in human-readable form base address/prefix length'
      view:
        type: string
        description: 'The name of the view'

  Networks:
    title: Networks
    properties:
      networks:
        type: array
        items:
          $ref: '#/definitions/Network'