blob: 2510db9027c55943d696760f2816aa0f0c9cda96 [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07006from rest_framework import status
Scott Bakerf3816ac2014-11-12 01:13:53 -08007from rest_framework.generics import GenericAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04008from core.models import *
9from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -070010from rest_framework import filters
Scott Baker55a2e292014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Sapan Bhatiadea39432014-06-13 03:10:36 -040012
13"""
Scott Baker08898c12014-10-29 23:41:11 -070014 Schema of the generator object:
15 all: Set of all Model objects
16 all_if(regex): Set of Model objects that match regex
Scott Bakerf3816ac2014-11-12 01:13:53 -080017
Scott Baker08898c12014-10-29 23:41:11 -070018 Model object:
19 plural: English plural of object name
20 camel: CamelCase version of object name
21 refs: list of references to other Model objects
22 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040023
Scott Baker08898c12014-10-29 23:41:11 -070024 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040025"""
26
Scott Baker55a2e292014-11-10 16:31:15 -080027def get_REST_patterns():
28 return patterns('',
29 url(r'^plstackapi/$', api_root),
30
31 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
32 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
33
34 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
35 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
36
37 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
38 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
39
40 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
41 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
42
43 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
44 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
45
46 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
47 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
48
49 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
50 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
51
52 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
53 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
54
55 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
56 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
57
58 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
59 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
60
61 url(r'plstackapi/networkdeployments/$', NetworkDeploymentsList.as_view(), name='networkdeployments-list'),
62 url(r'plstackapi/networkdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDeploymentsDetail.as_view(), name ='networkdeployments-detail'),
63
64 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
65 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
66
67 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
68 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
69
70 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
71 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
72
73 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
74 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
75
76 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
77 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
78
79 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
80 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
81
Scott Baker196ffef2014-11-21 11:32:24 -080082 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
83 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -080084
85 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
86 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
87
88 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
89 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
90
91 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
92 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
93
94 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
95 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
96
97 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
98 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
99
100 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
101 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
102
103 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
104 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
105
106 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
107 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
108
Scott Baker196ffef2014-11-21 11:32:24 -0800109 url(r'plstackapi/imagedeployments/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
110 url(r'plstackapi/imagedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800111
Scott Baker55a2e292014-11-10 16:31:15 -0800112 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
113 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
114
115 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
116 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
117
118 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
119 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
120
121 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
122 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
123
124 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
125 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
126
127 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
128 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
129
130 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
131 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
132
Scott Baker72bcf352014-11-21 11:36:19 -0800133 url(r'plstackapi/slicedeployments/$', SliceDeploymentsList.as_view(), name='slicedeployments-list'),
134 url(r'plstackapi/slicedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDeploymentsDetail.as_view(), name ='slicedeployments-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800135
Scott Baker55a2e292014-11-10 16:31:15 -0800136 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
137 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
138
Scott Baker196ffef2014-11-21 11:32:24 -0800139 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
140 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800141
Scott Baker72bcf352014-11-21 11:36:19 -0800142 url(r'plstackapi/userdeployments/$', UserDeploymentsList.as_view(), name='userdeployments-list'),
143 url(r'plstackapi/userdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentsDetail.as_view(), name ='userdeployments-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800144
145 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
146 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
147
148 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
149 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
150
151 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
152 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
153
154 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
155 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
156
157 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
158 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
159
160 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
161 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
162
Scott Baker196ffef2014-11-21 11:32:24 -0800163 url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'),
164 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800165
Scott Baker55a2e292014-11-10 16:31:15 -0800166 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
167 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
168
169 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
170 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
171
172 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
173 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
174
175 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
176 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
177
178 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400179
180@api_view(['GET'])
181def api_root(request, format=None):
182 return Response({
Scott Baker08898c12014-10-29 23:41:11 -0700183 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
184 'images': reverse('image-list', request=request, format=format),
185 'networkparameters': reverse('networkparameter-list', request=request, format=format),
186 'sites': reverse('site-list', request=request, format=format),
187 'sliceroles': reverse('slicerole-list', request=request, format=format),
188 'tags': reverse('tag-list', request=request, format=format),
189 'invoices': reverse('invoice-list', request=request, format=format),
190 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
191 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
192 'networkslivers': reverse('networksliver-list', request=request, format=format),
193 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format),
194 'flavors': reverse('flavor-list', request=request, format=format),
195 'projects': reverse('project-list', request=request, format=format),
196 'slices': reverse('slice-list', request=request, format=format),
197 'networks': reverse('network-list', request=request, format=format),
198 'services': reverse('service-list', request=request, format=format),
199 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800200 'payments': reverse('payment-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700201 'charges': reverse('charge-list', request=request, format=format),
202 'roles': reverse('role-list', request=request, format=format),
203 'usableobjects': reverse('usableobject-list', request=request, format=format),
204 'siteroles': reverse('siterole-list', request=request, format=format),
205 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
206 'slivers': reverse('sliver-list', request=request, format=format),
207 'nodes': reverse('node-list', request=request, format=format),
208 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800209 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700210 'reservedresources': reverse('reservedresource-list', request=request, format=format),
211 'networkslices': reverse('networkslice-list', request=request, format=format),
212 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
213 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
214 'users': reverse('user-list', request=request, format=format),
215 'deployments': reverse('deployment-list', request=request, format=format),
216 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800217 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700218 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800219 'planetstacks': reverse('planetstack-list', request=request, format=format),
220 'userdeploymentses': reverse('userdeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700221 'accounts': reverse('account-list', request=request, format=format),
222 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
223 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
224 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
225 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
226 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800227 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700228 'slicetags': reverse('slicetag-list', request=request, format=format),
229 'networktemplates': reverse('networktemplate-list', request=request, format=format),
230 'routers': reverse('router-list', request=request, format=format),
231 'serviceresources': reverse('serviceresource-list', request=request, format=format),
232
Sapan Bhatiadea39432014-06-13 03:10:36 -0400233 })
234
235# Based on serializers.py
236
237
238
Scott Baker0caeaf02014-06-19 11:12:55 -0700239class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700240 id = serializers.Field()
241
Scott Baker196ffef2014-11-21 11:32:24 -0800242 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800243 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800244 def getHumanReadableName(self, obj):
245 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800246 def getValidators(self, obj):
247 try:
248 return obj.getValidators()
249 except:
250 return None
Scott Baker08898c12014-10-29 23:41:11 -0700251 class Meta:
252 model = ServiceAttribute
Scott Baker351148c2014-11-25 00:53:25 -0800253 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700254
255class ServiceAttributeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700256 id = serializers.Field()
257
Scott Baker196ffef2014-11-21 11:32:24 -0800258 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800259 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800260 def getHumanReadableName(self, obj):
261 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800262 def getValidators(self, obj):
263 try:
264 return obj.getValidators()
265 except:
266 return None
Scott Baker08898c12014-10-29 23:41:11 -0700267 class Meta:
268 model = ServiceAttribute
Scott Baker351148c2014-11-25 00:53:25 -0800269 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700270
271
Sapan Bhatiadea39432014-06-13 03:10:36 -0400272
273
274class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700275 id = serializers.Field()
276
Scott Baker196ffef2014-11-21 11:32:24 -0800277 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800278 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800279 def getHumanReadableName(self, obj):
280 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800281 def getValidators(self, obj):
282 try:
283 return obj.getValidators()
284 except:
285 return None
Scott Baker08898c12014-10-29 23:41:11 -0700286 class Meta:
287 model = Image
Scott Baker351148c2014-11-25 00:53:25 -0800288 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700289
290class ImageIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700291 id = serializers.Field()
292
Scott Baker196ffef2014-11-21 11:32:24 -0800293 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800294 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800295 def getHumanReadableName(self, obj):
296 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800297 def getValidators(self, obj):
298 try:
299 return obj.getValidators()
300 except:
301 return None
Scott Baker08898c12014-10-29 23:41:11 -0700302 class Meta:
303 model = Image
Scott Baker351148c2014-11-25 00:53:25 -0800304 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700305
306
Sapan Bhatiadea39432014-06-13 03:10:36 -0400307
308
Scott Baker0caeaf02014-06-19 11:12:55 -0700309class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700310 id = serializers.Field()
311
Scott Baker196ffef2014-11-21 11:32:24 -0800312 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800313 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800314 def getHumanReadableName(self, obj):
315 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800316 def getValidators(self, obj):
317 try:
318 return obj.getValidators()
319 except:
320 return None
Scott Baker08898c12014-10-29 23:41:11 -0700321 class Meta:
322 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800323 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700324
325class NetworkParameterIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700326 id = serializers.Field()
327
Scott Baker196ffef2014-11-21 11:32:24 -0800328 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800329 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800330 def getHumanReadableName(self, obj):
331 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800332 def getValidators(self, obj):
333 try:
334 return obj.getValidators()
335 except:
336 return None
Scott Baker08898c12014-10-29 23:41:11 -0700337 class Meta:
338 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800339 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700340
341
Sapan Bhatiadea39432014-06-13 03:10:36 -0400342
343
344class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700345 id = serializers.Field()
346
Scott Baker196ffef2014-11-21 11:32:24 -0800347 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800348 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800349 def getHumanReadableName(self, obj):
350 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800351 def getValidators(self, obj):
352 try:
353 return obj.getValidators()
354 except:
355 return None
Scott Baker08898c12014-10-29 23:41:11 -0700356 class Meta:
357 model = Site
Scott Baker351148c2014-11-25 00:53:25 -0800358 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Scott Baker46b58542014-08-11 17:26:12 -0700359
360class SiteIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700361 id = serializers.Field()
362
Scott Baker196ffef2014-11-21 11:32:24 -0800363 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800364 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800365 def getHumanReadableName(self, obj):
366 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800367 def getValidators(self, obj):
368 try:
369 return obj.getValidators()
370 except:
371 return None
Scott Baker08898c12014-10-29 23:41:11 -0700372 class Meta:
373 model = Site
Scott Baker351148c2014-11-25 00:53:25 -0800374 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Scott Baker46b58542014-08-11 17:26:12 -0700375
376
Sapan Bhatiadea39432014-06-13 03:10:36 -0400377
378
Scott Baker0caeaf02014-06-19 11:12:55 -0700379class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700380 id = serializers.Field()
381
Scott Baker196ffef2014-11-21 11:32:24 -0800382 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800383 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800384 def getHumanReadableName(self, obj):
385 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800386 def getValidators(self, obj):
387 try:
388 return obj.getValidators()
389 except:
390 return None
Scott Baker08898c12014-10-29 23:41:11 -0700391 class Meta:
392 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800393 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700394
395class SliceRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700396 id = serializers.Field()
397
Scott Baker196ffef2014-11-21 11:32:24 -0800398 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800399 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800400 def getHumanReadableName(self, obj):
401 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800402 def getValidators(self, obj):
403 try:
404 return obj.getValidators()
405 except:
406 return None
Scott Baker08898c12014-10-29 23:41:11 -0700407 class Meta:
408 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800409 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700410
411
Sapan Bhatiadea39432014-06-13 03:10:36 -0400412
413
414class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700415 id = serializers.Field()
416
Scott Baker196ffef2014-11-21 11:32:24 -0800417 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800418 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800419 def getHumanReadableName(self, obj):
420 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800421 def getValidators(self, obj):
422 try:
423 return obj.getValidators()
424 except:
425 return None
Scott Baker08898c12014-10-29 23:41:11 -0700426 class Meta:
427 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800428 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700429
430class TagIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700431 id = serializers.Field()
432
Scott Baker196ffef2014-11-21 11:32:24 -0800433 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800434 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800435 def getHumanReadableName(self, obj):
436 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800437 def getValidators(self, obj):
438 try:
439 return obj.getValidators()
440 except:
441 return None
Scott Baker08898c12014-10-29 23:41:11 -0700442 class Meta:
443 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800444 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700445
446
Sapan Bhatiadea39432014-06-13 03:10:36 -0400447
448
449class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700450 id = serializers.Field()
451
Scott Baker196ffef2014-11-21 11:32:24 -0800452 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800453 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800454 def getHumanReadableName(self, obj):
455 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800456 def getValidators(self, obj):
457 try:
458 return obj.getValidators()
459 except:
460 return None
Scott Baker08898c12014-10-29 23:41:11 -0700461 class Meta:
462 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800463 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700464
465class InvoiceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700466 id = serializers.Field()
467
Scott Baker196ffef2014-11-21 11:32:24 -0800468 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800469 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800470 def getHumanReadableName(self, obj):
471 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800472 def getValidators(self, obj):
473 try:
474 return obj.getValidators()
475 except:
476 return None
Scott Baker08898c12014-10-29 23:41:11 -0700477 class Meta:
478 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800479 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700480
481
Sapan Bhatiadea39432014-06-13 03:10:36 -0400482
483
Scott Baker0caeaf02014-06-19 11:12:55 -0700484class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700485 id = serializers.Field()
486
Scott Baker196ffef2014-11-21 11:32:24 -0800487 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800488 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800489 def getHumanReadableName(self, obj):
490 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800491 def getValidators(self, obj):
492 try:
493 return obj.getValidators()
494 except:
495 return None
Scott Baker08898c12014-10-29 23:41:11 -0700496 class Meta:
497 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800498 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700499
500class SlicePrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700501 id = serializers.Field()
502
Scott Baker196ffef2014-11-21 11:32:24 -0800503 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800504 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800505 def getHumanReadableName(self, obj):
506 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800507 def getValidators(self, obj):
508 try:
509 return obj.getValidators()
510 except:
511 return None
Scott Baker08898c12014-10-29 23:41:11 -0700512 class Meta:
513 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800514 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700515
516
Scott Baker0caeaf02014-06-19 11:12:55 -0700517
518
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700519class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700520 id = serializers.Field()
521
Scott Baker196ffef2014-11-21 11:32:24 -0800522 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800523 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800524 def getHumanReadableName(self, obj):
525 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800526 def getValidators(self, obj):
527 try:
528 return obj.getValidators()
529 except:
530 return None
Scott Baker08898c12014-10-29 23:41:11 -0700531 class Meta:
532 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800533 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700534
535class PlanetStackRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700536 id = serializers.Field()
537
Scott Baker196ffef2014-11-21 11:32:24 -0800538 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800539 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800540 def getHumanReadableName(self, obj):
541 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800542 def getValidators(self, obj):
543 try:
544 return obj.getValidators()
545 except:
546 return None
Scott Baker08898c12014-10-29 23:41:11 -0700547 class Meta:
548 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800549 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700550
551
552
553
Scott Baker0caeaf02014-06-19 11:12:55 -0700554class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700555 id = serializers.Field()
556
Scott Baker196ffef2014-11-21 11:32:24 -0800557 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800558 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800559 def getHumanReadableName(self, obj):
560 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800561 def getValidators(self, obj):
562 try:
563 return obj.getValidators()
564 except:
565 return None
Scott Baker08898c12014-10-29 23:41:11 -0700566 class Meta:
567 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800568 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700569
570class NetworkSliverIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700571 id = serializers.Field()
572
Scott Baker196ffef2014-11-21 11:32:24 -0800573 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800574 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800575 def getHumanReadableName(self, obj):
576 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800577 def getValidators(self, obj):
578 try:
579 return obj.getValidators()
580 except:
581 return None
Scott Baker08898c12014-10-29 23:41:11 -0700582 class Meta:
583 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800584 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700585
586
Scott Baker0caeaf02014-06-19 11:12:55 -0700587
588
589class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700590 id = serializers.Field()
591
Scott Baker196ffef2014-11-21 11:32:24 -0800592 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800593 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800594 def getHumanReadableName(self, obj):
595 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800596 def getValidators(self, obj):
597 try:
598 return obj.getValidators()
599 except:
600 return None
Scott Baker08898c12014-10-29 23:41:11 -0700601 class Meta:
602 model = NetworkDeployments
Scott Baker351148c2014-11-25 00:53:25 -0800603 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700604
605class NetworkDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700606 id = serializers.Field()
607
Scott Baker196ffef2014-11-21 11:32:24 -0800608 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800609 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800610 def getHumanReadableName(self, obj):
611 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800612 def getValidators(self, obj):
613 try:
614 return obj.getValidators()
615 except:
616 return None
Scott Baker08898c12014-10-29 23:41:11 -0700617 class Meta:
618 model = NetworkDeployments
Scott Baker351148c2014-11-25 00:53:25 -0800619 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700620
621
Sapan Bhatiadea39432014-06-13 03:10:36 -0400622
623
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700624class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700625 id = serializers.Field()
626
Scott Baker196ffef2014-11-21 11:32:24 -0800627 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800628 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800629 def getHumanReadableName(self, obj):
630 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800631 def getValidators(self, obj):
632 try:
633 return obj.getValidators()
634 except:
635 return None
Scott Baker08898c12014-10-29 23:41:11 -0700636 class Meta:
637 model = Flavor
Scott Baker351148c2014-11-25 00:53:25 -0800638 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700639
640class FlavorIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700641 id = serializers.Field()
642
Scott Baker196ffef2014-11-21 11:32:24 -0800643 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800644 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800645 def getHumanReadableName(self, obj):
646 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800647 def getValidators(self, obj):
648 try:
649 return obj.getValidators()
650 except:
651 return None
Scott Baker08898c12014-10-29 23:41:11 -0700652 class Meta:
653 model = Flavor
Scott Baker351148c2014-11-25 00:53:25 -0800654 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700655
656
657
658
659class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700660 id = serializers.Field()
661
Scott Baker196ffef2014-11-21 11:32:24 -0800662 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800663 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800664 def getHumanReadableName(self, obj):
665 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800666 def getValidators(self, obj):
667 try:
668 return obj.getValidators()
669 except:
670 return None
Scott Baker08898c12014-10-29 23:41:11 -0700671 class Meta:
672 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800673 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700674
675class ProjectIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700676 id = serializers.Field()
677
Scott Baker196ffef2014-11-21 11:32:24 -0800678 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800679 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800680 def getHumanReadableName(self, obj):
681 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800682 def getValidators(self, obj):
683 try:
684 return obj.getValidators()
685 except:
686 return None
Scott Baker08898c12014-10-29 23:41:11 -0700687 class Meta:
688 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800689 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700690
691
692
693
Sapan Bhatiadea39432014-06-13 03:10:36 -0400694class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700695 id = serializers.Field()
696
697
698 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
699
700
701
702 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
703
704
705
706 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
707
708
709
710 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
711
712
Scott Baker196ffef2014-11-21 11:32:24 -0800713 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800714 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800715 def getHumanReadableName(self, obj):
716 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800717 def getValidators(self, obj):
718 try:
719 return obj.getValidators()
720 except:
721 return None
Scott Baker08898c12014-10-29 23:41:11 -0700722 class Meta:
723 model = Slice
Scott Baker351148c2014-11-25 00:53:25 -0800724 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700725
726class SliceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700727 id = serializers.Field()
728
729
730 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
731
732
733
734 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
735
736
737
738 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
739
740
741
742 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
743
744
Scott Baker196ffef2014-11-21 11:32:24 -0800745 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800746 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800747 def getHumanReadableName(self, obj):
748 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800749 def getValidators(self, obj):
750 try:
751 return obj.getValidators()
752 except:
753 return None
Scott Baker08898c12014-10-29 23:41:11 -0700754 class Meta:
755 model = Slice
Scott Baker351148c2014-11-25 00:53:25 -0800756 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700757
758
Sapan Bhatiadea39432014-06-13 03:10:36 -0400759
760
761class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700762 id = serializers.Field()
763
764
765 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
766
767
768
769 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
770
771
772
773 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
774
775
776
777 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
778
779
Scott Baker196ffef2014-11-21 11:32:24 -0800780 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800781 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800782 def getHumanReadableName(self, obj):
783 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800784 def getValidators(self, obj):
785 try:
786 return obj.getValidators()
787 except:
788 return None
Scott Baker08898c12014-10-29 23:41:11 -0700789 class Meta:
790 model = Network
Scott Baker351148c2014-11-25 00:53:25 -0800791 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700792
793class NetworkIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700794 id = serializers.Field()
795
796
797 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
798
799
800
801 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
802
803
804
805 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
806
807
808
809 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
810
811
Scott Baker196ffef2014-11-21 11:32:24 -0800812 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800813 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800814 def getHumanReadableName(self, obj):
815 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800816 def getValidators(self, obj):
817 try:
818 return obj.getValidators()
819 except:
820 return None
Scott Baker08898c12014-10-29 23:41:11 -0700821 class Meta:
822 model = Network
Scott Baker351148c2014-11-25 00:53:25 -0800823 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700824
825
Sapan Bhatiadea39432014-06-13 03:10:36 -0400826
827
828class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700829 id = serializers.Field()
830
Scott Baker196ffef2014-11-21 11:32:24 -0800831 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800832 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800833 def getHumanReadableName(self, obj):
834 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800835 def getValidators(self, obj):
836 try:
837 return obj.getValidators()
838 except:
839 return None
Scott Baker08898c12014-10-29 23:41:11 -0700840 class Meta:
841 model = Service
Scott Baker351148c2014-11-25 00:53:25 -0800842 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700843
844class ServiceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700845 id = serializers.Field()
846
Scott Baker196ffef2014-11-21 11:32:24 -0800847 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800848 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800849 def getHumanReadableName(self, obj):
850 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800851 def getValidators(self, obj):
852 try:
853 return obj.getValidators()
854 except:
855 return None
Scott Baker08898c12014-10-29 23:41:11 -0700856 class Meta:
857 model = Service
Scott Baker351148c2014-11-25 00:53:25 -0800858 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700859
860
Sapan Bhatiadea39432014-06-13 03:10:36 -0400861
862
Scott Baker0caeaf02014-06-19 11:12:55 -0700863class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700864 id = serializers.Field()
865
Scott Baker196ffef2014-11-21 11:32:24 -0800866 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800867 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800868 def getHumanReadableName(self, obj):
869 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800870 def getValidators(self, obj):
871 try:
872 return obj.getValidators()
873 except:
874 return None
Scott Baker08898c12014-10-29 23:41:11 -0700875 class Meta:
876 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -0800877 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700878
879class ServiceClassIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700880 id = serializers.Field()
881
Scott Baker196ffef2014-11-21 11:32:24 -0800882 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800883 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800884 def getHumanReadableName(self, obj):
885 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800886 def getValidators(self, obj):
887 try:
888 return obj.getValidators()
889 except:
890 return None
Scott Baker08898c12014-10-29 23:41:11 -0700891 class Meta:
892 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -0800893 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700894
895
Sapan Bhatiadea39432014-06-13 03:10:36 -0400896
897
Scott Baker196ffef2014-11-21 11:32:24 -0800898class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700899 id = serializers.Field()
900
Scott Baker196ffef2014-11-21 11:32:24 -0800901 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800902 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800903 def getHumanReadableName(self, obj):
904 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800905 def getValidators(self, obj):
906 try:
907 return obj.getValidators()
908 except:
909 return None
Scott Baker08898c12014-10-29 23:41:11 -0700910 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -0800911 model = Payment
Scott Baker351148c2014-11-25 00:53:25 -0800912 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700913
Scott Baker196ffef2014-11-21 11:32:24 -0800914class PaymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700915 id = serializers.Field()
916
Scott Baker196ffef2014-11-21 11:32:24 -0800917 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800918 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800919 def getHumanReadableName(self, obj):
920 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800921 def getValidators(self, obj):
922 try:
923 return obj.getValidators()
924 except:
925 return None
Scott Baker08898c12014-10-29 23:41:11 -0700926 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -0800927 model = Payment
Scott Baker351148c2014-11-25 00:53:25 -0800928 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700929
930
Sapan Bhatiadea39432014-06-13 03:10:36 -0400931
932
933class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700934 id = serializers.Field()
935
Scott Baker196ffef2014-11-21 11:32:24 -0800936 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800937 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800938 def getHumanReadableName(self, obj):
939 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800940 def getValidators(self, obj):
941 try:
942 return obj.getValidators()
943 except:
944 return None
Scott Baker08898c12014-10-29 23:41:11 -0700945 class Meta:
946 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -0800947 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700948
949class ChargeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700950 id = serializers.Field()
951
Scott Baker196ffef2014-11-21 11:32:24 -0800952 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800953 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800954 def getHumanReadableName(self, obj):
955 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800956 def getValidators(self, obj):
957 try:
958 return obj.getValidators()
959 except:
960 return None
Scott Baker08898c12014-10-29 23:41:11 -0700961 class Meta:
962 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -0800963 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700964
965
Sapan Bhatiadea39432014-06-13 03:10:36 -0400966
967
968class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700969 id = serializers.Field()
970
Scott Baker196ffef2014-11-21 11:32:24 -0800971 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800972 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800973 def getHumanReadableName(self, obj):
974 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800975 def getValidators(self, obj):
976 try:
977 return obj.getValidators()
978 except:
979 return None
Scott Baker08898c12014-10-29 23:41:11 -0700980 class Meta:
981 model = Role
Scott Baker351148c2014-11-25 00:53:25 -0800982 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700983
984class RoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700985 id = serializers.Field()
986
Scott Baker196ffef2014-11-21 11:32:24 -0800987 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800988 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800989 def getHumanReadableName(self, obj):
990 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800991 def getValidators(self, obj):
992 try:
993 return obj.getValidators()
994 except:
995 return None
Scott Baker08898c12014-10-29 23:41:11 -0700996 class Meta:
997 model = Role
Scott Baker351148c2014-11-25 00:53:25 -0800998 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700999
1000
Sapan Bhatiadea39432014-06-13 03:10:36 -04001001
1002
Scott Baker0caeaf02014-06-19 11:12:55 -07001003class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001004 id = serializers.Field()
1005
Scott Baker196ffef2014-11-21 11:32:24 -08001006 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001007 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001008 def getHumanReadableName(self, obj):
1009 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001010 def getValidators(self, obj):
1011 try:
1012 return obj.getValidators()
1013 except:
1014 return None
Scott Baker08898c12014-10-29 23:41:11 -07001015 class Meta:
1016 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001017 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001018
1019class UsableObjectIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001020 id = serializers.Field()
1021
Scott Baker196ffef2014-11-21 11:32:24 -08001022 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001023 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001024 def getHumanReadableName(self, obj):
1025 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001026 def getValidators(self, obj):
1027 try:
1028 return obj.getValidators()
1029 except:
1030 return None
Scott Baker08898c12014-10-29 23:41:11 -07001031 class Meta:
1032 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001033 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001034
1035
Sapan Bhatiadea39432014-06-13 03:10:36 -04001036
1037
Scott Baker0caeaf02014-06-19 11:12:55 -07001038class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001039 id = serializers.Field()
1040
Scott Baker196ffef2014-11-21 11:32:24 -08001041 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001042 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001043 def getHumanReadableName(self, obj):
1044 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001045 def getValidators(self, obj):
1046 try:
1047 return obj.getValidators()
1048 except:
1049 return None
Scott Baker08898c12014-10-29 23:41:11 -07001050 class Meta:
1051 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001052 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001053
1054class SiteRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001055 id = serializers.Field()
1056
Scott Baker196ffef2014-11-21 11:32:24 -08001057 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001058 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001059 def getHumanReadableName(self, obj):
1060 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001061 def getValidators(self, obj):
1062 try:
1063 return obj.getValidators()
1064 except:
1065 return None
Scott Baker08898c12014-10-29 23:41:11 -07001066 class Meta:
1067 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001068 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001069
1070
Scott Baker0caeaf02014-06-19 11:12:55 -07001071
1072
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001073class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001074 id = serializers.Field()
1075
Scott Baker196ffef2014-11-21 11:32:24 -08001076 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001077 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001078 def getHumanReadableName(self, obj):
1079 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001080 def getValidators(self, obj):
1081 try:
1082 return obj.getValidators()
1083 except:
1084 return None
Scott Baker08898c12014-10-29 23:41:11 -07001085 class Meta:
1086 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001087 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001088
1089class SliceCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001090 id = serializers.Field()
1091
Scott Baker196ffef2014-11-21 11:32:24 -08001092 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001093 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001094 def getHumanReadableName(self, obj):
1095 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001096 def getValidators(self, obj):
1097 try:
1098 return obj.getValidators()
1099 except:
1100 return None
Scott Baker08898c12014-10-29 23:41:11 -07001101 class Meta:
1102 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001103 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001104
1105
1106
1107
Sapan Bhatiadea39432014-06-13 03:10:36 -04001108class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001109 id = serializers.Field()
1110
1111
1112 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1113
1114
1115
1116 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1117
1118
Scott Baker196ffef2014-11-21 11:32:24 -08001119 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001120 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001121 def getHumanReadableName(self, obj):
1122 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001123 def getValidators(self, obj):
1124 try:
1125 return obj.getValidators()
1126 except:
1127 return None
Scott Baker08898c12014-10-29 23:41:11 -07001128 class Meta:
1129 model = Sliver
Scott Baker351148c2014-11-25 00:53:25 -08001130 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001131
1132class SliverIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001133 id = serializers.Field()
1134
1135
1136 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1137
1138
1139
1140 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1141
1142
Scott Baker196ffef2014-11-21 11:32:24 -08001143 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001144 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001145 def getHumanReadableName(self, obj):
1146 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001147 def getValidators(self, obj):
1148 try:
1149 return obj.getValidators()
1150 except:
1151 return None
Scott Baker08898c12014-10-29 23:41:11 -07001152 class Meta:
1153 model = Sliver
Scott Baker351148c2014-11-25 00:53:25 -08001154 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001155
1156
Sapan Bhatiadea39432014-06-13 03:10:36 -04001157
1158
1159class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001160 id = serializers.Field()
1161
Scott Baker196ffef2014-11-21 11:32:24 -08001162 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001163 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001164 def getHumanReadableName(self, obj):
1165 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001166 def getValidators(self, obj):
1167 try:
1168 return obj.getValidators()
1169 except:
1170 return None
Scott Baker08898c12014-10-29 23:41:11 -07001171 class Meta:
1172 model = Node
Scott Baker351148c2014-11-25 00:53:25 -08001173 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001174
1175class NodeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001176 id = serializers.Field()
1177
Scott Baker196ffef2014-11-21 11:32:24 -08001178 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001179 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001180 def getHumanReadableName(self, obj):
1181 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001182 def getValidators(self, obj):
1183 try:
1184 return obj.getValidators()
1185 except:
1186 return None
Scott Baker08898c12014-10-29 23:41:11 -07001187 class Meta:
1188 model = Node
Scott Baker351148c2014-11-25 00:53:25 -08001189 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001190
1191
Sapan Bhatiadea39432014-06-13 03:10:36 -04001192
1193
Scott Baker0caeaf02014-06-19 11:12:55 -07001194class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001195 id = serializers.Field()
1196
Scott Baker196ffef2014-11-21 11:32:24 -08001197 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001198 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001199 def getHumanReadableName(self, obj):
1200 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001201 def getValidators(self, obj):
1202 try:
1203 return obj.getValidators()
1204 except:
1205 return None
Scott Baker08898c12014-10-29 23:41:11 -07001206 class Meta:
1207 model = DashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001208 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker46b58542014-08-11 17:26:12 -07001209
1210class DashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001211 id = serializers.Field()
1212
Scott Baker196ffef2014-11-21 11:32:24 -08001213 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001214 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001215 def getHumanReadableName(self, obj):
1216 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001217 def getValidators(self, obj):
1218 try:
1219 return obj.getValidators()
1220 except:
1221 return None
Scott Baker08898c12014-10-29 23:41:11 -07001222 class Meta:
1223 model = DashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001224 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker196ffef2014-11-21 11:32:24 -08001225
1226
1227
1228
1229class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
1230 id = serializers.Field()
1231
1232 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001233 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001234 def getHumanReadableName(self, obj):
1235 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001236 def getValidators(self, obj):
1237 try:
1238 return obj.getValidators()
1239 except:
1240 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001241 class Meta:
1242 model = ImageDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001243 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08001244
1245class ImageDeploymentsIdSerializer(serializers.ModelSerializer):
1246 id = serializers.Field()
1247
1248 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001249 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001250 def getHumanReadableName(self, obj):
1251 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001252 def getValidators(self, obj):
1253 try:
1254 return obj.getValidators()
1255 except:
1256 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001257 class Meta:
1258 model = ImageDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001259 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001260
1261
Sapan Bhatiadea39432014-06-13 03:10:36 -04001262
1263
Scott Baker0caeaf02014-06-19 11:12:55 -07001264class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001265 id = serializers.Field()
1266
Scott Baker196ffef2014-11-21 11:32:24 -08001267 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001268 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001269 def getHumanReadableName(self, obj):
1270 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001271 def getValidators(self, obj):
1272 try:
1273 return obj.getValidators()
1274 except:
1275 return None
Scott Baker08898c12014-10-29 23:41:11 -07001276 class Meta:
1277 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001278 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001279
1280class ReservedResourceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001281 id = serializers.Field()
1282
Scott Baker196ffef2014-11-21 11:32:24 -08001283 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001284 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001285 def getHumanReadableName(self, obj):
1286 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001287 def getValidators(self, obj):
1288 try:
1289 return obj.getValidators()
1290 except:
1291 return None
Scott Baker08898c12014-10-29 23:41:11 -07001292 class Meta:
1293 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001294 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001295
1296
1297
1298
Scott Baker0caeaf02014-06-19 11:12:55 -07001299class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001300 id = serializers.Field()
1301
Scott Baker196ffef2014-11-21 11:32:24 -08001302 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001303 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001304 def getHumanReadableName(self, obj):
1305 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001306 def getValidators(self, obj):
1307 try:
1308 return obj.getValidators()
1309 except:
1310 return None
Scott Baker08898c12014-10-29 23:41:11 -07001311 class Meta:
1312 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001313 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001314
1315class NetworkSliceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001316 id = serializers.Field()
1317
Scott Baker196ffef2014-11-21 11:32:24 -08001318 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001319 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001320 def getHumanReadableName(self, obj):
1321 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001322 def getValidators(self, obj):
1323 try:
1324 return obj.getValidators()
1325 except:
1326 return None
Scott Baker08898c12014-10-29 23:41:11 -07001327 class Meta:
1328 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001329 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001330
1331
Scott Baker0caeaf02014-06-19 11:12:55 -07001332
1333
1334class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001335 id = serializers.Field()
1336
Scott Baker196ffef2014-11-21 11:32:24 -08001337 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001338 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001339 def getHumanReadableName(self, obj):
1340 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001341 def getValidators(self, obj):
1342 try:
1343 return obj.getValidators()
1344 except:
1345 return None
Scott Baker08898c12014-10-29 23:41:11 -07001346 class Meta:
1347 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001348 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001349
1350class UserDashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001351 id = serializers.Field()
1352
Scott Baker196ffef2014-11-21 11:32:24 -08001353 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001354 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001355 def getHumanReadableName(self, obj):
1356 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001357 def getValidators(self, obj):
1358 try:
1359 return obj.getValidators()
1360 except:
1361 return None
Scott Baker08898c12014-10-29 23:41:11 -07001362 class Meta:
1363 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001364 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001365
1366
1367
1368
Scott Baker0caeaf02014-06-19 11:12:55 -07001369class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001370 id = serializers.Field()
1371
Scott Baker196ffef2014-11-21 11:32:24 -08001372 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001373 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001374 def getHumanReadableName(self, obj):
1375 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001376 def getValidators(self, obj):
1377 try:
1378 return obj.getValidators()
1379 except:
1380 return None
Scott Baker08898c12014-10-29 23:41:11 -07001381 class Meta:
1382 model = PlanetStackPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001383 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001384
1385class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001386 id = serializers.Field()
1387
Scott Baker196ffef2014-11-21 11:32:24 -08001388 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001389 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001390 def getHumanReadableName(self, obj):
1391 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001392 def getValidators(self, obj):
1393 try:
1394 return obj.getValidators()
1395 except:
1396 return None
Scott Baker08898c12014-10-29 23:41:11 -07001397 class Meta:
1398 model = PlanetStackPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001399 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001400
1401
Sapan Bhatiadea39432014-06-13 03:10:36 -04001402
1403
1404class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001405 id = serializers.Field()
1406
Scott Baker196ffef2014-11-21 11:32:24 -08001407 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001408 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001409 def getHumanReadableName(self, obj):
1410 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001411 def getValidators(self, obj):
1412 try:
1413 return obj.getValidators()
1414 except:
1415 return None
Scott Baker08898c12014-10-29 23:41:11 -07001416 class Meta:
1417 model = User
Scott Baker351148c2014-11-25 00:53:25 -08001418 fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
Scott Baker46b58542014-08-11 17:26:12 -07001419
1420class UserIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001421 id = serializers.Field()
1422
Scott Baker196ffef2014-11-21 11:32:24 -08001423 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001424 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001425 def getHumanReadableName(self, obj):
1426 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001427 def getValidators(self, obj):
1428 try:
1429 return obj.getValidators()
1430 except:
1431 return None
Scott Baker08898c12014-10-29 23:41:11 -07001432 class Meta:
1433 model = User
Scott Baker351148c2014-11-25 00:53:25 -08001434 fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
Scott Baker46b58542014-08-11 17:26:12 -07001435
1436
Sapan Bhatiadea39432014-06-13 03:10:36 -04001437
1438
1439class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001440 id = serializers.Field()
1441
1442
1443 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1444
1445
1446
1447 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1448
1449
1450
1451 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1452
1453
1454
1455 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1456
1457
Scott Baker196ffef2014-11-21 11:32:24 -08001458 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001459 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001460 def getHumanReadableName(self, obj):
1461 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001462 def getValidators(self, obj):
1463 try:
1464 return obj.getValidators()
1465 except:
1466 return None
Scott Baker08898c12014-10-29 23:41:11 -07001467 class Meta:
1468 model = Deployment
Scott Baker351148c2014-11-25 00:53:25 -08001469 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001470
1471class DeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001472 id = serializers.Field()
1473
1474
1475 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1476
1477
1478
1479 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1480
1481
1482
1483 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1484
1485
1486
1487 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1488
1489
Scott Baker196ffef2014-11-21 11:32:24 -08001490 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001491 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001492 def getHumanReadableName(self, obj):
1493 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001494 def getValidators(self, obj):
1495 try:
1496 return obj.getValidators()
1497 except:
1498 return None
Scott Baker08898c12014-10-29 23:41:11 -07001499 class Meta:
1500 model = Deployment
Scott Baker351148c2014-11-25 00:53:25 -08001501 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001502
1503
Sapan Bhatiadea39432014-06-13 03:10:36 -04001504
1505
1506class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001507 id = serializers.Field()
1508
Scott Baker196ffef2014-11-21 11:32:24 -08001509 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001510 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001511 def getHumanReadableName(self, obj):
1512 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001513 def getValidators(self, obj):
1514 try:
1515 return obj.getValidators()
1516 except:
1517 return None
Scott Baker08898c12014-10-29 23:41:11 -07001518 class Meta:
1519 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001520 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001521
1522class ReservationIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001523 id = serializers.Field()
1524
Scott Baker196ffef2014-11-21 11:32:24 -08001525 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001526 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001527 def getHumanReadableName(self, obj):
1528 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001529 def getValidators(self, obj):
1530 try:
1531 return obj.getValidators()
1532 except:
1533 return None
Scott Baker08898c12014-10-29 23:41:11 -07001534 class Meta:
1535 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001536 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001537
1538
Scott Baker0caeaf02014-06-19 11:12:55 -07001539
1540
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001541class SliceDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001542 id = serializers.Field()
1543
Scott Baker196ffef2014-11-21 11:32:24 -08001544 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001545 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001546 def getHumanReadableName(self, obj):
1547 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001548 def getValidators(self, obj):
1549 try:
1550 return obj.getValidators()
1551 except:
1552 return None
Scott Baker08898c12014-10-29 23:41:11 -07001553 class Meta:
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001554 model = SliceDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001555 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001556
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001557class SliceDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001558 id = serializers.Field()
1559
Scott Baker196ffef2014-11-21 11:32:24 -08001560 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001561 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001562 def getHumanReadableName(self, obj):
1563 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001564 def getValidators(self, obj):
1565 try:
1566 return obj.getValidators()
1567 except:
1568 return None
Scott Baker08898c12014-10-29 23:41:11 -07001569 class Meta:
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001570 model = SliceDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001571 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08001572
1573
1574
1575
1576class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1577 id = serializers.Field()
1578
1579 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001580 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001581 def getHumanReadableName(self, obj):
1582 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001583 def getValidators(self, obj):
1584 try:
1585 return obj.getValidators()
1586 except:
1587 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001588 class Meta:
1589 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001590 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001591
1592class SitePrivilegeIdSerializer(serializers.ModelSerializer):
1593 id = serializers.Field()
1594
1595 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001596 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001597 def getHumanReadableName(self, obj):
1598 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001599 def getValidators(self, obj):
1600 try:
1601 return obj.getValidators()
1602 except:
1603 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001604 class Meta:
1605 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001606 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001607
1608
1609
1610
1611class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
1612 id = serializers.Field()
1613
1614 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001615 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001616 def getHumanReadableName(self, obj):
1617 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001618 def getValidators(self, obj):
1619 try:
1620 return obj.getValidators()
1621 except:
1622 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001623 class Meta:
1624 model = PlanetStack
Scott Baker351148c2014-11-25 00:53:25 -08001625 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker196ffef2014-11-21 11:32:24 -08001626
1627class PlanetStackIdSerializer(serializers.ModelSerializer):
1628 id = serializers.Field()
1629
1630 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001631 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001632 def getHumanReadableName(self, obj):
1633 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001634 def getValidators(self, obj):
1635 try:
1636 return obj.getValidators()
1637 except:
1638 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001639 class Meta:
1640 model = PlanetStack
Scott Baker351148c2014-11-25 00:53:25 -08001641 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001642
1643
Sapan Bhatiadea39432014-06-13 03:10:36 -04001644
1645
Sapan Bhatia3f879692014-11-19 15:10:51 -05001646class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001647 id = serializers.Field()
1648
Scott Baker196ffef2014-11-21 11:32:24 -08001649 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001650 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001651 def getHumanReadableName(self, obj):
1652 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001653 def getValidators(self, obj):
1654 try:
1655 return obj.getValidators()
1656 except:
1657 return None
Scott Baker08898c12014-10-29 23:41:11 -07001658 class Meta:
Sapan Bhatia3f879692014-11-19 15:10:51 -05001659 model = UserDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001660 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001661
Sapan Bhatia3f879692014-11-19 15:10:51 -05001662class UserDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001663 id = serializers.Field()
1664
Scott Baker196ffef2014-11-21 11:32:24 -08001665 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001666 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001667 def getHumanReadableName(self, obj):
1668 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001669 def getValidators(self, obj):
1670 try:
1671 return obj.getValidators()
1672 except:
1673 return None
Scott Baker08898c12014-10-29 23:41:11 -07001674 class Meta:
Sapan Bhatia3f879692014-11-19 15:10:51 -05001675 model = UserDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001676 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001677
1678
Scott Baker0caeaf02014-06-19 11:12:55 -07001679
1680
Sapan Bhatiadea39432014-06-13 03:10:36 -04001681class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001682 id = serializers.Field()
1683
Scott Baker196ffef2014-11-21 11:32:24 -08001684 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001685 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001686 def getHumanReadableName(self, obj):
1687 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001688 def getValidators(self, obj):
1689 try:
1690 return obj.getValidators()
1691 except:
1692 return None
Scott Baker08898c12014-10-29 23:41:11 -07001693 class Meta:
1694 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001695 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001696
1697class AccountIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001698 id = serializers.Field()
1699
Scott Baker196ffef2014-11-21 11:32:24 -08001700 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001701 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001702 def getHumanReadableName(self, obj):
1703 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001704 def getValidators(self, obj):
1705 try:
1706 return obj.getValidators()
1707 except:
1708 return None
Scott Baker08898c12014-10-29 23:41:11 -07001709 class Meta:
1710 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001711 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001712
1713
Sapan Bhatiadea39432014-06-13 03:10:36 -04001714
1715
Scott Baker0caeaf02014-06-19 11:12:55 -07001716class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001717 id = serializers.Field()
1718
Scott Baker196ffef2014-11-21 11:32:24 -08001719 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001720 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001721 def getHumanReadableName(self, obj):
1722 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001723 def getValidators(self, obj):
1724 try:
1725 return obj.getValidators()
1726 except:
1727 return None
Scott Baker08898c12014-10-29 23:41:11 -07001728 class Meta:
1729 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08001730 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001731
1732class NetworkParameterTypeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001733 id = serializers.Field()
1734
Scott Baker196ffef2014-11-21 11:32:24 -08001735 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001736 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001737 def getHumanReadableName(self, obj):
1738 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001739 def getValidators(self, obj):
1740 try:
1741 return obj.getValidators()
1742 except:
1743 return None
Scott Baker08898c12014-10-29 23:41:11 -07001744 class Meta:
1745 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08001746 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001747
1748
Sapan Bhatiadea39432014-06-13 03:10:36 -04001749
1750
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001751class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001752 id = serializers.Field()
1753
Scott Baker196ffef2014-11-21 11:32:24 -08001754 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001755 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001756 def getHumanReadableName(self, obj):
1757 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001758 def getValidators(self, obj):
1759 try:
1760 return obj.getValidators()
1761 except:
1762 return None
Scott Baker08898c12014-10-29 23:41:11 -07001763 class Meta:
1764 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08001765 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001766
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001767class SiteCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001768 id = serializers.Field()
1769
Scott Baker196ffef2014-11-21 11:32:24 -08001770 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001771 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001772 def getHumanReadableName(self, obj):
1773 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001774 def getValidators(self, obj):
1775 try:
1776 return obj.getValidators()
1777 except:
1778 return None
Scott Baker08898c12014-10-29 23:41:11 -07001779 class Meta:
1780 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08001781 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001782
1783
Scott Baker0caeaf02014-06-19 11:12:55 -07001784
1785
1786class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001787 id = serializers.Field()
1788
Scott Baker196ffef2014-11-21 11:32:24 -08001789 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001790 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001791 def getHumanReadableName(self, obj):
1792 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001793 def getValidators(self, obj):
1794 try:
1795 return obj.getValidators()
1796 except:
1797 return None
Scott Baker08898c12014-10-29 23:41:11 -07001798 class Meta:
1799 model = DeploymentPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001800 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001801
1802class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001803 id = serializers.Field()
1804
Scott Baker196ffef2014-11-21 11:32:24 -08001805 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001806 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001807 def getHumanReadableName(self, obj):
1808 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001809 def getValidators(self, obj):
1810 try:
1811 return obj.getValidators()
1812 except:
1813 return None
Scott Baker08898c12014-10-29 23:41:11 -07001814 class Meta:
1815 model = DeploymentPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001816 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001817
1818
1819
1820
Scott Baker0caeaf02014-06-19 11:12:55 -07001821class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001822 id = serializers.Field()
1823
Scott Baker196ffef2014-11-21 11:32:24 -08001824 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001825 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001826 def getHumanReadableName(self, obj):
1827 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001828 def getValidators(self, obj):
1829 try:
1830 return obj.getValidators()
1831 except:
1832 return None
Scott Baker08898c12014-10-29 23:41:11 -07001833 class Meta:
1834 model = DeploymentRole
Scott Baker351148c2014-11-25 00:53:25 -08001835 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001836
1837class DeploymentRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001838 id = serializers.Field()
1839
Scott Baker196ffef2014-11-21 11:32:24 -08001840 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001841 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001842 def getHumanReadableName(self, obj):
1843 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001844 def getValidators(self, obj):
1845 try:
1846 return obj.getValidators()
1847 except:
1848 return None
Scott Baker08898c12014-10-29 23:41:11 -07001849 class Meta:
1850 model = DeploymentRole
Scott Baker351148c2014-11-25 00:53:25 -08001851 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001852
1853
Sapan Bhatiadea39432014-06-13 03:10:36 -04001854
1855
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001856class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001857 id = serializers.Field()
1858
Scott Baker196ffef2014-11-21 11:32:24 -08001859 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001860 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001861 def getHumanReadableName(self, obj):
1862 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001863 def getValidators(self, obj):
1864 try:
1865 return obj.getValidators()
1866 except:
1867 return None
Scott Baker08898c12014-10-29 23:41:11 -07001868 class Meta:
1869 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08001870 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001871
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001872class UserCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001873 id = serializers.Field()
1874
Scott Baker196ffef2014-11-21 11:32:24 -08001875 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001876 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001877 def getHumanReadableName(self, obj):
1878 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001879 def getValidators(self, obj):
1880 try:
1881 return obj.getValidators()
1882 except:
1883 return None
Scott Baker08898c12014-10-29 23:41:11 -07001884 class Meta:
1885 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08001886 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker196ffef2014-11-21 11:32:24 -08001887
1888
1889
1890
1891class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
1892 id = serializers.Field()
1893
1894 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001895 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001896 def getHumanReadableName(self, obj):
1897 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001898 def getValidators(self, obj):
1899 try:
1900 return obj.getValidators()
1901 except:
1902 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001903 class Meta:
1904 model = SiteDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001905 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08001906
1907class SiteDeploymentsIdSerializer(serializers.ModelSerializer):
1908 id = serializers.Field()
1909
1910 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001911 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001912 def getHumanReadableName(self, obj):
1913 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001914 def getValidators(self, obj):
1915 try:
1916 return obj.getValidators()
1917 except:
1918 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001919 class Meta:
1920 model = SiteDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001921 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001922
1923
1924
1925
Scott Baker0caeaf02014-06-19 11:12:55 -07001926class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001927 id = serializers.Field()
1928
Scott Baker196ffef2014-11-21 11:32:24 -08001929 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001930 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001931 def getHumanReadableName(self, obj):
1932 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001933 def getValidators(self, obj):
1934 try:
1935 return obj.getValidators()
1936 except:
1937 return None
Scott Baker08898c12014-10-29 23:41:11 -07001938 class Meta:
1939 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08001940 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07001941
1942class SliceTagIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001943 id = serializers.Field()
1944
Scott Baker196ffef2014-11-21 11:32:24 -08001945 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001946 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001947 def getHumanReadableName(self, obj):
1948 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001949 def getValidators(self, obj):
1950 try:
1951 return obj.getValidators()
1952 except:
1953 return None
Scott Baker08898c12014-10-29 23:41:11 -07001954 class Meta:
1955 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08001956 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07001957
1958
Scott Baker0caeaf02014-06-19 11:12:55 -07001959
1960
1961class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001962 id = serializers.Field()
1963
Scott Baker196ffef2014-11-21 11:32:24 -08001964 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001965 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001966 def getHumanReadableName(self, obj):
1967 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001968 def getValidators(self, obj):
1969 try:
1970 return obj.getValidators()
1971 except:
1972 return None
Scott Baker08898c12014-10-29 23:41:11 -07001973 class Meta:
1974 model = NetworkTemplate
Scott Baker351148c2014-11-25 00:53:25 -08001975 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07001976
1977class NetworkTemplateIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001978 id = serializers.Field()
1979
Scott Baker196ffef2014-11-21 11:32:24 -08001980 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001981 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001982 def getHumanReadableName(self, obj):
1983 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001984 def getValidators(self, obj):
1985 try:
1986 return obj.getValidators()
1987 except:
1988 return None
Scott Baker08898c12014-10-29 23:41:11 -07001989 class Meta:
1990 model = NetworkTemplate
Scott Baker351148c2014-11-25 00:53:25 -08001991 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07001992
1993
Sapan Bhatiadea39432014-06-13 03:10:36 -04001994
1995
1996class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001997 id = serializers.Field()
1998
Scott Baker196ffef2014-11-21 11:32:24 -08001999 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002000 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002001 def getHumanReadableName(self, obj):
2002 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002003 def getValidators(self, obj):
2004 try:
2005 return obj.getValidators()
2006 except:
2007 return None
Scott Baker08898c12014-10-29 23:41:11 -07002008 class Meta:
2009 model = Router
Scott Baker351148c2014-11-25 00:53:25 -08002010 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07002011
2012class RouterIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002013 id = serializers.Field()
2014
Scott Baker196ffef2014-11-21 11:32:24 -08002015 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002016 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002017 def getHumanReadableName(self, obj):
2018 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002019 def getValidators(self, obj):
2020 try:
2021 return obj.getValidators()
2022 except:
2023 return None
Scott Baker08898c12014-10-29 23:41:11 -07002024 class Meta:
2025 model = Router
Scott Baker351148c2014-11-25 00:53:25 -08002026 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07002027
2028
Sapan Bhatiadea39432014-06-13 03:10:36 -04002029
2030
Scott Baker0caeaf02014-06-19 11:12:55 -07002031class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002032 id = serializers.Field()
2033
Scott Baker196ffef2014-11-21 11:32:24 -08002034 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002035 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002036 def getHumanReadableName(self, obj):
2037 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002038 def getValidators(self, obj):
2039 try:
2040 return obj.getValidators()
2041 except:
2042 return None
Scott Baker08898c12014-10-29 23:41:11 -07002043 class Meta:
2044 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002045 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002046
2047class ServiceResourceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002048 id = serializers.Field()
2049
Scott Baker196ffef2014-11-21 11:32:24 -08002050 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002051 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002052 def getHumanReadableName(self, obj):
2053 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002054 def getValidators(self, obj):
2055 try:
2056 return obj.getValidators()
2057 except:
2058 return None
Scott Baker08898c12014-10-29 23:41:11 -07002059 class Meta:
2060 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002061 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002062
2063
Sapan Bhatiadea39432014-06-13 03:10:36 -04002064
2065
2066serializerLookUp = {
2067
Scott Baker0caeaf02014-06-19 11:12:55 -07002068 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002069
2070 Image: ImageSerializer,
2071
Scott Baker0caeaf02014-06-19 11:12:55 -07002072 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002073
2074 Site: SiteSerializer,
2075
Scott Baker0caeaf02014-06-19 11:12:55 -07002076 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002077
2078 Tag: TagSerializer,
2079
2080 Invoice: InvoiceSerializer,
2081
Scott Baker0caeaf02014-06-19 11:12:55 -07002082 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002083
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002084 PlanetStackRole: PlanetStackRoleSerializer,
2085
Scott Baker0caeaf02014-06-19 11:12:55 -07002086 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002087
Scott Baker0caeaf02014-06-19 11:12:55 -07002088 NetworkDeployments: NetworkDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002089
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002090 Flavor: FlavorSerializer,
2091
2092 Project: ProjectSerializer,
2093
Sapan Bhatiadea39432014-06-13 03:10:36 -04002094 Slice: SliceSerializer,
2095
2096 Network: NetworkSerializer,
2097
2098 Service: ServiceSerializer,
2099
Scott Baker0caeaf02014-06-19 11:12:55 -07002100 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002101
Scott Baker196ffef2014-11-21 11:32:24 -08002102 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002103
2104 Charge: ChargeSerializer,
2105
2106 Role: RoleSerializer,
2107
Scott Baker0caeaf02014-06-19 11:12:55 -07002108 UsableObject: UsableObjectSerializer,
2109
2110 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002111
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002112 SliceCredential: SliceCredentialSerializer,
2113
Sapan Bhatiadea39432014-06-13 03:10:36 -04002114 Sliver: SliverSerializer,
2115
2116 Node: NodeSerializer,
2117
Scott Baker0caeaf02014-06-19 11:12:55 -07002118 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002119
Scott Baker196ffef2014-11-21 11:32:24 -08002120 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002121
Scott Baker196ffef2014-11-21 11:32:24 -08002122 ReservedResource: ReservedResourceSerializer,
Scott Baker645dc9d2014-11-17 22:32:19 -08002123
Scott Baker0caeaf02014-06-19 11:12:55 -07002124 NetworkSlice: NetworkSliceSerializer,
2125
2126 UserDashboardView: UserDashboardViewSerializer,
2127
2128 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002129
2130 User: UserSerializer,
2131
2132 Deployment: DeploymentSerializer,
2133
2134 Reservation: ReservationSerializer,
2135
Scott Baker196ffef2014-11-21 11:32:24 -08002136 SliceDeployments: SliceDeploymentsSerializer,
2137
Scott Baker0caeaf02014-06-19 11:12:55 -07002138 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002139
Scott Baker196ffef2014-11-21 11:32:24 -08002140 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002141
Sapan Bhatia3f879692014-11-19 15:10:51 -05002142 UserDeployments: UserDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002143
2144 Account: AccountSerializer,
2145
Scott Baker0caeaf02014-06-19 11:12:55 -07002146 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002147
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002148 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002149
Scott Baker0caeaf02014-06-19 11:12:55 -07002150 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002151
Scott Baker0caeaf02014-06-19 11:12:55 -07002152 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002153
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002154 UserCredential: UserCredentialSerializer,
2155
Scott Baker196ffef2014-11-21 11:32:24 -08002156 SiteDeployments: SiteDeploymentsSerializer,
2157
Scott Baker0caeaf02014-06-19 11:12:55 -07002158 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002159
Scott Baker0caeaf02014-06-19 11:12:55 -07002160 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002161
2162 Router: RouterSerializer,
2163
Scott Baker0caeaf02014-06-19 11:12:55 -07002164 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002165
2166 None: None,
2167 }
2168
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002169class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2170
2171 # To handle fine-grained field permissions, we have to check can_update
2172 # the object has been updated but before it has been saved.
2173
2174 def update(self, request, *args, **kwargs):
2175 partial = kwargs.pop('partial', False)
2176 self.object = self.get_object_or_none()
2177
2178 serializer = self.get_serializer(self.object, data=request.DATA,
2179 files=request.FILES, partial=partial)
2180
2181 if not serializer.is_valid():
Scott Baker351148c2014-11-25 00:53:25 -08002182 response = {"error": "validation",
2183 "specific_error": "not serializer.is_valid()",
2184 "reasons": serializer.errors}
2185 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002186
2187 try:
2188 self.pre_save(serializer.object)
2189 except ValidationError as err:
2190 # full_clean on model instance may be called in pre_save,
2191 # so we have to handle eventual errors.
Scott Baker351148c2014-11-25 00:53:25 -08002192 response = {"error": "validation",
2193 "specific_error": "ValidationError in pre_save",
2194 "reasons": err.message_dict}
2195 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002196
2197 if serializer.object is not None:
2198 if not serializer.object.can_update(request.user):
2199 return Response(status=status.HTTP_400_BAD_REQUEST)
2200
2201 if self.object is None:
2202 self.object = serializer.save(force_insert=True)
2203 self.post_save(self.object, created=True)
2204 return Response(serializer.data, status=status.HTTP_201_CREATED)
2205
2206 self.object = serializer.save(force_update=True)
2207 self.post_save(self.object, created=False)
2208 return Response(serializer.data, status=status.HTTP_200_OK)
2209
2210 def destroy(self, request, *args, **kwargs):
2211 obj = self.get_object()
2212 if obj.can_update(request.user):
Scott Baker08898c12014-10-29 23:41:11 -07002213 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002214 else:
2215 return Response(status=status.HTTP_400_BAD_REQUEST)
2216
2217
Sapan Bhatiadea39432014-06-13 03:10:36 -04002218# Based on core/views/*.py
2219
2220
Scott Baker0caeaf02014-06-19 11:12:55 -07002221class ServiceAttributeList(generics.ListCreateAPIView):
2222 queryset = ServiceAttribute.objects.select_related().all()
2223 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002224 id_serializer_class = ServiceAttributeIdSerializer
2225 filter_backends = (filters.DjangoFilterBackend,)
2226 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2227
2228 def get_serializer_class(self):
2229 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2230 if (no_hyperlinks):
2231 return self.id_serializer_class
2232 else:
2233 return self.serializer_class
2234
Scott Baker0caeaf02014-06-19 11:12:55 -07002235 def get_queryset(self):
2236 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002237
Scott Baker0caeaf02014-06-19 11:12:55 -07002238 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002239 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2240 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002241 response = {"error": "validation",
2242 "specific_error": "not serializer.is_valid()",
2243 "reasons": serializer.errors}
2244 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002245 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002246 obj.caller = request.user
2247 if obj.can_update(request.user):
2248 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2249 else:
Scott Baker08898c12014-10-29 23:41:11 -07002250 raise Exception("failed obj.can_update")
2251
2252 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2253 if (ret.status_code%100 != 200):
2254 raise Exception(ret.data)
2255
2256 return ret
2257
Scott Baker0caeaf02014-06-19 11:12:55 -07002258
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002259class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002260 queryset = ServiceAttribute.objects.select_related().all()
2261 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002262 id_serializer_class = ServiceAttributeIdSerializer
2263
2264 def get_serializer_class(self):
2265 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2266 if (no_hyperlinks):
2267 return self.id_serializer_class
2268 else:
2269 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002270
2271 def get_queryset(self):
2272 return ServiceAttribute.select_by_user(self.request.user)
2273
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002274 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002275
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002276 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002277
2278
2279
2280class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002281 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002282 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002283 id_serializer_class = ImageIdSerializer
2284 filter_backends = (filters.DjangoFilterBackend,)
2285 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
2286
2287 def get_serializer_class(self):
2288 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2289 if (no_hyperlinks):
2290 return self.id_serializer_class
2291 else:
2292 return self.serializer_class
2293
Scott Baker0caeaf02014-06-19 11:12:55 -07002294 def get_queryset(self):
2295 return Image.select_by_user(self.request.user)
2296
2297 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002298 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2299 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002300 response = {"error": "validation",
2301 "specific_error": "not serializer.is_valid()",
2302 "reasons": serializer.errors}
2303 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002304 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002305 obj.caller = request.user
2306 if obj.can_update(request.user):
2307 return super(ImageList, self).create(request, *args, **kwargs)
2308 else:
Scott Baker08898c12014-10-29 23:41:11 -07002309 raise Exception("failed obj.can_update")
2310
2311 ret = super(ImageList, self).create(request, *args, **kwargs)
2312 if (ret.status_code%100 != 200):
2313 raise Exception(ret.data)
2314
2315 return ret
2316
Sapan Bhatiadea39432014-06-13 03:10:36 -04002317
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002318class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002319 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002320 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002321 id_serializer_class = ImageIdSerializer
2322
2323 def get_serializer_class(self):
2324 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2325 if (no_hyperlinks):
2326 return self.id_serializer_class
2327 else:
2328 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002329
2330 def get_queryset(self):
2331 return Image.select_by_user(self.request.user)
2332
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002333 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002334
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002335 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002336
2337
2338
Scott Baker0caeaf02014-06-19 11:12:55 -07002339class NetworkParameterList(generics.ListCreateAPIView):
2340 queryset = NetworkParameter.objects.select_related().all()
2341 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002342 id_serializer_class = NetworkParameterIdSerializer
2343 filter_backends = (filters.DjangoFilterBackend,)
2344 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2345
2346 def get_serializer_class(self):
2347 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2348 if (no_hyperlinks):
2349 return self.id_serializer_class
2350 else:
2351 return self.serializer_class
2352
Scott Baker0caeaf02014-06-19 11:12:55 -07002353 def get_queryset(self):
2354 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002355
Scott Baker0caeaf02014-06-19 11:12:55 -07002356 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002357 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2358 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002359 response = {"error": "validation",
2360 "specific_error": "not serializer.is_valid()",
2361 "reasons": serializer.errors}
2362 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002363 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002364 obj.caller = request.user
2365 if obj.can_update(request.user):
2366 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2367 else:
Scott Baker08898c12014-10-29 23:41:11 -07002368 raise Exception("failed obj.can_update")
2369
2370 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2371 if (ret.status_code%100 != 200):
2372 raise Exception(ret.data)
2373
2374 return ret
2375
Scott Baker0caeaf02014-06-19 11:12:55 -07002376
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002377class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002378 queryset = NetworkParameter.objects.select_related().all()
2379 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002380 id_serializer_class = NetworkParameterIdSerializer
2381
2382 def get_serializer_class(self):
2383 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2384 if (no_hyperlinks):
2385 return self.id_serializer_class
2386 else:
2387 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002388
2389 def get_queryset(self):
2390 return NetworkParameter.select_by_user(self.request.user)
2391
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002392 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002393
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002394 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002395
2396
2397
2398class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002399 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002400 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002401 id_serializer_class = SiteIdSerializer
2402 filter_backends = (filters.DjangoFilterBackend,)
2403 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
2404
2405 def get_serializer_class(self):
2406 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2407 if (no_hyperlinks):
2408 return self.id_serializer_class
2409 else:
2410 return self.serializer_class
2411
Scott Baker0caeaf02014-06-19 11:12:55 -07002412 def get_queryset(self):
2413 return Site.select_by_user(self.request.user)
2414
2415 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002416 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2417 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002418 response = {"error": "validation",
2419 "specific_error": "not serializer.is_valid()",
2420 "reasons": serializer.errors}
2421 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002422 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002423 obj.caller = request.user
2424 if obj.can_update(request.user):
2425 return super(SiteList, self).create(request, *args, **kwargs)
2426 else:
Scott Baker08898c12014-10-29 23:41:11 -07002427 raise Exception("failed obj.can_update")
2428
2429 ret = super(SiteList, self).create(request, *args, **kwargs)
2430 if (ret.status_code%100 != 200):
2431 raise Exception(ret.data)
2432
2433 return ret
2434
Sapan Bhatiadea39432014-06-13 03:10:36 -04002435
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002436class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002437 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002438 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002439 id_serializer_class = SiteIdSerializer
2440
2441 def get_serializer_class(self):
2442 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2443 if (no_hyperlinks):
2444 return self.id_serializer_class
2445 else:
2446 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002447
2448 def get_queryset(self):
2449 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002450
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002451 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002452
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002453 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002454
2455
2456
2457class SliceRoleList(generics.ListCreateAPIView):
2458 queryset = SliceRole.objects.select_related().all()
2459 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002460 id_serializer_class = SliceRoleIdSerializer
2461 filter_backends = (filters.DjangoFilterBackend,)
2462 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2463
2464 def get_serializer_class(self):
2465 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2466 if (no_hyperlinks):
2467 return self.id_serializer_class
2468 else:
2469 return self.serializer_class
2470
Scott Baker0caeaf02014-06-19 11:12:55 -07002471 def get_queryset(self):
2472 return SliceRole.select_by_user(self.request.user)
2473
2474 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002475 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2476 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002477 response = {"error": "validation",
2478 "specific_error": "not serializer.is_valid()",
2479 "reasons": serializer.errors}
2480 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002481 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002482 obj.caller = request.user
2483 if obj.can_update(request.user):
2484 return super(SliceRoleList, self).create(request, *args, **kwargs)
2485 else:
Scott Baker08898c12014-10-29 23:41:11 -07002486 raise Exception("failed obj.can_update")
2487
2488 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2489 if (ret.status_code%100 != 200):
2490 raise Exception(ret.data)
2491
2492 return ret
2493
Scott Baker0caeaf02014-06-19 11:12:55 -07002494
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002495class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002496 queryset = SliceRole.objects.select_related().all()
2497 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002498 id_serializer_class = SliceRoleIdSerializer
2499
2500 def get_serializer_class(self):
2501 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2502 if (no_hyperlinks):
2503 return self.id_serializer_class
2504 else:
2505 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002506
2507 def get_queryset(self):
2508 return SliceRole.select_by_user(self.request.user)
2509
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002510 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002511
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002512 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002513
2514
2515
2516class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002517 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002518 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002519 id_serializer_class = TagIdSerializer
2520 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002521 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002522
2523 def get_serializer_class(self):
2524 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2525 if (no_hyperlinks):
2526 return self.id_serializer_class
2527 else:
2528 return self.serializer_class
2529
Scott Baker0caeaf02014-06-19 11:12:55 -07002530 def get_queryset(self):
2531 return Tag.select_by_user(self.request.user)
2532
2533 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002534 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2535 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002536 response = {"error": "validation",
2537 "specific_error": "not serializer.is_valid()",
2538 "reasons": serializer.errors}
2539 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002540 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002541 obj.caller = request.user
2542 if obj.can_update(request.user):
2543 return super(TagList, self).create(request, *args, **kwargs)
2544 else:
Scott Baker08898c12014-10-29 23:41:11 -07002545 raise Exception("failed obj.can_update")
2546
2547 ret = super(TagList, self).create(request, *args, **kwargs)
2548 if (ret.status_code%100 != 200):
2549 raise Exception(ret.data)
2550
2551 return ret
2552
Sapan Bhatiadea39432014-06-13 03:10:36 -04002553
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002554class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002555 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002556 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002557 id_serializer_class = TagIdSerializer
2558
2559 def get_serializer_class(self):
2560 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2561 if (no_hyperlinks):
2562 return self.id_serializer_class
2563 else:
2564 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002565
2566 def get_queryset(self):
2567 return Tag.select_by_user(self.request.user)
2568
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002569 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002570
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002571 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002572
2573
2574
2575class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002576 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002577 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002578 id_serializer_class = InvoiceIdSerializer
2579 filter_backends = (filters.DjangoFilterBackend,)
2580 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
2581
2582 def get_serializer_class(self):
2583 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2584 if (no_hyperlinks):
2585 return self.id_serializer_class
2586 else:
2587 return self.serializer_class
2588
Scott Baker0caeaf02014-06-19 11:12:55 -07002589 def get_queryset(self):
2590 return Invoice.select_by_user(self.request.user)
2591
2592 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002593 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2594 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002595 response = {"error": "validation",
2596 "specific_error": "not serializer.is_valid()",
2597 "reasons": serializer.errors}
2598 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002599 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002600 obj.caller = request.user
2601 if obj.can_update(request.user):
2602 return super(InvoiceList, self).create(request, *args, **kwargs)
2603 else:
Scott Baker08898c12014-10-29 23:41:11 -07002604 raise Exception("failed obj.can_update")
2605
2606 ret = super(InvoiceList, self).create(request, *args, **kwargs)
2607 if (ret.status_code%100 != 200):
2608 raise Exception(ret.data)
2609
2610 return ret
2611
Sapan Bhatiadea39432014-06-13 03:10:36 -04002612
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002613class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002614 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002615 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002616 id_serializer_class = InvoiceIdSerializer
2617
2618 def get_serializer_class(self):
2619 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2620 if (no_hyperlinks):
2621 return self.id_serializer_class
2622 else:
2623 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002624
2625 def get_queryset(self):
2626 return Invoice.select_by_user(self.request.user)
2627
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002628 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002629
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002630 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002631
2632
2633
Scott Baker0caeaf02014-06-19 11:12:55 -07002634class SlicePrivilegeList(generics.ListCreateAPIView):
2635 queryset = SlicePrivilege.objects.select_related().all()
2636 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002637 id_serializer_class = SlicePrivilegeIdSerializer
2638 filter_backends = (filters.DjangoFilterBackend,)
2639 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
2640
2641 def get_serializer_class(self):
2642 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2643 if (no_hyperlinks):
2644 return self.id_serializer_class
2645 else:
2646 return self.serializer_class
2647
Scott Baker0caeaf02014-06-19 11:12:55 -07002648 def get_queryset(self):
2649 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002650
Scott Baker0caeaf02014-06-19 11:12:55 -07002651 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002652 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2653 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002654 response = {"error": "validation",
2655 "specific_error": "not serializer.is_valid()",
2656 "reasons": serializer.errors}
2657 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002658 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002659 obj.caller = request.user
2660 if obj.can_update(request.user):
2661 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
2662 else:
Scott Baker08898c12014-10-29 23:41:11 -07002663 raise Exception("failed obj.can_update")
2664
2665 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
2666 if (ret.status_code%100 != 200):
2667 raise Exception(ret.data)
2668
2669 return ret
2670
Scott Baker0caeaf02014-06-19 11:12:55 -07002671
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002672class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002673 queryset = SlicePrivilege.objects.select_related().all()
2674 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002675 id_serializer_class = SlicePrivilegeIdSerializer
2676
2677 def get_serializer_class(self):
2678 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2679 if (no_hyperlinks):
2680 return self.id_serializer_class
2681 else:
2682 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002683
2684 def get_queryset(self):
2685 return SlicePrivilege.select_by_user(self.request.user)
2686
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002687 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2688
2689 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2690
2691
2692
2693class PlanetStackRoleList(generics.ListCreateAPIView):
2694 queryset = PlanetStackRole.objects.select_related().all()
2695 serializer_class = PlanetStackRoleSerializer
2696 id_serializer_class = PlanetStackRoleIdSerializer
2697 filter_backends = (filters.DjangoFilterBackend,)
2698 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2699
2700 def get_serializer_class(self):
2701 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2702 if (no_hyperlinks):
2703 return self.id_serializer_class
2704 else:
2705 return self.serializer_class
2706
2707 def get_queryset(self):
2708 return PlanetStackRole.select_by_user(self.request.user)
2709
2710 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002711 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2712 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002713 response = {"error": "validation",
2714 "specific_error": "not serializer.is_valid()",
2715 "reasons": serializer.errors}
2716 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002717 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002718 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07002719 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002720 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002721 else:
Scott Baker08898c12014-10-29 23:41:11 -07002722 raise Exception("failed obj.can_update")
2723
2724 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
2725 if (ret.status_code%100 != 200):
2726 raise Exception(ret.data)
2727
2728 return ret
2729
Scott Baker0caeaf02014-06-19 11:12:55 -07002730
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002731class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2732 queryset = PlanetStackRole.objects.select_related().all()
2733 serializer_class = PlanetStackRoleSerializer
2734 id_serializer_class = PlanetStackRoleIdSerializer
2735
2736 def get_serializer_class(self):
2737 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2738 if (no_hyperlinks):
2739 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002740 else:
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002741 return self.serializer_class
2742
2743 def get_queryset(self):
2744 return PlanetStackRole.select_by_user(self.request.user)
2745
2746 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2747
2748 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002749
2750
2751
Scott Baker0caeaf02014-06-19 11:12:55 -07002752class NetworkSliverList(generics.ListCreateAPIView):
2753 queryset = NetworkSliver.objects.select_related().all()
2754 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002755 id_serializer_class = NetworkSliverIdSerializer
2756 filter_backends = (filters.DjangoFilterBackend,)
2757 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
2758
2759 def get_serializer_class(self):
2760 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2761 if (no_hyperlinks):
2762 return self.id_serializer_class
2763 else:
2764 return self.serializer_class
2765
Scott Baker0caeaf02014-06-19 11:12:55 -07002766 def get_queryset(self):
2767 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002768
Scott Baker0caeaf02014-06-19 11:12:55 -07002769 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002770 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2771 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002772 response = {"error": "validation",
2773 "specific_error": "not serializer.is_valid()",
2774 "reasons": serializer.errors}
2775 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002776 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002777 obj.caller = request.user
2778 if obj.can_update(request.user):
2779 return super(NetworkSliverList, self).create(request, *args, **kwargs)
2780 else:
Scott Baker08898c12014-10-29 23:41:11 -07002781 raise Exception("failed obj.can_update")
2782
2783 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
2784 if (ret.status_code%100 != 200):
2785 raise Exception(ret.data)
2786
2787 return ret
2788
Scott Baker0caeaf02014-06-19 11:12:55 -07002789
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002790class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002791 queryset = NetworkSliver.objects.select_related().all()
2792 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002793 id_serializer_class = NetworkSliverIdSerializer
2794
2795 def get_serializer_class(self):
2796 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2797 if (no_hyperlinks):
2798 return self.id_serializer_class
2799 else:
2800 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002801
2802 def get_queryset(self):
2803 return NetworkSliver.select_by_user(self.request.user)
2804
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002805 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002806
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002807 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002808
2809
2810
Scott Baker0caeaf02014-06-19 11:12:55 -07002811class NetworkDeploymentsList(generics.ListCreateAPIView):
2812 queryset = NetworkDeployments.objects.select_related().all()
2813 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002814 id_serializer_class = NetworkDeploymentsIdSerializer
2815 filter_backends = (filters.DjangoFilterBackend,)
2816 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
2817
2818 def get_serializer_class(self):
2819 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2820 if (no_hyperlinks):
2821 return self.id_serializer_class
2822 else:
2823 return self.serializer_class
2824
Scott Baker0caeaf02014-06-19 11:12:55 -07002825 def get_queryset(self):
2826 return NetworkDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002827
Scott Baker0caeaf02014-06-19 11:12:55 -07002828 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002829 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2830 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002831 response = {"error": "validation",
2832 "specific_error": "not serializer.is_valid()",
2833 "reasons": serializer.errors}
2834 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002835 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002836 obj.caller = request.user
2837 if obj.can_update(request.user):
2838 return super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
2839 else:
Scott Baker08898c12014-10-29 23:41:11 -07002840 raise Exception("failed obj.can_update")
2841
2842 ret = super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
2843 if (ret.status_code%100 != 200):
2844 raise Exception(ret.data)
2845
2846 return ret
2847
Scott Baker0caeaf02014-06-19 11:12:55 -07002848
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002849class NetworkDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002850 queryset = NetworkDeployments.objects.select_related().all()
2851 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002852 id_serializer_class = NetworkDeploymentsIdSerializer
2853
2854 def get_serializer_class(self):
2855 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2856 if (no_hyperlinks):
2857 return self.id_serializer_class
2858 else:
2859 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002860
2861 def get_queryset(self):
2862 return NetworkDeployments.select_by_user(self.request.user)
2863
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002864 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002865
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002866 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002867
2868
2869
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002870class FlavorList(generics.ListCreateAPIView):
2871 queryset = Flavor.objects.select_related().all()
2872 serializer_class = FlavorSerializer
2873 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002874 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002875 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker46b58542014-08-11 17:26:12 -07002876
2877 def get_serializer_class(self):
2878 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2879 if (no_hyperlinks):
2880 return self.id_serializer_class
2881 else:
2882 return self.serializer_class
2883
Scott Baker0caeaf02014-06-19 11:12:55 -07002884 def get_queryset(self):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002885 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002886
2887 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002888 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2889 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002890 response = {"error": "validation",
2891 "specific_error": "not serializer.is_valid()",
2892 "reasons": serializer.errors}
2893 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002894 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002895 obj.caller = request.user
2896 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002897 return super(FlavorList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002898 else:
Scott Baker08898c12014-10-29 23:41:11 -07002899 raise Exception("failed obj.can_update")
2900
2901 ret = super(FlavorList, self).create(request, *args, **kwargs)
2902 if (ret.status_code%100 != 200):
2903 raise Exception(ret.data)
2904
2905 return ret
2906
Sapan Bhatiadea39432014-06-13 03:10:36 -04002907
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002908class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2909 queryset = Flavor.objects.select_related().all()
2910 serializer_class = FlavorSerializer
2911 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002912
2913 def get_serializer_class(self):
2914 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2915 if (no_hyperlinks):
2916 return self.id_serializer_class
2917 else:
2918 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002919
2920 def get_queryset(self):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002921 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002922
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002923 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002924
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002925 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002926
2927
2928
Scott Baker0caeaf02014-06-19 11:12:55 -07002929class ProjectList(generics.ListCreateAPIView):
2930 queryset = Project.objects.select_related().all()
2931 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002932 id_serializer_class = ProjectIdSerializer
2933 filter_backends = (filters.DjangoFilterBackend,)
2934 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
2935
2936 def get_serializer_class(self):
2937 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2938 if (no_hyperlinks):
2939 return self.id_serializer_class
2940 else:
2941 return self.serializer_class
2942
Scott Baker0caeaf02014-06-19 11:12:55 -07002943 def get_queryset(self):
2944 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002945
Scott Baker0caeaf02014-06-19 11:12:55 -07002946 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002947 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2948 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002949 response = {"error": "validation",
2950 "specific_error": "not serializer.is_valid()",
2951 "reasons": serializer.errors}
2952 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002953 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002954 obj.caller = request.user
2955 if obj.can_update(request.user):
2956 return super(ProjectList, self).create(request, *args, **kwargs)
2957 else:
Scott Baker08898c12014-10-29 23:41:11 -07002958 raise Exception("failed obj.can_update")
2959
2960 ret = super(ProjectList, self).create(request, *args, **kwargs)
2961 if (ret.status_code%100 != 200):
2962 raise Exception(ret.data)
2963
2964 return ret
2965
Scott Baker0caeaf02014-06-19 11:12:55 -07002966
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002967class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002968 queryset = Project.objects.select_related().all()
2969 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002970 id_serializer_class = ProjectIdSerializer
2971
2972 def get_serializer_class(self):
2973 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2974 if (no_hyperlinks):
2975 return self.id_serializer_class
2976 else:
2977 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002978
2979 def get_queryset(self):
2980 return Project.select_by_user(self.request.user)
2981
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002982 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2983
2984 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2985
2986
2987
2988class SliceList(generics.ListCreateAPIView):
2989 queryset = Slice.objects.select_related().all()
2990 serializer_class = SliceSerializer
2991 id_serializer_class = SliceIdSerializer
2992 filter_backends = (filters.DjangoFilterBackend,)
2993 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
2994
2995 def get_serializer_class(self):
2996 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2997 if (no_hyperlinks):
2998 return self.id_serializer_class
2999 else:
3000 return self.serializer_class
3001
3002 def get_queryset(self):
3003 return Slice.select_by_user(self.request.user)
3004
3005 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003006 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3007 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003008 response = {"error": "validation",
3009 "specific_error": "not serializer.is_valid()",
3010 "reasons": serializer.errors}
3011 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003012 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003013 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003014 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003015 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003016 else:
Scott Baker08898c12014-10-29 23:41:11 -07003017 raise Exception("failed obj.can_update")
3018
3019 ret = super(SliceList, self).create(request, *args, **kwargs)
3020 if (ret.status_code%100 != 200):
3021 raise Exception(ret.data)
3022
3023 return ret
3024
Scott Baker0caeaf02014-06-19 11:12:55 -07003025
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003026class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3027 queryset = Slice.objects.select_related().all()
3028 serializer_class = SliceSerializer
3029 id_serializer_class = SliceIdSerializer
3030
3031 def get_serializer_class(self):
3032 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3033 if (no_hyperlinks):
3034 return self.id_serializer_class
3035 else:
3036 return self.serializer_class
3037
3038 def get_queryset(self):
3039 return Slice.select_by_user(self.request.user)
3040
3041 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3042
3043 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3044
3045
3046
3047class NetworkList(generics.ListCreateAPIView):
3048 queryset = Network.objects.select_related().all()
3049 serializer_class = NetworkSerializer
3050 id_serializer_class = NetworkIdSerializer
3051 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker645dc9d2014-11-17 22:32:19 -08003052 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003053
3054 def get_serializer_class(self):
3055 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3056 if (no_hyperlinks):
3057 return self.id_serializer_class
3058 else:
3059 return self.serializer_class
3060
3061 def get_queryset(self):
3062 return Network.select_by_user(self.request.user)
3063
3064 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003065 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3066 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003067 response = {"error": "validation",
3068 "specific_error": "not serializer.is_valid()",
3069 "reasons": serializer.errors}
3070 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003071 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003072 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003073 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003074 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003075 else:
Scott Baker08898c12014-10-29 23:41:11 -07003076 raise Exception("failed obj.can_update")
3077
3078 ret = super(NetworkList, self).create(request, *args, **kwargs)
3079 if (ret.status_code%100 != 200):
3080 raise Exception(ret.data)
3081
3082 return ret
3083
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003084
3085class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3086 queryset = Network.objects.select_related().all()
3087 serializer_class = NetworkSerializer
3088 id_serializer_class = NetworkIdSerializer
3089
3090 def get_serializer_class(self):
3091 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3092 if (no_hyperlinks):
3093 return self.id_serializer_class
3094 else:
3095 return self.serializer_class
3096
3097 def get_queryset(self):
3098 return Network.select_by_user(self.request.user)
3099
3100 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3101
3102 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3103
3104
3105
3106class ServiceList(generics.ListCreateAPIView):
3107 queryset = Service.objects.select_related().all()
3108 serializer_class = ServiceSerializer
3109 id_serializer_class = ServiceIdSerializer
3110 filter_backends = (filters.DjangoFilterBackend,)
3111 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3112
3113 def get_serializer_class(self):
3114 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3115 if (no_hyperlinks):
3116 return self.id_serializer_class
3117 else:
3118 return self.serializer_class
3119
3120 def get_queryset(self):
3121 return Service.select_by_user(self.request.user)
3122
3123 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003124 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3125 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003126 response = {"error": "validation",
3127 "specific_error": "not serializer.is_valid()",
3128 "reasons": serializer.errors}
3129 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003130 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003131 obj.caller = request.user
3132 if obj.can_update(request.user):
3133 return super(ServiceList, self).create(request, *args, **kwargs)
3134 else:
Scott Baker08898c12014-10-29 23:41:11 -07003135 raise Exception("failed obj.can_update")
3136
3137 ret = super(ServiceList, self).create(request, *args, **kwargs)
3138 if (ret.status_code%100 != 200):
3139 raise Exception(ret.data)
3140
3141 return ret
3142
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003143
3144class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3145 queryset = Service.objects.select_related().all()
3146 serializer_class = ServiceSerializer
3147 id_serializer_class = ServiceIdSerializer
3148
3149 def get_serializer_class(self):
3150 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3151 if (no_hyperlinks):
3152 return self.id_serializer_class
3153 else:
3154 return self.serializer_class
3155
3156 def get_queryset(self):
3157 return Service.select_by_user(self.request.user)
3158
3159 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3160
3161 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3162
3163
3164
3165class ServiceClassList(generics.ListCreateAPIView):
3166 queryset = ServiceClass.objects.select_related().all()
3167 serializer_class = ServiceClassSerializer
3168 id_serializer_class = ServiceClassIdSerializer
3169 filter_backends = (filters.DjangoFilterBackend,)
3170 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3171
3172 def get_serializer_class(self):
3173 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3174 if (no_hyperlinks):
3175 return self.id_serializer_class
3176 else:
3177 return self.serializer_class
3178
3179 def get_queryset(self):
3180 return ServiceClass.select_by_user(self.request.user)
3181
3182 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003183 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3184 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003185 response = {"error": "validation",
3186 "specific_error": "not serializer.is_valid()",
3187 "reasons": serializer.errors}
3188 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003189 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003190 obj.caller = request.user
3191 if obj.can_update(request.user):
3192 return super(ServiceClassList, self).create(request, *args, **kwargs)
3193 else:
Scott Baker08898c12014-10-29 23:41:11 -07003194 raise Exception("failed obj.can_update")
3195
3196 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3197 if (ret.status_code%100 != 200):
3198 raise Exception(ret.data)
3199
3200 return ret
3201
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003202
3203class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3204 queryset = ServiceClass.objects.select_related().all()
3205 serializer_class = ServiceClassSerializer
3206 id_serializer_class = ServiceClassIdSerializer
3207
3208 def get_serializer_class(self):
3209 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3210 if (no_hyperlinks):
3211 return self.id_serializer_class
3212 else:
3213 return self.serializer_class
3214
3215 def get_queryset(self):
3216 return ServiceClass.select_by_user(self.request.user)
3217
3218 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3219
3220 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3221
3222
3223
Scott Baker196ffef2014-11-21 11:32:24 -08003224class PaymentList(generics.ListCreateAPIView):
3225 queryset = Payment.objects.select_related().all()
3226 serializer_class = PaymentSerializer
3227 id_serializer_class = PaymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003228 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker196ffef2014-11-21 11:32:24 -08003229 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003230
3231 def get_serializer_class(self):
3232 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3233 if (no_hyperlinks):
3234 return self.id_serializer_class
3235 else:
3236 return self.serializer_class
3237
3238 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08003239 return Payment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003240
3241 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003242 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3243 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003244 response = {"error": "validation",
3245 "specific_error": "not serializer.is_valid()",
3246 "reasons": serializer.errors}
3247 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003248 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003249 obj.caller = request.user
3250 if obj.can_update(request.user):
Scott Baker196ffef2014-11-21 11:32:24 -08003251 return super(PaymentList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003252 else:
Scott Baker08898c12014-10-29 23:41:11 -07003253 raise Exception("failed obj.can_update")
3254
Scott Baker196ffef2014-11-21 11:32:24 -08003255 ret = super(PaymentList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003256 if (ret.status_code%100 != 200):
3257 raise Exception(ret.data)
3258
3259 return ret
3260
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003261
Scott Baker196ffef2014-11-21 11:32:24 -08003262class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3263 queryset = Payment.objects.select_related().all()
3264 serializer_class = PaymentSerializer
3265 id_serializer_class = PaymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003266
3267 def get_serializer_class(self):
3268 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3269 if (no_hyperlinks):
3270 return self.id_serializer_class
3271 else:
3272 return self.serializer_class
3273
3274 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08003275 return Payment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003276
3277 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3278
3279 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3280
3281
3282
3283class ChargeList(generics.ListCreateAPIView):
3284 queryset = Charge.objects.select_related().all()
3285 serializer_class = ChargeSerializer
3286 id_serializer_class = ChargeIdSerializer
3287 filter_backends = (filters.DjangoFilterBackend,)
3288 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3289
3290 def get_serializer_class(self):
3291 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3292 if (no_hyperlinks):
3293 return self.id_serializer_class
3294 else:
3295 return self.serializer_class
3296
3297 def get_queryset(self):
3298 return Charge.select_by_user(self.request.user)
3299
3300 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003301 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3302 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003303 response = {"error": "validation",
3304 "specific_error": "not serializer.is_valid()",
3305 "reasons": serializer.errors}
3306 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003307 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003308 obj.caller = request.user
3309 if obj.can_update(request.user):
3310 return super(ChargeList, self).create(request, *args, **kwargs)
3311 else:
Scott Baker08898c12014-10-29 23:41:11 -07003312 raise Exception("failed obj.can_update")
3313
3314 ret = super(ChargeList, self).create(request, *args, **kwargs)
3315 if (ret.status_code%100 != 200):
3316 raise Exception(ret.data)
3317
3318 return ret
3319
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003320
3321class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3322 queryset = Charge.objects.select_related().all()
3323 serializer_class = ChargeSerializer
3324 id_serializer_class = ChargeIdSerializer
3325
3326 def get_serializer_class(self):
3327 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3328 if (no_hyperlinks):
3329 return self.id_serializer_class
3330 else:
3331 return self.serializer_class
3332
3333 def get_queryset(self):
3334 return Charge.select_by_user(self.request.user)
3335
3336 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3337
3338 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3339
3340
3341
3342class RoleList(generics.ListCreateAPIView):
3343 queryset = Role.objects.select_related().all()
3344 serializer_class = RoleSerializer
3345 id_serializer_class = RoleIdSerializer
3346 filter_backends = (filters.DjangoFilterBackend,)
3347 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3348
3349 def get_serializer_class(self):
3350 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3351 if (no_hyperlinks):
3352 return self.id_serializer_class
3353 else:
3354 return self.serializer_class
3355
3356 def get_queryset(self):
3357 return Role.select_by_user(self.request.user)
3358
3359 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003360 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3361 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003362 response = {"error": "validation",
3363 "specific_error": "not serializer.is_valid()",
3364 "reasons": serializer.errors}
3365 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003366 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003367 obj.caller = request.user
3368 if obj.can_update(request.user):
3369 return super(RoleList, self).create(request, *args, **kwargs)
3370 else:
Scott Baker08898c12014-10-29 23:41:11 -07003371 raise Exception("failed obj.can_update")
3372
3373 ret = super(RoleList, self).create(request, *args, **kwargs)
3374 if (ret.status_code%100 != 200):
3375 raise Exception(ret.data)
3376
3377 return ret
3378
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003379
3380class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3381 queryset = Role.objects.select_related().all()
3382 serializer_class = RoleSerializer
3383 id_serializer_class = RoleIdSerializer
3384
3385 def get_serializer_class(self):
3386 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3387 if (no_hyperlinks):
3388 return self.id_serializer_class
3389 else:
3390 return self.serializer_class
3391
3392 def get_queryset(self):
3393 return Role.select_by_user(self.request.user)
3394
3395 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3396
3397 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3398
3399
3400
3401class UsableObjectList(generics.ListCreateAPIView):
3402 queryset = UsableObject.objects.select_related().all()
3403 serializer_class = UsableObjectSerializer
3404 id_serializer_class = UsableObjectIdSerializer
3405 filter_backends = (filters.DjangoFilterBackend,)
3406 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3407
3408 def get_serializer_class(self):
3409 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3410 if (no_hyperlinks):
3411 return self.id_serializer_class
3412 else:
3413 return self.serializer_class
3414
3415 def get_queryset(self):
3416 return UsableObject.select_by_user(self.request.user)
3417
3418 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003419 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3420 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003421 response = {"error": "validation",
3422 "specific_error": "not serializer.is_valid()",
3423 "reasons": serializer.errors}
3424 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003425 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003426 obj.caller = request.user
3427 if obj.can_update(request.user):
3428 return super(UsableObjectList, self).create(request, *args, **kwargs)
3429 else:
Scott Baker08898c12014-10-29 23:41:11 -07003430 raise Exception("failed obj.can_update")
3431
3432 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3433 if (ret.status_code%100 != 200):
3434 raise Exception(ret.data)
3435
3436 return ret
3437
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003438
3439class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3440 queryset = UsableObject.objects.select_related().all()
3441 serializer_class = UsableObjectSerializer
3442 id_serializer_class = UsableObjectIdSerializer
3443
3444 def get_serializer_class(self):
3445 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3446 if (no_hyperlinks):
3447 return self.id_serializer_class
3448 else:
3449 return self.serializer_class
3450
3451 def get_queryset(self):
3452 return UsableObject.select_by_user(self.request.user)
3453
3454 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3455
3456 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3457
3458
3459
3460class SiteRoleList(generics.ListCreateAPIView):
3461 queryset = SiteRole.objects.select_related().all()
3462 serializer_class = SiteRoleSerializer
3463 id_serializer_class = SiteRoleIdSerializer
3464 filter_backends = (filters.DjangoFilterBackend,)
3465 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3466
3467 def get_serializer_class(self):
3468 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3469 if (no_hyperlinks):
3470 return self.id_serializer_class
3471 else:
3472 return self.serializer_class
3473
3474 def get_queryset(self):
3475 return SiteRole.select_by_user(self.request.user)
3476
3477 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003478 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3479 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003480 response = {"error": "validation",
3481 "specific_error": "not serializer.is_valid()",
3482 "reasons": serializer.errors}
3483 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003484 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003485 obj.caller = request.user
3486 if obj.can_update(request.user):
3487 return super(SiteRoleList, self).create(request, *args, **kwargs)
3488 else:
Scott Baker08898c12014-10-29 23:41:11 -07003489 raise Exception("failed obj.can_update")
3490
3491 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3492 if (ret.status_code%100 != 200):
3493 raise Exception(ret.data)
3494
3495 return ret
3496
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003497
3498class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3499 queryset = SiteRole.objects.select_related().all()
3500 serializer_class = SiteRoleSerializer
3501 id_serializer_class = SiteRoleIdSerializer
3502
3503 def get_serializer_class(self):
3504 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3505 if (no_hyperlinks):
3506 return self.id_serializer_class
3507 else:
3508 return self.serializer_class
3509
3510 def get_queryset(self):
3511 return SiteRole.select_by_user(self.request.user)
3512
3513 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3514
3515 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3516
3517
3518
3519class SliceCredentialList(generics.ListCreateAPIView):
3520 queryset = SliceCredential.objects.select_related().all()
3521 serializer_class = SliceCredentialSerializer
3522 id_serializer_class = SliceCredentialIdSerializer
3523 filter_backends = (filters.DjangoFilterBackend,)
3524 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3525
3526 def get_serializer_class(self):
3527 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3528 if (no_hyperlinks):
3529 return self.id_serializer_class
3530 else:
3531 return self.serializer_class
3532
3533 def get_queryset(self):
3534 return SliceCredential.select_by_user(self.request.user)
3535
3536 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003537 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3538 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003539 response = {"error": "validation",
3540 "specific_error": "not serializer.is_valid()",
3541 "reasons": serializer.errors}
3542 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003543 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003544 obj.caller = request.user
3545 if obj.can_update(request.user):
3546 return super(SliceCredentialList, self).create(request, *args, **kwargs)
3547 else:
Scott Baker08898c12014-10-29 23:41:11 -07003548 raise Exception("failed obj.can_update")
3549
3550 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
3551 if (ret.status_code%100 != 200):
3552 raise Exception(ret.data)
3553
3554 return ret
3555
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003556
3557class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3558 queryset = SliceCredential.objects.select_related().all()
3559 serializer_class = SliceCredentialSerializer
3560 id_serializer_class = SliceCredentialIdSerializer
3561
3562 def get_serializer_class(self):
3563 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3564 if (no_hyperlinks):
3565 return self.id_serializer_class
3566 else:
3567 return self.serializer_class
3568
3569 def get_queryset(self):
3570 return SliceCredential.select_by_user(self.request.user)
3571
3572 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3573
3574 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3575
3576
3577
3578class SliverList(generics.ListCreateAPIView):
3579 queryset = Sliver.objects.select_related().all()
3580 serializer_class = SliverSerializer
3581 id_serializer_class = SliverIdSerializer
3582 filter_backends = (filters.DjangoFilterBackend,)
3583 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
3584
3585 def get_serializer_class(self):
3586 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3587 if (no_hyperlinks):
3588 return self.id_serializer_class
3589 else:
3590 return self.serializer_class
3591
3592 def get_queryset(self):
3593 return Sliver.select_by_user(self.request.user)
3594
3595 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003596 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3597 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003598 response = {"error": "validation",
3599 "specific_error": "not serializer.is_valid()",
3600 "reasons": serializer.errors}
3601 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003602 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003603 obj.caller = request.user
3604 if obj.can_update(request.user):
3605 return super(SliverList, self).create(request, *args, **kwargs)
3606 else:
Scott Baker08898c12014-10-29 23:41:11 -07003607 raise Exception("failed obj.can_update")
3608
3609 ret = super(SliverList, self).create(request, *args, **kwargs)
3610 if (ret.status_code%100 != 200):
3611 raise Exception(ret.data)
3612
3613 return ret
3614
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003615
3616class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3617 queryset = Sliver.objects.select_related().all()
3618 serializer_class = SliverSerializer
3619 id_serializer_class = SliverIdSerializer
3620
3621 def get_serializer_class(self):
3622 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3623 if (no_hyperlinks):
3624 return self.id_serializer_class
3625 else:
3626 return self.serializer_class
3627
3628 def get_queryset(self):
3629 return Sliver.select_by_user(self.request.user)
3630
3631 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3632
3633 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3634
3635
3636
3637class NodeList(generics.ListCreateAPIView):
3638 queryset = Node.objects.select_related().all()
3639 serializer_class = NodeSerializer
3640 id_serializer_class = NodeIdSerializer
3641 filter_backends = (filters.DjangoFilterBackend,)
3642 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
3643
3644 def get_serializer_class(self):
3645 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3646 if (no_hyperlinks):
3647 return self.id_serializer_class
3648 else:
3649 return self.serializer_class
3650
3651 def get_queryset(self):
3652 return Node.select_by_user(self.request.user)
3653
3654 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003655 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3656 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003657 response = {"error": "validation",
3658 "specific_error": "not serializer.is_valid()",
3659 "reasons": serializer.errors}
3660 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003661 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003662 obj.caller = request.user
3663 if obj.can_update(request.user):
3664 return super(NodeList, self).create(request, *args, **kwargs)
3665 else:
Scott Baker08898c12014-10-29 23:41:11 -07003666 raise Exception("failed obj.can_update")
3667
3668 ret = super(NodeList, self).create(request, *args, **kwargs)
3669 if (ret.status_code%100 != 200):
3670 raise Exception(ret.data)
3671
3672 return ret
3673
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003674
3675class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3676 queryset = Node.objects.select_related().all()
3677 serializer_class = NodeSerializer
3678 id_serializer_class = NodeIdSerializer
3679
3680 def get_serializer_class(self):
3681 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3682 if (no_hyperlinks):
3683 return self.id_serializer_class
3684 else:
3685 return self.serializer_class
3686
3687 def get_queryset(self):
3688 return Node.select_by_user(self.request.user)
3689
3690 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3691
3692 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3693
3694
3695
3696class DashboardViewList(generics.ListCreateAPIView):
3697 queryset = DashboardView.objects.select_related().all()
3698 serializer_class = DashboardViewSerializer
3699 id_serializer_class = DashboardViewIdSerializer
3700 filter_backends = (filters.DjangoFilterBackend,)
3701 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
3702
3703 def get_serializer_class(self):
3704 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3705 if (no_hyperlinks):
3706 return self.id_serializer_class
3707 else:
3708 return self.serializer_class
3709
3710 def get_queryset(self):
3711 return DashboardView.select_by_user(self.request.user)
3712
3713 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003714 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3715 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003716 response = {"error": "validation",
3717 "specific_error": "not serializer.is_valid()",
3718 "reasons": serializer.errors}
3719 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003720 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003721 obj.caller = request.user
3722 if obj.can_update(request.user):
3723 return super(DashboardViewList, self).create(request, *args, **kwargs)
3724 else:
Scott Baker08898c12014-10-29 23:41:11 -07003725 raise Exception("failed obj.can_update")
3726
3727 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
3728 if (ret.status_code%100 != 200):
3729 raise Exception(ret.data)
3730
3731 return ret
3732
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003733
3734class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3735 queryset = DashboardView.objects.select_related().all()
3736 serializer_class = DashboardViewSerializer
3737 id_serializer_class = DashboardViewIdSerializer
3738
3739 def get_serializer_class(self):
3740 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3741 if (no_hyperlinks):
3742 return self.id_serializer_class
3743 else:
3744 return self.serializer_class
3745
3746 def get_queryset(self):
3747 return DashboardView.select_by_user(self.request.user)
3748
3749 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3750
3751 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3752
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003753
Scott Bakerf3816ac2014-11-12 01:13:53 -08003754
Scott Baker196ffef2014-11-21 11:32:24 -08003755class ImageDeploymentsList(generics.ListCreateAPIView):
3756 queryset = ImageDeployments.objects.select_related().all()
3757 serializer_class = ImageDeploymentsSerializer
3758 id_serializer_class = ImageDeploymentsIdSerializer
3759 filter_backends = (filters.DjangoFilterBackend,)
3760 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
3761
3762 def get_serializer_class(self):
3763 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3764 if (no_hyperlinks):
3765 return self.id_serializer_class
3766 else:
3767 return self.serializer_class
3768
3769 def get_queryset(self):
3770 return ImageDeployments.select_by_user(self.request.user)
3771
3772 def create(self, request, *args, **kwargs):
3773 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3774 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003775 response = {"error": "validation",
3776 "specific_error": "not serializer.is_valid()",
3777 "reasons": serializer.errors}
3778 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08003779 obj = serializer.object
3780 obj.caller = request.user
3781 if obj.can_update(request.user):
3782 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
3783 else:
3784 raise Exception("failed obj.can_update")
3785
3786 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
3787 if (ret.status_code%100 != 200):
3788 raise Exception(ret.data)
3789
3790 return ret
3791
3792
3793class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3794 queryset = ImageDeployments.objects.select_related().all()
3795 serializer_class = ImageDeploymentsSerializer
3796 id_serializer_class = ImageDeploymentsIdSerializer
3797
3798 def get_serializer_class(self):
3799 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3800 if (no_hyperlinks):
3801 return self.id_serializer_class
3802 else:
3803 return self.serializer_class
3804
3805 def get_queryset(self):
3806 return ImageDeployments.select_by_user(self.request.user)
3807
3808 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3809
3810 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3811
Scott Baker196ffef2014-11-21 11:32:24 -08003812
3813
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003814class ReservedResourceList(generics.ListCreateAPIView):
3815 queryset = ReservedResource.objects.select_related().all()
3816 serializer_class = ReservedResourceSerializer
3817 id_serializer_class = ReservedResourceIdSerializer
3818 filter_backends = (filters.DjangoFilterBackend,)
3819 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
3820
3821 def get_serializer_class(self):
3822 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3823 if (no_hyperlinks):
3824 return self.id_serializer_class
3825 else:
3826 return self.serializer_class
3827
3828 def get_queryset(self):
3829 return ReservedResource.select_by_user(self.request.user)
3830
3831 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003832 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3833 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003834 response = {"error": "validation",
3835 "specific_error": "not serializer.is_valid()",
3836 "reasons": serializer.errors}
3837 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003838 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003839 obj.caller = request.user
3840 if obj.can_update(request.user):
3841 return super(ReservedResourceList, self).create(request, *args, **kwargs)
3842 else:
Scott Baker08898c12014-10-29 23:41:11 -07003843 raise Exception("failed obj.can_update")
3844
3845 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
3846 if (ret.status_code%100 != 200):
3847 raise Exception(ret.data)
3848
3849 return ret
3850
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003851
3852class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3853 queryset = ReservedResource.objects.select_related().all()
3854 serializer_class = ReservedResourceSerializer
3855 id_serializer_class = ReservedResourceIdSerializer
3856
3857 def get_serializer_class(self):
3858 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3859 if (no_hyperlinks):
3860 return self.id_serializer_class
3861 else:
3862 return self.serializer_class
3863
3864 def get_queryset(self):
3865 return ReservedResource.select_by_user(self.request.user)
3866
3867 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3868
3869 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3870
3871
3872
3873class NetworkSliceList(generics.ListCreateAPIView):
3874 queryset = NetworkSlice.objects.select_related().all()
3875 serializer_class = NetworkSliceSerializer
3876 id_serializer_class = NetworkSliceIdSerializer
3877 filter_backends = (filters.DjangoFilterBackend,)
3878 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
3879
3880 def get_serializer_class(self):
3881 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3882 if (no_hyperlinks):
3883 return self.id_serializer_class
3884 else:
3885 return self.serializer_class
3886
3887 def get_queryset(self):
3888 return NetworkSlice.select_by_user(self.request.user)
3889
3890 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003891 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3892 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003893 response = {"error": "validation",
3894 "specific_error": "not serializer.is_valid()",
3895 "reasons": serializer.errors}
3896 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003897 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003898 obj.caller = request.user
3899 if obj.can_update(request.user):
3900 return super(NetworkSliceList, self).create(request, *args, **kwargs)
3901 else:
Scott Baker08898c12014-10-29 23:41:11 -07003902 raise Exception("failed obj.can_update")
3903
3904 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
3905 if (ret.status_code%100 != 200):
3906 raise Exception(ret.data)
3907
3908 return ret
3909
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003910
3911class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3912 queryset = NetworkSlice.objects.select_related().all()
3913 serializer_class = NetworkSliceSerializer
3914 id_serializer_class = NetworkSliceIdSerializer
3915
3916 def get_serializer_class(self):
3917 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3918 if (no_hyperlinks):
3919 return self.id_serializer_class
3920 else:
3921 return self.serializer_class
3922
3923 def get_queryset(self):
3924 return NetworkSlice.select_by_user(self.request.user)
3925
3926 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3927
3928 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3929
3930
3931
3932class UserDashboardViewList(generics.ListCreateAPIView):
3933 queryset = UserDashboardView.objects.select_related().all()
3934 serializer_class = UserDashboardViewSerializer
3935 id_serializer_class = UserDashboardViewIdSerializer
3936 filter_backends = (filters.DjangoFilterBackend,)
3937 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
3938
3939 def get_serializer_class(self):
3940 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3941 if (no_hyperlinks):
3942 return self.id_serializer_class
3943 else:
3944 return self.serializer_class
3945
3946 def get_queryset(self):
3947 return UserDashboardView.select_by_user(self.request.user)
3948
3949 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003950 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3951 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003952 response = {"error": "validation",
3953 "specific_error": "not serializer.is_valid()",
3954 "reasons": serializer.errors}
3955 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003956 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003957 obj.caller = request.user
3958 if obj.can_update(request.user):
3959 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
3960 else:
Scott Baker08898c12014-10-29 23:41:11 -07003961 raise Exception("failed obj.can_update")
3962
3963 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
3964 if (ret.status_code%100 != 200):
3965 raise Exception(ret.data)
3966
3967 return ret
3968
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003969
3970class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3971 queryset = UserDashboardView.objects.select_related().all()
3972 serializer_class = UserDashboardViewSerializer
3973 id_serializer_class = UserDashboardViewIdSerializer
3974
3975 def get_serializer_class(self):
3976 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3977 if (no_hyperlinks):
3978 return self.id_serializer_class
3979 else:
3980 return self.serializer_class
3981
3982 def get_queryset(self):
3983 return UserDashboardView.select_by_user(self.request.user)
3984
3985 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3986
3987 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3988
3989
3990
3991class PlanetStackPrivilegeList(generics.ListCreateAPIView):
3992 queryset = PlanetStackPrivilege.objects.select_related().all()
3993 serializer_class = PlanetStackPrivilegeSerializer
3994 id_serializer_class = PlanetStackPrivilegeIdSerializer
3995 filter_backends = (filters.DjangoFilterBackend,)
3996 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
3997
3998 def get_serializer_class(self):
3999 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4000 if (no_hyperlinks):
4001 return self.id_serializer_class
4002 else:
4003 return self.serializer_class
4004
4005 def get_queryset(self):
4006 return PlanetStackPrivilege.select_by_user(self.request.user)
4007
4008 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004009 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4010 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004011 response = {"error": "validation",
4012 "specific_error": "not serializer.is_valid()",
4013 "reasons": serializer.errors}
4014 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004015 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004016 obj.caller = request.user
4017 if obj.can_update(request.user):
4018 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4019 else:
Scott Baker08898c12014-10-29 23:41:11 -07004020 raise Exception("failed obj.can_update")
4021
4022 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4023 if (ret.status_code%100 != 200):
4024 raise Exception(ret.data)
4025
4026 return ret
4027
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004028
4029class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4030 queryset = PlanetStackPrivilege.objects.select_related().all()
4031 serializer_class = PlanetStackPrivilegeSerializer
4032 id_serializer_class = PlanetStackPrivilegeIdSerializer
4033
4034 def get_serializer_class(self):
4035 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4036 if (no_hyperlinks):
4037 return self.id_serializer_class
4038 else:
4039 return self.serializer_class
4040
4041 def get_queryset(self):
4042 return PlanetStackPrivilege.select_by_user(self.request.user)
4043
4044 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4045
4046 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4047
4048
4049
4050class UserList(generics.ListCreateAPIView):
4051 queryset = User.objects.select_related().all()
4052 serializer_class = UserSerializer
4053 id_serializer_class = UserIdSerializer
4054 filter_backends = (filters.DjangoFilterBackend,)
4055 filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
4056
4057 def get_serializer_class(self):
4058 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4059 if (no_hyperlinks):
4060 return self.id_serializer_class
4061 else:
4062 return self.serializer_class
4063
4064 def get_queryset(self):
4065 return User.select_by_user(self.request.user)
4066
4067 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004068 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4069 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004070 response = {"error": "validation",
4071 "specific_error": "not serializer.is_valid()",
4072 "reasons": serializer.errors}
4073 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004074 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004075 obj.caller = request.user
4076 if obj.can_update(request.user):
4077 return super(UserList, self).create(request, *args, **kwargs)
4078 else:
Scott Baker08898c12014-10-29 23:41:11 -07004079 raise Exception("failed obj.can_update")
4080
4081 ret = super(UserList, self).create(request, *args, **kwargs)
4082 if (ret.status_code%100 != 200):
4083 raise Exception(ret.data)
4084
4085 return ret
4086
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004087
4088class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4089 queryset = User.objects.select_related().all()
4090 serializer_class = UserSerializer
4091 id_serializer_class = UserIdSerializer
4092
4093 def get_serializer_class(self):
4094 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4095 if (no_hyperlinks):
4096 return self.id_serializer_class
4097 else:
4098 return self.serializer_class
4099
4100 def get_queryset(self):
4101 return User.select_by_user(self.request.user)
4102
4103 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4104
4105 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4106
4107
4108
4109class DeploymentList(generics.ListCreateAPIView):
4110 queryset = Deployment.objects.select_related().all()
4111 serializer_class = DeploymentSerializer
4112 id_serializer_class = DeploymentIdSerializer
4113 filter_backends = (filters.DjangoFilterBackend,)
4114 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
4115
4116 def get_serializer_class(self):
4117 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4118 if (no_hyperlinks):
4119 return self.id_serializer_class
4120 else:
4121 return self.serializer_class
4122
4123 def get_queryset(self):
4124 return Deployment.select_by_user(self.request.user)
4125
4126 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004127 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4128 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004129 response = {"error": "validation",
4130 "specific_error": "not serializer.is_valid()",
4131 "reasons": serializer.errors}
4132 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004133 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004134 obj.caller = request.user
4135 if obj.can_update(request.user):
4136 return super(DeploymentList, self).create(request, *args, **kwargs)
4137 else:
Scott Baker08898c12014-10-29 23:41:11 -07004138 raise Exception("failed obj.can_update")
4139
4140 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4141 if (ret.status_code%100 != 200):
4142 raise Exception(ret.data)
4143
4144 return ret
4145
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004146
4147class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4148 queryset = Deployment.objects.select_related().all()
4149 serializer_class = DeploymentSerializer
4150 id_serializer_class = DeploymentIdSerializer
4151
4152 def get_serializer_class(self):
4153 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4154 if (no_hyperlinks):
4155 return self.id_serializer_class
4156 else:
4157 return self.serializer_class
4158
4159 def get_queryset(self):
4160 return Deployment.select_by_user(self.request.user)
4161
4162 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4163
4164 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4165
4166
4167
4168class ReservationList(generics.ListCreateAPIView):
4169 queryset = Reservation.objects.select_related().all()
4170 serializer_class = ReservationSerializer
4171 id_serializer_class = ReservationIdSerializer
4172 filter_backends = (filters.DjangoFilterBackend,)
4173 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4174
4175 def get_serializer_class(self):
4176 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4177 if (no_hyperlinks):
4178 return self.id_serializer_class
4179 else:
4180 return self.serializer_class
4181
4182 def get_queryset(self):
4183 return Reservation.select_by_user(self.request.user)
4184
4185 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004186 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4187 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004188 response = {"error": "validation",
4189 "specific_error": "not serializer.is_valid()",
4190 "reasons": serializer.errors}
4191 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004192 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004193 obj.caller = request.user
4194 if obj.can_update(request.user):
4195 return super(ReservationList, self).create(request, *args, **kwargs)
4196 else:
Scott Baker08898c12014-10-29 23:41:11 -07004197 raise Exception("failed obj.can_update")
4198
4199 ret = super(ReservationList, self).create(request, *args, **kwargs)
4200 if (ret.status_code%100 != 200):
4201 raise Exception(ret.data)
4202
4203 return ret
4204
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004205
4206class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4207 queryset = Reservation.objects.select_related().all()
4208 serializer_class = ReservationSerializer
4209 id_serializer_class = ReservationIdSerializer
4210
4211 def get_serializer_class(self):
4212 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4213 if (no_hyperlinks):
4214 return self.id_serializer_class
4215 else:
4216 return self.serializer_class
4217
4218 def get_queryset(self):
4219 return Reservation.select_by_user(self.request.user)
4220
4221 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4222
4223 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4224
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004225
Scott Bakerf3816ac2014-11-12 01:13:53 -08004226
Scott Baker196ffef2014-11-21 11:32:24 -08004227class SliceDeploymentsList(generics.ListCreateAPIView):
4228 queryset = SliceDeployments.objects.select_related().all()
4229 serializer_class = SliceDeploymentsSerializer
4230 id_serializer_class = SliceDeploymentsIdSerializer
4231 filter_backends = (filters.DjangoFilterBackend,)
4232 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
4233
4234 def get_serializer_class(self):
4235 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4236 if (no_hyperlinks):
4237 return self.id_serializer_class
4238 else:
4239 return self.serializer_class
4240
4241 def get_queryset(self):
4242 return SliceDeployments.select_by_user(self.request.user)
4243
4244 def create(self, request, *args, **kwargs):
4245 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4246 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004247 response = {"error": "validation",
4248 "specific_error": "not serializer.is_valid()",
4249 "reasons": serializer.errors}
4250 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08004251 obj = serializer.object
4252 obj.caller = request.user
4253 if obj.can_update(request.user):
4254 return super(SliceDeploymentsList, self).create(request, *args, **kwargs)
4255 else:
4256 raise Exception("failed obj.can_update")
4257
4258 ret = super(SliceDeploymentsList, self).create(request, *args, **kwargs)
4259 if (ret.status_code%100 != 200):
4260 raise Exception(ret.data)
4261
4262 return ret
4263
4264
4265class SliceDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4266 queryset = SliceDeployments.objects.select_related().all()
4267 serializer_class = SliceDeploymentsSerializer
4268 id_serializer_class = SliceDeploymentsIdSerializer
4269
4270 def get_serializer_class(self):
4271 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4272 if (no_hyperlinks):
4273 return self.id_serializer_class
4274 else:
4275 return self.serializer_class
4276
4277 def get_queryset(self):
4278 return SliceDeployments.select_by_user(self.request.user)
4279
4280 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4281
4282 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4283
Scott Baker196ffef2014-11-21 11:32:24 -08004284
4285
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004286class SitePrivilegeList(generics.ListCreateAPIView):
4287 queryset = SitePrivilege.objects.select_related().all()
4288 serializer_class = SitePrivilegeSerializer
4289 id_serializer_class = SitePrivilegeIdSerializer
4290 filter_backends = (filters.DjangoFilterBackend,)
4291 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4292
4293 def get_serializer_class(self):
4294 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4295 if (no_hyperlinks):
4296 return self.id_serializer_class
4297 else:
4298 return self.serializer_class
4299
4300 def get_queryset(self):
4301 return SitePrivilege.select_by_user(self.request.user)
4302
4303 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004304 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4305 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004306 response = {"error": "validation",
4307 "specific_error": "not serializer.is_valid()",
4308 "reasons": serializer.errors}
4309 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004310 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004311 obj.caller = request.user
4312 if obj.can_update(request.user):
4313 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4314 else:
Scott Baker08898c12014-10-29 23:41:11 -07004315 raise Exception("failed obj.can_update")
4316
4317 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4318 if (ret.status_code%100 != 200):
4319 raise Exception(ret.data)
4320
4321 return ret
4322
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004323
4324class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4325 queryset = SitePrivilege.objects.select_related().all()
4326 serializer_class = SitePrivilegeSerializer
4327 id_serializer_class = SitePrivilegeIdSerializer
4328
4329 def get_serializer_class(self):
4330 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4331 if (no_hyperlinks):
4332 return self.id_serializer_class
4333 else:
4334 return self.serializer_class
4335
4336 def get_queryset(self):
4337 return SitePrivilege.select_by_user(self.request.user)
4338
4339 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4340
4341 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4342
4343
4344
Scott Baker196ffef2014-11-21 11:32:24 -08004345class PlanetStackList(generics.ListCreateAPIView):
4346 queryset = PlanetStack.objects.select_related().all()
4347 serializer_class = PlanetStackSerializer
4348 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004349 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker196ffef2014-11-21 11:32:24 -08004350 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004351
4352 def get_serializer_class(self):
4353 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4354 if (no_hyperlinks):
4355 return self.id_serializer_class
4356 else:
4357 return self.serializer_class
4358
4359 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004360 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004361
4362 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004363 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4364 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004365 response = {"error": "validation",
4366 "specific_error": "not serializer.is_valid()",
4367 "reasons": serializer.errors}
4368 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004369 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004370 obj.caller = request.user
4371 if obj.can_update(request.user):
Scott Baker196ffef2014-11-21 11:32:24 -08004372 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004373 else:
Scott Baker08898c12014-10-29 23:41:11 -07004374 raise Exception("failed obj.can_update")
4375
Scott Baker196ffef2014-11-21 11:32:24 -08004376 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004377 if (ret.status_code%100 != 200):
4378 raise Exception(ret.data)
4379
4380 return ret
4381
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004382
Scott Baker196ffef2014-11-21 11:32:24 -08004383class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4384 queryset = PlanetStack.objects.select_related().all()
4385 serializer_class = PlanetStackSerializer
4386 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004387
4388 def get_serializer_class(self):
4389 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4390 if (no_hyperlinks):
4391 return self.id_serializer_class
4392 else:
4393 return self.serializer_class
4394
4395 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004396 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004397
4398 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4399
4400 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4401
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004402
Scott Bakerf3816ac2014-11-12 01:13:53 -08004403
Sapan Bhatia3f879692014-11-19 15:10:51 -05004404class UserDeploymentsList(generics.ListCreateAPIView):
4405 queryset = UserDeployments.objects.select_related().all()
4406 serializer_class = UserDeploymentsSerializer
4407 id_serializer_class = UserDeploymentsIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004408 filter_backends = (filters.DjangoFilterBackend,)
4409 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
4410
4411 def get_serializer_class(self):
4412 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4413 if (no_hyperlinks):
4414 return self.id_serializer_class
4415 else:
4416 return self.serializer_class
4417
4418 def get_queryset(self):
Sapan Bhatia3f879692014-11-19 15:10:51 -05004419 return UserDeployments.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004420
4421 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004422 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4423 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004424 response = {"error": "validation",
4425 "specific_error": "not serializer.is_valid()",
4426 "reasons": serializer.errors}
4427 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004428 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004429 obj.caller = request.user
4430 if obj.can_update(request.user):
Sapan Bhatia3f879692014-11-19 15:10:51 -05004431 return super(UserDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004432 else:
Scott Baker08898c12014-10-29 23:41:11 -07004433 raise Exception("failed obj.can_update")
4434
Sapan Bhatia3f879692014-11-19 15:10:51 -05004435 ret = super(UserDeploymentsList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004436 if (ret.status_code%100 != 200):
4437 raise Exception(ret.data)
4438
4439 return ret
4440
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004441
Sapan Bhatia3f879692014-11-19 15:10:51 -05004442class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4443 queryset = UserDeployments.objects.select_related().all()
4444 serializer_class = UserDeploymentsSerializer
4445 id_serializer_class = UserDeploymentsIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004446
4447 def get_serializer_class(self):
4448 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4449 if (no_hyperlinks):
4450 return self.id_serializer_class
4451 else:
4452 return self.serializer_class
4453
4454 def get_queryset(self):
Sapan Bhatia3f879692014-11-19 15:10:51 -05004455 return UserDeployments.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004456
4457 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4458
4459 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4460
4461
4462
4463class AccountList(generics.ListCreateAPIView):
4464 queryset = Account.objects.select_related().all()
4465 serializer_class = AccountSerializer
4466 id_serializer_class = AccountIdSerializer
4467 filter_backends = (filters.DjangoFilterBackend,)
4468 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4469
4470 def get_serializer_class(self):
4471 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4472 if (no_hyperlinks):
4473 return self.id_serializer_class
4474 else:
4475 return self.serializer_class
4476
4477 def get_queryset(self):
4478 return Account.select_by_user(self.request.user)
4479
4480 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004481 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4482 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004483 response = {"error": "validation",
4484 "specific_error": "not serializer.is_valid()",
4485 "reasons": serializer.errors}
4486 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004487 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004488 obj.caller = request.user
4489 if obj.can_update(request.user):
4490 return super(AccountList, self).create(request, *args, **kwargs)
4491 else:
Scott Baker08898c12014-10-29 23:41:11 -07004492 raise Exception("failed obj.can_update")
4493
4494 ret = super(AccountList, self).create(request, *args, **kwargs)
4495 if (ret.status_code%100 != 200):
4496 raise Exception(ret.data)
4497
4498 return ret
4499
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004500
4501class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4502 queryset = Account.objects.select_related().all()
4503 serializer_class = AccountSerializer
4504 id_serializer_class = AccountIdSerializer
4505
4506 def get_serializer_class(self):
4507 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4508 if (no_hyperlinks):
4509 return self.id_serializer_class
4510 else:
4511 return self.serializer_class
4512
4513 def get_queryset(self):
4514 return Account.select_by_user(self.request.user)
4515
4516 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4517
4518 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4519
4520
4521
4522class NetworkParameterTypeList(generics.ListCreateAPIView):
4523 queryset = NetworkParameterType.objects.select_related().all()
4524 serializer_class = NetworkParameterTypeSerializer
4525 id_serializer_class = NetworkParameterTypeIdSerializer
4526 filter_backends = (filters.DjangoFilterBackend,)
4527 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
4528
4529 def get_serializer_class(self):
4530 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4531 if (no_hyperlinks):
4532 return self.id_serializer_class
4533 else:
4534 return self.serializer_class
4535
4536 def get_queryset(self):
4537 return NetworkParameterType.select_by_user(self.request.user)
4538
4539 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004540 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4541 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004542 response = {"error": "validation",
4543 "specific_error": "not serializer.is_valid()",
4544 "reasons": serializer.errors}
4545 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004546 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004547 obj.caller = request.user
4548 if obj.can_update(request.user):
4549 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4550 else:
Scott Baker08898c12014-10-29 23:41:11 -07004551 raise Exception("failed obj.can_update")
4552
4553 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4554 if (ret.status_code%100 != 200):
4555 raise Exception(ret.data)
4556
4557 return ret
4558
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004559
4560class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4561 queryset = NetworkParameterType.objects.select_related().all()
4562 serializer_class = NetworkParameterTypeSerializer
4563 id_serializer_class = NetworkParameterTypeIdSerializer
4564
4565 def get_serializer_class(self):
4566 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4567 if (no_hyperlinks):
4568 return self.id_serializer_class
4569 else:
4570 return self.serializer_class
4571
4572 def get_queryset(self):
4573 return NetworkParameterType.select_by_user(self.request.user)
4574
4575 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4576
4577 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4578
4579
4580
4581class SiteCredentialList(generics.ListCreateAPIView):
4582 queryset = SiteCredential.objects.select_related().all()
4583 serializer_class = SiteCredentialSerializer
4584 id_serializer_class = SiteCredentialIdSerializer
4585 filter_backends = (filters.DjangoFilterBackend,)
4586 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
4587
4588 def get_serializer_class(self):
4589 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4590 if (no_hyperlinks):
4591 return self.id_serializer_class
4592 else:
4593 return self.serializer_class
4594
4595 def get_queryset(self):
4596 return SiteCredential.select_by_user(self.request.user)
4597
4598 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004599 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4600 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004601 response = {"error": "validation",
4602 "specific_error": "not serializer.is_valid()",
4603 "reasons": serializer.errors}
4604 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004605 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004606 obj.caller = request.user
4607 if obj.can_update(request.user):
4608 return super(SiteCredentialList, self).create(request, *args, **kwargs)
4609 else:
Scott Baker08898c12014-10-29 23:41:11 -07004610 raise Exception("failed obj.can_update")
4611
4612 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
4613 if (ret.status_code%100 != 200):
4614 raise Exception(ret.data)
4615
4616 return ret
4617
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004618
4619class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4620 queryset = SiteCredential.objects.select_related().all()
4621 serializer_class = SiteCredentialSerializer
4622 id_serializer_class = SiteCredentialIdSerializer
4623
4624 def get_serializer_class(self):
4625 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4626 if (no_hyperlinks):
4627 return self.id_serializer_class
4628 else:
4629 return self.serializer_class
4630
4631 def get_queryset(self):
4632 return SiteCredential.select_by_user(self.request.user)
4633
4634 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4635
4636 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4637
4638
4639
4640class DeploymentPrivilegeList(generics.ListCreateAPIView):
4641 queryset = DeploymentPrivilege.objects.select_related().all()
4642 serializer_class = DeploymentPrivilegeSerializer
4643 id_serializer_class = DeploymentPrivilegeIdSerializer
4644 filter_backends = (filters.DjangoFilterBackend,)
4645 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
4646
4647 def get_serializer_class(self):
4648 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4649 if (no_hyperlinks):
4650 return self.id_serializer_class
4651 else:
4652 return self.serializer_class
4653
4654 def get_queryset(self):
4655 return DeploymentPrivilege.select_by_user(self.request.user)
4656
4657 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004658 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4659 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004660 response = {"error": "validation",
4661 "specific_error": "not serializer.is_valid()",
4662 "reasons": serializer.errors}
4663 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004664 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004665 obj.caller = request.user
4666 if obj.can_update(request.user):
4667 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
4668 else:
Scott Baker08898c12014-10-29 23:41:11 -07004669 raise Exception("failed obj.can_update")
4670
4671 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
4672 if (ret.status_code%100 != 200):
4673 raise Exception(ret.data)
4674
4675 return ret
4676
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004677
4678class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4679 queryset = DeploymentPrivilege.objects.select_related().all()
4680 serializer_class = DeploymentPrivilegeSerializer
4681 id_serializer_class = DeploymentPrivilegeIdSerializer
4682
4683 def get_serializer_class(self):
4684 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4685 if (no_hyperlinks):
4686 return self.id_serializer_class
4687 else:
4688 return self.serializer_class
4689
4690 def get_queryset(self):
4691 return DeploymentPrivilege.select_by_user(self.request.user)
4692
4693 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4694
4695 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4696
4697
4698
4699class DeploymentRoleList(generics.ListCreateAPIView):
4700 queryset = DeploymentRole.objects.select_related().all()
4701 serializer_class = DeploymentRoleSerializer
4702 id_serializer_class = DeploymentRoleIdSerializer
4703 filter_backends = (filters.DjangoFilterBackend,)
4704 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
4705
4706 def get_serializer_class(self):
4707 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4708 if (no_hyperlinks):
4709 return self.id_serializer_class
4710 else:
4711 return self.serializer_class
4712
4713 def get_queryset(self):
4714 return DeploymentRole.select_by_user(self.request.user)
4715
4716 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004717 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4718 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004719 response = {"error": "validation",
4720 "specific_error": "not serializer.is_valid()",
4721 "reasons": serializer.errors}
4722 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004723 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004724 obj.caller = request.user
4725 if obj.can_update(request.user):
4726 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
4727 else:
Scott Baker08898c12014-10-29 23:41:11 -07004728 raise Exception("failed obj.can_update")
4729
4730 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
4731 if (ret.status_code%100 != 200):
4732 raise Exception(ret.data)
4733
4734 return ret
4735
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004736
4737class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4738 queryset = DeploymentRole.objects.select_related().all()
4739 serializer_class = DeploymentRoleSerializer
4740 id_serializer_class = DeploymentRoleIdSerializer
4741
4742 def get_serializer_class(self):
4743 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4744 if (no_hyperlinks):
4745 return self.id_serializer_class
4746 else:
4747 return self.serializer_class
4748
4749 def get_queryset(self):
4750 return DeploymentRole.select_by_user(self.request.user)
4751
4752 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4753
4754 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4755
4756
4757
4758class UserCredentialList(generics.ListCreateAPIView):
4759 queryset = UserCredential.objects.select_related().all()
4760 serializer_class = UserCredentialSerializer
4761 id_serializer_class = UserCredentialIdSerializer
4762 filter_backends = (filters.DjangoFilterBackend,)
4763 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
4764
4765 def get_serializer_class(self):
4766 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4767 if (no_hyperlinks):
4768 return self.id_serializer_class
4769 else:
4770 return self.serializer_class
4771
4772 def get_queryset(self):
4773 return UserCredential.select_by_user(self.request.user)
4774
4775 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004776 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4777 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004778 response = {"error": "validation",
4779 "specific_error": "not serializer.is_valid()",
4780 "reasons": serializer.errors}
4781 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004782 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004783 obj.caller = request.user
4784 if obj.can_update(request.user):
4785 return super(UserCredentialList, self).create(request, *args, **kwargs)
4786 else:
Scott Baker08898c12014-10-29 23:41:11 -07004787 raise Exception("failed obj.can_update")
4788
4789 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
4790 if (ret.status_code%100 != 200):
4791 raise Exception(ret.data)
4792
4793 return ret
4794
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004795
4796class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4797 queryset = UserCredential.objects.select_related().all()
4798 serializer_class = UserCredentialSerializer
4799 id_serializer_class = UserCredentialIdSerializer
4800
4801 def get_serializer_class(self):
4802 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4803 if (no_hyperlinks):
4804 return self.id_serializer_class
4805 else:
4806 return self.serializer_class
4807
4808 def get_queryset(self):
4809 return UserCredential.select_by_user(self.request.user)
4810
4811 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4812
4813 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4814
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004815
Scott Bakerf3816ac2014-11-12 01:13:53 -08004816
Scott Baker196ffef2014-11-21 11:32:24 -08004817class SiteDeploymentsList(generics.ListCreateAPIView):
4818 queryset = SiteDeployments.objects.select_related().all()
4819 serializer_class = SiteDeploymentsSerializer
4820 id_serializer_class = SiteDeploymentsIdSerializer
4821 filter_backends = (filters.DjangoFilterBackend,)
4822 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
4823
4824 def get_serializer_class(self):
4825 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4826 if (no_hyperlinks):
4827 return self.id_serializer_class
4828 else:
4829 return self.serializer_class
4830
4831 def get_queryset(self):
4832 return SiteDeployments.select_by_user(self.request.user)
4833
4834 def create(self, request, *args, **kwargs):
4835 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4836 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004837 response = {"error": "validation",
4838 "specific_error": "not serializer.is_valid()",
4839 "reasons": serializer.errors}
4840 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08004841 obj = serializer.object
4842 obj.caller = request.user
4843 if obj.can_update(request.user):
4844 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
4845 else:
4846 raise Exception("failed obj.can_update")
4847
4848 ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
4849 if (ret.status_code%100 != 200):
4850 raise Exception(ret.data)
4851
4852 return ret
4853
4854
4855class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4856 queryset = SiteDeployments.objects.select_related().all()
4857 serializer_class = SiteDeploymentsSerializer
4858 id_serializer_class = SiteDeploymentsIdSerializer
4859
4860 def get_serializer_class(self):
4861 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4862 if (no_hyperlinks):
4863 return self.id_serializer_class
4864 else:
4865 return self.serializer_class
4866
4867 def get_queryset(self):
4868 return SiteDeployments.select_by_user(self.request.user)
4869
4870 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4871
4872 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4873
Scott Baker196ffef2014-11-21 11:32:24 -08004874
4875
Scott Baker0caeaf02014-06-19 11:12:55 -07004876class SliceTagList(generics.ListCreateAPIView):
4877 queryset = SliceTag.objects.select_related().all()
4878 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07004879 id_serializer_class = SliceTagIdSerializer
4880 filter_backends = (filters.DjangoFilterBackend,)
4881 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
4882
4883 def get_serializer_class(self):
4884 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4885 if (no_hyperlinks):
4886 return self.id_serializer_class
4887 else:
4888 return self.serializer_class
4889
Scott Baker0caeaf02014-06-19 11:12:55 -07004890 def get_queryset(self):
4891 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04004892
Scott Baker0caeaf02014-06-19 11:12:55 -07004893 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004894 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4895 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004896 response = {"error": "validation",
4897 "specific_error": "not serializer.is_valid()",
4898 "reasons": serializer.errors}
4899 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004900 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07004901 obj.caller = request.user
4902 if obj.can_update(request.user):
4903 return super(SliceTagList, self).create(request, *args, **kwargs)
4904 else:
Scott Baker08898c12014-10-29 23:41:11 -07004905 raise Exception("failed obj.can_update")
4906
4907 ret = super(SliceTagList, self).create(request, *args, **kwargs)
4908 if (ret.status_code%100 != 200):
4909 raise Exception(ret.data)
4910
4911 return ret
4912
Scott Baker0caeaf02014-06-19 11:12:55 -07004913
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004914class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07004915 queryset = SliceTag.objects.select_related().all()
4916 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07004917 id_serializer_class = SliceTagIdSerializer
4918
4919 def get_serializer_class(self):
4920 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4921 if (no_hyperlinks):
4922 return self.id_serializer_class
4923 else:
4924 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07004925
4926 def get_queryset(self):
4927 return SliceTag.select_by_user(self.request.user)
4928
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004929 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07004930
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004931 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04004932
4933
4934
Scott Baker0caeaf02014-06-19 11:12:55 -07004935class NetworkTemplateList(generics.ListCreateAPIView):
4936 queryset = NetworkTemplate.objects.select_related().all()
4937 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07004938 id_serializer_class = NetworkTemplateIdSerializer
4939 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker645dc9d2014-11-17 22:32:19 -08004940 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07004941
4942 def get_serializer_class(self):
4943 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4944 if (no_hyperlinks):
4945 return self.id_serializer_class
4946 else:
4947 return self.serializer_class
4948
Scott Baker0caeaf02014-06-19 11:12:55 -07004949 def get_queryset(self):
4950 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04004951
Scott Baker0caeaf02014-06-19 11:12:55 -07004952 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004953 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4954 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004955 response = {"error": "validation",
4956 "specific_error": "not serializer.is_valid()",
4957 "reasons": serializer.errors}
4958 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004959 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07004960 obj.caller = request.user
4961 if obj.can_update(request.user):
4962 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
4963 else:
Scott Baker08898c12014-10-29 23:41:11 -07004964 raise Exception("failed obj.can_update")
4965
4966 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
4967 if (ret.status_code%100 != 200):
4968 raise Exception(ret.data)
4969
4970 return ret
4971
Scott Baker0caeaf02014-06-19 11:12:55 -07004972
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004973class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07004974 queryset = NetworkTemplate.objects.select_related().all()
4975 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07004976 id_serializer_class = NetworkTemplateIdSerializer
4977
4978 def get_serializer_class(self):
4979 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4980 if (no_hyperlinks):
4981 return self.id_serializer_class
4982 else:
4983 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07004984
4985 def get_queryset(self):
4986 return NetworkTemplate.select_by_user(self.request.user)
4987
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004988 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07004989
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004990 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04004991
4992
4993
4994class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07004995 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04004996 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07004997 id_serializer_class = RouterIdSerializer
4998 filter_backends = (filters.DjangoFilterBackend,)
4999 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
5000
5001 def get_serializer_class(self):
5002 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5003 if (no_hyperlinks):
5004 return self.id_serializer_class
5005 else:
5006 return self.serializer_class
5007
Scott Baker0caeaf02014-06-19 11:12:55 -07005008 def get_queryset(self):
5009 return Router.select_by_user(self.request.user)
5010
5011 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005012 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5013 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005014 response = {"error": "validation",
5015 "specific_error": "not serializer.is_valid()",
5016 "reasons": serializer.errors}
5017 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005018 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005019 obj.caller = request.user
5020 if obj.can_update(request.user):
5021 return super(RouterList, self).create(request, *args, **kwargs)
5022 else:
Scott Baker08898c12014-10-29 23:41:11 -07005023 raise Exception("failed obj.can_update")
5024
5025 ret = super(RouterList, self).create(request, *args, **kwargs)
5026 if (ret.status_code%100 != 200):
5027 raise Exception(ret.data)
5028
5029 return ret
5030
Sapan Bhatiadea39432014-06-13 03:10:36 -04005031
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005032class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005033 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005034 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005035 id_serializer_class = RouterIdSerializer
5036
5037 def get_serializer_class(self):
5038 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5039 if (no_hyperlinks):
5040 return self.id_serializer_class
5041 else:
5042 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005043
5044 def get_queryset(self):
5045 return Router.select_by_user(self.request.user)
5046
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005047 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005048
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005049 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005050
5051
5052
Scott Baker0caeaf02014-06-19 11:12:55 -07005053class ServiceResourceList(generics.ListCreateAPIView):
5054 queryset = ServiceResource.objects.select_related().all()
5055 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005056 id_serializer_class = ServiceResourceIdSerializer
5057 filter_backends = (filters.DjangoFilterBackend,)
5058 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5059
5060 def get_serializer_class(self):
5061 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5062 if (no_hyperlinks):
5063 return self.id_serializer_class
5064 else:
5065 return self.serializer_class
5066
Scott Baker0caeaf02014-06-19 11:12:55 -07005067 def get_queryset(self):
5068 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005069
Scott Baker0caeaf02014-06-19 11:12:55 -07005070 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005071 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5072 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005073 response = {"error": "validation",
5074 "specific_error": "not serializer.is_valid()",
5075 "reasons": serializer.errors}
5076 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005077 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005078 obj.caller = request.user
5079 if obj.can_update(request.user):
5080 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5081 else:
Scott Baker08898c12014-10-29 23:41:11 -07005082 raise Exception("failed obj.can_update")
5083
5084 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5085 if (ret.status_code%100 != 200):
5086 raise Exception(ret.data)
5087
5088 return ret
5089
Scott Baker0caeaf02014-06-19 11:12:55 -07005090
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005091class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005092 queryset = ServiceResource.objects.select_related().all()
5093 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005094 id_serializer_class = ServiceResourceIdSerializer
5095
5096 def get_serializer_class(self):
5097 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5098 if (no_hyperlinks):
5099 return self.id_serializer_class
5100 else:
5101 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005102
5103 def get_queryset(self):
5104 return ServiceResource.select_by_user(self.request.user)
5105
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005106 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005107
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005108 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005109
Sapan Bhatiadea39432014-06-13 03:10:36 -04005110
5111