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

Proposed by Spencer Seidel
Status: Merged
Approved by: Spencer Seidel
Approved revision: 183b5f6a327633fc32bda84b6b5dac21f4d1328c
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~jsseidel/maas:jsseidel-pkgrepos-api-annotations
Merge into: maas:master
Diff against target: 310 lines (+197/-44)
2 files modified
src/maasserver/api/examples/package-repositories.json (+95/-0)
src/maasserver/api/packagerepositories.py (+102/-44)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Mike Pontillo (community) Approve
Review via email: mp+361147@code.launchpad.net

Commit message

Added API annotations and examples to packagerespositories.

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

I'm going to approve, but I did notice something that could be inconsistent - please check before you land. Thanks!

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

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

STATUS: FAILED
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/4777/console
COMMIT: 211b75d21d77170c4fac8a6c654366b25cadbf65

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

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

STATUS: SUCCESS
COMMIT: 183b5f6a327633fc32bda84b6b5dac21f4d1328c

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

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

STATUS: FAILED BUILD
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/4797/consoleText

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

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

STATUS: FAILED BUILD
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/4804/consoleText

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

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

STATUS: FAILED BUILD
LOG: http://maas-ci-jenkins.internal:8080/job/maas/job/branch-tester/4819/consoleText

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/api/examples/package-repositories.json b/src/maasserver/api/examples/package-repositories.json
2new file mode 100644
3index 0000000..a797442
4--- /dev/null
5+++ b/src/maasserver/api/examples/package-repositories.json
6@@ -0,0 +1,95 @@
7+{
8+ "pkg-repos-read": [
9+ {
10+ "name": "main_archive",
11+ "url": "http://archive.ubuntu.com/ubuntu",
12+ "distributions": [],
13+ "disabled_pockets": [],
14+ "disabled_components": [],
15+ "disable_sources": true,
16+ "components": [],
17+ "arches": [
18+ "amd64",
19+ "i386"
20+ ],
21+ "key": "",
22+ "enabled": true,
23+ "id": 1,
24+ "resource_uri": "/MAAS/api/2.0/package-repositories/1/"
25+ },
26+ {
27+ "name": "ports_archive",
28+ "url": "http://ports.ubuntu.com/ubuntu-ports",
29+ "distributions": [],
30+ "disabled_pockets": [],
31+ "disabled_components": [],
32+ "disable_sources": true,
33+ "components": [],
34+ "arches": [
35+ "armhf",
36+ "arm64",
37+ "ppc64el",
38+ "s390x"
39+ ],
40+ "key": "",
41+ "enabled": true,
42+ "id": 2,
43+ "resource_uri": "/MAAS/api/2.0/package-repositories/2/"
44+ }
45+ ],
46+ "pkg-repos-read-by-id": {
47+ "name": "ports_archive",
48+ "url": "http://ports.ubuntu.com/ubuntu-ports",
49+ "distributions": [],
50+ "disabled_pockets": [],
51+ "disabled_components": [],
52+ "disable_sources": true,
53+ "components": [],
54+ "arches": [
55+ "armhf",
56+ "arm64",
57+ "ppc64el",
58+ "s390x"
59+ ],
60+ "key": "",
61+ "enabled": true,
62+ "id": 2,
63+ "resource_uri": "/MAAS/api/2.0/package-repositories/2/"
64+ },
65+ "pkg-repos-update": {
66+ "name": "ports_archive",
67+ "url": "http://ports.ubuntu.com/ubuntu-ports",
68+ "distributions": [],
69+ "disabled_pockets": [],
70+ "disabled_components": [],
71+ "disable_sources": true,
72+ "components": [],
73+ "arches": [
74+ "armhf",
75+ "arm64",
76+ "ppc64el",
77+ "s390x"
78+ ],
79+ "key": "",
80+ "enabled": true,
81+ "id": 2,
82+ "resource_uri": "/MAAS/api/2.0/package-repositories/2/"
83+ },
84+ "pkg-repos-create": {
85+ "name": "new_repo",
86+ "url": "http://ports.ubuntu.com/ubuntu-ports-2",
87+ "distributions": [],
88+ "disabled_pockets": [],
89+ "disabled_components": [],
90+ "disable_sources": false,
91+ "components": [],
92+ "arches": [
93+ "amd64",
94+ "i386"
95+ ],
96+ "key": "",
97+ "enabled": true,
98+ "id": 3,
99+ "resource_uri": "/MAAS/api/2.0/package-repositories/3/"
100+ }
101+}
102diff --git a/src/maasserver/api/packagerepositories.py b/src/maasserver/api/packagerepositories.py
103index 74451f8..4d32b02 100644
104--- a/src/maasserver/api/packagerepositories.py
105+++ b/src/maasserver/api/packagerepositories.py
106@@ -35,9 +35,10 @@ DISPLAYED_PACKAGE_REPOSITORY_FIELDS = (
107
108
109 class PackageRepositoryHandler(OperationsHandler):
110- """Manage an individual Package Repository.
111+ """
112+ Manage an individual package repository.
113
114- The Package Repository is identified by its id.
115+ A package repository is identified by its id.
116 """
117 api_doc_section_name = "Package Repository"
118 create = None
119@@ -54,44 +55,74 @@ class PackageRepositoryHandler(OperationsHandler):
120 return ('package_repository_handler', (package_repository_id,))
121
122 def read(self, request, id):
123- """Read Package Repository.
124-
125- Returns 404 if the repository is not found.
126+ """@description-title Read a package repository
127+ @description Read a package repository with the given id.
128+
129+ @param (int) "{id}" [required=true] A package repository id.
130+
131+ @success (http-status-code) "server-success" 200
132+ @success (json) "success-json" A JSON object containing information
133+ about the requested package repository.
134+ @success-example "success-json" [exkey=pkg-repos-read-by-id]
135+ placeholder text
136+
137+ @error (http-status-code) "404" 404
138+ @error (content) "not-found" The requested package repository is not
139+ found.
140+ @error-example "not-found"
141+ Not Found
142 """
143 return PackageRepository.objects.get_object_or_404(id)
144
145 @admin_method
146 def update(self, request, id):
147- """Update a Package Repository.
148+ """@description-title Update a package repository
149+ @description Update the package repository with the given id.
150+
151+ @param (int) "{id}" [required=true] A package repository id.
152+
153+ @param (string) "name" [required=false] The name of the package
154+ repository.
155
156- :param name: The name of the Package Repository.
157- :type name: unicode
158+ @param (string) "url" [required=false] The url of the package
159+ repository.
160
161- :param url: The url of the Package Repository.
162- :type url: unicode
163+ @param (string) "distributions" [required=false] Which package
164+ distributions to include.
165
166- :param distributions: Which package distributions to include.
167- :type distributions: unicode
168+ @param (string) "disabled_pockets" [required=false] The list of pockets
169+ to disable.
170
171- :param disabled_pockets: The list of pockets to disable.
172+ @param (string) "disabled_components" [required=false] The list of
173+ components to disable. Only applicable to the default Ubuntu
174+ repositories.
175
176- :param disabled_components: The list of components to disable. Only
177- applicable to the default Ubuntu repositories.
178+ @param (string) "disable_sources" [required=false] Disable deb-src
179+ lines.
180
181- :param disable_sources: Disable deb-src lines.
182+ @param (string) "components" [required=false] The list of components to
183+ enable. Only applicable to custom repositories.
184
185- :param components: The list of components to enable. Only applicable
186- to custom repositories.
187+ @param (string) "arches" [required=false] The list of supported
188+ architectures.
189
190- :param arches: The list of supported architectures.
191+ @param (string) "key" [required=false] The authentication key to use
192+ with the repository.
193
194- :param key: The authentication key to use with the repository.
195- :type key: unicode
196+ @param (boolean) "enabled" [required=false] Whether or not the
197+ repository is enabled.
198
199- :param enabled: Whether or not the repository is enabled.
200- :type enabled: boolean
201+ @success (http-status-code) "server-success" 200
202+ @success (json) "success-json" A JSON object containing information
203+ about the updated package repository.
204+ @success-example "success-json" [exkey=pkg-repos-update] placeholder
205+ text
206
207- Returns 404 if the Package Repository is not found.
208+ @error (http-status-code) "404" 404
209+ @error (content) "not-found" The requested package repository is not
210+ found.
211+ @error-example "not-found"
212+ Not Found
213 """
214 package_repository = PackageRepository.objects.get_object_or_404(id)
215 form = PackageRepositoryForm(
216@@ -103,9 +134,18 @@ class PackageRepositoryHandler(OperationsHandler):
217
218 @admin_method
219 def delete(self, request, id):
220- """Delete a Package Repository.
221+ """@description-title Delete a package repository
222+ @description Delete a package repository with the given id.
223
224- Returns 404 if the Package Repository is not found.
225+ @param (int) "{id}" [required=true] A package repository id.
226+
227+ @success (http-status-code) "server-success" 204
228+
229+ @error (http-status-code) "404" 404
230+ @error (content) "not-found" The requested package repository is not
231+ found.
232+ @error-example "not-found"
233+ Not Found
234 """
235 package_repository = PackageRepository.objects.get_object_or_404(id)
236 package_repository.delete()
237@@ -125,37 +165,55 @@ class PackageRepositoriesHandler(OperationsHandler):
238 return ('package_repositories_handler', [])
239
240 def read(self, request):
241- """List all Package Repositories."""
242+ """@description-title List package repositories
243+ @description List all available package repositories.
244+
245+ @success (http-status-code) "server-success" 200
246+ @success (json) "success-json" A JSON object containing information
247+ about the updated package repository.
248+ @success-example "success-json" [exkey=pkg-repos-update] placeholder
249+ text
250+ """
251 return PackageRepository.objects.all()
252
253 @admin_method
254 def create(Self, request):
255- """Create a Package Repository.
256+ """@description-title Create a package repository
257+ @description Create a new package repository.
258+
259+ @param (string) "name" [required=true] The name of the package
260+ repository.
261
262- :param name: The name of the Package Repository.
263- :type name: unicode
264+ @param (string) "url" [required=true] The url of the package
265+ repository.
266
267- :param url: The url of the Package Repository.
268- :type url: unicode
269+ @param (string) "distributions" [required=false] Which package
270+ distributions to include.
271
272- :param distributions: Which package distributions to include.
273- :type distributions: unicode
274+ @param (string) "disabled_pockets" [required=false] The list of pockets
275+ to disable.
276
277- :param disabled_pockets: The list of pockets to disable.
278+ @param (string) "disabled_components" [required=false] The list of
279+ components to disable. Only applicable to the default Ubuntu
280+ repositories.
281
282- :param disabled_components: The list of components to disable. Only
283- applicable to the default Ubuntu repositories.
284+ @param (string) "components" [required=false] The list of components to
285+ enable. Only applicable to custom repositories.
286
287- :param components: The list of components to enable. Only applicable
288- to custom repositories.
289+ @param (string) "arches" [required=false] The list of supported
290+ architectures.
291
292- :param arches: The list of supported architectures.
293+ @param (string) "key" [required=false] The authentication key to use
294+ with the repository.
295
296- :param key: The authentication key to use with the repository.
297- :type key: unicode
298+ @param (boolean) "enabled" [required=false] Whether or not the
299+ repository is enabled.
300
301- :param enabled: Whether or not the repository is enabled.
302- :type enabled: boolean
303+ @success (http-status-code) "server-success" 200
304+ @success (json) "success-json" A JSON object containing information
305+ about the new package repository.
306+ @success-example "success-json" [exkey=pkg-repos-update] placeholder
307+ text
308 """
309 form = PackageRepositoryForm(data=request.data)
310 if form.is_valid():

Subscribers

People subscribed via source and target branches