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
diff --git a/src/maasserver/api/examples/license-keys.json b/src/maasserver/api/examples/license-keys.json
0new file mode 1006440new file mode 100644
index 0000000..685a47c
--- /dev/null
+++ b/src/maasserver/api/examples/license-keys.json
@@ -0,0 +1,5 @@
1{
2 "license-keys-placeholder": {
3 "message": "Information about this object is not available at this time."
4 }
5}
diff --git a/src/maasserver/api/license_keys.py b/src/maasserver/api/license_keys.py
index 51c8bd5..176c681 100644
--- a/src/maasserver/api/license_keys.py
+++ b/src/maasserver/api/license_keys.py
@@ -25,15 +25,35 @@ class LicenseKeysHandler(OperationsHandler):
25 update = delete = None25 update = delete = None
2626
27 def read(self, request):27 def read(self, request):
28 """List license keys."""28 """@description-title List license keys
29 @description List all available license keys.
30
31 @success (http-status-code) "server-success" 200
32 @success (json) "success-json" A JSON object containing a list of
33 available license keys.
34 @success-example "success-json" [exkey=license-keys-placeholder]
35 placeholder text
36 """
29 return LicenseKey.objects.all().order_by('osystem', 'distro_series')37 return LicenseKey.objects.all().order_by('osystem', 'distro_series')
3038
31 def create(self, request):39 def create(self, request):
32 """Define a license key.40 """@description-title Define a license key
41 @description Define a license key.
42
43 @param (string) "osystem" [required=true] Operating system that the key
44 belongs to.
45
46 @param (string) "distro_series" [required=true] OS release that the key
47 belongs to.
3348
34 :param osystem: Operating system that the key belongs to.49 @param (string) "license_key" [required=true] License key for
35 :param distro_series: OS release that the key belongs to.50 osystem/distro_series combo.
36 :param license_key: License key for osystem/distro_series combo.51
52 @success (http-status-code) "server-success" 200
53 @success (json) "success-json" A JSON object containing the new license
54 key.
55 @success-example "success-json" [exkey=license-keys-placeholder]
56 placeholder text
37 """57 """
38 # If the user provides no parametes to the create command, then58 # If the user provides no parametes to the create command, then
39 # django will make the request.data=None. This will cause the form59 # django will make the request.data=None. This will cause the form
@@ -77,16 +97,56 @@ class LicenseKeyHandler(OperationsHandler):
77 create = None97 create = None
7898
79 def read(self, request, osystem, distro_series):99 def read(self, request, osystem, distro_series):
80 """Read license key."""100 """@description-title Read license key
101 @description Read a license key for the given operating sytem and
102 distro series.
103
104 @param (string) "{osystem}" [required=true] Operating system that the
105 key belongs to.
106
107 @param (string) "{distro_series}" [required=true] OS release that the
108 key belongs to.
109
110 @success (http-status-code) "server-success" 200
111 @success (json) "success-json" A JSON object containing the requested
112 license key.
113 @success-example "success-json" [exkey=license-keys-placeholder]
114 placeholder text
115
116 @error (http-status-code) "404" 404
117 @error (content) "not-found" The requested operating system and distro
118 series combination is not found.
119 @error-example "not-found"
120 Unknown API endpoint: /MAAS/api/2.0/license-key/windows/win2012/.
121 """
81 return get_object_or_404(122 return get_object_or_404(
82 LicenseKey, osystem=osystem, distro_series=distro_series)123 LicenseKey, osystem=osystem, distro_series=distro_series)
83124
84 def update(self, request, osystem, distro_series):125 def update(self, request, osystem, distro_series):
85 """Update license key.126 """@description-title Update license key
86127 @description Update a license key for the given operating system and
87 :param osystem: Operating system that the key belongs to.128 distro series.
88 :param distro_series: OS release that the key belongs to.129
89 :param license_key: License key for osystem/distro_series combo.130 @param (string) "{osystem}" [required=true] Operating system that the
131 key belongs to.
132
133 @param (string) "{distro_series}" [required=true] OS release that the
134 key belongs to.
135
136 @param (string) "license_key" [required=false] License key for
137 osystem/distro_series combo.
138
139 @success (http-status-code) "server-success" 200
140 @success (json) "success-json" A JSON object containing the updated
141 license key.
142 @success-example "success-json" [exkey=license-keys-placeholder]
143 placeholder text
144
145 @error (http-status-code) "404" 404
146 @error (content) "not-found" The requested operating system and distro
147 series combination is not found.
148 @error-example "not-found"
149 Unknown API endpoint: /MAAS/api/2.0/license-key/windows/win2012/.
90 """150 """
91 license_key = get_object_or_404(151 license_key = get_object_or_404(
92 LicenseKey, osystem=osystem, distro_series=distro_series)152 LicenseKey, osystem=osystem, distro_series=distro_series)
@@ -99,7 +159,24 @@ class LicenseKeyHandler(OperationsHandler):
99 return form.save()159 return form.save()
100160
101 def delete(self, request, osystem, distro_series):161 def delete(self, request, osystem, distro_series):
102 """Delete license key."""162 """@description-title Delete license key
163 @description Delete license key for the given operation system and
164 distro series.
165
166 @param (string) "{osystem}" [required=false] Operating system that the
167 key belongs to.
168
169 @param (string) "{distro_series}" [required=false] OS release that the
170 key belongs to.
171
172 @success (http-status-code) "server-success" 204
173
174 @error (http-status-code) "404" 404
175 @error (content) "not-found" The requested operating system and distro
176 series combination is not found.
177 @error-example "not-found"
178 Unknown API endpoint: /MAAS/api/2.0/license-key/windows/win2012/.
179 """
103 license_key = get_one(180 license_key = get_one(
104 LicenseKey.objects.filter(181 LicenseKey.objects.filter(
105 osystem=osystem, distro_series=distro_series))182 osystem=osystem, distro_series=distro_series))

Subscribers

People subscribed via source and target branches