diff --git a/SAS/TMSS/client/lib/tmss_http_rest_client.py b/SAS/TMSS/client/lib/tmss_http_rest_client.py index 1f426c0b52a58d0c33c54cf10583ba0c6e5d2408..68d256dc8d30b2f49a45cedd6e26038d5b4fd7d2 100644 --- a/SAS/TMSS/client/lib/tmss_http_rest_client.py +++ b/SAS/TMSS/client/lib/tmss_http_rest_client.py @@ -204,6 +204,14 @@ class TMSSsession(object): return None return result + def get_subtask_output_dataproducts(self, subtask_id: int) -> []: + '''get the output dataproducts of the subtask with the given subtask_id''' + return self.get_path_as_json_object('subtask/%s/output_dataproducts' % subtask_id) + + def get_subtask_input_dataproducts(self, subtask_id: int) -> []: + '''get the input dataproducts of the subtask with the given subtask_id''' + return self.get_path_as_json_object('subtask/%s/input_dataproducts' % subtask_id) + def specify_observation_task(self, task_id: int) -> requests.Response: """specify observation for the given draft task by just doing a REST API call """ result = self.session.get(url='%s/api/task/%s/specify_observation' % (self.base_url, task_id)) diff --git a/SAS/TMSS/src/tmss/tmssapp/viewsets/scheduling.py b/SAS/TMSS/src/tmss/tmssapp/viewsets/scheduling.py index a8b6c5f55def5061b26a9ac20ed5570d9842fe3c..359342b1c9c1204773860aeb795cd46f95002b88 100644 --- a/SAS/TMSS/src/tmss/tmssapp/viewsets/scheduling.py +++ b/SAS/TMSS/src/tmss/tmssapp/viewsets/scheduling.py @@ -224,6 +224,27 @@ class SubtaskViewSet(LOFARViewSet): context={'request': request}) return RestResponse(serializer.data) + + @swagger_auto_schema(responses={200: 'The input dataproducts of this subtask.', + 403: 'forbidden'}, + operation_description="Get the input dataproducts of this subtask.") + @action(methods=['get'], detail=True, url_name='input_dataproducts') + def input_dataproducts(self, request, pk=None): + dataproducts = models.Dataproduct.objects.filter(subtaskinput__subtask_id=pk) + serializer = serializers.DataproductSerializer(dataproducts, many=True, context={'request': request}) + return RestResponse(serializer.data) + + + @swagger_auto_schema(responses={200: 'The output dataproducts of this subtask.', + 403: 'forbidden'}, + operation_description="Get the output dataproducts of this subtask.") + @action(methods=['get'], detail=True, url_name='output_dataproducts') + def output_dataproducts(self, request, pk=None): + dataproducts = models.Dataproduct.objects.filter(producer__subtask_id=pk) + serializer = serializers.DataproductSerializer(dataproducts, many=True, context={'request': request}) + return RestResponse(serializer.data) + + class SubtaskNestedViewSet(LOFARNestedViewSet): queryset = models.Subtask.objects.all() serializer_class = serializers.SubtaskSerializer