You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/11/29 21:53:08 UTC
[airavata-django-portal] branch master updated: AIRAVATA-2597
Convert Application Module REST endpoint to ViewSet
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
The following commit(s) were added to refs/heads/master by this push:
new c3f4a1d AIRAVATA-2597 Convert Application Module REST endpoint to ViewSet
c3f4a1d is described below
commit c3f4a1d3e61717764d4bc065f108f8c9c4ff9bfe
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Wed Nov 29 12:07:07 2017 -0500
AIRAVATA-2597 Convert Application Module REST endpoint to ViewSet
---
django_airavata/apps/api/urls.py | 3 +--
django_airavata/apps/api/views.py | 28 ++++++++++++++++++++++------
django_airavata/settings.py | 1 -
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/django_airavata/apps/api/urls.py b/django_airavata/apps/api/urls.py
index bc95836..5dc9a3a 100644
--- a/django_airavata/apps/api/urls.py
+++ b/django_airavata/apps/api/urls.py
@@ -11,13 +11,12 @@ logger = logging.getLogger(__name__)
router = routers.DefaultRouter()
router.register(r'projects', views.ProjectViewSet, base_name='project')
router.register(r'new/application/module', views.RegisterApplicationModule, base_name='register_app_module')
-router.register(r'experiments', views.ApplicationList, base_name='experiments')
router.register(r'application-interface', views.ApplicationInterfaceViewSet, base_name='application-interface')
+router.register(r'applications', views.ApplicationModuleViewSet, base_name='application')
app_name = 'django_airavata_api'
urlpatterns = [
url(r'^', include(router.urls)),
- url(r'^applications/$', views.ApplicationList.as_view(), name='application_module_list'),
url(r'^new/application/module$', views.RegisterApplicationModule.as_view(), name='register_application_module'),
url(r'^new/application/interface', views.RegisterApplicationInterface.as_view(), name='register_application_interface'),
url(r'^new/application/deployment', views.RegisterApplicationDeployments.as_view(), name='register_application_deployments'),
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index ee0149c..6c3347e 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -125,6 +125,8 @@ class APIResultPagination(pagination.LimitOffsetPagination):
have a known count, so it isn't always possible to know how many pages there
are.
"""
+ default_limit = 10
+
def paginate_queryset(self, queryset, request, view=None):
assert isinstance(queryset, APIResultIterator), "queryset is not an APIResultIterator: {}".format(queryset)
self.limit = self.get_limit(request)
@@ -222,14 +224,26 @@ class ExperimentList(APIView):
return Response(serializer.data)
-class ApplicationList(APIView):
- def get(self, request, format=None):
- gateway_id = settings.GATEWAY_ID
- app_modules = request.airavata_client.getAllAppModules(request.authz_token, gateway_id)
- serializer = serializers.ApplicationModuleSerializer(app_modules, many=True, context={'request': request})
- return Response(serializer.data)
+class ApplicationModuleViewSet(APIBackedViewSet):
+ serializer_class = serializers.ApplicationModuleSerializer
+
+ def get_list(self):
+ return self.request.airavata_client.getAllAppModules(self.authz_token, self.gateway_id)
+
+ def get_instance(self, lookup_value):
+ return self.request.airavata_client.getApplicationModule(self.authz_token, lookup_value)
+
+ def perform_create(self, serializer):
+ app_module = serializer.save()
+ app_module_id = self.request.airavata_client.registerApplicationModule(self.authz_token, self.gateway_id, app_module)
+ app_module.appModuleId = app_module_id
+
+ def perform_update(self, serializer):
+ app_module = serializer.save()
+ self.request.airavata_client.updateApplicationModule(self.authz_token, app_module.appModuleId, app_module)
+# TODO convert to APIBackedViewSet
class RegisterApplicationModule(APIView):
parser_classes = (JSONParser,)
@@ -240,6 +254,7 @@ class RegisterApplicationModule(APIView):
return Response(response)
+# TODO use ApplicationInterfaceViewSet instead
class RegisterApplicationInterface(APIView):
parser_classes = (JSONParser,)
@@ -254,6 +269,7 @@ class RegisterApplicationInterface(APIView):
return Response(response)
+# TODO convert to APIBackedViewSet
class RegisterApplicationDeployments(APIView):
parser_classes = (JSONParser,)
diff --git a/django_airavata/settings.py b/django_airavata/settings.py
index c37e8e5..f123e60 100644
--- a/django_airavata/settings.py
+++ b/django_airavata/settings.py
@@ -138,7 +138,6 @@ REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
- 'PAGE_SIZE': 10,
}
AUTHENTICATION_BACKENDS = [
--
To stop receiving notification emails like this one, please contact
['"commits@airavata.apache.org" <co...@airavata.apache.org>'].