blob: b368a9a750da8e28036b0e471e7016bb43a05ca1 [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
Sapan Bhatiadea39432014-06-13 03:10:36 -04007from core.models import *
8from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -07009from rest_framework import filters
Scott Baker55a2e292014-11-10 16:31:15 -080010from django.conf.urls import patterns, url
Sapan Bhatiadea39432014-06-13 03:10:36 -040011
12"""
Scott Baker08898c12014-10-29 23:41:11 -070013 Schema of the generator object:
14 all: Set of all Model objects
15 all_if(regex): Set of Model objects that match regex
16
17 Model object:
18 plural: English plural of object name
19 camel: CamelCase version of object name
20 refs: list of references to other Model objects
21 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040022
Scott Baker08898c12014-10-29 23:41:11 -070023 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040024"""
25
Scott Baker55a2e292014-11-10 16:31:15 -080026def get_REST_patterns():
27 return patterns('',
28 url(r'^plstackapi/$', api_root),
29
30 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
31 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
32
33 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
34 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
35
36 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
37 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
38
39 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
40 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
41
42 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
43 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
44
45 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
46 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
47
48 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
49 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
50
51 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
52 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
53
54 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
55 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
56
57 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
58 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
59
60 url(r'plstackapi/networkdeployments/$', NetworkDeploymentsList.as_view(), name='networkdeployments-list'),
61 url(r'plstackapi/networkdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDeploymentsDetail.as_view(), name ='networkdeployments-detail'),
62
63 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
64 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
65
66 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
67 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
68
69 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
70 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
71
72 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
73 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
74
75 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
76 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
77
78 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
79 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
80
81 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
82 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
83
84 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
85 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
86
87 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
88 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
89
90 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
91 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
92
93 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
94 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
95
96 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
97 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
98
99 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
100 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
101
102 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
103 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
104
105 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
106 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
107
Sapan Bhatia18b779c2014-11-11 23:05:53 -0500108 url(r'plstackapi/imagedeployments/$', ImageDeploymentList.as_view(), name='imagedeployments-list'),
109 url(r'plstackapi/imagedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentDetail.as_view(), name ='imagedeployments-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800110
111 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
112 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
113
114 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
115 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
116
117 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
118 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
119
120 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
121 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
122
123 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
124 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
125
126 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
127 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
128
129 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
130 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
131
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -0500132 url(r'plstackapi/slice_deployments/$', SliceDeploymentList.as_view(), name='slicedeployments-list'),
133 url(r'plstackapi/slice_deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDeploymentDetail.as_view(), name ='slicedeployments-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800134
135 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
136 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
137
138 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
139 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
140
Sapan Bhatia84ba65d2014-11-11 21:44:35 -0500141 url(r'plstackapi/user_deployments/$', UserDeploymentList.as_view(), name='userdeployments-list'),
142 url(r'plstackapi/user_deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentDetail.as_view(), name ='userdeployments-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800143
144 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
145 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
146
147 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
148 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
149
150 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
151 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
152
153 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
154 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
155
156 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
157 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
158
159 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
160 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
161
Sapan Bhatia6d21da32014-11-11 21:41:12 -0500162 url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployments-list'),
163 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployments-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800164
165 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
166 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
167
168 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
169 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
170
171 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
172 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
173
174 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
175 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
176
177 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400178
179@api_view(['GET'])
180def api_root(request, format=None):
181 return Response({
Scott Baker08898c12014-10-29 23:41:11 -0700182 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
183 'images': reverse('image-list', request=request, format=format),
184 'networkparameters': reverse('networkparameter-list', request=request, format=format),
185 'sites': reverse('site-list', request=request, format=format),
186 'sliceroles': reverse('slicerole-list', request=request, format=format),
187 'tags': reverse('tag-list', request=request, format=format),
188 'invoices': reverse('invoice-list', request=request, format=format),
189 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
190 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
191 'networkslivers': reverse('networksliver-list', request=request, format=format),
192 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format),
193 'flavors': reverse('flavor-list', request=request, format=format),
194 'projects': reverse('project-list', request=request, format=format),
195 'slices': reverse('slice-list', request=request, format=format),
196 'networks': reverse('network-list', request=request, format=format),
197 'services': reverse('service-list', request=request, format=format),
198 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
199 'payments': reverse('payment-list', request=request, format=format),
200 'charges': reverse('charge-list', request=request, format=format),
201 'roles': reverse('role-list', request=request, format=format),
202 'usableobjects': reverse('usableobject-list', request=request, format=format),
203 'siteroles': reverse('siterole-list', request=request, format=format),
204 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
205 'slivers': reverse('sliver-list', request=request, format=format),
206 'nodes': reverse('node-list', request=request, format=format),
207 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
208 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
209 'reservedresources': reverse('reservedresource-list', request=request, format=format),
210 'networkslices': reverse('networkslice-list', request=request, format=format),
211 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
212 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
213 'users': reverse('user-list', request=request, format=format),
214 'deployments': reverse('deployment-list', request=request, format=format),
215 'reservations': reverse('reservation-list', request=request, format=format),
216 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format),
217 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
218 'planetstacks': reverse('planetstack-list', request=request, format=format),
219 'userdeploymentses': reverse('userdeployments-list', request=request, format=format),
220 'accounts': reverse('account-list', request=request, format=format),
221 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
222 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
223 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
224 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
225 'usercredentials': reverse('usercredential-list', request=request, format=format),
226 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
227 'slicetags': reverse('slicetag-list', request=request, format=format),
228 'networktemplates': reverse('networktemplate-list', request=request, format=format),
229 'routers': reverse('router-list', request=request, format=format),
230 'serviceresources': reverse('serviceresource-list', request=request, format=format),
231
Sapan Bhatiadea39432014-06-13 03:10:36 -0400232 })
233
234# Based on serializers.py
235
236
237
Scott Baker0caeaf02014-06-19 11:12:55 -0700238class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700239 id = serializers.Field()
240
241 class Meta:
242 model = ServiceAttribute
243 fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700244
245class ServiceAttributeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700246 id = serializers.Field()
247
248 class Meta:
249 model = ServiceAttribute
250 fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700251
252
Sapan Bhatiadea39432014-06-13 03:10:36 -0400253
254
255class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700256 id = serializers.Field()
257
258 class Meta:
259 model = Image
260 fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700261
262class ImageIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700263 id = serializers.Field()
264
265 class Meta:
266 model = Image
267 fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700268
269
Sapan Bhatiadea39432014-06-13 03:10:36 -0400270
271
Scott Baker0caeaf02014-06-19 11:12:55 -0700272class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700273 id = serializers.Field()
274
275 class Meta:
276 model = NetworkParameter
277 fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700278
279class NetworkParameterIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700280 id = serializers.Field()
281
282 class Meta:
283 model = NetworkParameter
284 fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700285
286
Sapan Bhatiadea39432014-06-13 03:10:36 -0400287
288
289class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700290 id = serializers.Field()
291
292 class Meta:
293 model = Site
294 fields = ('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 -0700295
296class SiteIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700297 id = serializers.Field()
298
299 class Meta:
300 model = Site
301 fields = ('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 -0700302
303
Sapan Bhatiadea39432014-06-13 03:10:36 -0400304
305
Scott Baker0caeaf02014-06-19 11:12:55 -0700306class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700307 id = serializers.Field()
308
309 class Meta:
310 model = SliceRole
311 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700312
313class SliceRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700314 id = serializers.Field()
315
316 class Meta:
317 model = SliceRole
318 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700319
320
Sapan Bhatiadea39432014-06-13 03:10:36 -0400321
322
323class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700324 id = serializers.Field()
325
326 class Meta:
327 model = Tag
328 fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700329
330class TagIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700331 id = serializers.Field()
332
333 class Meta:
334 model = Tag
335 fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700336
337
Sapan Bhatiadea39432014-06-13 03:10:36 -0400338
339
340class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700341 id = serializers.Field()
342
343 class Meta:
344 model = Invoice
345 fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700346
347class InvoiceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700348 id = serializers.Field()
349
350 class Meta:
351 model = Invoice
352 fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700353
354
Sapan Bhatiadea39432014-06-13 03:10:36 -0400355
356
Scott Baker0caeaf02014-06-19 11:12:55 -0700357class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700358 id = serializers.Field()
359
360 class Meta:
361 model = SlicePrivilege
362 fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700363
364class SlicePrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700365 id = serializers.Field()
366
367 class Meta:
368 model = SlicePrivilege
369 fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700370
371
Scott Baker0caeaf02014-06-19 11:12:55 -0700372
373
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700374class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700375 id = serializers.Field()
376
377 class Meta:
378 model = PlanetStackRole
379 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700380
381class PlanetStackRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700382 id = serializers.Field()
383
384 class Meta:
385 model = PlanetStackRole
386 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700387
388
389
390
Scott Baker0caeaf02014-06-19 11:12:55 -0700391class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700392 id = serializers.Field()
393
394 class Meta:
395 model = NetworkSliver
396 fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700397
398class NetworkSliverIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700399 id = serializers.Field()
400
401 class Meta:
402 model = NetworkSliver
403 fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700404
405
Scott Baker0caeaf02014-06-19 11:12:55 -0700406
407
408class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700409 id = serializers.Field()
410
411 class Meta:
412 model = NetworkDeployments
413 fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700414
415class NetworkDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700416 id = serializers.Field()
417
418 class Meta:
419 model = NetworkDeployments
420 fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700421
422
Sapan Bhatiadea39432014-06-13 03:10:36 -0400423
424
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700425class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700426 id = serializers.Field()
427
428 class Meta:
429 model = Flavor
430 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700431
432class FlavorIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700433 id = serializers.Field()
434
435 class Meta:
436 model = Flavor
437 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700438
439
440
441
442class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700443 id = serializers.Field()
444
445 class Meta:
446 model = Project
447 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700448
449class ProjectIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700450 id = serializers.Field()
451
452 class Meta:
453 model = Project
454 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700455
456
457
458
Sapan Bhatiadea39432014-06-13 03:10:36 -0400459class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700460 id = serializers.Field()
461
462
463 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
464
465
466
467 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
468
469
470
471 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
472
473
474
475 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
476
477
478 class Meta:
479 model = Slice
480 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',)
Scott Baker46b58542014-08-11 17:26:12 -0700481
482class SliceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700483 id = serializers.Field()
484
485
486 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
487
488
489
490 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
491
492
493
494 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
495
496
497
498 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
499
500
501 class Meta:
502 model = Slice
503 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',)
Scott Baker46b58542014-08-11 17:26:12 -0700504
505
Sapan Bhatiadea39432014-06-13 03:10:36 -0400506
507
508class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700509 id = serializers.Field()
510
511
512 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
513
514
515
516 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
517
518
519
520 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
521
522
523
524 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
525
526
527 class Meta:
528 model = Network
529 fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700530
531class NetworkIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700532 id = serializers.Field()
533
534
535 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
536
537
538
539 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
540
541
542
543 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
544
545
546
547 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
548
549
550 class Meta:
551 model = Network
552 fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700553
554
Sapan Bhatiadea39432014-06-13 03:10:36 -0400555
556
557class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700558 id = serializers.Field()
559
560 class Meta:
561 model = Service
562 fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700563
564class ServiceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700565 id = serializers.Field()
566
567 class Meta:
568 model = Service
569 fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700570
571
Sapan Bhatiadea39432014-06-13 03:10:36 -0400572
573
Scott Baker0caeaf02014-06-19 11:12:55 -0700574class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700575 id = serializers.Field()
576
577 class Meta:
578 model = ServiceClass
579 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700580
581class ServiceClassIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700582 id = serializers.Field()
583
584 class Meta:
585 model = ServiceClass
586 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700587
588
Sapan Bhatiadea39432014-06-13 03:10:36 -0400589
590
Scott Baker0caeaf02014-06-19 11:12:55 -0700591class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700592 id = serializers.Field()
593
594 class Meta:
595 model = Payment
596 fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700597
598class PaymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700599 id = serializers.Field()
600
601 class Meta:
602 model = Payment
603 fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700604
605
Sapan Bhatiadea39432014-06-13 03:10:36 -0400606
607
608class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700609 id = serializers.Field()
610
611 class Meta:
612 model = Charge
613 fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700614
615class ChargeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700616 id = serializers.Field()
617
618 class Meta:
619 model = Charge
620 fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700621
622
Sapan Bhatiadea39432014-06-13 03:10:36 -0400623
624
625class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700626 id = serializers.Field()
627
628 class Meta:
629 model = Role
630 fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700631
632class RoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700633 id = serializers.Field()
634
635 class Meta:
636 model = Role
637 fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700638
639
Sapan Bhatiadea39432014-06-13 03:10:36 -0400640
641
Scott Baker0caeaf02014-06-19 11:12:55 -0700642class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700643 id = serializers.Field()
644
645 class Meta:
646 model = UsableObject
647 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -0700648
649class UsableObjectIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700650 id = serializers.Field()
651
652 class Meta:
653 model = UsableObject
654 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -0700655
656
Sapan Bhatiadea39432014-06-13 03:10:36 -0400657
658
Scott Baker0caeaf02014-06-19 11:12:55 -0700659class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700660 id = serializers.Field()
661
662 class Meta:
663 model = SiteRole
664 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700665
666class SiteRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700667 id = serializers.Field()
668
669 class Meta:
670 model = SiteRole
671 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700672
673
Scott Baker0caeaf02014-06-19 11:12:55 -0700674
675
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700676class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700677 id = serializers.Field()
678
679 class Meta:
680 model = SliceCredential
681 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700682
683class SliceCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700684 id = serializers.Field()
685
686 class Meta:
687 model = SliceCredential
688 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700689
690
691
692
Sapan Bhatiadea39432014-06-13 03:10:36 -0400693class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700694 id = serializers.Field()
695
696
697 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
698
699
700
701 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
702
703
704 class Meta:
705 model = Sliver
706 fields = ('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 -0700707
708class SliverIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700709 id = serializers.Field()
710
711
712 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
713
714
715
716 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
717
718
719 class Meta:
720 model = Sliver
721 fields = ('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 -0700722
723
Sapan Bhatiadea39432014-06-13 03:10:36 -0400724
725
726class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700727 id = serializers.Field()
728
729 class Meta:
730 model = Node
731 fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -0700732
733class NodeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700734 id = serializers.Field()
735
736 class Meta:
737 model = Node
738 fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -0700739
740
Sapan Bhatiadea39432014-06-13 03:10:36 -0400741
742
Scott Baker0caeaf02014-06-19 11:12:55 -0700743class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700744 id = serializers.Field()
745
746 class Meta:
747 model = DashboardView
748 fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker46b58542014-08-11 17:26:12 -0700749
750class DashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700751 id = serializers.Field()
752
753 class Meta:
754 model = DashboardView
755 fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker46b58542014-08-11 17:26:12 -0700756
757
Sapan Bhatiadea39432014-06-13 03:10:36 -0400758
759
Sapan Bhatia18b779c2014-11-11 23:05:53 -0500760class ImageDeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700761 id = serializers.Field()
762
763 class Meta:
Sapan Bhatia18b779c2014-11-11 23:05:53 -0500764 model = ImageDeployment
Scott Baker08898c12014-10-29 23:41:11 -0700765 fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700766
Sapan Bhatia18b779c2014-11-11 23:05:53 -0500767class ImageDeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700768 id = serializers.Field()
769
770 class Meta:
Sapan Bhatia18b779c2014-11-11 23:05:53 -0500771 model = ImageDeployment
Scott Baker08898c12014-10-29 23:41:11 -0700772 fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700773
774
Sapan Bhatiadea39432014-06-13 03:10:36 -0400775
776
Scott Baker0caeaf02014-06-19 11:12:55 -0700777class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700778 id = serializers.Field()
779
780 class Meta:
781 model = ReservedResource
782 fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -0700783
784class ReservedResourceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700785 id = serializers.Field()
786
787 class Meta:
788 model = ReservedResource
789 fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -0700790
791
Sapan Bhatiadea39432014-06-13 03:10:36 -0400792
793
Scott Baker0caeaf02014-06-19 11:12:55 -0700794class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700795 id = serializers.Field()
796
797 class Meta:
798 model = NetworkSlice
799 fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -0700800
801class NetworkSliceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700802 id = serializers.Field()
803
804 class Meta:
805 model = NetworkSlice
806 fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -0700807
808
Scott Baker0caeaf02014-06-19 11:12:55 -0700809
810
811class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700812 id = serializers.Field()
813
814 class Meta:
815 model = UserDashboardView
816 fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -0700817
818class UserDashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700819 id = serializers.Field()
820
821 class Meta:
822 model = UserDashboardView
823 fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -0700824
825
Scott Baker0caeaf02014-06-19 11:12:55 -0700826
827
828class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700829 id = serializers.Field()
830
831 class Meta:
832 model = PlanetStackPrivilege
833 fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700834
835class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700836 id = serializers.Field()
837
838 class Meta:
839 model = PlanetStackPrivilege
840 fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700841
842
Sapan Bhatiadea39432014-06-13 03:10:36 -0400843
844
845class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700846 id = serializers.Field()
847
848 class Meta:
849 model = User
850 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',)
Scott Baker46b58542014-08-11 17:26:12 -0700851
852class UserIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700853 id = serializers.Field()
854
855 class Meta:
856 model = User
857 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',)
Scott Baker46b58542014-08-11 17:26:12 -0700858
859
Sapan Bhatiadea39432014-06-13 03:10:36 -0400860
861
862class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700863 id = serializers.Field()
864
865
866 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
867
868
869
870 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
871
872
873
874 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
875
876
877
878 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
879
880
881 class Meta:
882 model = Deployment
883 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',)
Scott Baker46b58542014-08-11 17:26:12 -0700884
885class DeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700886 id = serializers.Field()
887
888
889 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
890
891
892
893 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
894
895
896
897 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
898
899
900
901 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
902
903
904 class Meta:
905 model = Deployment
906 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',)
Scott Baker46b58542014-08-11 17:26:12 -0700907
908
Sapan Bhatiadea39432014-06-13 03:10:36 -0400909
910
911class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700912 id = serializers.Field()
913
914 class Meta:
915 model = Reservation
916 fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -0700917
918class ReservationIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700919 id = serializers.Field()
920
921 class Meta:
922 model = Reservation
923 fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -0700924
925
Sapan Bhatiadea39432014-06-13 03:10:36 -0400926
927
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -0500928class SliceDeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700929 id = serializers.Field()
930
931 class Meta:
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -0500932 model = SliceDeployment
Scott Baker08898c12014-10-29 23:41:11 -0700933 fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700934
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -0500935class SliceDeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700936 id = serializers.Field()
937
938 class Meta:
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -0500939 model = SliceDeployment
Scott Baker08898c12014-10-29 23:41:11 -0700940 fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700941
942
Sapan Bhatiadea39432014-06-13 03:10:36 -0400943
944
Scott Baker0caeaf02014-06-19 11:12:55 -0700945class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700946 id = serializers.Field()
947
948 class Meta:
949 model = SitePrivilege
950 fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700951
952class SitePrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700953 id = serializers.Field()
954
955 class Meta:
956 model = SitePrivilege
957 fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700958
959
Scott Baker0caeaf02014-06-19 11:12:55 -0700960
961
962class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700963 id = serializers.Field()
964
965 class Meta:
966 model = PlanetStack
967 fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -0700968
969class PlanetStackIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700970 id = serializers.Field()
971
972 class Meta:
973 model = PlanetStack
974 fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -0700975
976
Sapan Bhatiadea39432014-06-13 03:10:36 -0400977
978
Sapan Bhatia84ba65d2014-11-11 21:44:35 -0500979class UserDeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700980 id = serializers.Field()
981
982 class Meta:
Sapan Bhatia84ba65d2014-11-11 21:44:35 -0500983 model = UserDeployment
Scott Baker08898c12014-10-29 23:41:11 -0700984 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700985
Sapan Bhatia84ba65d2014-11-11 21:44:35 -0500986class UserDeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700987 id = serializers.Field()
988
989 class Meta:
Sapan Bhatia84ba65d2014-11-11 21:44:35 -0500990 model = UserDeployment
Scott Baker08898c12014-10-29 23:41:11 -0700991 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700992
993
Scott Baker0caeaf02014-06-19 11:12:55 -0700994
995
Sapan Bhatiadea39432014-06-13 03:10:36 -0400996class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700997 id = serializers.Field()
998
999 class Meta:
1000 model = Account
1001 fields = ('id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001002
1003class AccountIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001004 id = serializers.Field()
1005
1006 class Meta:
1007 model = Account
1008 fields = ('id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001009
1010
Sapan Bhatiadea39432014-06-13 03:10:36 -04001011
1012
Scott Baker0caeaf02014-06-19 11:12:55 -07001013class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001014 id = serializers.Field()
1015
1016 class Meta:
1017 model = NetworkParameterType
1018 fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001019
1020class NetworkParameterTypeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001021 id = serializers.Field()
1022
1023 class Meta:
1024 model = NetworkParameterType
1025 fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001026
1027
Sapan Bhatiadea39432014-06-13 03:10:36 -04001028
1029
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001030class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001031 id = serializers.Field()
1032
1033 class Meta:
1034 model = SiteCredential
1035 fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001036
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001037class SiteCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001038 id = serializers.Field()
1039
1040 class Meta:
1041 model = SiteCredential
1042 fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001043
1044
Scott Baker0caeaf02014-06-19 11:12:55 -07001045
1046
1047class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001048 id = serializers.Field()
1049
1050 class Meta:
1051 model = DeploymentPrivilege
1052 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001053
1054class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001055 id = serializers.Field()
1056
1057 class Meta:
1058 model = DeploymentPrivilege
1059 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001060
1061
Scott Baker0caeaf02014-06-19 11:12:55 -07001062
1063
1064class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001065 id = serializers.Field()
1066
1067 class Meta:
1068 model = DeploymentRole
1069 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001070
1071class DeploymentRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001072 id = serializers.Field()
1073
1074 class Meta:
1075 model = DeploymentRole
1076 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001077
1078
Sapan Bhatiadea39432014-06-13 03:10:36 -04001079
1080
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001081class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001082 id = serializers.Field()
1083
1084 class Meta:
1085 model = UserCredential
1086 fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001087
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001088class UserCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001089 id = serializers.Field()
1090
1091 class Meta:
1092 model = UserCredential
1093 fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001094
1095
1096
1097
Sapan Bhatia6d21da32014-11-11 21:41:12 -05001098class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001099 id = serializers.Field()
1100
1101 class Meta:
Sapan Bhatia6d21da32014-11-11 21:41:12 -05001102 model = SiteDeployment
Scott Baker08898c12014-10-29 23:41:11 -07001103 fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001104
Sapan Bhatia6d21da32014-11-11 21:41:12 -05001105class SiteDeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001106 id = serializers.Field()
1107
1108 class Meta:
Sapan Bhatia6d21da32014-11-11 21:41:12 -05001109 model = SiteDeployment
Scott Baker08898c12014-10-29 23:41:11 -07001110 fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001111
1112
Sapan Bhatiadea39432014-06-13 03:10:36 -04001113
1114
Scott Baker0caeaf02014-06-19 11:12:55 -07001115class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001116 id = serializers.Field()
1117
1118 class Meta:
1119 model = SliceTag
1120 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07001121
1122class SliceTagIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001123 id = serializers.Field()
1124
1125 class Meta:
1126 model = SliceTag
1127 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07001128
1129
Scott Baker0caeaf02014-06-19 11:12:55 -07001130
1131
1132class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001133 id = serializers.Field()
1134
1135 class Meta:
1136 model = NetworkTemplate
1137 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
Scott Baker46b58542014-08-11 17:26:12 -07001138
1139class NetworkTemplateIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001140 id = serializers.Field()
1141
1142 class Meta:
1143 model = NetworkTemplate
1144 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
Scott Baker46b58542014-08-11 17:26:12 -07001145
1146
Sapan Bhatiadea39432014-06-13 03:10:36 -04001147
1148
1149class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001150 id = serializers.Field()
1151
1152 class Meta:
1153 model = Router
1154 fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07001155
1156class RouterIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001157 id = serializers.Field()
1158
1159 class Meta:
1160 model = Router
1161 fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07001162
1163
Sapan Bhatiadea39432014-06-13 03:10:36 -04001164
1165
Scott Baker0caeaf02014-06-19 11:12:55 -07001166class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001167 id = serializers.Field()
1168
1169 class Meta:
1170 model = ServiceResource
1171 fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07001172
1173class ServiceResourceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001174 id = serializers.Field()
1175
1176 class Meta:
1177 model = ServiceResource
1178 fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07001179
1180
Sapan Bhatiadea39432014-06-13 03:10:36 -04001181
1182
1183serializerLookUp = {
1184
Scott Baker0caeaf02014-06-19 11:12:55 -07001185 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001186
1187 Image: ImageSerializer,
1188
Scott Baker0caeaf02014-06-19 11:12:55 -07001189 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001190
1191 Site: SiteSerializer,
1192
Scott Baker0caeaf02014-06-19 11:12:55 -07001193 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001194
1195 Tag: TagSerializer,
1196
1197 Invoice: InvoiceSerializer,
1198
Scott Baker0caeaf02014-06-19 11:12:55 -07001199 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001200
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001201 PlanetStackRole: PlanetStackRoleSerializer,
1202
Scott Baker0caeaf02014-06-19 11:12:55 -07001203 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001204
Scott Baker0caeaf02014-06-19 11:12:55 -07001205 NetworkDeployments: NetworkDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001206
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001207 Flavor: FlavorSerializer,
1208
1209 Project: ProjectSerializer,
1210
Sapan Bhatiadea39432014-06-13 03:10:36 -04001211 Slice: SliceSerializer,
1212
1213 Network: NetworkSerializer,
1214
1215 Service: ServiceSerializer,
1216
Scott Baker0caeaf02014-06-19 11:12:55 -07001217 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001218
Scott Baker0caeaf02014-06-19 11:12:55 -07001219 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001220
1221 Charge: ChargeSerializer,
1222
1223 Role: RoleSerializer,
1224
Scott Baker0caeaf02014-06-19 11:12:55 -07001225 UsableObject: UsableObjectSerializer,
1226
1227 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001228
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001229 SliceCredential: SliceCredentialSerializer,
1230
Sapan Bhatiadea39432014-06-13 03:10:36 -04001231 Sliver: SliverSerializer,
1232
1233 Node: NodeSerializer,
1234
Scott Baker0caeaf02014-06-19 11:12:55 -07001235 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001236
Sapan Bhatia18b779c2014-11-11 23:05:53 -05001237 ImageDeployment: ImageDeploymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001238
Scott Baker0caeaf02014-06-19 11:12:55 -07001239 ReservedResource: ReservedResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001240
Scott Baker0caeaf02014-06-19 11:12:55 -07001241 NetworkSlice: NetworkSliceSerializer,
1242
1243 UserDashboardView: UserDashboardViewSerializer,
1244
1245 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001246
1247 User: UserSerializer,
1248
1249 Deployment: DeploymentSerializer,
1250
1251 Reservation: ReservationSerializer,
1252
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05001253 SliceDeployment: SliceDeploymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001254
Scott Baker0caeaf02014-06-19 11:12:55 -07001255 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001256
Scott Baker0caeaf02014-06-19 11:12:55 -07001257 PlanetStack: PlanetStackSerializer,
1258
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05001259 UserDeployment: UserDeploymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001260
1261 Account: AccountSerializer,
1262
Scott Baker0caeaf02014-06-19 11:12:55 -07001263 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001264
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001265 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001266
Scott Baker0caeaf02014-06-19 11:12:55 -07001267 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001268
Scott Baker0caeaf02014-06-19 11:12:55 -07001269 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001270
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001271 UserCredential: UserCredentialSerializer,
1272
Sapan Bhatia6d21da32014-11-11 21:41:12 -05001273 SiteDeployment: SiteDeploymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001274
Scott Baker0caeaf02014-06-19 11:12:55 -07001275 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001276
Scott Baker0caeaf02014-06-19 11:12:55 -07001277 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001278
1279 Router: RouterSerializer,
1280
Scott Baker0caeaf02014-06-19 11:12:55 -07001281 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001282
1283 None: None,
1284 }
1285
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001286class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
1287
1288 # To handle fine-grained field permissions, we have to check can_update
1289 # the object has been updated but before it has been saved.
1290
1291 def update(self, request, *args, **kwargs):
1292 partial = kwargs.pop('partial', False)
1293 self.object = self.get_object_or_none()
1294
1295 serializer = self.get_serializer(self.object, data=request.DATA,
1296 files=request.FILES, partial=partial)
1297
1298 if not serializer.is_valid():
1299 print "UpdateModelMixin: not serializer.is_valid"
1300 print serializer.errors
1301 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
1302
1303 try:
1304 self.pre_save(serializer.object)
1305 except ValidationError as err:
1306 # full_clean on model instance may be called in pre_save,
1307 # so we have to handle eventual errors.
1308 return Response(err.message_dict, status=status.HTTP_400_BAD_REQUEST)
1309
1310 if serializer.object is not None:
1311 if not serializer.object.can_update(request.user):
1312 return Response(status=status.HTTP_400_BAD_REQUEST)
1313
1314 if self.object is None:
1315 self.object = serializer.save(force_insert=True)
1316 self.post_save(self.object, created=True)
1317 return Response(serializer.data, status=status.HTTP_201_CREATED)
1318
1319 self.object = serializer.save(force_update=True)
1320 self.post_save(self.object, created=False)
1321 return Response(serializer.data, status=status.HTTP_200_OK)
1322
1323 def destroy(self, request, *args, **kwargs):
1324 obj = self.get_object()
1325 if obj.can_update(request.user):
Scott Baker08898c12014-10-29 23:41:11 -07001326 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001327 else:
1328 return Response(status=status.HTTP_400_BAD_REQUEST)
1329
1330
Sapan Bhatiadea39432014-06-13 03:10:36 -04001331# Based on core/views/*.py
1332
1333
Scott Baker0caeaf02014-06-19 11:12:55 -07001334class ServiceAttributeList(generics.ListCreateAPIView):
1335 queryset = ServiceAttribute.objects.select_related().all()
1336 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001337 id_serializer_class = ServiceAttributeIdSerializer
1338 filter_backends = (filters.DjangoFilterBackend,)
1339 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
1340
1341 def get_serializer_class(self):
1342 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1343 if (no_hyperlinks):
1344 return self.id_serializer_class
1345 else:
1346 return self.serializer_class
1347
Scott Baker0caeaf02014-06-19 11:12:55 -07001348 def get_queryset(self):
1349 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001350
Scott Baker0caeaf02014-06-19 11:12:55 -07001351 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001352 obj = ServiceAttribute(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001353 obj.caller = request.user
1354 if obj.can_update(request.user):
1355 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
1356 else:
Scott Baker08898c12014-10-29 23:41:11 -07001357 raise Exception("failed obj.can_update")
1358
1359 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
1360 if (ret.status_code%100 != 200):
1361 raise Exception(ret.data)
1362
1363 return ret
1364
Scott Baker0caeaf02014-06-19 11:12:55 -07001365
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001366class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001367 queryset = ServiceAttribute.objects.select_related().all()
1368 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001369 id_serializer_class = ServiceAttributeIdSerializer
1370
1371 def get_serializer_class(self):
1372 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1373 if (no_hyperlinks):
1374 return self.id_serializer_class
1375 else:
1376 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001377
1378 def get_queryset(self):
1379 return ServiceAttribute.select_by_user(self.request.user)
1380
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001381 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001382
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001383 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001384
1385
1386
1387class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001388 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001389 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001390 id_serializer_class = ImageIdSerializer
1391 filter_backends = (filters.DjangoFilterBackend,)
1392 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
1393
1394 def get_serializer_class(self):
1395 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1396 if (no_hyperlinks):
1397 return self.id_serializer_class
1398 else:
1399 return self.serializer_class
1400
Scott Baker0caeaf02014-06-19 11:12:55 -07001401 def get_queryset(self):
1402 return Image.select_by_user(self.request.user)
1403
1404 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001405 obj = Image(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001406 obj.caller = request.user
1407 if obj.can_update(request.user):
1408 return super(ImageList, self).create(request, *args, **kwargs)
1409 else:
Scott Baker08898c12014-10-29 23:41:11 -07001410 raise Exception("failed obj.can_update")
1411
1412 ret = super(ImageList, self).create(request, *args, **kwargs)
1413 if (ret.status_code%100 != 200):
1414 raise Exception(ret.data)
1415
1416 return ret
1417
Sapan Bhatiadea39432014-06-13 03:10:36 -04001418
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001419class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001420 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001421 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001422 id_serializer_class = ImageIdSerializer
1423
1424 def get_serializer_class(self):
1425 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1426 if (no_hyperlinks):
1427 return self.id_serializer_class
1428 else:
1429 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001430
1431 def get_queryset(self):
1432 return Image.select_by_user(self.request.user)
1433
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001434 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001435
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001436 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001437
1438
1439
Scott Baker0caeaf02014-06-19 11:12:55 -07001440class NetworkParameterList(generics.ListCreateAPIView):
1441 queryset = NetworkParameter.objects.select_related().all()
1442 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001443 id_serializer_class = NetworkParameterIdSerializer
1444 filter_backends = (filters.DjangoFilterBackend,)
1445 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
1446
1447 def get_serializer_class(self):
1448 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1449 if (no_hyperlinks):
1450 return self.id_serializer_class
1451 else:
1452 return self.serializer_class
1453
Scott Baker0caeaf02014-06-19 11:12:55 -07001454 def get_queryset(self):
1455 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001456
Scott Baker0caeaf02014-06-19 11:12:55 -07001457 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001458 obj = NetworkParameter(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001459 obj.caller = request.user
1460 if obj.can_update(request.user):
1461 return super(NetworkParameterList, self).create(request, *args, **kwargs)
1462 else:
Scott Baker08898c12014-10-29 23:41:11 -07001463 raise Exception("failed obj.can_update")
1464
1465 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
1466 if (ret.status_code%100 != 200):
1467 raise Exception(ret.data)
1468
1469 return ret
1470
Scott Baker0caeaf02014-06-19 11:12:55 -07001471
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001472class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001473 queryset = NetworkParameter.objects.select_related().all()
1474 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001475 id_serializer_class = NetworkParameterIdSerializer
1476
1477 def get_serializer_class(self):
1478 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1479 if (no_hyperlinks):
1480 return self.id_serializer_class
1481 else:
1482 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001483
1484 def get_queryset(self):
1485 return NetworkParameter.select_by_user(self.request.user)
1486
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001487 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001488
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001489 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001490
1491
1492
1493class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001494 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001495 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001496 id_serializer_class = SiteIdSerializer
1497 filter_backends = (filters.DjangoFilterBackend,)
1498 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
1499
1500 def get_serializer_class(self):
1501 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1502 if (no_hyperlinks):
1503 return self.id_serializer_class
1504 else:
1505 return self.serializer_class
1506
Scott Baker0caeaf02014-06-19 11:12:55 -07001507 def get_queryset(self):
1508 return Site.select_by_user(self.request.user)
1509
1510 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001511 obj = Site(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001512 obj.caller = request.user
1513 if obj.can_update(request.user):
1514 return super(SiteList, self).create(request, *args, **kwargs)
1515 else:
Scott Baker08898c12014-10-29 23:41:11 -07001516 raise Exception("failed obj.can_update")
1517
1518 ret = super(SiteList, self).create(request, *args, **kwargs)
1519 if (ret.status_code%100 != 200):
1520 raise Exception(ret.data)
1521
1522 return ret
1523
Sapan Bhatiadea39432014-06-13 03:10:36 -04001524
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001525class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001526 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001527 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001528 id_serializer_class = SiteIdSerializer
1529
1530 def get_serializer_class(self):
1531 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1532 if (no_hyperlinks):
1533 return self.id_serializer_class
1534 else:
1535 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001536
1537 def get_queryset(self):
1538 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001539
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001540 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001541
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001542 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001543
1544
1545
1546class SliceRoleList(generics.ListCreateAPIView):
1547 queryset = SliceRole.objects.select_related().all()
1548 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001549 id_serializer_class = SliceRoleIdSerializer
1550 filter_backends = (filters.DjangoFilterBackend,)
1551 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
1552
1553 def get_serializer_class(self):
1554 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1555 if (no_hyperlinks):
1556 return self.id_serializer_class
1557 else:
1558 return self.serializer_class
1559
Scott Baker0caeaf02014-06-19 11:12:55 -07001560 def get_queryset(self):
1561 return SliceRole.select_by_user(self.request.user)
1562
1563 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001564 obj = SliceRole(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001565 obj.caller = request.user
1566 if obj.can_update(request.user):
1567 return super(SliceRoleList, self).create(request, *args, **kwargs)
1568 else:
Scott Baker08898c12014-10-29 23:41:11 -07001569 raise Exception("failed obj.can_update")
1570
1571 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
1572 if (ret.status_code%100 != 200):
1573 raise Exception(ret.data)
1574
1575 return ret
1576
Scott Baker0caeaf02014-06-19 11:12:55 -07001577
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001578class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001579 queryset = SliceRole.objects.select_related().all()
1580 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001581 id_serializer_class = SliceRoleIdSerializer
1582
1583 def get_serializer_class(self):
1584 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1585 if (no_hyperlinks):
1586 return self.id_serializer_class
1587 else:
1588 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001589
1590 def get_queryset(self):
1591 return SliceRole.select_by_user(self.request.user)
1592
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001593 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001594
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001595 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001596
1597
1598
1599class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001600 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001601 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001602 id_serializer_class = TagIdSerializer
1603 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001604 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001605
1606 def get_serializer_class(self):
1607 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1608 if (no_hyperlinks):
1609 return self.id_serializer_class
1610 else:
1611 return self.serializer_class
1612
Scott Baker0caeaf02014-06-19 11:12:55 -07001613 def get_queryset(self):
1614 return Tag.select_by_user(self.request.user)
1615
1616 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001617 obj = Tag(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001618 obj.caller = request.user
1619 if obj.can_update(request.user):
1620 return super(TagList, self).create(request, *args, **kwargs)
1621 else:
Scott Baker08898c12014-10-29 23:41:11 -07001622 raise Exception("failed obj.can_update")
1623
1624 ret = super(TagList, self).create(request, *args, **kwargs)
1625 if (ret.status_code%100 != 200):
1626 raise Exception(ret.data)
1627
1628 return ret
1629
Sapan Bhatiadea39432014-06-13 03:10:36 -04001630
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001631class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001632 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001633 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001634 id_serializer_class = TagIdSerializer
1635
1636 def get_serializer_class(self):
1637 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1638 if (no_hyperlinks):
1639 return self.id_serializer_class
1640 else:
1641 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001642
1643 def get_queryset(self):
1644 return Tag.select_by_user(self.request.user)
1645
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001646 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001647
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001648 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001649
1650
1651
1652class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001653 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001654 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001655 id_serializer_class = InvoiceIdSerializer
1656 filter_backends = (filters.DjangoFilterBackend,)
1657 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
1658
1659 def get_serializer_class(self):
1660 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1661 if (no_hyperlinks):
1662 return self.id_serializer_class
1663 else:
1664 return self.serializer_class
1665
Scott Baker0caeaf02014-06-19 11:12:55 -07001666 def get_queryset(self):
1667 return Invoice.select_by_user(self.request.user)
1668
1669 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001670 obj = Invoice(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001671 obj.caller = request.user
1672 if obj.can_update(request.user):
1673 return super(InvoiceList, self).create(request, *args, **kwargs)
1674 else:
Scott Baker08898c12014-10-29 23:41:11 -07001675 raise Exception("failed obj.can_update")
1676
1677 ret = super(InvoiceList, self).create(request, *args, **kwargs)
1678 if (ret.status_code%100 != 200):
1679 raise Exception(ret.data)
1680
1681 return ret
1682
Sapan Bhatiadea39432014-06-13 03:10:36 -04001683
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001684class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001685 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001686 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001687 id_serializer_class = InvoiceIdSerializer
1688
1689 def get_serializer_class(self):
1690 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1691 if (no_hyperlinks):
1692 return self.id_serializer_class
1693 else:
1694 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001695
1696 def get_queryset(self):
1697 return Invoice.select_by_user(self.request.user)
1698
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001699 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001700
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001701 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001702
1703
1704
Scott Baker0caeaf02014-06-19 11:12:55 -07001705class SlicePrivilegeList(generics.ListCreateAPIView):
1706 queryset = SlicePrivilege.objects.select_related().all()
1707 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001708 id_serializer_class = SlicePrivilegeIdSerializer
1709 filter_backends = (filters.DjangoFilterBackend,)
1710 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
1711
1712 def get_serializer_class(self):
1713 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1714 if (no_hyperlinks):
1715 return self.id_serializer_class
1716 else:
1717 return self.serializer_class
1718
Scott Baker0caeaf02014-06-19 11:12:55 -07001719 def get_queryset(self):
1720 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001721
Scott Baker0caeaf02014-06-19 11:12:55 -07001722 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001723 obj = SlicePrivilege(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001724 obj.caller = request.user
1725 if obj.can_update(request.user):
1726 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
1727 else:
Scott Baker08898c12014-10-29 23:41:11 -07001728 raise Exception("failed obj.can_update")
1729
1730 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
1731 if (ret.status_code%100 != 200):
1732 raise Exception(ret.data)
1733
1734 return ret
1735
Scott Baker0caeaf02014-06-19 11:12:55 -07001736
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001737class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001738 queryset = SlicePrivilege.objects.select_related().all()
1739 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001740 id_serializer_class = SlicePrivilegeIdSerializer
1741
1742 def get_serializer_class(self):
1743 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1744 if (no_hyperlinks):
1745 return self.id_serializer_class
1746 else:
1747 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001748
1749 def get_queryset(self):
1750 return SlicePrivilege.select_by_user(self.request.user)
1751
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001752 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1753
1754 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1755
1756
1757
1758class PlanetStackRoleList(generics.ListCreateAPIView):
1759 queryset = PlanetStackRole.objects.select_related().all()
1760 serializer_class = PlanetStackRoleSerializer
1761 id_serializer_class = PlanetStackRoleIdSerializer
1762 filter_backends = (filters.DjangoFilterBackend,)
1763 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
1764
1765 def get_serializer_class(self):
1766 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1767 if (no_hyperlinks):
1768 return self.id_serializer_class
1769 else:
1770 return self.serializer_class
1771
1772 def get_queryset(self):
1773 return PlanetStackRole.select_by_user(self.request.user)
1774
1775 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001776 obj = PlanetStackRole(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001777 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07001778 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001779 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001780 else:
Scott Baker08898c12014-10-29 23:41:11 -07001781 raise Exception("failed obj.can_update")
1782
1783 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
1784 if (ret.status_code%100 != 200):
1785 raise Exception(ret.data)
1786
1787 return ret
1788
Scott Baker0caeaf02014-06-19 11:12:55 -07001789
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001790class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1791 queryset = PlanetStackRole.objects.select_related().all()
1792 serializer_class = PlanetStackRoleSerializer
1793 id_serializer_class = PlanetStackRoleIdSerializer
1794
1795 def get_serializer_class(self):
1796 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1797 if (no_hyperlinks):
1798 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001799 else:
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001800 return self.serializer_class
1801
1802 def get_queryset(self):
1803 return PlanetStackRole.select_by_user(self.request.user)
1804
1805 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1806
1807 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001808
1809
1810
Scott Baker0caeaf02014-06-19 11:12:55 -07001811class NetworkSliverList(generics.ListCreateAPIView):
1812 queryset = NetworkSliver.objects.select_related().all()
1813 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001814 id_serializer_class = NetworkSliverIdSerializer
1815 filter_backends = (filters.DjangoFilterBackend,)
1816 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
1817
1818 def get_serializer_class(self):
1819 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1820 if (no_hyperlinks):
1821 return self.id_serializer_class
1822 else:
1823 return self.serializer_class
1824
Scott Baker0caeaf02014-06-19 11:12:55 -07001825 def get_queryset(self):
1826 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001827
Scott Baker0caeaf02014-06-19 11:12:55 -07001828 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001829 obj = NetworkSliver(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001830 obj.caller = request.user
1831 if obj.can_update(request.user):
1832 return super(NetworkSliverList, self).create(request, *args, **kwargs)
1833 else:
Scott Baker08898c12014-10-29 23:41:11 -07001834 raise Exception("failed obj.can_update")
1835
1836 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
1837 if (ret.status_code%100 != 200):
1838 raise Exception(ret.data)
1839
1840 return ret
1841
Scott Baker0caeaf02014-06-19 11:12:55 -07001842
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001843class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001844 queryset = NetworkSliver.objects.select_related().all()
1845 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001846 id_serializer_class = NetworkSliverIdSerializer
1847
1848 def get_serializer_class(self):
1849 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1850 if (no_hyperlinks):
1851 return self.id_serializer_class
1852 else:
1853 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001854
1855 def get_queryset(self):
1856 return NetworkSliver.select_by_user(self.request.user)
1857
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001858 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001859
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001860 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001861
1862
1863
Scott Baker0caeaf02014-06-19 11:12:55 -07001864class NetworkDeploymentsList(generics.ListCreateAPIView):
1865 queryset = NetworkDeployments.objects.select_related().all()
1866 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001867 id_serializer_class = NetworkDeploymentsIdSerializer
1868 filter_backends = (filters.DjangoFilterBackend,)
1869 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
1870
1871 def get_serializer_class(self):
1872 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1873 if (no_hyperlinks):
1874 return self.id_serializer_class
1875 else:
1876 return self.serializer_class
1877
Scott Baker0caeaf02014-06-19 11:12:55 -07001878 def get_queryset(self):
1879 return NetworkDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001880
Scott Baker0caeaf02014-06-19 11:12:55 -07001881 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001882 obj = NetworkDeployments(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001883 obj.caller = request.user
1884 if obj.can_update(request.user):
1885 return super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
1886 else:
Scott Baker08898c12014-10-29 23:41:11 -07001887 raise Exception("failed obj.can_update")
1888
1889 ret = super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
1890 if (ret.status_code%100 != 200):
1891 raise Exception(ret.data)
1892
1893 return ret
1894
Scott Baker0caeaf02014-06-19 11:12:55 -07001895
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001896class NetworkDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001897 queryset = NetworkDeployments.objects.select_related().all()
1898 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001899 id_serializer_class = NetworkDeploymentsIdSerializer
1900
1901 def get_serializer_class(self):
1902 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1903 if (no_hyperlinks):
1904 return self.id_serializer_class
1905 else:
1906 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001907
1908 def get_queryset(self):
1909 return NetworkDeployments.select_by_user(self.request.user)
1910
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001911 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001912
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001913 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001914
1915
1916
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001917class FlavorList(generics.ListCreateAPIView):
1918 queryset = Flavor.objects.select_related().all()
1919 serializer_class = FlavorSerializer
1920 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001921 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001922 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker46b58542014-08-11 17:26:12 -07001923
1924 def get_serializer_class(self):
1925 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1926 if (no_hyperlinks):
1927 return self.id_serializer_class
1928 else:
1929 return self.serializer_class
1930
Scott Baker0caeaf02014-06-19 11:12:55 -07001931 def get_queryset(self):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001932 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07001933
1934 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001935 obj = Flavor(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001936 obj.caller = request.user
1937 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001938 return super(FlavorList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001939 else:
Scott Baker08898c12014-10-29 23:41:11 -07001940 raise Exception("failed obj.can_update")
1941
1942 ret = super(FlavorList, self).create(request, *args, **kwargs)
1943 if (ret.status_code%100 != 200):
1944 raise Exception(ret.data)
1945
1946 return ret
1947
Sapan Bhatiadea39432014-06-13 03:10:36 -04001948
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001949class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1950 queryset = Flavor.objects.select_related().all()
1951 serializer_class = FlavorSerializer
1952 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001953
1954 def get_serializer_class(self):
1955 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1956 if (no_hyperlinks):
1957 return self.id_serializer_class
1958 else:
1959 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001960
1961 def get_queryset(self):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001962 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07001963
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001964 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001965
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001966 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001967
1968
1969
Scott Baker0caeaf02014-06-19 11:12:55 -07001970class ProjectList(generics.ListCreateAPIView):
1971 queryset = Project.objects.select_related().all()
1972 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001973 id_serializer_class = ProjectIdSerializer
1974 filter_backends = (filters.DjangoFilterBackend,)
1975 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
1976
1977 def get_serializer_class(self):
1978 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1979 if (no_hyperlinks):
1980 return self.id_serializer_class
1981 else:
1982 return self.serializer_class
1983
Scott Baker0caeaf02014-06-19 11:12:55 -07001984 def get_queryset(self):
1985 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001986
Scott Baker0caeaf02014-06-19 11:12:55 -07001987 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07001988 obj = Project(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001989 obj.caller = request.user
1990 if obj.can_update(request.user):
1991 return super(ProjectList, self).create(request, *args, **kwargs)
1992 else:
Scott Baker08898c12014-10-29 23:41:11 -07001993 raise Exception("failed obj.can_update")
1994
1995 ret = super(ProjectList, self).create(request, *args, **kwargs)
1996 if (ret.status_code%100 != 200):
1997 raise Exception(ret.data)
1998
1999 return ret
2000
Scott Baker0caeaf02014-06-19 11:12:55 -07002001
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002002class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002003 queryset = Project.objects.select_related().all()
2004 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002005 id_serializer_class = ProjectIdSerializer
2006
2007 def get_serializer_class(self):
2008 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2009 if (no_hyperlinks):
2010 return self.id_serializer_class
2011 else:
2012 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002013
2014 def get_queryset(self):
2015 return Project.select_by_user(self.request.user)
2016
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002017 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2018
2019 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2020
2021
2022
2023class SliceList(generics.ListCreateAPIView):
2024 queryset = Slice.objects.select_related().all()
2025 serializer_class = SliceSerializer
2026 id_serializer_class = SliceIdSerializer
2027 filter_backends = (filters.DjangoFilterBackend,)
2028 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',)
2029
2030 def get_serializer_class(self):
2031 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2032 if (no_hyperlinks):
2033 return self.id_serializer_class
2034 else:
2035 return self.serializer_class
2036
2037 def get_queryset(self):
2038 return Slice.select_by_user(self.request.user)
2039
2040 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002041 obj = Slice(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002042 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07002043 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002044 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002045 else:
Scott Baker08898c12014-10-29 23:41:11 -07002046 raise Exception("failed obj.can_update")
2047
2048 ret = super(SliceList, self).create(request, *args, **kwargs)
2049 if (ret.status_code%100 != 200):
2050 raise Exception(ret.data)
2051
2052 return ret
2053
Scott Baker0caeaf02014-06-19 11:12:55 -07002054
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002055class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2056 queryset = Slice.objects.select_related().all()
2057 serializer_class = SliceSerializer
2058 id_serializer_class = SliceIdSerializer
2059
2060 def get_serializer_class(self):
2061 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2062 if (no_hyperlinks):
2063 return self.id_serializer_class
2064 else:
2065 return self.serializer_class
2066
2067 def get_queryset(self):
2068 return Slice.select_by_user(self.request.user)
2069
2070 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2071
2072 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2073
2074
2075
2076class NetworkList(generics.ListCreateAPIView):
2077 queryset = Network.objects.select_related().all()
2078 serializer_class = NetworkSerializer
2079 id_serializer_class = NetworkIdSerializer
2080 filter_backends = (filters.DjangoFilterBackend,)
2081 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
2082
2083 def get_serializer_class(self):
2084 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2085 if (no_hyperlinks):
2086 return self.id_serializer_class
2087 else:
2088 return self.serializer_class
2089
2090 def get_queryset(self):
2091 return Network.select_by_user(self.request.user)
2092
2093 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002094 obj = Network(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002095 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07002096 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002097 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002098 else:
Scott Baker08898c12014-10-29 23:41:11 -07002099 raise Exception("failed obj.can_update")
2100
2101 ret = super(NetworkList, self).create(request, *args, **kwargs)
2102 if (ret.status_code%100 != 200):
2103 raise Exception(ret.data)
2104
2105 return ret
2106
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002107
2108class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2109 queryset = Network.objects.select_related().all()
2110 serializer_class = NetworkSerializer
2111 id_serializer_class = NetworkIdSerializer
2112
2113 def get_serializer_class(self):
2114 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2115 if (no_hyperlinks):
2116 return self.id_serializer_class
2117 else:
2118 return self.serializer_class
2119
2120 def get_queryset(self):
2121 return Network.select_by_user(self.request.user)
2122
2123 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2124
2125 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2126
2127
2128
2129class ServiceList(generics.ListCreateAPIView):
2130 queryset = Service.objects.select_related().all()
2131 serializer_class = ServiceSerializer
2132 id_serializer_class = ServiceIdSerializer
2133 filter_backends = (filters.DjangoFilterBackend,)
2134 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
2135
2136 def get_serializer_class(self):
2137 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2138 if (no_hyperlinks):
2139 return self.id_serializer_class
2140 else:
2141 return self.serializer_class
2142
2143 def get_queryset(self):
2144 return Service.select_by_user(self.request.user)
2145
2146 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002147 obj = Service(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002148 obj.caller = request.user
2149 if obj.can_update(request.user):
2150 return super(ServiceList, self).create(request, *args, **kwargs)
2151 else:
Scott Baker08898c12014-10-29 23:41:11 -07002152 raise Exception("failed obj.can_update")
2153
2154 ret = super(ServiceList, self).create(request, *args, **kwargs)
2155 if (ret.status_code%100 != 200):
2156 raise Exception(ret.data)
2157
2158 return ret
2159
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002160
2161class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2162 queryset = Service.objects.select_related().all()
2163 serializer_class = ServiceSerializer
2164 id_serializer_class = ServiceIdSerializer
2165
2166 def get_serializer_class(self):
2167 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2168 if (no_hyperlinks):
2169 return self.id_serializer_class
2170 else:
2171 return self.serializer_class
2172
2173 def get_queryset(self):
2174 return Service.select_by_user(self.request.user)
2175
2176 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2177
2178 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2179
2180
2181
2182class ServiceClassList(generics.ListCreateAPIView):
2183 queryset = ServiceClass.objects.select_related().all()
2184 serializer_class = ServiceClassSerializer
2185 id_serializer_class = ServiceClassIdSerializer
2186 filter_backends = (filters.DjangoFilterBackend,)
2187 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
2188
2189 def get_serializer_class(self):
2190 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2191 if (no_hyperlinks):
2192 return self.id_serializer_class
2193 else:
2194 return self.serializer_class
2195
2196 def get_queryset(self):
2197 return ServiceClass.select_by_user(self.request.user)
2198
2199 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002200 obj = ServiceClass(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002201 obj.caller = request.user
2202 if obj.can_update(request.user):
2203 return super(ServiceClassList, self).create(request, *args, **kwargs)
2204 else:
Scott Baker08898c12014-10-29 23:41:11 -07002205 raise Exception("failed obj.can_update")
2206
2207 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
2208 if (ret.status_code%100 != 200):
2209 raise Exception(ret.data)
2210
2211 return ret
2212
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002213
2214class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2215 queryset = ServiceClass.objects.select_related().all()
2216 serializer_class = ServiceClassSerializer
2217 id_serializer_class = ServiceClassIdSerializer
2218
2219 def get_serializer_class(self):
2220 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2221 if (no_hyperlinks):
2222 return self.id_serializer_class
2223 else:
2224 return self.serializer_class
2225
2226 def get_queryset(self):
2227 return ServiceClass.select_by_user(self.request.user)
2228
2229 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2230
2231 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2232
2233
2234
2235class PaymentList(generics.ListCreateAPIView):
2236 queryset = Payment.objects.select_related().all()
2237 serializer_class = PaymentSerializer
2238 id_serializer_class = PaymentIdSerializer
2239 filter_backends = (filters.DjangoFilterBackend,)
2240 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
2241
2242 def get_serializer_class(self):
2243 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2244 if (no_hyperlinks):
2245 return self.id_serializer_class
2246 else:
2247 return self.serializer_class
2248
2249 def get_queryset(self):
2250 return Payment.select_by_user(self.request.user)
2251
2252 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002253 obj = Payment(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002254 obj.caller = request.user
2255 if obj.can_update(request.user):
2256 return super(PaymentList, self).create(request, *args, **kwargs)
2257 else:
Scott Baker08898c12014-10-29 23:41:11 -07002258 raise Exception("failed obj.can_update")
2259
2260 ret = super(PaymentList, self).create(request, *args, **kwargs)
2261 if (ret.status_code%100 != 200):
2262 raise Exception(ret.data)
2263
2264 return ret
2265
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002266
2267class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2268 queryset = Payment.objects.select_related().all()
2269 serializer_class = PaymentSerializer
2270 id_serializer_class = PaymentIdSerializer
2271
2272 def get_serializer_class(self):
2273 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2274 if (no_hyperlinks):
2275 return self.id_serializer_class
2276 else:
2277 return self.serializer_class
2278
2279 def get_queryset(self):
2280 return Payment.select_by_user(self.request.user)
2281
2282 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2283
2284 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2285
2286
2287
2288class ChargeList(generics.ListCreateAPIView):
2289 queryset = Charge.objects.select_related().all()
2290 serializer_class = ChargeSerializer
2291 id_serializer_class = ChargeIdSerializer
2292 filter_backends = (filters.DjangoFilterBackend,)
2293 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
2294
2295 def get_serializer_class(self):
2296 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2297 if (no_hyperlinks):
2298 return self.id_serializer_class
2299 else:
2300 return self.serializer_class
2301
2302 def get_queryset(self):
2303 return Charge.select_by_user(self.request.user)
2304
2305 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002306 obj = Charge(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002307 obj.caller = request.user
2308 if obj.can_update(request.user):
2309 return super(ChargeList, self).create(request, *args, **kwargs)
2310 else:
Scott Baker08898c12014-10-29 23:41:11 -07002311 raise Exception("failed obj.can_update")
2312
2313 ret = super(ChargeList, self).create(request, *args, **kwargs)
2314 if (ret.status_code%100 != 200):
2315 raise Exception(ret.data)
2316
2317 return ret
2318
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002319
2320class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2321 queryset = Charge.objects.select_related().all()
2322 serializer_class = ChargeSerializer
2323 id_serializer_class = ChargeIdSerializer
2324
2325 def get_serializer_class(self):
2326 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2327 if (no_hyperlinks):
2328 return self.id_serializer_class
2329 else:
2330 return self.serializer_class
2331
2332 def get_queryset(self):
2333 return Charge.select_by_user(self.request.user)
2334
2335 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2336
2337 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2338
2339
2340
2341class RoleList(generics.ListCreateAPIView):
2342 queryset = Role.objects.select_related().all()
2343 serializer_class = RoleSerializer
2344 id_serializer_class = RoleIdSerializer
2345 filter_backends = (filters.DjangoFilterBackend,)
2346 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
2347
2348 def get_serializer_class(self):
2349 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2350 if (no_hyperlinks):
2351 return self.id_serializer_class
2352 else:
2353 return self.serializer_class
2354
2355 def get_queryset(self):
2356 return Role.select_by_user(self.request.user)
2357
2358 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002359 obj = Role(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002360 obj.caller = request.user
2361 if obj.can_update(request.user):
2362 return super(RoleList, self).create(request, *args, **kwargs)
2363 else:
Scott Baker08898c12014-10-29 23:41:11 -07002364 raise Exception("failed obj.can_update")
2365
2366 ret = super(RoleList, self).create(request, *args, **kwargs)
2367 if (ret.status_code%100 != 200):
2368 raise Exception(ret.data)
2369
2370 return ret
2371
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002372
2373class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2374 queryset = Role.objects.select_related().all()
2375 serializer_class = RoleSerializer
2376 id_serializer_class = RoleIdSerializer
2377
2378 def get_serializer_class(self):
2379 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2380 if (no_hyperlinks):
2381 return self.id_serializer_class
2382 else:
2383 return self.serializer_class
2384
2385 def get_queryset(self):
2386 return Role.select_by_user(self.request.user)
2387
2388 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2389
2390 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2391
2392
2393
2394class UsableObjectList(generics.ListCreateAPIView):
2395 queryset = UsableObject.objects.select_related().all()
2396 serializer_class = UsableObjectSerializer
2397 id_serializer_class = UsableObjectIdSerializer
2398 filter_backends = (filters.DjangoFilterBackend,)
2399 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
2400
2401 def get_serializer_class(self):
2402 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2403 if (no_hyperlinks):
2404 return self.id_serializer_class
2405 else:
2406 return self.serializer_class
2407
2408 def get_queryset(self):
2409 return UsableObject.select_by_user(self.request.user)
2410
2411 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002412 obj = UsableObject(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002413 obj.caller = request.user
2414 if obj.can_update(request.user):
2415 return super(UsableObjectList, self).create(request, *args, **kwargs)
2416 else:
Scott Baker08898c12014-10-29 23:41:11 -07002417 raise Exception("failed obj.can_update")
2418
2419 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
2420 if (ret.status_code%100 != 200):
2421 raise Exception(ret.data)
2422
2423 return ret
2424
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002425
2426class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2427 queryset = UsableObject.objects.select_related().all()
2428 serializer_class = UsableObjectSerializer
2429 id_serializer_class = UsableObjectIdSerializer
2430
2431 def get_serializer_class(self):
2432 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2433 if (no_hyperlinks):
2434 return self.id_serializer_class
2435 else:
2436 return self.serializer_class
2437
2438 def get_queryset(self):
2439 return UsableObject.select_by_user(self.request.user)
2440
2441 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2442
2443 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2444
2445
2446
2447class SiteRoleList(generics.ListCreateAPIView):
2448 queryset = SiteRole.objects.select_related().all()
2449 serializer_class = SiteRoleSerializer
2450 id_serializer_class = SiteRoleIdSerializer
2451 filter_backends = (filters.DjangoFilterBackend,)
2452 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2453
2454 def get_serializer_class(self):
2455 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2456 if (no_hyperlinks):
2457 return self.id_serializer_class
2458 else:
2459 return self.serializer_class
2460
2461 def get_queryset(self):
2462 return SiteRole.select_by_user(self.request.user)
2463
2464 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002465 obj = SiteRole(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002466 obj.caller = request.user
2467 if obj.can_update(request.user):
2468 return super(SiteRoleList, self).create(request, *args, **kwargs)
2469 else:
Scott Baker08898c12014-10-29 23:41:11 -07002470 raise Exception("failed obj.can_update")
2471
2472 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
2473 if (ret.status_code%100 != 200):
2474 raise Exception(ret.data)
2475
2476 return ret
2477
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002478
2479class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2480 queryset = SiteRole.objects.select_related().all()
2481 serializer_class = SiteRoleSerializer
2482 id_serializer_class = SiteRoleIdSerializer
2483
2484 def get_serializer_class(self):
2485 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2486 if (no_hyperlinks):
2487 return self.id_serializer_class
2488 else:
2489 return self.serializer_class
2490
2491 def get_queryset(self):
2492 return SiteRole.select_by_user(self.request.user)
2493
2494 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2495
2496 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2497
2498
2499
2500class SliceCredentialList(generics.ListCreateAPIView):
2501 queryset = SliceCredential.objects.select_related().all()
2502 serializer_class = SliceCredentialSerializer
2503 id_serializer_class = SliceCredentialIdSerializer
2504 filter_backends = (filters.DjangoFilterBackend,)
2505 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
2506
2507 def get_serializer_class(self):
2508 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2509 if (no_hyperlinks):
2510 return self.id_serializer_class
2511 else:
2512 return self.serializer_class
2513
2514 def get_queryset(self):
2515 return SliceCredential.select_by_user(self.request.user)
2516
2517 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002518 obj = SliceCredential(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002519 obj.caller = request.user
2520 if obj.can_update(request.user):
2521 return super(SliceCredentialList, self).create(request, *args, **kwargs)
2522 else:
Scott Baker08898c12014-10-29 23:41:11 -07002523 raise Exception("failed obj.can_update")
2524
2525 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
2526 if (ret.status_code%100 != 200):
2527 raise Exception(ret.data)
2528
2529 return ret
2530
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002531
2532class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2533 queryset = SliceCredential.objects.select_related().all()
2534 serializer_class = SliceCredentialSerializer
2535 id_serializer_class = SliceCredentialIdSerializer
2536
2537 def get_serializer_class(self):
2538 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2539 if (no_hyperlinks):
2540 return self.id_serializer_class
2541 else:
2542 return self.serializer_class
2543
2544 def get_queryset(self):
2545 return SliceCredential.select_by_user(self.request.user)
2546
2547 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2548
2549 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2550
2551
2552
2553class SliverList(generics.ListCreateAPIView):
2554 queryset = Sliver.objects.select_related().all()
2555 serializer_class = SliverSerializer
2556 id_serializer_class = SliverIdSerializer
2557 filter_backends = (filters.DjangoFilterBackend,)
2558 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',)
2559
2560 def get_serializer_class(self):
2561 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2562 if (no_hyperlinks):
2563 return self.id_serializer_class
2564 else:
2565 return self.serializer_class
2566
2567 def get_queryset(self):
2568 return Sliver.select_by_user(self.request.user)
2569
2570 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002571 obj = Sliver(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002572 obj.caller = request.user
2573 if obj.can_update(request.user):
2574 return super(SliverList, self).create(request, *args, **kwargs)
2575 else:
Scott Baker08898c12014-10-29 23:41:11 -07002576 raise Exception("failed obj.can_update")
2577
2578 ret = super(SliverList, self).create(request, *args, **kwargs)
2579 if (ret.status_code%100 != 200):
2580 raise Exception(ret.data)
2581
2582 return ret
2583
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002584
2585class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2586 queryset = Sliver.objects.select_related().all()
2587 serializer_class = SliverSerializer
2588 id_serializer_class = SliverIdSerializer
2589
2590 def get_serializer_class(self):
2591 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2592 if (no_hyperlinks):
2593 return self.id_serializer_class
2594 else:
2595 return self.serializer_class
2596
2597 def get_queryset(self):
2598 return Sliver.select_by_user(self.request.user)
2599
2600 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2601
2602 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2603
2604
2605
2606class NodeList(generics.ListCreateAPIView):
2607 queryset = Node.objects.select_related().all()
2608 serializer_class = NodeSerializer
2609 id_serializer_class = NodeIdSerializer
2610 filter_backends = (filters.DjangoFilterBackend,)
2611 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
2612
2613 def get_serializer_class(self):
2614 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2615 if (no_hyperlinks):
2616 return self.id_serializer_class
2617 else:
2618 return self.serializer_class
2619
2620 def get_queryset(self):
2621 return Node.select_by_user(self.request.user)
2622
2623 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002624 obj = Node(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002625 obj.caller = request.user
2626 if obj.can_update(request.user):
2627 return super(NodeList, self).create(request, *args, **kwargs)
2628 else:
Scott Baker08898c12014-10-29 23:41:11 -07002629 raise Exception("failed obj.can_update")
2630
2631 ret = super(NodeList, self).create(request, *args, **kwargs)
2632 if (ret.status_code%100 != 200):
2633 raise Exception(ret.data)
2634
2635 return ret
2636
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002637
2638class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2639 queryset = Node.objects.select_related().all()
2640 serializer_class = NodeSerializer
2641 id_serializer_class = NodeIdSerializer
2642
2643 def get_serializer_class(self):
2644 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2645 if (no_hyperlinks):
2646 return self.id_serializer_class
2647 else:
2648 return self.serializer_class
2649
2650 def get_queryset(self):
2651 return Node.select_by_user(self.request.user)
2652
2653 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2654
2655 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2656
2657
2658
2659class DashboardViewList(generics.ListCreateAPIView):
2660 queryset = DashboardView.objects.select_related().all()
2661 serializer_class = DashboardViewSerializer
2662 id_serializer_class = DashboardViewIdSerializer
2663 filter_backends = (filters.DjangoFilterBackend,)
2664 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
2665
2666 def get_serializer_class(self):
2667 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2668 if (no_hyperlinks):
2669 return self.id_serializer_class
2670 else:
2671 return self.serializer_class
2672
2673 def get_queryset(self):
2674 return DashboardView.select_by_user(self.request.user)
2675
2676 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002677 obj = DashboardView(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002678 obj.caller = request.user
2679 if obj.can_update(request.user):
2680 return super(DashboardViewList, self).create(request, *args, **kwargs)
2681 else:
Scott Baker08898c12014-10-29 23:41:11 -07002682 raise Exception("failed obj.can_update")
2683
2684 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
2685 if (ret.status_code%100 != 200):
2686 raise Exception(ret.data)
2687
2688 return ret
2689
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002690
2691class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2692 queryset = DashboardView.objects.select_related().all()
2693 serializer_class = DashboardViewSerializer
2694 id_serializer_class = DashboardViewIdSerializer
2695
2696 def get_serializer_class(self):
2697 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2698 if (no_hyperlinks):
2699 return self.id_serializer_class
2700 else:
2701 return self.serializer_class
2702
2703 def get_queryset(self):
2704 return DashboardView.select_by_user(self.request.user)
2705
2706 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2707
2708 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2709
2710
2711
Sapan Bhatia18b779c2014-11-11 23:05:53 -05002712class ImageDeploymentList(generics.ListCreateAPIView):
2713 queryset = ImageDeployment.objects.select_related().all()
2714 serializer_class = ImageDeploymentSerializer
2715 id_serializer_class = ImageDeploymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002716 filter_backends = (filters.DjangoFilterBackend,)
2717 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
2718
2719 def get_serializer_class(self):
2720 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2721 if (no_hyperlinks):
2722 return self.id_serializer_class
2723 else:
2724 return self.serializer_class
2725
2726 def get_queryset(self):
Sapan Bhatia18b779c2014-11-11 23:05:53 -05002727 return ImageDeployment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002728
2729 def create(self, request, *args, **kwargs):
Sapan Bhatia18b779c2014-11-11 23:05:53 -05002730 obj = ImageDeployment(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002731 obj.caller = request.user
2732 if obj.can_update(request.user):
Sapan Bhatia18b779c2014-11-11 23:05:53 -05002733 return super(ImageDeploymentList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002734 else:
Scott Baker08898c12014-10-29 23:41:11 -07002735 raise Exception("failed obj.can_update")
2736
Sapan Bhatia18b779c2014-11-11 23:05:53 -05002737 ret = super(ImageDeploymentList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07002738 if (ret.status_code%100 != 200):
2739 raise Exception(ret.data)
2740
2741 return ret
2742
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002743
Sapan Bhatia18b779c2014-11-11 23:05:53 -05002744class ImageDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2745 queryset = ImageDeployment.objects.select_related().all()
2746 serializer_class = ImageDeploymentSerializer
2747 id_serializer_class = ImageDeploymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002748
2749 def get_serializer_class(self):
2750 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2751 if (no_hyperlinks):
2752 return self.id_serializer_class
2753 else:
2754 return self.serializer_class
2755
2756 def get_queryset(self):
Sapan Bhatia18b779c2014-11-11 23:05:53 -05002757 return ImageDeployment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002758
2759 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2760
2761 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2762
2763
2764
2765class ReservedResourceList(generics.ListCreateAPIView):
2766 queryset = ReservedResource.objects.select_related().all()
2767 serializer_class = ReservedResourceSerializer
2768 id_serializer_class = ReservedResourceIdSerializer
2769 filter_backends = (filters.DjangoFilterBackend,)
2770 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
2771
2772 def get_serializer_class(self):
2773 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2774 if (no_hyperlinks):
2775 return self.id_serializer_class
2776 else:
2777 return self.serializer_class
2778
2779 def get_queryset(self):
2780 return ReservedResource.select_by_user(self.request.user)
2781
2782 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002783 obj = ReservedResource(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002784 obj.caller = request.user
2785 if obj.can_update(request.user):
2786 return super(ReservedResourceList, self).create(request, *args, **kwargs)
2787 else:
Scott Baker08898c12014-10-29 23:41:11 -07002788 raise Exception("failed obj.can_update")
2789
2790 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
2791 if (ret.status_code%100 != 200):
2792 raise Exception(ret.data)
2793
2794 return ret
2795
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002796
2797class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2798 queryset = ReservedResource.objects.select_related().all()
2799 serializer_class = ReservedResourceSerializer
2800 id_serializer_class = ReservedResourceIdSerializer
2801
2802 def get_serializer_class(self):
2803 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2804 if (no_hyperlinks):
2805 return self.id_serializer_class
2806 else:
2807 return self.serializer_class
2808
2809 def get_queryset(self):
2810 return ReservedResource.select_by_user(self.request.user)
2811
2812 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2813
2814 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2815
2816
2817
2818class NetworkSliceList(generics.ListCreateAPIView):
2819 queryset = NetworkSlice.objects.select_related().all()
2820 serializer_class = NetworkSliceSerializer
2821 id_serializer_class = NetworkSliceIdSerializer
2822 filter_backends = (filters.DjangoFilterBackend,)
2823 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
2824
2825 def get_serializer_class(self):
2826 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2827 if (no_hyperlinks):
2828 return self.id_serializer_class
2829 else:
2830 return self.serializer_class
2831
2832 def get_queryset(self):
2833 return NetworkSlice.select_by_user(self.request.user)
2834
2835 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002836 obj = NetworkSlice(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002837 obj.caller = request.user
2838 if obj.can_update(request.user):
2839 return super(NetworkSliceList, self).create(request, *args, **kwargs)
2840 else:
Scott Baker08898c12014-10-29 23:41:11 -07002841 raise Exception("failed obj.can_update")
2842
2843 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
2844 if (ret.status_code%100 != 200):
2845 raise Exception(ret.data)
2846
2847 return ret
2848
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002849
2850class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2851 queryset = NetworkSlice.objects.select_related().all()
2852 serializer_class = NetworkSliceSerializer
2853 id_serializer_class = NetworkSliceIdSerializer
2854
2855 def get_serializer_class(self):
2856 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2857 if (no_hyperlinks):
2858 return self.id_serializer_class
2859 else:
2860 return self.serializer_class
2861
2862 def get_queryset(self):
2863 return NetworkSlice.select_by_user(self.request.user)
2864
2865 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2866
2867 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2868
2869
2870
2871class UserDashboardViewList(generics.ListCreateAPIView):
2872 queryset = UserDashboardView.objects.select_related().all()
2873 serializer_class = UserDashboardViewSerializer
2874 id_serializer_class = UserDashboardViewIdSerializer
2875 filter_backends = (filters.DjangoFilterBackend,)
2876 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
2877
2878 def get_serializer_class(self):
2879 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2880 if (no_hyperlinks):
2881 return self.id_serializer_class
2882 else:
2883 return self.serializer_class
2884
2885 def get_queryset(self):
2886 return UserDashboardView.select_by_user(self.request.user)
2887
2888 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002889 obj = UserDashboardView(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002890 obj.caller = request.user
2891 if obj.can_update(request.user):
2892 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
2893 else:
Scott Baker08898c12014-10-29 23:41:11 -07002894 raise Exception("failed obj.can_update")
2895
2896 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
2897 if (ret.status_code%100 != 200):
2898 raise Exception(ret.data)
2899
2900 return ret
2901
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002902
2903class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2904 queryset = UserDashboardView.objects.select_related().all()
2905 serializer_class = UserDashboardViewSerializer
2906 id_serializer_class = UserDashboardViewIdSerializer
2907
2908 def get_serializer_class(self):
2909 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2910 if (no_hyperlinks):
2911 return self.id_serializer_class
2912 else:
2913 return self.serializer_class
2914
2915 def get_queryset(self):
2916 return UserDashboardView.select_by_user(self.request.user)
2917
2918 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2919
2920 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2921
2922
2923
2924class PlanetStackPrivilegeList(generics.ListCreateAPIView):
2925 queryset = PlanetStackPrivilege.objects.select_related().all()
2926 serializer_class = PlanetStackPrivilegeSerializer
2927 id_serializer_class = PlanetStackPrivilegeIdSerializer
2928 filter_backends = (filters.DjangoFilterBackend,)
2929 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
2930
2931 def get_serializer_class(self):
2932 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2933 if (no_hyperlinks):
2934 return self.id_serializer_class
2935 else:
2936 return self.serializer_class
2937
2938 def get_queryset(self):
2939 return PlanetStackPrivilege.select_by_user(self.request.user)
2940
2941 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002942 obj = PlanetStackPrivilege(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002943 obj.caller = request.user
2944 if obj.can_update(request.user):
2945 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
2946 else:
Scott Baker08898c12014-10-29 23:41:11 -07002947 raise Exception("failed obj.can_update")
2948
2949 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
2950 if (ret.status_code%100 != 200):
2951 raise Exception(ret.data)
2952
2953 return ret
2954
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002955
2956class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2957 queryset = PlanetStackPrivilege.objects.select_related().all()
2958 serializer_class = PlanetStackPrivilegeSerializer
2959 id_serializer_class = PlanetStackPrivilegeIdSerializer
2960
2961 def get_serializer_class(self):
2962 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2963 if (no_hyperlinks):
2964 return self.id_serializer_class
2965 else:
2966 return self.serializer_class
2967
2968 def get_queryset(self):
2969 return PlanetStackPrivilege.select_by_user(self.request.user)
2970
2971 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2972
2973 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2974
2975
2976
2977class UserList(generics.ListCreateAPIView):
2978 queryset = User.objects.select_related().all()
2979 serializer_class = UserSerializer
2980 id_serializer_class = UserIdSerializer
2981 filter_backends = (filters.DjangoFilterBackend,)
2982 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',)
2983
2984 def get_serializer_class(self):
2985 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2986 if (no_hyperlinks):
2987 return self.id_serializer_class
2988 else:
2989 return self.serializer_class
2990
2991 def get_queryset(self):
2992 return User.select_by_user(self.request.user)
2993
2994 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07002995 obj = User(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002996 obj.caller = request.user
2997 if obj.can_update(request.user):
2998 return super(UserList, self).create(request, *args, **kwargs)
2999 else:
Scott Baker08898c12014-10-29 23:41:11 -07003000 raise Exception("failed obj.can_update")
3001
3002 ret = super(UserList, self).create(request, *args, **kwargs)
3003 if (ret.status_code%100 != 200):
3004 raise Exception(ret.data)
3005
3006 return ret
3007
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003008
3009class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3010 queryset = User.objects.select_related().all()
3011 serializer_class = UserSerializer
3012 id_serializer_class = UserIdSerializer
3013
3014 def get_serializer_class(self):
3015 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3016 if (no_hyperlinks):
3017 return self.id_serializer_class
3018 else:
3019 return self.serializer_class
3020
3021 def get_queryset(self):
3022 return User.select_by_user(self.request.user)
3023
3024 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3025
3026 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3027
3028
3029
3030class DeploymentList(generics.ListCreateAPIView):
3031 queryset = Deployment.objects.select_related().all()
3032 serializer_class = DeploymentSerializer
3033 id_serializer_class = DeploymentIdSerializer
3034 filter_backends = (filters.DjangoFilterBackend,)
3035 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',)
3036
3037 def get_serializer_class(self):
3038 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3039 if (no_hyperlinks):
3040 return self.id_serializer_class
3041 else:
3042 return self.serializer_class
3043
3044 def get_queryset(self):
3045 return Deployment.select_by_user(self.request.user)
3046
3047 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003048 obj = Deployment(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003049 obj.caller = request.user
3050 if obj.can_update(request.user):
3051 return super(DeploymentList, self).create(request, *args, **kwargs)
3052 else:
Scott Baker08898c12014-10-29 23:41:11 -07003053 raise Exception("failed obj.can_update")
3054
3055 ret = super(DeploymentList, self).create(request, *args, **kwargs)
3056 if (ret.status_code%100 != 200):
3057 raise Exception(ret.data)
3058
3059 return ret
3060
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003061
3062class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3063 queryset = Deployment.objects.select_related().all()
3064 serializer_class = DeploymentSerializer
3065 id_serializer_class = DeploymentIdSerializer
3066
3067 def get_serializer_class(self):
3068 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3069 if (no_hyperlinks):
3070 return self.id_serializer_class
3071 else:
3072 return self.serializer_class
3073
3074 def get_queryset(self):
3075 return Deployment.select_by_user(self.request.user)
3076
3077 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3078
3079 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3080
3081
3082
3083class ReservationList(generics.ListCreateAPIView):
3084 queryset = Reservation.objects.select_related().all()
3085 serializer_class = ReservationSerializer
3086 id_serializer_class = ReservationIdSerializer
3087 filter_backends = (filters.DjangoFilterBackend,)
3088 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
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 Reservation.select_by_user(self.request.user)
3099
3100 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003101 obj = Reservation(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003102 obj.caller = request.user
3103 if obj.can_update(request.user):
3104 return super(ReservationList, self).create(request, *args, **kwargs)
3105 else:
Scott Baker08898c12014-10-29 23:41:11 -07003106 raise Exception("failed obj.can_update")
3107
3108 ret = super(ReservationList, self).create(request, *args, **kwargs)
3109 if (ret.status_code%100 != 200):
3110 raise Exception(ret.data)
3111
3112 return ret
3113
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003114
3115class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3116 queryset = Reservation.objects.select_related().all()
3117 serializer_class = ReservationSerializer
3118 id_serializer_class = ReservationIdSerializer
3119
3120 def get_serializer_class(self):
3121 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3122 if (no_hyperlinks):
3123 return self.id_serializer_class
3124 else:
3125 return self.serializer_class
3126
3127 def get_queryset(self):
3128 return Reservation.select_by_user(self.request.user)
3129
3130 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3131
3132 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3133
3134
3135
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05003136class SliceDeploymentList(generics.ListCreateAPIView):
3137 queryset = SliceDeployment.objects.select_related().all()
3138 serializer_class = SliceDeploymentSerializer
3139 id_serializer_class = SliceDeploymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003140 filter_backends = (filters.DjangoFilterBackend,)
3141 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
3142
3143 def get_serializer_class(self):
3144 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3145 if (no_hyperlinks):
3146 return self.id_serializer_class
3147 else:
3148 return self.serializer_class
3149
3150 def get_queryset(self):
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05003151 return SliceDeployment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003152
3153 def create(self, request, *args, **kwargs):
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05003154 obj = SliceDeployment(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003155 obj.caller = request.user
3156 if obj.can_update(request.user):
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05003157 return super(SliceDeploymentList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003158 else:
Scott Baker08898c12014-10-29 23:41:11 -07003159 raise Exception("failed obj.can_update")
3160
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05003161 ret = super(SliceDeploymentList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003162 if (ret.status_code%100 != 200):
3163 raise Exception(ret.data)
3164
3165 return ret
3166
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003167
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05003168class SliceDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3169 queryset = SliceDeployment.objects.select_related().all()
3170 serializer_class = SliceDeploymentSerializer
3171 id_serializer_class = SliceDeploymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003172
3173 def get_serializer_class(self):
3174 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3175 if (no_hyperlinks):
3176 return self.id_serializer_class
3177 else:
3178 return self.serializer_class
3179
3180 def get_queryset(self):
Sapan Bhatia7a8b7e92014-11-11 21:43:31 -05003181 return SliceDeployment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003182
3183 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3184
3185 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3186
3187
3188
3189class SitePrivilegeList(generics.ListCreateAPIView):
3190 queryset = SitePrivilege.objects.select_related().all()
3191 serializer_class = SitePrivilegeSerializer
3192 id_serializer_class = SitePrivilegeIdSerializer
3193 filter_backends = (filters.DjangoFilterBackend,)
3194 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
3195
3196 def get_serializer_class(self):
3197 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3198 if (no_hyperlinks):
3199 return self.id_serializer_class
3200 else:
3201 return self.serializer_class
3202
3203 def get_queryset(self):
3204 return SitePrivilege.select_by_user(self.request.user)
3205
3206 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003207 obj = SitePrivilege(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003208 obj.caller = request.user
3209 if obj.can_update(request.user):
3210 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
3211 else:
Scott Baker08898c12014-10-29 23:41:11 -07003212 raise Exception("failed obj.can_update")
3213
3214 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
3215 if (ret.status_code%100 != 200):
3216 raise Exception(ret.data)
3217
3218 return ret
3219
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003220
3221class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3222 queryset = SitePrivilege.objects.select_related().all()
3223 serializer_class = SitePrivilegeSerializer
3224 id_serializer_class = SitePrivilegeIdSerializer
3225
3226 def get_serializer_class(self):
3227 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3228 if (no_hyperlinks):
3229 return self.id_serializer_class
3230 else:
3231 return self.serializer_class
3232
3233 def get_queryset(self):
3234 return SitePrivilege.select_by_user(self.request.user)
3235
3236 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3237
3238 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3239
3240
3241
3242class PlanetStackList(generics.ListCreateAPIView):
3243 queryset = PlanetStack.objects.select_related().all()
3244 serializer_class = PlanetStackSerializer
3245 id_serializer_class = PlanetStackIdSerializer
3246 filter_backends = (filters.DjangoFilterBackend,)
3247 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
3248
3249 def get_serializer_class(self):
3250 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3251 if (no_hyperlinks):
3252 return self.id_serializer_class
3253 else:
3254 return self.serializer_class
3255
3256 def get_queryset(self):
3257 return PlanetStack.select_by_user(self.request.user)
3258
3259 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003260 obj = PlanetStack(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003261 obj.caller = request.user
3262 if obj.can_update(request.user):
3263 return super(PlanetStackList, self).create(request, *args, **kwargs)
3264 else:
Scott Baker08898c12014-10-29 23:41:11 -07003265 raise Exception("failed obj.can_update")
3266
3267 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
3268 if (ret.status_code%100 != 200):
3269 raise Exception(ret.data)
3270
3271 return ret
3272
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003273
3274class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3275 queryset = PlanetStack.objects.select_related().all()
3276 serializer_class = PlanetStackSerializer
3277 id_serializer_class = PlanetStackIdSerializer
3278
3279 def get_serializer_class(self):
3280 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3281 if (no_hyperlinks):
3282 return self.id_serializer_class
3283 else:
3284 return self.serializer_class
3285
3286 def get_queryset(self):
3287 return PlanetStack.select_by_user(self.request.user)
3288
3289 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3290
3291 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3292
3293
3294
Sapan Bhatia84ba65d2014-11-11 21:44:35 -05003295class UserDeploymentList(generics.ListCreateAPIView):
3296 queryset = UserDeployment.objects.select_related().all()
3297 serializer_class = UserDeploymentSerializer
3298 id_serializer_class = UserDeploymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003299 filter_backends = (filters.DjangoFilterBackend,)
3300 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
3301
3302 def get_serializer_class(self):
3303 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3304 if (no_hyperlinks):
3305 return self.id_serializer_class
3306 else:
3307 return self.serializer_class
3308
3309 def get_queryset(self):
Sapan Bhatia84ba65d2014-11-11 21:44:35 -05003310 return UserDeployment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003311
3312 def create(self, request, *args, **kwargs):
Sapan Bhatia84ba65d2014-11-11 21:44:35 -05003313 obj = UserDeployment(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003314 obj.caller = request.user
3315 if obj.can_update(request.user):
Sapan Bhatia84ba65d2014-11-11 21:44:35 -05003316 return super(UserDeploymentList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003317 else:
Scott Baker08898c12014-10-29 23:41:11 -07003318 raise Exception("failed obj.can_update")
3319
Sapan Bhatia84ba65d2014-11-11 21:44:35 -05003320 ret = super(UserDeploymentList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003321 if (ret.status_code%100 != 200):
3322 raise Exception(ret.data)
3323
3324 return ret
3325
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003326
Sapan Bhatia84ba65d2014-11-11 21:44:35 -05003327class UserDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3328 queryset = UserDeployment.objects.select_related().all()
3329 serializer_class = UserDeploymentSerializer
3330 id_serializer_class = UserDeploymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003331
3332 def get_serializer_class(self):
3333 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3334 if (no_hyperlinks):
3335 return self.id_serializer_class
3336 else:
3337 return self.serializer_class
3338
3339 def get_queryset(self):
Sapan Bhatia84ba65d2014-11-11 21:44:35 -05003340 return UserDeployment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003341
3342 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3343
3344 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3345
3346
3347
3348class AccountList(generics.ListCreateAPIView):
3349 queryset = Account.objects.select_related().all()
3350 serializer_class = AccountSerializer
3351 id_serializer_class = AccountIdSerializer
3352 filter_backends = (filters.DjangoFilterBackend,)
3353 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
3354
3355 def get_serializer_class(self):
3356 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3357 if (no_hyperlinks):
3358 return self.id_serializer_class
3359 else:
3360 return self.serializer_class
3361
3362 def get_queryset(self):
3363 return Account.select_by_user(self.request.user)
3364
3365 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003366 obj = Account(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003367 obj.caller = request.user
3368 if obj.can_update(request.user):
3369 return super(AccountList, 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(AccountList, 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 AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3381 queryset = Account.objects.select_related().all()
3382 serializer_class = AccountSerializer
3383 id_serializer_class = AccountIdSerializer
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 Account.select_by_user(self.request.user)
3394
3395 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3396
3397 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3398
3399
3400
3401class NetworkParameterTypeList(generics.ListCreateAPIView):
3402 queryset = NetworkParameterType.objects.select_related().all()
3403 serializer_class = NetworkParameterTypeSerializer
3404 id_serializer_class = NetworkParameterTypeIdSerializer
3405 filter_backends = (filters.DjangoFilterBackend,)
3406 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
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 NetworkParameterType.select_by_user(self.request.user)
3417
3418 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003419 obj = NetworkParameterType(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003420 obj.caller = request.user
3421 if obj.can_update(request.user):
3422 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
3423 else:
Scott Baker08898c12014-10-29 23:41:11 -07003424 raise Exception("failed obj.can_update")
3425
3426 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
3427 if (ret.status_code%100 != 200):
3428 raise Exception(ret.data)
3429
3430 return ret
3431
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003432
3433class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3434 queryset = NetworkParameterType.objects.select_related().all()
3435 serializer_class = NetworkParameterTypeSerializer
3436 id_serializer_class = NetworkParameterTypeIdSerializer
3437
3438 def get_serializer_class(self):
3439 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3440 if (no_hyperlinks):
3441 return self.id_serializer_class
3442 else:
3443 return self.serializer_class
3444
3445 def get_queryset(self):
3446 return NetworkParameterType.select_by_user(self.request.user)
3447
3448 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3449
3450 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3451
3452
3453
3454class SiteCredentialList(generics.ListCreateAPIView):
3455 queryset = SiteCredential.objects.select_related().all()
3456 serializer_class = SiteCredentialSerializer
3457 id_serializer_class = SiteCredentialIdSerializer
3458 filter_backends = (filters.DjangoFilterBackend,)
3459 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
3460
3461 def get_serializer_class(self):
3462 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3463 if (no_hyperlinks):
3464 return self.id_serializer_class
3465 else:
3466 return self.serializer_class
3467
3468 def get_queryset(self):
3469 return SiteCredential.select_by_user(self.request.user)
3470
3471 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003472 obj = SiteCredential(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003473 obj.caller = request.user
3474 if obj.can_update(request.user):
3475 return super(SiteCredentialList, self).create(request, *args, **kwargs)
3476 else:
Scott Baker08898c12014-10-29 23:41:11 -07003477 raise Exception("failed obj.can_update")
3478
3479 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
3480 if (ret.status_code%100 != 200):
3481 raise Exception(ret.data)
3482
3483 return ret
3484
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003485
3486class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3487 queryset = SiteCredential.objects.select_related().all()
3488 serializer_class = SiteCredentialSerializer
3489 id_serializer_class = SiteCredentialIdSerializer
3490
3491 def get_serializer_class(self):
3492 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3493 if (no_hyperlinks):
3494 return self.id_serializer_class
3495 else:
3496 return self.serializer_class
3497
3498 def get_queryset(self):
3499 return SiteCredential.select_by_user(self.request.user)
3500
3501 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3502
3503 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3504
3505
3506
3507class DeploymentPrivilegeList(generics.ListCreateAPIView):
3508 queryset = DeploymentPrivilege.objects.select_related().all()
3509 serializer_class = DeploymentPrivilegeSerializer
3510 id_serializer_class = DeploymentPrivilegeIdSerializer
3511 filter_backends = (filters.DjangoFilterBackend,)
3512 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
3513
3514 def get_serializer_class(self):
3515 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3516 if (no_hyperlinks):
3517 return self.id_serializer_class
3518 else:
3519 return self.serializer_class
3520
3521 def get_queryset(self):
3522 return DeploymentPrivilege.select_by_user(self.request.user)
3523
3524 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003525 obj = DeploymentPrivilege(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003526 obj.caller = request.user
3527 if obj.can_update(request.user):
3528 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
3529 else:
Scott Baker08898c12014-10-29 23:41:11 -07003530 raise Exception("failed obj.can_update")
3531
3532 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
3533 if (ret.status_code%100 != 200):
3534 raise Exception(ret.data)
3535
3536 return ret
3537
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003538
3539class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3540 queryset = DeploymentPrivilege.objects.select_related().all()
3541 serializer_class = DeploymentPrivilegeSerializer
3542 id_serializer_class = DeploymentPrivilegeIdSerializer
3543
3544 def get_serializer_class(self):
3545 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3546 if (no_hyperlinks):
3547 return self.id_serializer_class
3548 else:
3549 return self.serializer_class
3550
3551 def get_queryset(self):
3552 return DeploymentPrivilege.select_by_user(self.request.user)
3553
3554 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3555
3556 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3557
3558
3559
3560class DeploymentRoleList(generics.ListCreateAPIView):
3561 queryset = DeploymentRole.objects.select_related().all()
3562 serializer_class = DeploymentRoleSerializer
3563 id_serializer_class = DeploymentRoleIdSerializer
3564 filter_backends = (filters.DjangoFilterBackend,)
3565 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3566
3567 def get_serializer_class(self):
3568 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3569 if (no_hyperlinks):
3570 return self.id_serializer_class
3571 else:
3572 return self.serializer_class
3573
3574 def get_queryset(self):
3575 return DeploymentRole.select_by_user(self.request.user)
3576
3577 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003578 obj = DeploymentRole(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003579 obj.caller = request.user
3580 if obj.can_update(request.user):
3581 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
3582 else:
Scott Baker08898c12014-10-29 23:41:11 -07003583 raise Exception("failed obj.can_update")
3584
3585 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
3586 if (ret.status_code%100 != 200):
3587 raise Exception(ret.data)
3588
3589 return ret
3590
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003591
3592class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3593 queryset = DeploymentRole.objects.select_related().all()
3594 serializer_class = DeploymentRoleSerializer
3595 id_serializer_class = DeploymentRoleIdSerializer
3596
3597 def get_serializer_class(self):
3598 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3599 if (no_hyperlinks):
3600 return self.id_serializer_class
3601 else:
3602 return self.serializer_class
3603
3604 def get_queryset(self):
3605 return DeploymentRole.select_by_user(self.request.user)
3606
3607 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3608
3609 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3610
3611
3612
3613class UserCredentialList(generics.ListCreateAPIView):
3614 queryset = UserCredential.objects.select_related().all()
3615 serializer_class = UserCredentialSerializer
3616 id_serializer_class = UserCredentialIdSerializer
3617 filter_backends = (filters.DjangoFilterBackend,)
3618 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
3619
3620 def get_serializer_class(self):
3621 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3622 if (no_hyperlinks):
3623 return self.id_serializer_class
3624 else:
3625 return self.serializer_class
3626
3627 def get_queryset(self):
3628 return UserCredential.select_by_user(self.request.user)
3629
3630 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003631 obj = UserCredential(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003632 obj.caller = request.user
3633 if obj.can_update(request.user):
3634 return super(UserCredentialList, self).create(request, *args, **kwargs)
3635 else:
Scott Baker08898c12014-10-29 23:41:11 -07003636 raise Exception("failed obj.can_update")
3637
3638 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
3639 if (ret.status_code%100 != 200):
3640 raise Exception(ret.data)
3641
3642 return ret
3643
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003644
3645class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3646 queryset = UserCredential.objects.select_related().all()
3647 serializer_class = UserCredentialSerializer
3648 id_serializer_class = UserCredentialIdSerializer
3649
3650 def get_serializer_class(self):
3651 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3652 if (no_hyperlinks):
3653 return self.id_serializer_class
3654 else:
3655 return self.serializer_class
3656
3657 def get_queryset(self):
3658 return UserCredential.select_by_user(self.request.user)
3659
3660 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3661
3662 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3663
3664
3665
Sapan Bhatia6d21da32014-11-11 21:41:12 -05003666class SiteDeploymentList(generics.ListCreateAPIView):
3667 queryset = SiteDeployment.objects.select_related().all()
3668 serializer_class = SiteDeploymentSerializer
3669 id_serializer_class = SiteDeploymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003670 filter_backends = (filters.DjangoFilterBackend,)
3671 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
3672
3673 def get_serializer_class(self):
3674 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3675 if (no_hyperlinks):
3676 return self.id_serializer_class
3677 else:
3678 return self.serializer_class
3679
3680 def get_queryset(self):
Sapan Bhatia6d21da32014-11-11 21:41:12 -05003681 return SiteDeployment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003682
3683 def create(self, request, *args, **kwargs):
Sapan Bhatia6d21da32014-11-11 21:41:12 -05003684 obj = SiteDeployment(**request.DATA)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003685 obj.caller = request.user
3686 if obj.can_update(request.user):
Sapan Bhatia6d21da32014-11-11 21:41:12 -05003687 return super(SiteDeploymentList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003688 else:
Scott Baker08898c12014-10-29 23:41:11 -07003689 raise Exception("failed obj.can_update")
3690
Sapan Bhatia6d21da32014-11-11 21:41:12 -05003691 ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003692 if (ret.status_code%100 != 200):
3693 raise Exception(ret.data)
3694
3695 return ret
3696
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003697
Sapan Bhatia6d21da32014-11-11 21:41:12 -05003698class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3699 queryset = SiteDeployment.objects.select_related().all()
3700 serializer_class = SiteDeploymentSerializer
3701 id_serializer_class = SiteDeploymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003702
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):
Sapan Bhatia6d21da32014-11-11 21:41:12 -05003711 return SiteDeployment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003712
3713 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3714
3715 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003716
3717
3718
Scott Baker0caeaf02014-06-19 11:12:55 -07003719class SliceTagList(generics.ListCreateAPIView):
3720 queryset = SliceTag.objects.select_related().all()
3721 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003722 id_serializer_class = SliceTagIdSerializer
3723 filter_backends = (filters.DjangoFilterBackend,)
3724 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
3725
3726 def get_serializer_class(self):
3727 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3728 if (no_hyperlinks):
3729 return self.id_serializer_class
3730 else:
3731 return self.serializer_class
3732
Scott Baker0caeaf02014-06-19 11:12:55 -07003733 def get_queryset(self):
3734 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003735
Scott Baker0caeaf02014-06-19 11:12:55 -07003736 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003737 obj = SliceTag(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07003738 obj.caller = request.user
3739 if obj.can_update(request.user):
3740 return super(SliceTagList, self).create(request, *args, **kwargs)
3741 else:
Scott Baker08898c12014-10-29 23:41:11 -07003742 raise Exception("failed obj.can_update")
3743
3744 ret = super(SliceTagList, self).create(request, *args, **kwargs)
3745 if (ret.status_code%100 != 200):
3746 raise Exception(ret.data)
3747
3748 return ret
3749
Scott Baker0caeaf02014-06-19 11:12:55 -07003750
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003751class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003752 queryset = SliceTag.objects.select_related().all()
3753 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003754 id_serializer_class = SliceTagIdSerializer
3755
3756 def get_serializer_class(self):
3757 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3758 if (no_hyperlinks):
3759 return self.id_serializer_class
3760 else:
3761 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003762
3763 def get_queryset(self):
3764 return SliceTag.select_by_user(self.request.user)
3765
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003766 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003767
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003768 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003769
3770
3771
Scott Baker0caeaf02014-06-19 11:12:55 -07003772class NetworkTemplateList(generics.ListCreateAPIView):
3773 queryset = NetworkTemplate.objects.select_related().all()
3774 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003775 id_serializer_class = NetworkTemplateIdSerializer
3776 filter_backends = (filters.DjangoFilterBackend,)
3777 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
3778
3779 def get_serializer_class(self):
3780 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3781 if (no_hyperlinks):
3782 return self.id_serializer_class
3783 else:
3784 return self.serializer_class
3785
Scott Baker0caeaf02014-06-19 11:12:55 -07003786 def get_queryset(self):
3787 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003788
Scott Baker0caeaf02014-06-19 11:12:55 -07003789 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003790 obj = NetworkTemplate(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07003791 obj.caller = request.user
3792 if obj.can_update(request.user):
3793 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
3794 else:
Scott Baker08898c12014-10-29 23:41:11 -07003795 raise Exception("failed obj.can_update")
3796
3797 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
3798 if (ret.status_code%100 != 200):
3799 raise Exception(ret.data)
3800
3801 return ret
3802
Scott Baker0caeaf02014-06-19 11:12:55 -07003803
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003804class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003805 queryset = NetworkTemplate.objects.select_related().all()
3806 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003807 id_serializer_class = NetworkTemplateIdSerializer
3808
3809 def get_serializer_class(self):
3810 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3811 if (no_hyperlinks):
3812 return self.id_serializer_class
3813 else:
3814 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003815
3816 def get_queryset(self):
3817 return NetworkTemplate.select_by_user(self.request.user)
3818
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003819 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003820
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003821 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003822
3823
3824
3825class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003826 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003827 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003828 id_serializer_class = RouterIdSerializer
3829 filter_backends = (filters.DjangoFilterBackend,)
3830 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
3831
3832 def get_serializer_class(self):
3833 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3834 if (no_hyperlinks):
3835 return self.id_serializer_class
3836 else:
3837 return self.serializer_class
3838
Scott Baker0caeaf02014-06-19 11:12:55 -07003839 def get_queryset(self):
3840 return Router.select_by_user(self.request.user)
3841
3842 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003843 obj = Router(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07003844 obj.caller = request.user
3845 if obj.can_update(request.user):
3846 return super(RouterList, self).create(request, *args, **kwargs)
3847 else:
Scott Baker08898c12014-10-29 23:41:11 -07003848 raise Exception("failed obj.can_update")
3849
3850 ret = super(RouterList, self).create(request, *args, **kwargs)
3851 if (ret.status_code%100 != 200):
3852 raise Exception(ret.data)
3853
3854 return ret
3855
Sapan Bhatiadea39432014-06-13 03:10:36 -04003856
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003857class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003858 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003859 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003860 id_serializer_class = RouterIdSerializer
3861
3862 def get_serializer_class(self):
3863 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3864 if (no_hyperlinks):
3865 return self.id_serializer_class
3866 else:
3867 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003868
3869 def get_queryset(self):
3870 return Router.select_by_user(self.request.user)
3871
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003872 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003873
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003874 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003875
3876
3877
Scott Baker0caeaf02014-06-19 11:12:55 -07003878class ServiceResourceList(generics.ListCreateAPIView):
3879 queryset = ServiceResource.objects.select_related().all()
3880 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003881 id_serializer_class = ServiceResourceIdSerializer
3882 filter_backends = (filters.DjangoFilterBackend,)
3883 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
3884
3885 def get_serializer_class(self):
3886 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3887 if (no_hyperlinks):
3888 return self.id_serializer_class
3889 else:
3890 return self.serializer_class
3891
Scott Baker0caeaf02014-06-19 11:12:55 -07003892 def get_queryset(self):
3893 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003894
Scott Baker0caeaf02014-06-19 11:12:55 -07003895 def create(self, request, *args, **kwargs):
Scott Baker08898c12014-10-29 23:41:11 -07003896 obj = ServiceResource(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07003897 obj.caller = request.user
3898 if obj.can_update(request.user):
3899 return super(ServiceResourceList, self).create(request, *args, **kwargs)
3900 else:
Scott Baker08898c12014-10-29 23:41:11 -07003901 raise Exception("failed obj.can_update")
3902
3903 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
3904 if (ret.status_code%100 != 200):
3905 raise Exception(ret.data)
3906
3907 return ret
3908
Scott Baker0caeaf02014-06-19 11:12:55 -07003909
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003910class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003911 queryset = ServiceResource.objects.select_related().all()
3912 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003913 id_serializer_class = ServiceResourceIdSerializer
3914
3915 def get_serializer_class(self):
3916 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3917 if (no_hyperlinks):
3918 return self.id_serializer_class
3919 else:
3920 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003921
3922 def get_queryset(self):
3923 return ServiceResource.select_by_user(self.request.user)
3924
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003925 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003926
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003927 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003928
3929
3930