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

Proposed by Spencer Seidel
Status: Merged
Approved by: Spencer Seidel
Approved revision: dce57113b31422cb085056cfbf0c76035c7a4bad
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~jsseidel/maas:jsseidel-license_keys-api-annotations
Merge into: maas:master
Diff against target: 145 lines (+94/-12)
2 files modified
src/maasserver/api/examples/license-keys.json (+5/-0)
src/maasserver/api/license_keys.py (+89/-12)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Mike Pontillo (community) Approve
Review via email: mp+361022@code.launchpad.net

Commit message

Added API annotations and examples to license_keys. Note that placeholder examples were used because good examples could not be found with sample data.

To post a comment you must log in.
Revision history for this message
Mike Pontillo (mpontillo) wrote :

Looks good.

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

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

STATUS: SUCCESS
COMMIT: dce57113b31422cb085056cfbf0c76035c7a4bad

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

LANDING
-b jsseidel-license_keys-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/345175/console

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/examples/license-keys.json b/src/maasserver/api/examples/license-keys.json
2new file mode 100644
3index 0000000..685a47c
4--- /dev/null
5+++ b/src/maasserver/api/examples/license-keys.json
6@@ -0,0 +1,5 @@
7+{
8+ "license-keys-placeholder": {
9+ "message": "Information about this object is not available at this time."
10+ }
11+}
12diff --git a/src/maasserver/api/license_keys.py b/src/maasserver/api/license_keys.py
13index 51c8bd5..176c681 100644
14--- a/src/maasserver/api/license_keys.py
15+++ b/src/maasserver/api/license_keys.py
16@@ -25,15 +25,35 @@ class LicenseKeysHandler(OperationsHandler):
17 update = delete = None
18
19 def read(self, request):
20- """List license keys."""
21+ """@description-title List license keys
22+ @description List all available license keys.
23+
24+ @success (http-status-code) "server-success" 200
25+ @success (json) "success-json" A JSON object containing a list of
26+ available license keys.
27+ @success-example "success-json" [exkey=license-keys-placeholder]
28+ placeholder text
29+ """
30 return LicenseKey.objects.all().order_by('osystem', 'distro_series')
31
32 def create(self, request):
33- """Define a license key.
34+ """@description-title Define a license key
35+ @description Define a license key.
36+
37+ @param (string) "osystem" [required=true] Operating system that the key
38+ belongs to.
39+
40+ @param (string) "distro_series" [required=true] OS release that the key
41+ belongs to.
42
43- :param osystem: Operating system that the key belongs to.
44- :param distro_series: OS release that the key belongs to.
45- :param license_key: License key for osystem/distro_series combo.
46+ @param (string) "license_key" [required=true] License key for
47+ osystem/distro_series combo.
48+
49+ @success (http-status-code) "server-success" 200
50+ @success (json) "success-json" A JSON object containing the new license
51+ key.
52+ @success-example "success-json" [exkey=license-keys-placeholder]
53+ placeholder text
54 """
55 # If the user provides no parametes to the create command, then
56 # django will make the request.data=None. This will cause the form
57@@ -77,16 +97,56 @@ class LicenseKeyHandler(OperationsHandler):
58 create = None
59
60 def read(self, request, osystem, distro_series):
61- """Read license key."""
62+ """@description-title Read license key
63+ @description Read a license key for the given operating sytem and
64+ distro series.
65+
66+ @param (string) "{osystem}" [required=true] Operating system that the
67+ key belongs to.
68+
69+ @param (string) "{distro_series}" [required=true] OS release that the
70+ key belongs to.
71+
72+ @success (http-status-code) "server-success" 200
73+ @success (json) "success-json" A JSON object containing the requested
74+ license key.
75+ @success-example "success-json" [exkey=license-keys-placeholder]
76+ placeholder text
77+
78+ @error (http-status-code) "404" 404
79+ @error (content) "not-found" The requested operating system and distro
80+ series combination is not found.
81+ @error-example "not-found"
82+ Unknown API endpoint: /MAAS/api/2.0/license-key/windows/win2012/.
83+ """
84 return get_object_or_404(
85 LicenseKey, osystem=osystem, distro_series=distro_series)
86
87 def update(self, request, osystem, distro_series):
88- """Update license key.
89-
90- :param osystem: Operating system that the key belongs to.
91- :param distro_series: OS release that the key belongs to.
92- :param license_key: License key for osystem/distro_series combo.
93+ """@description-title Update license key
94+ @description Update a license key for the given operating system and
95+ distro series.
96+
97+ @param (string) "{osystem}" [required=true] Operating system that the
98+ key belongs to.
99+
100+ @param (string) "{distro_series}" [required=true] OS release that the
101+ key belongs to.
102+
103+ @param (string) "license_key" [required=false] License key for
104+ osystem/distro_series combo.
105+
106+ @success (http-status-code) "server-success" 200
107+ @success (json) "success-json" A JSON object containing the updated
108+ license key.
109+ @success-example "success-json" [exkey=license-keys-placeholder]
110+ placeholder text
111+
112+ @error (http-status-code) "404" 404
113+ @error (content) "not-found" The requested operating system and distro
114+ series combination is not found.
115+ @error-example "not-found"
116+ Unknown API endpoint: /MAAS/api/2.0/license-key/windows/win2012/.
117 """
118 license_key = get_object_or_404(
119 LicenseKey, osystem=osystem, distro_series=distro_series)
120@@ -99,7 +159,24 @@ class LicenseKeyHandler(OperationsHandler):
121 return form.save()
122
123 def delete(self, request, osystem, distro_series):
124- """Delete license key."""
125+ """@description-title Delete license key
126+ @description Delete license key for the given operation system and
127+ distro series.
128+
129+ @param (string) "{osystem}" [required=false] Operating system that the
130+ key belongs to.
131+
132+ @param (string) "{distro_series}" [required=false] OS release that the
133+ key belongs to.
134+
135+ @success (http-status-code) "server-success" 204
136+
137+ @error (http-status-code) "404" 404
138+ @error (content) "not-found" The requested operating system and distro
139+ series combination is not found.
140+ @error-example "not-found"
141+ Unknown API endpoint: /MAAS/api/2.0/license-key/windows/win2012/.
142+ """
143 license_key = get_one(
144 LicenseKey.objects.filter(
145 osystem=osystem, distro_series=distro_series))

Subscribers

People subscribed via source and target branches