summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-12-09 16:52:51 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-12 20:44:54 +0000
commitde0295e5bb29510cf08c3680d55fba51902605d8 (patch)
tree709fa98c1dfcd51ce3f62bedec92e6774935a7b6 /bitbake/lib/toaster
parent23ad2a8ca08da30bd5ef1e01860021ced1967c07 (diff)
downloadpoky-de0295e5bb29510cf08c3680d55fba51902605d8.tar.gz
bitbake: toaster: api Add GET REST API for Layer information
Add a get API for returning information about layers. (Bitbake rev: 3fa5170c98c699d2a7a8380b696fc599efcc5dee) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r--bitbake/lib/toaster/toastergui/api.py55
1 files changed, 52 insertions, 3 deletions
diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py
index 5be633ed11..5b035505c2 100644
--- a/bitbake/lib/toaster/toastergui/api.py
+++ b/bitbake/lib/toaster/toastergui/api.py
@@ -139,9 +139,55 @@ class XhrBuildRequest(View):
139class XhrLayer(View): 139class XhrLayer(View):
140 """ Delete, Get, Add and Update Layer information 140 """ Delete, Get, Add and Update Layer information
141 141
142 Methods: POST DELETE PUT 142 Methods: GET POST DELETE PUT
143 """ 143 """
144 144
145 def get(self, request, *args, **kwargs):
146 """
147 Get layer information
148
149 Method: GET
150 Entry point: /xhr_layer/<project id>/<layerversion_id>
151 """
152
153 try:
154 layer_version = Layer_Version.objects.get(
155 pk=kwargs['layerversion_id'])
156
157 project = Project.objects.get(pk=kwargs['pid'])
158
159 project_layers = ProjectLayer.objects.filter(
160 project=project).values_list("layercommit_id",
161 flat=True)
162
163 ret = {
164 'error': 'ok',
165 'id': layer_version.pk,
166 'name': layer_version.layer.name,
167 'layerdetailurl':
168 layer_version.get_detailspage_url(project.pk),
169 'vcs_ref': layer_version.get_vcs_reference(),
170 'vcs_url': layer_version.layer.vcs_url,
171 'local_source_dir': layer_version.layer.local_source_dir,
172 'layerdeps': {
173 "list": [
174 {
175 "id": dep.id,
176 "name": dep.layer.name,
177 "layerdetailurl":
178 dep.get_detailspage_url(project.pk),
179 "vcs_url": dep.layer.vcs_url,
180 "vcs_reference": dep.get_vcs_reference()
181 }
182 for dep in layer_version.get_alldeps(project.id)]
183 },
184 'projectlayers': list(project_layers)
185 }
186
187 return JsonResponse(ret)
188 except Layer_Version.DoesNotExist:
189 error_response("No such layer")
190
145 def post(self, request, *args, **kwargs): 191 def post(self, request, *args, **kwargs):
146 """ 192 """
147 Update a layer 193 Update a layer
@@ -211,7 +257,7 @@ class XhrLayer(View):
211 """ Add a new layer 257 """ Add a new layer
212 258
213 Method: PUT 259 Method: PUT
214 Entry point: /xhr_layer/ 260 Entry point: /xhr_layer/<project id>/
215 Args: 261 Args:
216 project_id, name, 262 project_id, name,
217 [vcs_url, dir_path, git_ref], [local_source_dir], [layer_deps 263 [vcs_url, dir_path, git_ref], [local_source_dir], [layer_deps
@@ -296,7 +342,7 @@ class XhrLayer(View):
296 """ Delete an imported layer 342 """ Delete an imported layer
297 343
298 Method: DELETE 344 Method: DELETE
299 Entry point: /xhr_layer/<layerversion_id> 345 Entry point: /xhr_layer/<projed id>/<layerversion_id>
300 346
301 """ 347 """
302 try: 348 try:
@@ -888,6 +934,9 @@ class XhrProject(View):
888 "url": layer.layercommit.layer.layer_index_url, 934 "url": layer.layercommit.layer.layer_index_url,
889 "layerdetailurl": layer.layercommit.get_detailspage_url( 935 "layerdetailurl": layer.layercommit.get_detailspage_url(
890 project.pk), 936 project.pk),
937 "xhrLayerUrl": reverse("xhr_layer",
938 args=(project.pk,
939 layer.layercommit.pk)),
891 "layersource": layer.layercommit.layer_source 940 "layersource": layer.layercommit.layer_source
892 }) 941 })
893 942