Merge ~jsseidel/maas:jsseidel-dnsresources-api-annotations into maas:master

Proposed by Spencer Seidel
Status: Merged
Approved by: Spencer Seidel
Approved revision: 01d55d6f219f2b060b0d776b02f2ac2f6c1810a7
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~jsseidel/maas:jsseidel-dnsresources-api-annotations
Merge into: maas:master
Diff against target: 430 lines (+275/-59)
4 files modified
src/maasserver/api/dnsresourcerecords.py (+94/-30)
src/maasserver/api/dnsresources.py (+98/-29)
src/maasserver/api/examples/dnsresourcerecords.json (+36/-0)
src/maasserver/api/examples/dnsresources.json (+47/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Newell Jensen (community) Approve
Review via email: mp+360627@code.launchpad.net

Commit message

Added API annotations and examples for dnsresources and dnsresourcerecords.

To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote :

Looks good.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b jsseidel-dnsresources-api-annotations lp:~jsseidel/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 01d55d6f219f2b060b0d776b02f2ac2f6c1810a7

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

LANDING
-b jsseidel-dnsresources-api-annotations lp:~jsseidel/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED MERGE
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-lander/341301/console

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/dnsresourcerecords.py b/src/maasserver/api/dnsresourcerecords.py
2index 992a580..5a74342 100644
3--- a/src/maasserver/api/dnsresourcerecords.py
4+++ b/src/maasserver/api/dnsresourcerecords.py
5@@ -43,12 +43,23 @@ class DNSResourceRecordsHandler(OperationsHandler):
6 return ('dnsresourcerecords_handler', [])
7
8 def read(self, request):
9- """List all dnsresourcerecords.
10+ """@description-title List all DNS resource records
11+ @description List all DNS resource records.
12
13- :param domain: restrict the listing to entries for the domain.
14- :param name: restrict the listing to entries of the given name.
15- :param rrtype: restrict the listing to entries which have
16- records of the given rrtype.
17+ @param (string) "domain" [required=false] Restricts the listing to
18+ entries for the domain.
19+
20+ @param (string) "name" [required=false] Restricts the listing to
21+ entries of the given name.
22+
23+ @param (string) "rrtype" [required=false] Restricts the listing to
24+ entries which have records of the given rrtype.
25+
26+ @success (http-status-code) "server-success" 200
27+ @success (json) "success-json" A JSON object containing a list of the
28+ requested DNS resource record objects.
29+ @success-example "success-json" [exkey=dnsresourcerecords-read]
30+ placeholder text
31 """
32 data = request.GET
33 fqdn = data.get('fqdn', None)
34@@ -82,19 +93,31 @@ class DNSResourceRecordsHandler(OperationsHandler):
35
36 @admin_method
37 def create(self, request):
38- """Create a DNS resource record.
39-
40- :param fqdn: Hostname (with domain) for the dnsresource. Either fqdn
41- or (name, domain) must be specified. Fqdn is ignored if either
42- name or domain is given (e.g. www.your-maas.maas).
43- :param name: The name (or hostname without a domain) of the DNS
44- resource record (e.g. www.your-maas)
45- :param domain: The domain (name or id) where to create the DNS
46- resource record (Domain (e.g. 'maas')
47- :param rrtype: The resource record type (e.g 'cname', 'mx', 'ns',
48- 'srv', 'sshfp', 'txt')
49- :param rrdata: The resource record data (e.g. 'your-maas',
50- '10 mail.your-maas.maas')
51+ """@description-title Create a DNS resource record
52+ @description Create a new DNS resource record.
53+
54+ @param (string) "fqdn" [required=false] Hostname (with domain) for the
55+ dnsresource. Either ``fqdn`` or ``name`` and ``domain`` must be
56+ specified. ``fqdn`` is ignored if either name or domain is given (e.g.
57+ www.your-maas.maas).
58+
59+ @param (string) "name" [required=false] The name (or hostname without a
60+ domain) of the DNS resource record (e.g. www.your-maas)
61+
62+ @param (string) "domain" [required=false] The domain (name or id) where
63+ to create the DNS resource record (Domain (e.g. 'maas')
64+
65+ @param (string) "rrtype" [required=false] The resource record type (e.g
66+ ``cname``, ``mx``, ``ns``, ``srv``, ``sshfp``, ``txt``).
67+
68+ @param (string) "rrdata" [required=false] The resource record data
69+ (e.g. 'your-maas', '10 mail.your-maas.maas')
70+
71+ @success (http-status-code) "server-success" 200
72+ @success (json) "success-json" A JSON object containing the new DNS
73+ resource record object.
74+ @success-example "success-json" [exkey=dnsresourcerecords-create]
75+ placeholder text
76 """
77 data = request.data.copy()
78 domain = None
79@@ -167,22 +190,52 @@ class DNSResourceRecordHandler(OperationsHandler):
80 return dnsresourcerecord.fqdn()
81
82 def read(self, request, id):
83- """Read dnsresourcerecord.
84+ """@description-title Read a DNS resource record
85+ description Read a DNS resource record with the given id.
86
87- Returns 404 if the dnsresourcerecord is not found.
88+ @param (int) "{id}" [required=true] The DNS resource record id.
89+
90+ @success (http-status-code) "server-success" 200
91+ @success (json) "success-json" A JSON object containing the requested
92+ DNS resource object.
93+ @success-example "success-json" [exkey=dnsresourcerecords-read-by-id]
94+ placeholder text
95+
96+ @error (http-status-code) "404" 404
97+ @error (content) "not-found" The requested DNS resource record was not
98+ found.
99+ @error-example "not-found"
100+ Not Found
101 """
102 return DNSData.objects.get_dnsdata_or_404(
103 id, request.user, NodePermission.view)
104
105 def update(self, request, id):
106- """Update dnsresourcerecord.
107+ """@description-title Update a DNS resource record
108+ @description Update a DNS resource record with the given id.
109+
110+ @param (int) "{id}" [required=true] The DNS resource record id.
111+
112+ @param (string) "rrtype" [required=false] Resource type.
113+
114+ @param (string) "rrdata" [required=false] Resource data (everything to
115+ the right of type.)
116
117- :param rrtype: Resource Type
118- :param rrdata: Resource Data (everything to the right of Type.)
119+ @success (http-status-code) "server-success" 200
120+ @success (json) "success-json" A JSON object containing the updated DNS
121+ resource record object.
122+ @success-example "success-json" [exkey=dnsresourcerecords-update]
123+ placeholder text
124
125- Returns 403 if the user does not have permission to update the
126- dnsresourcerecord.
127- Returns 404 if the dnsresourcerecord is not found.
128+ @error (http-status-code) "403" 403
129+ @error (content) "no-perms" The user does not have permission to update
130+ the requested DNS resource record.
131+
132+ @error (http-status-code) "404" 404
133+ @error (content) "not-found" The requested DNS resource record is not
134+ found.
135+ @error-example "not-found"
136+ Not Found
137 """
138 dnsdata = DNSData.objects.get_dnsdata_or_404(
139 id, request.user, NodePermission.admin)
140@@ -195,11 +248,22 @@ class DNSResourceRecordHandler(OperationsHandler):
141 raise MAASAPIValidationError(form.errors)
142
143 def delete(self, request, id):
144- """Delete dnsresourcerecord.
145+ """@description-title Delete a DNS resource record
146+ @description Delete a DNS resource record with the given id.
147+
148+ @param (int) "{id}" [required=true] The DNS resource record id.
149+
150+ @success (http-status-code) "server-success" 204
151+
152+ @error (http-status-code) "403" 403
153+ @error (content) "no-perms" The user does not have permission to delete
154+ the requested DNS resource record.
155
156- Returns 403 if the user does not have permission to delete the
157- dnsresourcerecord.
158- Returns 404 if the dnsresourcerecord is not found.
159+ @error (http-status-code) "404" 404
160+ @error (content) "not-found" The requested DNS resource record is not
161+ found.
162+ @error-example "not-found"
163+ Not Found
164 """
165 dnsdata = DNSData.objects.get_dnsdata_or_404(
166 id, request.user, NodePermission.admin)
167diff --git a/src/maasserver/api/dnsresources.py b/src/maasserver/api/dnsresources.py
168index 68babe7..28a1027 100644
169--- a/src/maasserver/api/dnsresources.py
170+++ b/src/maasserver/api/dnsresources.py
171@@ -123,14 +123,31 @@ class DNSResourcesHandler(OperationsHandler):
172 return ('dnsresources_handler', [])
173
174 def read(self, request):
175- """List all resources for the specified criteria.
176-
177- :param domain: restrict the listing to entries for the domain.
178- :param name: restrict the listing to entries of the given name.
179- :param rrtype: restrict the listing to entries which have
180- records of the given rrtype.
181- :param all: if True, also include implicit DNS records created for
182- nodes registered in MAAS.
183+ """@description-title List resources
184+ @description List all resources for the specified criteria.
185+
186+ @param (string) "domain" [required=false] Restricts the listing to
187+ entries for the domain.
188+
189+ @param (string) "name" [required=false] Restricts the listing to
190+ entries of the given name.
191+
192+ @param (string) "rrtype" [required=false] Restricts the listing to
193+ entries which have records of the given rrtype.
194+
195+ @param (boolean) "all" [required=false] Include implicit DNS records
196+ created for nodes registered in MAAS if true.
197+
198+ @success (http-status-code) "server-success" 200
199+ @success (json) "success-json" A JSON object containing a list of the
200+ requested DNS resource objects.
201+ @success-example "success-json" [exkey=dnsresources-read] placeholder
202+ text
203+
204+ @error (http-status-code) "404" 404
205+ @error (content) "not-found" The requested DNS resources are not found.
206+ @error-example "not-found"
207+ Not Found
208 """
209 data = request.GET
210 fqdn = data.get('fqdn', None)
211@@ -151,16 +168,29 @@ class DNSResourcesHandler(OperationsHandler):
212
213 @admin_method
214 def create(self, request):
215- """Create a dnsresource.
216-
217- :param fqdn: Hostname (with domain) for the dnsresource. Either fqdn
218- or (name, domain) must be specified. Fqdn is ignored if either
219- name or domain is given.
220- :param name: Hostname (without domain)
221- :param domain: Domain (name or id)
222- :param address_ttl: Default ttl for entries in this zone.
223- :param ip_addresses: (optional) Address (ip or id) to assign to the
224- dnsresource.
225+ """@description-title Create a DNS resource
226+ @description Create a DNS resource.
227+
228+ @param (string) "fqdn" [required=false] Hostname (with domain) for the
229+ dnsresource. Either ``fqdn`` or ``name`` and ``domain`` must be
230+ specified. ``fqdn`` is ignored if either ``name`` or ``domain`` is
231+ given.
232+
233+ @param (string) "name" [required=true] Hostname (without domain).
234+
235+ @param (string) "domain" [required=true] Domain (name or id).
236+
237+ @param (string) "address_ttl" [required=false] Default TTL for entries
238+ in this zone.
239+
240+ @param (string) "ip_addresses" [required=false] Address (ip or id) to
241+ assign to the dnsresource.
242+
243+ @success (http-status-code) "server-success" 200
244+ @success (json) "success-json" A JSON object containing the new DNS
245+ resource object.
246+ @success-example "success-json" [exkey=dnsresources-create] placeholder
247+ text
248 """
249 data = request.data.copy()
250 fqdn = data.get('fqdn', None)
251@@ -232,22 +262,51 @@ class DNSResourceHandler(OperationsHandler):
252 return dnsresource.dnsdata_set.all().order_by('rrtype')
253
254 def read(self, request, id):
255- """Read dnsresource.
256+ """@description-title Read a DNS resource
257+ @description Read a DNS resource by id.
258
259- Returns 404 if the dnsresource is not found.
260+ @param (int) "{id}" [required=true] The DNS resource id.
261+
262+ @success (http-status-code) "server-success" 200
263+ @success (json) "success-json" A JSON object containing the requested
264+ DNS resource object.
265+ @success-example "success-json" [exkey=dnsresources-read-by-id]
266+ placeholder text
267+
268+ @error (http-status-code) "404" 404
269+ @error (content) "not-found" The requested DNS resource is not found.
270+ @error-example "not-found"
271+ Not Found
272 """
273 return DNSResource.objects.get_dnsresource_or_404(
274 id, request.user, NodePermission.view)
275
276 def update(self, request, id):
277- """Update dnsresource.
278+ """@description-title Update a DNS resource
279+ @description Update a DNS resource with the given id.
280+
281+ @param (int) "{id}" [required=true] The DNS resource id.
282
283- :param fqdn: Hostname (with domain) for the dnsresource.
284- :param ip_address: Address to assign to the dnsresource.
285+ @param (string) "fqdn" [required=false] Hostname (with domain) for the
286+ dnsresource.
287
288- Returns 403 if the user does not have permission to update the
289+ @param (string) "ip_address" [required=false] Address to assign to the
290 dnsresource.
291- Returns 404 if the dnsresource is not found.
292+
293+ @success (http-status-code) "server-success" 200
294+ @success (json) "success-json" A JSON object containing the updated DNS
295+ resource object.
296+ @success-example "success-json" [exkey=dnsresources-update] placeholder
297+ text
298+
299+ @error (http-status-code) "403" 403
300+ @error (content) "no-perms" The user does not have permission to update
301+ the requested DNS resource.
302+
303+ @error (http-status-code) "404" 404
304+ @error (content) "not-found" The requested DNS resource is not found.
305+ @error-example "not-found"
306+ Not Found
307 """
308 dnsresource = DNSResource.objects.get_dnsresource_or_404(
309 id, request.user, NodePermission.admin)
310@@ -259,11 +318,21 @@ class DNSResourceHandler(OperationsHandler):
311 raise MAASAPIValidationError(form.errors)
312
313 def delete(self, request, id):
314- """Delete dnsresource.
315+ """@description-title Delete a DNS resource
316+ @description Delete a DNS resource with the given id.
317
318- Returns 403 if the user does not have permission to delete the
319- dnsresource.
320- Returns 404 if the dnsresource is not found.
321+ @param (int) "{id}" [required=true] The DNS resource id.
322+
323+ @success (http-status-code) "server-success" 204
324+
325+ @error (http-status-code) "403" 403
326+ @error (content) "no-perms" The user does not have permission to update
327+ the requested DNS resource.
328+
329+ @error (http-status-code) "404" 404
330+ @error (content) "not-found" The requested DNS resource is not found.
331+ @error-example "not-found"
332+ Not Found
333 """
334 dnsresource = DNSResource.objects.get_dnsresource_or_404(
335 id, request.user, NodePermission.admin)
336diff --git a/src/maasserver/api/examples/dnsresourcerecords.json b/src/maasserver/api/examples/dnsresourcerecords.json
337new file mode 100644
338index 0000000..78dca29
339--- /dev/null
340+++ b/src/maasserver/api/examples/dnsresourcerecords.json
341@@ -0,0 +1,36 @@
342+{
343+ "dnsresourcerecords-read": [
344+ {
345+ "ttl": null,
346+ "rrtype": "CNAME",
347+ "rrdata": "172.16.0.0",
348+ "fqdn": "sample-machine-new.ubnt",
349+ "id": 1,
350+ "resource_uri": "/MAAS/api/2.0/dnsresourcerecords/1/"
351+ }
352+ ],
353+ "dnsresourcerecords-create": {
354+ "ttl": null,
355+ "rrtype": "TXT",
356+ "rrdata": "172.16.0.0",
357+ "fqdn": "sample-machine-new.ubnt",
358+ "id": 1,
359+ "resource_uri": "/MAAS/api/2.0/dnsresourcerecords/1/"
360+ },
361+ "dnsresourcerecords-read-by-id": {
362+ "ttl": null,
363+ "rrtype": "CNAME",
364+ "rrdata": "172.16.0.0",
365+ "fqdn": "sample-machine-new.ubnt",
366+ "id": 1,
367+ "resource_uri": "/MAAS/api/2.0/dnsresourcerecords/1/"
368+ },
369+ "dnsresourcerecords-update": {
370+ "ttl": null,
371+ "rrtype": "TXT",
372+ "rrdata": "172.16.0.0",
373+ "fqdn": "sample-machine-new.ubnt",
374+ "id": 1,
375+ "resource_uri": "/MAAS/api/2.0/dnsresourcerecords/1/"
376+ }
377+}
378diff --git a/src/maasserver/api/examples/dnsresources.json b/src/maasserver/api/examples/dnsresources.json
379new file mode 100644
380index 0000000..4818bb4
381--- /dev/null
382+++ b/src/maasserver/api/examples/dnsresources.json
383@@ -0,0 +1,47 @@
384+{
385+ "dnsresources-read": [
386+ {
387+ "address_ttl": null,
388+ "id": -1,
389+ "ip_addresses": null,
390+ "resource_records": [
391+ {
392+ "system_id": "ydpcwh",
393+ "node_type": 0,
394+ "user_id": null,
395+ "dnsresource_id": null,
396+ "ttl": null,
397+ "rrtype": "A",
398+ "rrdata": "172.16.2.111",
399+ "dnsdata_id": null
400+ }
401+ ],
402+ "fqdn": "divine-buck.ubnt",
403+ "resource_uri": "/MAAS/api/2.0/dnsresources/-1/"
404+ }
405+ ],
406+ "dnsresources-create": {
407+ "address_ttl": null,
408+ "fqdn": "sample-machine.ubnt",
409+ "resource_records": [],
410+ "id": 1,
411+ "ip_addresses": [],
412+ "resource_uri": "/MAAS/api/2.0/dnsresources/1/"
413+ },
414+ "dnsresources-read-by-id": {
415+ "address_ttl": null,
416+ "fqdn": "sample-machine.ubnt",
417+ "resource_records": [],
418+ "ip_addresses": [],
419+ "id": 1,
420+ "resource_uri": "/MAAS/api/2.0/dnsresources/1/"
421+ },
422+ "dnsresources-update": {
423+ "address_ttl": null,
424+ "fqdn": "sample-machine.ubnt",
425+ "resource_records": [],
426+ "ip_addresses": [],
427+ "id": 1,
428+ "resource_uri": "/MAAS/api/2.0/dnsresources/1/"
429+ }
430+}

Subscribers

People subscribed via source and target branches