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 2021/01/20 01:09:13 UTC
[airavata-django-portal] branch develop updated: AIRAVATA-3398
Remove REST methods for any gateway resource profile
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
The following commit(s) were added to refs/heads/develop by this push:
new f8742b7 AIRAVATA-3398 Remove REST methods for any gateway resource profile
new b21e754 Merge branch 'AIRAVATA-3398' into develop
f8742b7 is described below
commit f8742b7cfb6c7ab02f5e6bc2c83bc588f7095afb
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Tue Jan 19 20:08:39 2021 -0500
AIRAVATA-3398 Remove REST methods for any gateway resource profile
---
.../GatewayResourceProfileEditorContainer.vue | 3 +-
django_airavata/apps/api/serializers.py | 4 --
.../api/static/django_airavata_api/js/index.js | 2 +-
.../django_airavata_api/js/service_config.js | 14 +++++--
django_airavata/apps/api/urls.py | 5 +--
django_airavata/apps/api/views.py | 49 +++++++---------------
6 files changed, 29 insertions(+), 48 deletions(-)
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditorContainer.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditorContainer.vue
index c634c16..e1d247d 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditorContainer.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/gatewayprofile/GatewayResourceProfileEditorContainer.vue
@@ -61,7 +61,7 @@ export default {
};
},
created() {
- services.GatewayResourceProfileService.current().then((gwp) => {
+ services.GatewayResourceProfileService.get().then((gwp) => {
this.gatewayResourceProfile = gwp;
this.gatewayResourceProfileClone = gwp.clone();
});
@@ -69,7 +69,6 @@ export default {
methods: {
save() {
services.GatewayResourceProfileService.update({
- lookup: this.gatewayResourceProfile.gatewayID,
data: this.gatewayResourceProfile,
}).then((gwp) => {
this.gatewayResourceProfile = gwp;
diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index 43d10f6..b84edd0 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -852,10 +852,6 @@ class StoragePreferenceSerializer(
class GatewayResourceProfileSerializer(
thrift_utils.create_serializer_class(GatewayResourceProfile)):
- url = FullyEncodedHyperlinkedIdentityField(
- view_name='django_airavata_api:gateway-resource-profile-detail',
- lookup_field='gatewayID',
- lookup_url_kwarg='gateway_id')
storagePreferences = StoragePreferenceSerializer(many=True)
userHasWriteAccess = serializers.SerializerMethodField()
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/index.js b/django_airavata/apps/api/static/django_airavata_api/js/index.js
index a8d1581..4e9e568 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/index.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/index.js
@@ -112,7 +112,7 @@ const services = {
ExperimentStatisticsService: ServiceFactory.service("ExperimentStatistics"),
FullExperimentService: ServiceFactory.service("FullExperiments"),
GatewayResourceProfileService: ServiceFactory.service(
- "GatewayResourceProfiles"
+ "GatewayResourceProfile"
),
GlobusJobSubmissionService,
GridFTPDataMovementService,
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
index 35e0466..6a4cca3 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
@@ -231,15 +231,21 @@ export default {
],
modelClass: FullExperiment,
},
- GatewayResourceProfiles: {
- url: "/api/gateway-resource-profiles/",
- viewSet: true,
+ GatewayResourceProfile: {
+ url: "/api/gateway-resource-profile/",
methods: {
- current: {
+ get: {
url: "/api/gateway-resource-profile/",
requestType: "get",
modelClass: GatewayResourceProfile,
},
+ update: {
+ requestType: "put",
+ bodyParams: {
+ name: "data",
+ },
+ modelClass: GatewayResourceProfile,
+ },
},
modelClass: GatewayResourceProfile,
},
diff --git a/django_airavata/apps/api/urls.py b/django_airavata/apps/api/urls.py
index 9295a32..905c814 100644
--- a/django_airavata/apps/api/urls.py
+++ b/django_airavata/apps/api/urls.py
@@ -35,9 +35,6 @@ router.register(r'storage-resources', views.StorageResourceViewSet,
basename='storage-resource')
router.register(r'credential-summaries', views.CredentialSummaryViewSet,
basename='credential-summary')
-router.register(r'gateway-resource-profiles',
- views.GatewayResourceProfileViewSet,
- basename='gateway-resource-profile')
router.register(r'storage-preferences',
views.StoragePreferenceViewSet,
basename='storage-preference')
@@ -77,7 +74,7 @@ urlpatterns = [
url(r'^data/movement/scp', views.ScpDataMovementView.as_view(),
name="scp_ftp_data_movement"),
url(r'^gateway-resource-profile',
- views.GetCurrentGatewayResourceProfile.as_view(),
+ views.CurrentGatewayResourceProfile.as_view(),
name="current_gateway_resource_profile"),
url(r'^workspace-preferences',
views.WorkspacePreferencesView.as_view(),
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 878f60a..76b4148 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -29,12 +29,11 @@ from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.http import FileResponse, Http404, HttpResponse, JsonResponse
from django.urls import reverse
-from rest_framework import mixins
+from rest_framework import mixins, status
from rest_framework.decorators import action, api_view
from rest_framework.exceptions import ParseError
from rest_framework.renderers import JSONRenderer
from rest_framework.response import Response
-from rest_framework.status import HTTP_400_BAD_REQUEST
from rest_framework.views import APIView
from django_airavata.apps.api.view_utils import (
@@ -1411,36 +1410,7 @@ class CredentialSummaryViewSet(APIBackedViewSet):
self.authz_token, instance.token)
-class GatewayResourceProfileViewSet(APIBackedViewSet):
- serializer_class = serializers.GatewayResourceProfileSerializer
- lookup_field = 'gateway_id'
-
- def get_list(self):
- return self.request.airavata_client.getAllGatewayResourceProfiles(
- self.authz_token)
-
- def get_instance(self, lookup_value):
- return self.request.airavata_client.getGatewayResourceProfile(
- self.authz_token, lookup_value)
-
- def perform_create(self, serializer):
- gateway_resource_profile = serializer.save()
- self.request.airavata_client.registerGatewayResourceProfile(
- self.authz_token, gateway_resource_profile)
-
- def perform_update(self, serializer):
- gateway_resource_profile = serializer.save()
- self.request.airavata_client.updateGatewayResourceProfile(
- self.authz_token,
- gateway_resource_profile.gatewayID,
- gateway_resource_profile)
-
- def perform_destroy(self, instance):
- self.request.airavata_client.deleteGatewayResourceProfile(
- self.authz_token, instance.gatewayID)
-
-
-class GetCurrentGatewayResourceProfile(APIView):
+class CurrentGatewayResourceProfile(APIView):
def get(self, request, format=None):
gateway_resource_profile = \
@@ -1450,6 +1420,19 @@ class GetCurrentGatewayResourceProfile(APIView):
gateway_resource_profile, context={'request': request})
return Response(serializer.data)
+ def put(self, request, format=None):
+ serializer = serializers.GatewayResourceProfileSerializer(
+ data=request.data, context={'request': request})
+ if serializer.is_valid():
+ gateway_resource_profile = serializer.save()
+ request.airavata_client.updateGatewayResourceProfile(
+ request.authz_token,
+ settings.GATEWAY_ID,
+ gateway_resource_profile)
+ return Response(serializer.data, status=status.HTTP_201_CREATED)
+ else:
+ return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
class StorageResourceViewSet(mixins.RetrieveModelMixin,
GenericAPIBackedViewSet):
@@ -1567,7 +1550,7 @@ class UserStoragePathView(APIView):
path=path,
fileContentText=request.data["fileContentText"])
else:
- return Response(status=HTTP_400_BAD_REQUEST)
+ return Response(status=status.HTTP_400_BAD_REQUEST)
return self._create_response(request=request, path=path)