REST API set creator attribute when creating objects
diff --git a/planetstack/apigen/api.template.py b/planetstack/apigen/api.template.py
index 2b57613..7ba0fe3 100644
--- a/planetstack/apigen/api.template.py
+++ b/planetstack/apigen/api.template.py
@@ -192,9 +192,7 @@
return Response(status=status.HTTP_400_BAD_REQUEST)
if self.object is None:
- self.object = serializer.save(force_insert=True)
- self.post_save(self.object, created=True)
- return Response(serializer.data, status=status.HTTP_201_CREATED)
+ raise Exception("Use the List API for creating objects")
self.object = serializer.save(force_update=True)
self.post_save(self.object, created=False)
@@ -228,6 +226,39 @@
else:
return super(PlanetStackListCreateAPIView, self).handle_exception(exc)
+ def create(self, request, *args, **kwargs):
+ serializer = self.get_serializer(data=request.DATA, files=request.FILES)
+ if not (serializer.is_valid()):
+ response = {"error": "validation",
+ "specific_error": "not serializer.is_valid()",
+ "reasons": serializer.errors}
+ return Response(response, status=status.HTTP_400_BAD_REQUEST)
+
+ # now do XOS can_update permission checking
+
+ obj = serializer.object
+ obj.caller = request.user
+ if not obj.can_update(request.user):
+ response = {"error": "validation",
+ "specific_error": "failed can_update",
+ "reasons": []}
+ return Response(response, status=status.HTTP_400_BAD_REQUEST)
+
+ # stuff below is from generics.ListCreateAPIView
+
+ if (hasattr(self, "pre_save")):
+ # rest_framework 2.x
+ self.pre_save(serializer.object)
+ self.object = serializer.save(force_insert=True)
+ self.post_save(self.object, created=True)
+ else:
+ # rest_framework 3.x
+ self.perform_create(serializer)
+
+ headers = self.get_success_headers(serializer.data)
+ return Response(serializer.data, status=status.HTTP_201_CREATED,
+ headers=headers)
+
# Based on core/views/*.py
{% for object in generator.all %}
@@ -252,26 +283,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return {{ object.camel }}.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super({{ object.camel }}List, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super({{ object.camel }}List, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class {{ object.camel }}Detail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = {{ object.camel }}.objects.select_related().all()
diff --git a/planetstack/core/models/slice.py b/planetstack/core/models/slice.py
index bb06e6b..8dfde4c 100644
--- a/planetstack/core/models/slice.py
+++ b/planetstack/core/models/slice.py
@@ -68,10 +68,9 @@
if 'creator' in self.changed_fields and \
(not hasattr(self, 'caller') or not self.caller.is_admin):
- if (self._initial["creator"]==None): # and (self.creator==self.caller):
+ if (self._initial["creator"]==None) and (self.creator==getattr(self,"caller",None)):
# it's okay if the creator is being set by the caller to
# himeself on a new slice object.
- # TODO: self.caller is None when called from slicePlus REST API
pass
else:
raise PermissionDenied("Insufficient privileges to change slice creator")
diff --git a/planetstack/core/xoslib/methods/plus.py b/planetstack/core/xoslib/methods/plus.py
index 2fd5729..a50b064 100644
--- a/planetstack/core/xoslib/methods/plus.py
+++ b/planetstack/core/xoslib/methods/plus.py
@@ -27,19 +27,6 @@
# XXX this was lifted and hacked up a bit from genapi.py
class PlusListCreateAPIView(generics.ListCreateAPIView):
- # rest_framework 2.x
- # create() calls pre_save, then serializer.save, then post_save
- def pre_save(self, obj):
- super(PlusListCreateAPIView,self).pre_save(obj)
- obj.caller = self.request.user
-
- # rest_framework 3.x
- # pre_save/serializer.save/post_save is replaced with perform_save
- # *** UNTESTED ***
- def perform_create(self, serializer):
- self.pre_save(serializer.object)
- super(PlusListCreateAPIView,self).perform_save(serializer)
-
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.DATA, files=request.FILES)
if not (serializer.is_valid()):
@@ -47,14 +34,31 @@
"specific_error": "not serializer.is_valid()",
"reasons": serializer.errors}
return Response(response, status=status.HTTP_400_BAD_REQUEST)
+
+ # now do XOS can_update permission checking
+
obj = serializer.object
obj.caller = request.user
if not obj.can_update(request.user):
- raise Exception("failed obj.can_update")
+ response = {"error": "validation",
+ "specific_error": "failed can_update",
+ "reasons": []}
+ return Response(response, status=status.HTTP_400_BAD_REQUEST)
- ret = super(PlusListCreateAPIView, self).create(request, *args, **kwargs)
+ # stuff below is from generics.ListCreateAPIView
- return ret
+ if (hasattr(self, "pre_save")):
+ # rest_framework 2.x
+ self.pre_save(serializer.object)
+ self.object = serializer.save(force_insert=True)
+ self.post_save(self.object, created=True)
+ else:
+ # rest_framework 3.x
+ self.perform_create(serializer)
+
+ headers = self.get_success_headers(serializer.data)
+ return Response(serializer.data, status=status.HTTP_201_CREATED,
+ headers=headers)
# XXX this is taken from genapi.py
# XXX find a better way to re-use the code
@@ -91,10 +95,7 @@
return Response(status=status.HTTP_400_BAD_REQUEST)
if self.object is None:
- self.object = serializer.save(force_insert=True)
- self.object.caller = request.user
- self.post_save(self.object, created=True)
- return Response(serializer.data, status=status.HTTP_201_CREATED)
+ raise Exception("Use the List API for creating objects")
self.object = serializer.save(force_update=True)
self.object.caller = request.user
diff --git a/planetstack/genapi.py b/planetstack/genapi.py
index a853685..8912903 100644
--- a/planetstack/genapi.py
+++ b/planetstack/genapi.py
@@ -2579,9 +2579,7 @@
return Response(status=status.HTTP_400_BAD_REQUEST)
if self.object is None:
- self.object = serializer.save(force_insert=True)
- self.post_save(self.object, created=True)
- return Response(serializer.data, status=status.HTTP_201_CREATED)
+ raise Exception("Use the List API for creating objects")
self.object = serializer.save(force_update=True)
self.post_save(self.object, created=False)
@@ -2615,6 +2613,39 @@
else:
return super(PlanetStackListCreateAPIView, self).handle_exception(exc)
+ def create(self, request, *args, **kwargs):
+ serializer = self.get_serializer(data=request.DATA, files=request.FILES)
+ if not (serializer.is_valid()):
+ response = {"error": "validation",
+ "specific_error": "not serializer.is_valid()",
+ "reasons": serializer.errors}
+ return Response(response, status=status.HTTP_400_BAD_REQUEST)
+
+ # now do XOS can_update permission checking
+
+ obj = serializer.object
+ obj.caller = request.user
+ if not obj.can_update(request.user):
+ response = {"error": "validation",
+ "specific_error": "failed can_update",
+ "reasons": []}
+ return Response(response, status=status.HTTP_400_BAD_REQUEST)
+
+ # stuff below is from generics.ListCreateAPIView
+
+ if (hasattr(self, "pre_save")):
+ # rest_framework 2.x
+ self.pre_save(serializer.object)
+ self.object = serializer.save(force_insert=True)
+ self.post_save(self.object, created=True)
+ else:
+ # rest_framework 3.x
+ self.perform_create(serializer)
+
+ headers = self.get_success_headers(serializer.data)
+ return Response(serializer.data, status=status.HTTP_201_CREATED,
+ headers=headers)
+
# Based on core/views/*.py
@@ -2639,26 +2670,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ServiceAttribute.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ServiceAttributeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ServiceAttribute.objects.select_related().all()
@@ -2706,26 +2717,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerImages.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerImagesList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerImages.objects.select_related().all()
@@ -2773,26 +2764,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerSitePrivilege.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerSitePrivilege.objects.select_related().all()
@@ -2840,26 +2811,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Image.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ImageList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ImageList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Image.objects.select_related().all()
@@ -2907,26 +2858,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return NetworkParameter.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(NetworkParameterList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = NetworkParameter.objects.select_related().all()
@@ -2974,26 +2905,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Site.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SiteList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SiteList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Site.objects.select_related().all()
@@ -3041,26 +2952,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return SliceRole.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SliceRoleList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SliceRoleList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = SliceRole.objects.select_related().all()
@@ -3108,26 +2999,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Tag.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(TagList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(TagList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Tag.objects.select_related().all()
@@ -3175,26 +3046,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Invoice.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(InvoiceList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(InvoiceList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Invoice.objects.select_related().all()
@@ -3242,26 +3093,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return SlicePrivilege.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = SlicePrivilege.objects.select_related().all()
@@ -3309,26 +3140,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return PlanetStackRole.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = PlanetStackRole.objects.select_related().all()
@@ -3376,26 +3187,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return NetworkSliver.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(NetworkSliverList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = NetworkSliver.objects.select_related().all()
@@ -3443,26 +3234,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Flavor.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(FlavorList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(FlavorList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Flavor.objects.select_related().all()
@@ -3510,26 +3281,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerSite.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerSiteList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerSiteList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerSite.objects.select_related().all()
@@ -3577,26 +3328,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Project.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ProjectList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ProjectList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Project.objects.select_related().all()
@@ -3644,26 +3375,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Slice.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SliceList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SliceList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Slice.objects.select_related().all()
@@ -3711,26 +3422,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Network.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(NetworkList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(NetworkList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Network.objects.select_related().all()
@@ -3778,26 +3469,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Service.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ServiceList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ServiceList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Service.objects.select_related().all()
@@ -3845,26 +3516,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ServiceClass.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ServiceClassList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ServiceClassList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ServiceClass.objects.select_related().all()
@@ -3912,26 +3563,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return PlanetStack.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(PlanetStackList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(PlanetStackList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = PlanetStack.objects.select_related().all()
@@ -3979,26 +3610,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Charge.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ChargeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ChargeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Charge.objects.select_related().all()
@@ -4046,26 +3657,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Role.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(RoleList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(RoleList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Role.objects.select_related().all()
@@ -4113,26 +3704,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return UsableObject.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(UsableObjectList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(UsableObjectList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = UsableObject.objects.select_related().all()
@@ -4180,26 +3751,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return SiteRole.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SiteRoleList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SiteRoleList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = SiteRole.objects.select_related().all()
@@ -4247,26 +3798,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return SliceCredential.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SliceCredentialList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = SliceCredential.objects.select_related().all()
@@ -4314,26 +3845,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Sliver.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SliverList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SliverList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Sliver.objects.select_related().all()
@@ -4381,26 +3892,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Node.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(NodeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(NodeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Node.objects.select_related().all()
@@ -4448,26 +3939,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return DashboardView.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(DashboardViewList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(DashboardViewList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = DashboardView.objects.select_related().all()
@@ -4515,26 +3986,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerNetwork.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerNetworkList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerNetworkList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerNetwork.objects.select_related().all()
@@ -4582,26 +4033,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ImageDeployments.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ImageDeployments.objects.select_related().all()
@@ -4649,26 +4080,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerUser.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerUserList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerUserList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerUser.objects.select_related().all()
@@ -4716,26 +4127,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ReservedResource.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ReservedResourceList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ReservedResource.objects.select_related().all()
@@ -4783,26 +4174,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Payment.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(PaymentList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(PaymentList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Payment.objects.select_related().all()
@@ -4850,26 +4221,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return NetworkSlice.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(NetworkSliceList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = NetworkSlice.objects.select_related().all()
@@ -4917,26 +4268,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return UserDashboardView.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(UserDashboardViewList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = UserDashboardView.objects.select_related().all()
@@ -4984,26 +4315,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Controller.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Controller.objects.select_related().all()
@@ -5051,26 +4362,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return PlanetStackPrivilege.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = PlanetStackPrivilege.objects.select_related().all()
@@ -5118,26 +4409,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return User.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(UserList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(UserList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = User.objects.select_related().all()
@@ -5185,26 +4456,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Deployment.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(DeploymentList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(DeploymentList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Deployment.objects.select_related().all()
@@ -5252,26 +4503,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Reservation.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ReservationList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ReservationList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Reservation.objects.select_related().all()
@@ -5319,26 +4550,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return SitePrivilege.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SitePrivilegeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = SitePrivilege.objects.select_related().all()
@@ -5386,26 +4597,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerSlice.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerSliceList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerSliceList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerSlice.objects.select_related().all()
@@ -5453,26 +4644,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerDashboardView.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerDashboardView.objects.select_related().all()
@@ -5520,26 +4691,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Account.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(AccountList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(AccountList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Account.objects.select_related().all()
@@ -5587,26 +4738,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerRole.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerRoleList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerRole.objects.select_related().all()
@@ -5654,26 +4785,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return NetworkParameterType.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = NetworkParameterType.objects.select_related().all()
@@ -5721,26 +4832,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return SiteCredential.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SiteCredentialList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = SiteCredential.objects.select_related().all()
@@ -5788,26 +4879,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return DeploymentPrivilege.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = DeploymentPrivilege.objects.select_related().all()
@@ -5855,26 +4926,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ControllerSlicePrivilege.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ControllerSlicePrivilege.objects.select_related().all()
@@ -5922,26 +4973,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return SiteDeployment.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SiteDeploymentList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = SiteDeployment.objects.select_related().all()
@@ -5989,26 +5020,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return DeploymentRole.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(DeploymentRoleList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = DeploymentRole.objects.select_related().all()
@@ -6056,26 +5067,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return UserCredential.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(UserCredentialList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(UserCredentialList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = UserCredential.objects.select_related().all()
@@ -6123,26 +5114,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return SliceTag.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(SliceTagList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(SliceTagList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = SliceTag.objects.select_related().all()
@@ -6190,26 +5161,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return NetworkTemplate.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(NetworkTemplateList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = NetworkTemplate.objects.select_related().all()
@@ -6257,26 +5208,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return Router.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(RouterList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(RouterList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = Router.objects.select_related().all()
@@ -6324,26 +5255,6 @@
raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
return ServiceResource.select_by_user(self.request.user)
- def create(self, request, *args, **kwargs):
- serializer = self.get_serializer(data=request.DATA, files=request.FILES)
- if not (serializer.is_valid()):
- response = {"error": "validation",
- "specific_error": "not serializer.is_valid()",
- "reasons": serializer.errors}
- return Response(response, status=status.HTTP_400_BAD_REQUEST)
- obj = serializer.object
- obj.caller = request.user
- if obj.can_update(request.user):
- return super(ServiceResourceList, self).create(request, *args, **kwargs)
- else:
- raise Exception("failed obj.can_update")
-
- ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
- if (ret.status_code%100 != 200):
- raise Exception(ret.data)
-
- return ret
-
class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
queryset = ServiceResource.objects.select_related().all()