From de0295e5bb29510cf08c3680d55fba51902605d8 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Fri, 9 Dec 2016 16:52:51 +0000 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/api.py | 55 +++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'bitbake') 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): class XhrLayer(View): """ Delete, Get, Add and Update Layer information - Methods: POST DELETE PUT + Methods: GET POST DELETE PUT """ + def get(self, request, *args, **kwargs): + """ + Get layer information + + Method: GET + Entry point: /xhr_layer// + """ + + try: + layer_version = Layer_Version.objects.get( + pk=kwargs['layerversion_id']) + + project = Project.objects.get(pk=kwargs['pid']) + + project_layers = ProjectLayer.objects.filter( + project=project).values_list("layercommit_id", + flat=True) + + ret = { + 'error': 'ok', + 'id': layer_version.pk, + 'name': layer_version.layer.name, + 'layerdetailurl': + layer_version.get_detailspage_url(project.pk), + 'vcs_ref': layer_version.get_vcs_reference(), + 'vcs_url': layer_version.layer.vcs_url, + 'local_source_dir': layer_version.layer.local_source_dir, + 'layerdeps': { + "list": [ + { + "id": dep.id, + "name": dep.layer.name, + "layerdetailurl": + dep.get_detailspage_url(project.pk), + "vcs_url": dep.layer.vcs_url, + "vcs_reference": dep.get_vcs_reference() + } + for dep in layer_version.get_alldeps(project.id)] + }, + 'projectlayers': list(project_layers) + } + + return JsonResponse(ret) + except Layer_Version.DoesNotExist: + error_response("No such layer") + def post(self, request, *args, **kwargs): """ Update a layer @@ -211,7 +257,7 @@ class XhrLayer(View): """ Add a new layer Method: PUT - Entry point: /xhr_layer/ + Entry point: /xhr_layer// Args: project_id, name, [vcs_url, dir_path, git_ref], [local_source_dir], [layer_deps @@ -296,7 +342,7 @@ class XhrLayer(View): """ Delete an imported layer Method: DELETE - Entry point: /xhr_layer/ + Entry point: /xhr_layer// """ try: @@ -888,6 +934,9 @@ class XhrProject(View): "url": layer.layercommit.layer.layer_index_url, "layerdetailurl": layer.layercommit.get_detailspage_url( project.pk), + "xhrLayerUrl": reverse("xhr_layer", + args=(project.pk, + layer.layercommit.pk)), "layersource": layer.layercommit.layer_source }) -- cgit v1.2.3-54-g00ecf