blob: 4c2276017d8896ce1630536fca95b60bff5b5088 [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 Baker89a7b7c2014-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
Sapan Bhatiadea39432014-06-13 03:10:36 -040010
11"""
Scott Baker2bcbf372014-10-29 23:41:11 -070012 Schema of the generator object:
13 all: Set of all Model objects
14 all_if(regex): Set of Model objects that match regex
15
16 Model object:
17 plural: English plural of object name
18 camel: CamelCase version of object name
19 refs: list of references to other Model objects
20 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040021
Scott Baker2bcbf372014-10-29 23:41:11 -070022 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040023"""
24
25# Based on api_root.py
26
27@api_view(['GET'])
28def api_root(request, format=None):
29 return Response({
Scott Baker2bcbf372014-10-29 23:41:11 -070030 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
31 'images': reverse('image-list', request=request, format=format),
32 'networkparameters': reverse('networkparameter-list', request=request, format=format),
33 'sites': reverse('site-list', request=request, format=format),
34 'sliceroles': reverse('slicerole-list', request=request, format=format),
35 'tags': reverse('tag-list', request=request, format=format),
36 'invoices': reverse('invoice-list', request=request, format=format),
37 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
38 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
39 'networkslivers': reverse('networksliver-list', request=request, format=format),
40 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format),
41 'flavors': reverse('flavor-list', request=request, format=format),
42 'projects': reverse('project-list', request=request, format=format),
43 'slices': reverse('slice-list', request=request, format=format),
44 'networks': reverse('network-list', request=request, format=format),
45 'services': reverse('service-list', request=request, format=format),
46 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
47 'payments': reverse('payment-list', request=request, format=format),
48 'charges': reverse('charge-list', request=request, format=format),
49 'roles': reverse('role-list', request=request, format=format),
50 'usableobjects': reverse('usableobject-list', request=request, format=format),
51 'siteroles': reverse('siterole-list', request=request, format=format),
52 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
53 'slivers': reverse('sliver-list', request=request, format=format),
54 'nodes': reverse('node-list', request=request, format=format),
55 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
56 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
57 'reservedresources': reverse('reservedresource-list', request=request, format=format),
58 'networkslices': reverse('networkslice-list', request=request, format=format),
59 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
60 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
61 'users': reverse('user-list', request=request, format=format),
62 'deployments': reverse('deployment-list', request=request, format=format),
63 'reservations': reverse('reservation-list', request=request, format=format),
64 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format),
65 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
66 'planetstacks': reverse('planetstack-list', request=request, format=format),
67 'userdeploymentses': reverse('userdeployments-list', request=request, format=format),
68 'accounts': reverse('account-list', request=request, format=format),
69 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
70 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
71 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
72 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
73 'usercredentials': reverse('usercredential-list', request=request, format=format),
74 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
75 'slicetags': reverse('slicetag-list', request=request, format=format),
76 'networktemplates': reverse('networktemplate-list', request=request, format=format),
77 'routers': reverse('router-list', request=request, format=format),
78 'serviceresources': reverse('serviceresource-list', request=request, format=format),
79
Sapan Bhatiadea39432014-06-13 03:10:36 -040080 })
81
82# Based on serializers.py
83
84
85
Scott Baker0caeaf02014-06-19 11:12:55 -070086class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -070087 id = serializers.Field()
88
89 class Meta:
90 model = ServiceAttribute
91 fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -070092
93class ServiceAttributeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -070094 id = serializers.Field()
95
96 class Meta:
97 model = ServiceAttribute
98 fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -070099
100
Sapan Bhatiadea39432014-06-13 03:10:36 -0400101
102
103class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700104 id = serializers.Field()
105
106 class Meta:
107 model = Image
108 fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700109
110class ImageIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700111 id = serializers.Field()
112
113 class Meta:
114 model = Image
115 fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700116
117
Sapan Bhatiadea39432014-06-13 03:10:36 -0400118
119
Scott Baker0caeaf02014-06-19 11:12:55 -0700120class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700121 id = serializers.Field()
122
123 class Meta:
124 model = NetworkParameter
125 fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700126
127class NetworkParameterIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700128 id = serializers.Field()
129
130 class Meta:
131 model = NetworkParameter
132 fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700133
134
Sapan Bhatiadea39432014-06-13 03:10:36 -0400135
136
137class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700138 id = serializers.Field()
139
140 class Meta:
141 model = Site
142 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 -0700143
144class SiteIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700145 id = serializers.Field()
146
147 class Meta:
148 model = Site
149 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 -0700150
151
Sapan Bhatiadea39432014-06-13 03:10:36 -0400152
153
Scott Baker0caeaf02014-06-19 11:12:55 -0700154class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700155 id = serializers.Field()
156
157 class Meta:
158 model = SliceRole
159 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700160
161class SliceRoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700162 id = serializers.Field()
163
164 class Meta:
165 model = SliceRole
166 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700167
168
Sapan Bhatiadea39432014-06-13 03:10:36 -0400169
170
171class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700172 id = serializers.Field()
173
174 class Meta:
175 model = Tag
176 fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700177
178class TagIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700179 id = serializers.Field()
180
181 class Meta:
182 model = Tag
183 fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700184
185
Sapan Bhatiadea39432014-06-13 03:10:36 -0400186
187
188class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700189 id = serializers.Field()
190
191 class Meta:
192 model = Invoice
193 fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700194
195class InvoiceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700196 id = serializers.Field()
197
198 class Meta:
199 model = Invoice
200 fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700201
202
Sapan Bhatiadea39432014-06-13 03:10:36 -0400203
204
Scott Baker0caeaf02014-06-19 11:12:55 -0700205class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700206 id = serializers.Field()
207
208 class Meta:
209 model = SlicePrivilege
210 fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700211
212class SlicePrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700213 id = serializers.Field()
214
215 class Meta:
216 model = SlicePrivilege
217 fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700218
219
Scott Baker0caeaf02014-06-19 11:12:55 -0700220
221
Scott Baker89a7b7c2014-10-07 00:10:17 -0700222class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700223 id = serializers.Field()
224
225 class Meta:
226 model = PlanetStackRole
227 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700228
229class PlanetStackRoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700230 id = serializers.Field()
231
232 class Meta:
233 model = PlanetStackRole
234 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700235
236
237
238
Scott Baker0caeaf02014-06-19 11:12:55 -0700239class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700240 id = serializers.Field()
241
242 class Meta:
243 model = NetworkSliver
244 fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700245
246class NetworkSliverIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700247 id = serializers.Field()
248
249 class Meta:
250 model = NetworkSliver
251 fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700252
253
Scott Baker0caeaf02014-06-19 11:12:55 -0700254
255
256class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700257 id = serializers.Field()
258
259 class Meta:
260 model = NetworkDeployments
261 fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700262
263class NetworkDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700264 id = serializers.Field()
265
266 class Meta:
267 model = NetworkDeployments
268 fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700269
270
Sapan Bhatiadea39432014-06-13 03:10:36 -0400271
272
Scott Baker89a7b7c2014-10-07 00:10:17 -0700273class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700274 id = serializers.Field()
275
276 class Meta:
277 model = Flavor
278 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700279
280class FlavorIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700281 id = serializers.Field()
282
283 class Meta:
284 model = Flavor
285 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700286
287
288
289
290class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700291 id = serializers.Field()
292
293 class Meta:
294 model = Project
295 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700296
297class ProjectIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700298 id = serializers.Field()
299
300 class Meta:
301 model = Project
302 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700303
304
305
306
Sapan Bhatiadea39432014-06-13 03:10:36 -0400307class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700308 id = serializers.Field()
309
310
311 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
312
313
314
315 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
316
317
318
319 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
320
321
322
323 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
324
325
326 class Meta:
327 model = Slice
328 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 -0700329
330class SliceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700331 id = serializers.Field()
332
333
334 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
335
336
337
338 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
339
340
341
342 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
343
344
345
346 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
347
348
349 class Meta:
350 model = Slice
351 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 -0700352
353
Sapan Bhatiadea39432014-06-13 03:10:36 -0400354
355
356class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700357 id = serializers.Field()
358
359
360 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
361
362
363
364 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
365
366
367
368 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
369
370
371
372 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
373
374
375 class Meta:
376 model = Network
377 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 -0700378
379class NetworkIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700380 id = serializers.Field()
381
382
383 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
384
385
386
387 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
388
389
390
391 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
392
393
394
395 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
396
397
398 class Meta:
399 model = Network
400 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 -0700401
402
Sapan Bhatiadea39432014-06-13 03:10:36 -0400403
404
405class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700406 id = serializers.Field()
407
408 class Meta:
409 model = Service
410 fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700411
412class ServiceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700413 id = serializers.Field()
414
415 class Meta:
416 model = Service
417 fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700418
419
Sapan Bhatiadea39432014-06-13 03:10:36 -0400420
421
Scott Baker0caeaf02014-06-19 11:12:55 -0700422class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700423 id = serializers.Field()
424
425 class Meta:
426 model = ServiceClass
427 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700428
429class ServiceClassIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700430 id = serializers.Field()
431
432 class Meta:
433 model = ServiceClass
434 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700435
436
Sapan Bhatiadea39432014-06-13 03:10:36 -0400437
438
Scott Baker0caeaf02014-06-19 11:12:55 -0700439class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700440 id = serializers.Field()
441
442 class Meta:
443 model = Payment
444 fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700445
446class PaymentIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700447 id = serializers.Field()
448
449 class Meta:
450 model = Payment
451 fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700452
453
Sapan Bhatiadea39432014-06-13 03:10:36 -0400454
455
456class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700457 id = serializers.Field()
458
459 class Meta:
460 model = Charge
461 fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700462
463class ChargeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700464 id = serializers.Field()
465
466 class Meta:
467 model = Charge
468 fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700469
470
Sapan Bhatiadea39432014-06-13 03:10:36 -0400471
472
473class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700474 id = serializers.Field()
475
476 class Meta:
477 model = Role
478 fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700479
480class RoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700481 id = serializers.Field()
482
483 class Meta:
484 model = Role
485 fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700486
487
Sapan Bhatiadea39432014-06-13 03:10:36 -0400488
489
Scott Baker0caeaf02014-06-19 11:12:55 -0700490class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700491 id = serializers.Field()
492
493 class Meta:
494 model = UsableObject
495 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -0700496
497class UsableObjectIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700498 id = serializers.Field()
499
500 class Meta:
501 model = UsableObject
502 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -0700503
504
Sapan Bhatiadea39432014-06-13 03:10:36 -0400505
506
Scott Baker0caeaf02014-06-19 11:12:55 -0700507class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700508 id = serializers.Field()
509
510 class Meta:
511 model = SiteRole
512 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700513
514class SiteRoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700515 id = serializers.Field()
516
517 class Meta:
518 model = SiteRole
519 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700520
521
Scott Baker0caeaf02014-06-19 11:12:55 -0700522
523
Scott Baker89a7b7c2014-10-07 00:10:17 -0700524class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700525 id = serializers.Field()
526
527 class Meta:
528 model = SliceCredential
529 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700530
531class SliceCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700532 id = serializers.Field()
533
534 class Meta:
535 model = SliceCredential
536 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700537
538
539
540
Sapan Bhatiadea39432014-06-13 03:10:36 -0400541class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700542 id = serializers.Field()
543
544
545 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
546
547
548
549 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
550
551
552 class Meta:
553 model = Sliver
554 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 -0700555
556class SliverIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700557 id = serializers.Field()
558
559
560 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
561
562
563
564 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
565
566
567 class Meta:
568 model = Sliver
569 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 -0700570
571
Sapan Bhatiadea39432014-06-13 03:10:36 -0400572
573
574class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700575 id = serializers.Field()
576
577 class Meta:
578 model = Node
579 fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -0700580
581class NodeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700582 id = serializers.Field()
583
584 class Meta:
585 model = Node
586 fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
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 DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700592 id = serializers.Field()
593
594 class Meta:
595 model = DashboardView
596 fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker46b58542014-08-11 17:26:12 -0700597
598class DashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700599 id = serializers.Field()
600
601 class Meta:
602 model = DashboardView
603 fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker46b58542014-08-11 17:26:12 -0700604
605
Sapan Bhatiadea39432014-06-13 03:10:36 -0400606
607
Scott Baker0caeaf02014-06-19 11:12:55 -0700608class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700609 id = serializers.Field()
610
611 class Meta:
612 model = ImageDeployments
613 fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700614
615class ImageDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700616 id = serializers.Field()
617
618 class Meta:
619 model = ImageDeployments
620 fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700621
622
Sapan Bhatiadea39432014-06-13 03:10:36 -0400623
624
Scott Baker0caeaf02014-06-19 11:12:55 -0700625class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700626 id = serializers.Field()
627
628 class Meta:
629 model = ReservedResource
630 fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -0700631
632class ReservedResourceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700633 id = serializers.Field()
634
635 class Meta:
636 model = ReservedResource
637 fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
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 NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700643 id = serializers.Field()
644
645 class Meta:
646 model = NetworkSlice
647 fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -0700648
649class NetworkSliceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700650 id = serializers.Field()
651
652 class Meta:
653 model = NetworkSlice
654 fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -0700655
656
Scott Baker0caeaf02014-06-19 11:12:55 -0700657
658
659class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700660 id = serializers.Field()
661
662 class Meta:
663 model = UserDashboardView
664 fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -0700665
666class UserDashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700667 id = serializers.Field()
668
669 class Meta:
670 model = UserDashboardView
671 fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -0700672
673
Scott Baker0caeaf02014-06-19 11:12:55 -0700674
675
676class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700677 id = serializers.Field()
678
679 class Meta:
680 model = PlanetStackPrivilege
681 fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700682
683class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700684 id = serializers.Field()
685
686 class Meta:
687 model = PlanetStackPrivilege
688 fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700689
690
Sapan Bhatiadea39432014-06-13 03:10:36 -0400691
692
693class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700694 id = serializers.Field()
695
696 class Meta:
697 model = User
698 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 -0700699
700class UserIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700701 id = serializers.Field()
702
703 class Meta:
704 model = User
705 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 -0700706
707
Sapan Bhatiadea39432014-06-13 03:10:36 -0400708
709
710class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700711 id = serializers.Field()
712
713
714 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
715
716
717
718 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
719
720
721
722 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
723
724
725
726 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
727
728
729 class Meta:
730 model = Deployment
731 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 -0700732
733class DeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700734 id = serializers.Field()
735
736
737 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
738
739
740
741 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
742
743
744
745 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
746
747
748
749 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
750
751
752 class Meta:
753 model = Deployment
754 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 -0700755
756
Sapan Bhatiadea39432014-06-13 03:10:36 -0400757
758
759class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700760 id = serializers.Field()
761
762 class Meta:
763 model = Reservation
764 fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -0700765
766class ReservationIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700767 id = serializers.Field()
768
769 class Meta:
770 model = Reservation
771 fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -0700772
773
Sapan Bhatiadea39432014-06-13 03:10:36 -0400774
775
Scott Baker0caeaf02014-06-19 11:12:55 -0700776class SliceDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700777 id = serializers.Field()
778
779 class Meta:
780 model = SliceDeployments
781 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 -0700782
783class SliceDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700784 id = serializers.Field()
785
786 class Meta:
787 model = SliceDeployments
788 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 -0700789
790
Sapan Bhatiadea39432014-06-13 03:10:36 -0400791
792
Scott Baker0caeaf02014-06-19 11:12:55 -0700793class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700794 id = serializers.Field()
795
796 class Meta:
797 model = SitePrivilege
798 fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700799
800class SitePrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700801 id = serializers.Field()
802
803 class Meta:
804 model = SitePrivilege
805 fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700806
807
Scott Baker0caeaf02014-06-19 11:12:55 -0700808
809
810class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700811 id = serializers.Field()
812
813 class Meta:
814 model = PlanetStack
815 fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -0700816
817class PlanetStackIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700818 id = serializers.Field()
819
820 class Meta:
821 model = PlanetStack
822 fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -0700823
824
Sapan Bhatiadea39432014-06-13 03:10:36 -0400825
826
Scott Baker0caeaf02014-06-19 11:12:55 -0700827class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700828 id = serializers.Field()
829
830 class Meta:
831 model = UserDeployments
832 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700833
834class UserDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700835 id = serializers.Field()
836
837 class Meta:
838 model = UserDeployments
839 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700840
841
Scott Baker0caeaf02014-06-19 11:12:55 -0700842
843
Sapan Bhatiadea39432014-06-13 03:10:36 -0400844class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700845 id = serializers.Field()
846
847 class Meta:
848 model = Account
849 fields = ('id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -0700850
851class AccountIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700852 id = serializers.Field()
853
854 class Meta:
855 model = Account
856 fields = ('id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -0700857
858
Sapan Bhatiadea39432014-06-13 03:10:36 -0400859
860
Scott Baker0caeaf02014-06-19 11:12:55 -0700861class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700862 id = serializers.Field()
863
864 class Meta:
865 model = NetworkParameterType
866 fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -0700867
868class NetworkParameterTypeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700869 id = serializers.Field()
870
871 class Meta:
872 model = NetworkParameterType
873 fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -0700874
875
Sapan Bhatiadea39432014-06-13 03:10:36 -0400876
877
Scott Baker89a7b7c2014-10-07 00:10:17 -0700878class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700879 id = serializers.Field()
880
881 class Meta:
882 model = SiteCredential
883 fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -0700884
Scott Baker89a7b7c2014-10-07 00:10:17 -0700885class SiteCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700886 id = serializers.Field()
887
888 class Meta:
889 model = SiteCredential
890 fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -0700891
892
Scott Baker0caeaf02014-06-19 11:12:55 -0700893
894
895class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700896 id = serializers.Field()
897
898 class Meta:
899 model = DeploymentPrivilege
900 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700901
902class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700903 id = serializers.Field()
904
905 class Meta:
906 model = DeploymentPrivilege
907 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700908
909
Scott Baker0caeaf02014-06-19 11:12:55 -0700910
911
912class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700913 id = serializers.Field()
914
915 class Meta:
916 model = DeploymentRole
917 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700918
919class DeploymentRoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700920 id = serializers.Field()
921
922 class Meta:
923 model = DeploymentRole
924 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700925
926
Sapan Bhatiadea39432014-06-13 03:10:36 -0400927
928
Scott Baker89a7b7c2014-10-07 00:10:17 -0700929class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700930 id = serializers.Field()
931
932 class Meta:
933 model = UserCredential
934 fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -0700935
Scott Baker89a7b7c2014-10-07 00:10:17 -0700936class UserCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700937 id = serializers.Field()
938
939 class Meta:
940 model = UserCredential
941 fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700942
943
944
945
946class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700947 id = serializers.Field()
948
949 class Meta:
950 model = SiteDeployments
951 fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700952
953class SiteDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700954 id = serializers.Field()
955
956 class Meta:
957 model = SiteDeployments
958 fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700959
960
Sapan Bhatiadea39432014-06-13 03:10:36 -0400961
962
Scott Baker0caeaf02014-06-19 11:12:55 -0700963class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700964 id = serializers.Field()
965
966 class Meta:
967 model = SliceTag
968 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -0700969
970class SliceTagIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700971 id = serializers.Field()
972
973 class Meta:
974 model = SliceTag
975 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -0700976
977
Scott Baker0caeaf02014-06-19 11:12:55 -0700978
979
980class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700981 id = serializers.Field()
982
983 class Meta:
984 model = NetworkTemplate
985 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
Scott Baker46b58542014-08-11 17:26:12 -0700986
987class NetworkTemplateIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700988 id = serializers.Field()
989
990 class Meta:
991 model = NetworkTemplate
992 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
Scott Baker46b58542014-08-11 17:26:12 -0700993
994
Sapan Bhatiadea39432014-06-13 03:10:36 -0400995
996
997class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700998 id = serializers.Field()
999
1000 class Meta:
1001 model = Router
1002 fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07001003
1004class RouterIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001005 id = serializers.Field()
1006
1007 class Meta:
1008 model = Router
1009 fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07001010
1011
Sapan Bhatiadea39432014-06-13 03:10:36 -04001012
1013
Scott Baker0caeaf02014-06-19 11:12:55 -07001014class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001015 id = serializers.Field()
1016
1017 class Meta:
1018 model = ServiceResource
1019 fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07001020
1021class ServiceResourceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001022 id = serializers.Field()
1023
1024 class Meta:
1025 model = ServiceResource
1026 fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07001027
1028
Sapan Bhatiadea39432014-06-13 03:10:36 -04001029
1030
1031serializerLookUp = {
1032
Scott Baker0caeaf02014-06-19 11:12:55 -07001033 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001034
1035 Image: ImageSerializer,
1036
Scott Baker0caeaf02014-06-19 11:12:55 -07001037 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001038
1039 Site: SiteSerializer,
1040
Scott Baker0caeaf02014-06-19 11:12:55 -07001041 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001042
1043 Tag: TagSerializer,
1044
1045 Invoice: InvoiceSerializer,
1046
Scott Baker0caeaf02014-06-19 11:12:55 -07001047 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001048
Scott Baker89a7b7c2014-10-07 00:10:17 -07001049 PlanetStackRole: PlanetStackRoleSerializer,
1050
Scott Baker0caeaf02014-06-19 11:12:55 -07001051 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001052
Scott Baker0caeaf02014-06-19 11:12:55 -07001053 NetworkDeployments: NetworkDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001054
Scott Baker89a7b7c2014-10-07 00:10:17 -07001055 Flavor: FlavorSerializer,
1056
1057 Project: ProjectSerializer,
1058
Sapan Bhatiadea39432014-06-13 03:10:36 -04001059 Slice: SliceSerializer,
1060
1061 Network: NetworkSerializer,
1062
1063 Service: ServiceSerializer,
1064
Scott Baker0caeaf02014-06-19 11:12:55 -07001065 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001066
Scott Baker0caeaf02014-06-19 11:12:55 -07001067 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001068
1069 Charge: ChargeSerializer,
1070
1071 Role: RoleSerializer,
1072
Scott Baker0caeaf02014-06-19 11:12:55 -07001073 UsableObject: UsableObjectSerializer,
1074
1075 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001076
Scott Baker89a7b7c2014-10-07 00:10:17 -07001077 SliceCredential: SliceCredentialSerializer,
1078
Sapan Bhatiadea39432014-06-13 03:10:36 -04001079 Sliver: SliverSerializer,
1080
1081 Node: NodeSerializer,
1082
Scott Baker0caeaf02014-06-19 11:12:55 -07001083 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001084
Scott Baker0caeaf02014-06-19 11:12:55 -07001085 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001086
Scott Baker0caeaf02014-06-19 11:12:55 -07001087 ReservedResource: ReservedResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001088
Scott Baker0caeaf02014-06-19 11:12:55 -07001089 NetworkSlice: NetworkSliceSerializer,
1090
1091 UserDashboardView: UserDashboardViewSerializer,
1092
1093 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001094
1095 User: UserSerializer,
1096
1097 Deployment: DeploymentSerializer,
1098
1099 Reservation: ReservationSerializer,
1100
Scott Baker0caeaf02014-06-19 11:12:55 -07001101 SliceDeployments: SliceDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001102
Scott Baker0caeaf02014-06-19 11:12:55 -07001103 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001104
Scott Baker0caeaf02014-06-19 11:12:55 -07001105 PlanetStack: PlanetStackSerializer,
1106
1107 UserDeployments: UserDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001108
1109 Account: AccountSerializer,
1110
Scott Baker0caeaf02014-06-19 11:12:55 -07001111 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001112
Scott Baker89a7b7c2014-10-07 00:10:17 -07001113 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001114
Scott Baker0caeaf02014-06-19 11:12:55 -07001115 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001116
Scott Baker0caeaf02014-06-19 11:12:55 -07001117 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001118
Scott Baker89a7b7c2014-10-07 00:10:17 -07001119 UserCredential: UserCredentialSerializer,
1120
1121 SiteDeployments: SiteDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001122
Scott Baker0caeaf02014-06-19 11:12:55 -07001123 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001124
Scott Baker0caeaf02014-06-19 11:12:55 -07001125 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001126
1127 Router: RouterSerializer,
1128
Scott Baker0caeaf02014-06-19 11:12:55 -07001129 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001130
1131 None: None,
1132 }
1133
Scott Baker89a7b7c2014-10-07 00:10:17 -07001134class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
1135
1136 # To handle fine-grained field permissions, we have to check can_update
1137 # the object has been updated but before it has been saved.
1138
1139 def update(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001140 print "XXX update"
Scott Baker89a7b7c2014-10-07 00:10:17 -07001141 partial = kwargs.pop('partial', False)
1142 self.object = self.get_object_or_none()
1143
1144 serializer = self.get_serializer(self.object, data=request.DATA,
1145 files=request.FILES, partial=partial)
1146
1147 if not serializer.is_valid():
1148 print "UpdateModelMixin: not serializer.is_valid"
1149 print serializer.errors
1150 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
1151
1152 try:
1153 self.pre_save(serializer.object)
1154 except ValidationError as err:
1155 # full_clean on model instance may be called in pre_save,
1156 # so we have to handle eventual errors.
1157 return Response(err.message_dict, status=status.HTTP_400_BAD_REQUEST)
1158
1159 if serializer.object is not None:
1160 if not serializer.object.can_update(request.user):
1161 return Response(status=status.HTTP_400_BAD_REQUEST)
1162
1163 if self.object is None:
1164 self.object = serializer.save(force_insert=True)
1165 self.post_save(self.object, created=True)
1166 return Response(serializer.data, status=status.HTTP_201_CREATED)
1167
1168 self.object = serializer.save(force_update=True)
1169 self.post_save(self.object, created=False)
1170 return Response(serializer.data, status=status.HTTP_200_OK)
1171
1172 def destroy(self, request, *args, **kwargs):
1173 obj = self.get_object()
1174 if obj.can_update(request.user):
Scott Baker2bcbf372014-10-29 23:41:11 -07001175 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001176 else:
1177 return Response(status=status.HTTP_400_BAD_REQUEST)
1178
1179
Scott Baker2bcbf372014-10-29 23:41:11 -07001180 def put(self, request, *args, **kwargs):
1181 print "XXX put"
1182 return super(PlanetStackRetrieveUpdateDestroyAPIView,self).put(request,*args, **kwargs);
1183 #return self.update(request, *args, **kwargs)
1184
1185
Sapan Bhatiadea39432014-06-13 03:10:36 -04001186# Based on core/views/*.py
1187
1188
Scott Baker0caeaf02014-06-19 11:12:55 -07001189class ServiceAttributeList(generics.ListCreateAPIView):
1190 queryset = ServiceAttribute.objects.select_related().all()
1191 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001192 id_serializer_class = ServiceAttributeIdSerializer
1193 filter_backends = (filters.DjangoFilterBackend,)
1194 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
1195
1196 def get_serializer_class(self):
1197 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1198 if (no_hyperlinks):
1199 return self.id_serializer_class
1200 else:
1201 return self.serializer_class
1202
Scott Baker0caeaf02014-06-19 11:12:55 -07001203 def get_queryset(self):
1204 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001205
Scott Baker0caeaf02014-06-19 11:12:55 -07001206 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001207 obj = ServiceAttribute(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001208 obj.caller = request.user
1209 if obj.can_update(request.user):
1210 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
1211 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001212 raise Exception("failed obj.can_update")
1213
1214 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
1215 if (ret.status_code%100 != 200):
1216 raise Exception(ret.data)
1217
1218 return ret
1219
Scott Baker0caeaf02014-06-19 11:12:55 -07001220
Scott Baker89a7b7c2014-10-07 00:10:17 -07001221class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001222 queryset = ServiceAttribute.objects.select_related().all()
1223 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001224 id_serializer_class = ServiceAttributeIdSerializer
1225
1226 def get_serializer_class(self):
1227 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1228 if (no_hyperlinks):
1229 return self.id_serializer_class
1230 else:
1231 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001232
1233 def get_queryset(self):
1234 return ServiceAttribute.select_by_user(self.request.user)
1235
Scott Baker89a7b7c2014-10-07 00:10:17 -07001236 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001237
Scott Baker89a7b7c2014-10-07 00:10:17 -07001238 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001239
1240
1241
1242class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001243 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001244 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001245 id_serializer_class = ImageIdSerializer
1246 filter_backends = (filters.DjangoFilterBackend,)
1247 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
1248
1249 def get_serializer_class(self):
1250 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1251 if (no_hyperlinks):
1252 return self.id_serializer_class
1253 else:
1254 return self.serializer_class
1255
Scott Baker0caeaf02014-06-19 11:12:55 -07001256 def get_queryset(self):
1257 return Image.select_by_user(self.request.user)
1258
1259 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001260 obj = Image(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001261 obj.caller = request.user
1262 if obj.can_update(request.user):
1263 return super(ImageList, self).create(request, *args, **kwargs)
1264 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001265 raise Exception("failed obj.can_update")
1266
1267 ret = super(ImageList, self).create(request, *args, **kwargs)
1268 if (ret.status_code%100 != 200):
1269 raise Exception(ret.data)
1270
1271 return ret
1272
Sapan Bhatiadea39432014-06-13 03:10:36 -04001273
Scott Baker89a7b7c2014-10-07 00:10:17 -07001274class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001275 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001276 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001277 id_serializer_class = ImageIdSerializer
1278
1279 def get_serializer_class(self):
1280 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1281 if (no_hyperlinks):
1282 return self.id_serializer_class
1283 else:
1284 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001285
1286 def get_queryset(self):
1287 return Image.select_by_user(self.request.user)
1288
Scott Baker89a7b7c2014-10-07 00:10:17 -07001289 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001290
Scott Baker89a7b7c2014-10-07 00:10:17 -07001291 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001292
1293
1294
Scott Baker0caeaf02014-06-19 11:12:55 -07001295class NetworkParameterList(generics.ListCreateAPIView):
1296 queryset = NetworkParameter.objects.select_related().all()
1297 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001298 id_serializer_class = NetworkParameterIdSerializer
1299 filter_backends = (filters.DjangoFilterBackend,)
1300 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
1301
1302 def get_serializer_class(self):
1303 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1304 if (no_hyperlinks):
1305 return self.id_serializer_class
1306 else:
1307 return self.serializer_class
1308
Scott Baker0caeaf02014-06-19 11:12:55 -07001309 def get_queryset(self):
1310 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001311
Scott Baker0caeaf02014-06-19 11:12:55 -07001312 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001313 obj = NetworkParameter(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001314 obj.caller = request.user
1315 if obj.can_update(request.user):
1316 return super(NetworkParameterList, self).create(request, *args, **kwargs)
1317 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001318 raise Exception("failed obj.can_update")
1319
1320 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
1321 if (ret.status_code%100 != 200):
1322 raise Exception(ret.data)
1323
1324 return ret
1325
Scott Baker0caeaf02014-06-19 11:12:55 -07001326
Scott Baker89a7b7c2014-10-07 00:10:17 -07001327class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001328 queryset = NetworkParameter.objects.select_related().all()
1329 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001330 id_serializer_class = NetworkParameterIdSerializer
1331
1332 def get_serializer_class(self):
1333 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1334 if (no_hyperlinks):
1335 return self.id_serializer_class
1336 else:
1337 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001338
1339 def get_queryset(self):
1340 return NetworkParameter.select_by_user(self.request.user)
1341
Scott Baker89a7b7c2014-10-07 00:10:17 -07001342 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001343
Scott Baker89a7b7c2014-10-07 00:10:17 -07001344 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001345
1346
1347
1348class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001349 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001350 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001351 id_serializer_class = SiteIdSerializer
1352 filter_backends = (filters.DjangoFilterBackend,)
1353 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
1354
1355 def get_serializer_class(self):
1356 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1357 if (no_hyperlinks):
1358 return self.id_serializer_class
1359 else:
1360 return self.serializer_class
1361
Scott Baker0caeaf02014-06-19 11:12:55 -07001362 def get_queryset(self):
1363 return Site.select_by_user(self.request.user)
1364
1365 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001366 obj = Site(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001367 obj.caller = request.user
1368 if obj.can_update(request.user):
1369 return super(SiteList, self).create(request, *args, **kwargs)
1370 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001371 raise Exception("failed obj.can_update")
1372
1373 ret = super(SiteList, self).create(request, *args, **kwargs)
1374 if (ret.status_code%100 != 200):
1375 raise Exception(ret.data)
1376
1377 return ret
1378
Sapan Bhatiadea39432014-06-13 03:10:36 -04001379
Scott Baker89a7b7c2014-10-07 00:10:17 -07001380class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001381 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001382 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001383 id_serializer_class = SiteIdSerializer
1384
1385 def get_serializer_class(self):
1386 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1387 if (no_hyperlinks):
1388 return self.id_serializer_class
1389 else:
1390 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001391
1392 def get_queryset(self):
1393 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001394
Scott Baker89a7b7c2014-10-07 00:10:17 -07001395 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001396
Scott Baker89a7b7c2014-10-07 00:10:17 -07001397 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001398
1399
1400
1401class SliceRoleList(generics.ListCreateAPIView):
1402 queryset = SliceRole.objects.select_related().all()
1403 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001404 id_serializer_class = SliceRoleIdSerializer
1405 filter_backends = (filters.DjangoFilterBackend,)
1406 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
1407
1408 def get_serializer_class(self):
1409 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1410 if (no_hyperlinks):
1411 return self.id_serializer_class
1412 else:
1413 return self.serializer_class
1414
Scott Baker0caeaf02014-06-19 11:12:55 -07001415 def get_queryset(self):
1416 return SliceRole.select_by_user(self.request.user)
1417
1418 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001419 obj = SliceRole(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001420 obj.caller = request.user
1421 if obj.can_update(request.user):
1422 return super(SliceRoleList, self).create(request, *args, **kwargs)
1423 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001424 raise Exception("failed obj.can_update")
1425
1426 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
1427 if (ret.status_code%100 != 200):
1428 raise Exception(ret.data)
1429
1430 return ret
1431
Scott Baker0caeaf02014-06-19 11:12:55 -07001432
Scott Baker89a7b7c2014-10-07 00:10:17 -07001433class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001434 queryset = SliceRole.objects.select_related().all()
1435 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001436 id_serializer_class = SliceRoleIdSerializer
1437
1438 def get_serializer_class(self):
1439 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1440 if (no_hyperlinks):
1441 return self.id_serializer_class
1442 else:
1443 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001444
1445 def get_queryset(self):
1446 return SliceRole.select_by_user(self.request.user)
1447
Scott Baker89a7b7c2014-10-07 00:10:17 -07001448 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001449
Scott Baker89a7b7c2014-10-07 00:10:17 -07001450 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001451
1452
1453
1454class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001455 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001456 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001457 id_serializer_class = TagIdSerializer
1458 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001459 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001460
1461 def get_serializer_class(self):
1462 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1463 if (no_hyperlinks):
1464 return self.id_serializer_class
1465 else:
1466 return self.serializer_class
1467
Scott Baker0caeaf02014-06-19 11:12:55 -07001468 def get_queryset(self):
1469 return Tag.select_by_user(self.request.user)
1470
1471 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001472 obj = Tag(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001473 obj.caller = request.user
1474 if obj.can_update(request.user):
1475 return super(TagList, self).create(request, *args, **kwargs)
1476 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001477 raise Exception("failed obj.can_update")
1478
1479 ret = super(TagList, self).create(request, *args, **kwargs)
1480 if (ret.status_code%100 != 200):
1481 raise Exception(ret.data)
1482
1483 return ret
1484
Sapan Bhatiadea39432014-06-13 03:10:36 -04001485
Scott Baker89a7b7c2014-10-07 00:10:17 -07001486class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001487 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001488 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001489 id_serializer_class = TagIdSerializer
1490
1491 def get_serializer_class(self):
1492 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1493 if (no_hyperlinks):
1494 return self.id_serializer_class
1495 else:
1496 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001497
1498 def get_queryset(self):
1499 return Tag.select_by_user(self.request.user)
1500
Scott Baker89a7b7c2014-10-07 00:10:17 -07001501 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001502
Scott Baker89a7b7c2014-10-07 00:10:17 -07001503 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001504
1505
1506
1507class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001508 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001509 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001510 id_serializer_class = InvoiceIdSerializer
1511 filter_backends = (filters.DjangoFilterBackend,)
1512 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
1513
1514 def get_serializer_class(self):
1515 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1516 if (no_hyperlinks):
1517 return self.id_serializer_class
1518 else:
1519 return self.serializer_class
1520
Scott Baker0caeaf02014-06-19 11:12:55 -07001521 def get_queryset(self):
1522 return Invoice.select_by_user(self.request.user)
1523
1524 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001525 obj = Invoice(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001526 obj.caller = request.user
1527 if obj.can_update(request.user):
1528 return super(InvoiceList, self).create(request, *args, **kwargs)
1529 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001530 raise Exception("failed obj.can_update")
1531
1532 ret = super(InvoiceList, self).create(request, *args, **kwargs)
1533 if (ret.status_code%100 != 200):
1534 raise Exception(ret.data)
1535
1536 return ret
1537
Sapan Bhatiadea39432014-06-13 03:10:36 -04001538
Scott Baker89a7b7c2014-10-07 00:10:17 -07001539class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001540 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001541 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001542 id_serializer_class = InvoiceIdSerializer
1543
1544 def get_serializer_class(self):
1545 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1546 if (no_hyperlinks):
1547 return self.id_serializer_class
1548 else:
1549 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001550
1551 def get_queryset(self):
1552 return Invoice.select_by_user(self.request.user)
1553
Scott Baker89a7b7c2014-10-07 00:10:17 -07001554 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001555
Scott Baker89a7b7c2014-10-07 00:10:17 -07001556 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001557
1558
1559
Scott Baker0caeaf02014-06-19 11:12:55 -07001560class SlicePrivilegeList(generics.ListCreateAPIView):
1561 queryset = SlicePrivilege.objects.select_related().all()
1562 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001563 id_serializer_class = SlicePrivilegeIdSerializer
1564 filter_backends = (filters.DjangoFilterBackend,)
1565 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
1566
1567 def get_serializer_class(self):
1568 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1569 if (no_hyperlinks):
1570 return self.id_serializer_class
1571 else:
1572 return self.serializer_class
1573
Scott Baker0caeaf02014-06-19 11:12:55 -07001574 def get_queryset(self):
1575 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001576
Scott Baker0caeaf02014-06-19 11:12:55 -07001577 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001578 obj = SlicePrivilege(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001579 obj.caller = request.user
1580 if obj.can_update(request.user):
1581 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
1582 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001583 raise Exception("failed obj.can_update")
1584
1585 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
1586 if (ret.status_code%100 != 200):
1587 raise Exception(ret.data)
1588
1589 return ret
1590
Scott Baker0caeaf02014-06-19 11:12:55 -07001591
Scott Baker89a7b7c2014-10-07 00:10:17 -07001592class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001593 queryset = SlicePrivilege.objects.select_related().all()
1594 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001595 id_serializer_class = SlicePrivilegeIdSerializer
1596
1597 def get_serializer_class(self):
1598 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1599 if (no_hyperlinks):
1600 return self.id_serializer_class
1601 else:
1602 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001603
1604 def get_queryset(self):
1605 return SlicePrivilege.select_by_user(self.request.user)
1606
Scott Baker89a7b7c2014-10-07 00:10:17 -07001607 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1608
1609 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1610
1611
1612
1613class PlanetStackRoleList(generics.ListCreateAPIView):
1614 queryset = PlanetStackRole.objects.select_related().all()
1615 serializer_class = PlanetStackRoleSerializer
1616 id_serializer_class = PlanetStackRoleIdSerializer
1617 filter_backends = (filters.DjangoFilterBackend,)
1618 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
1619
1620 def get_serializer_class(self):
1621 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1622 if (no_hyperlinks):
1623 return self.id_serializer_class
1624 else:
1625 return self.serializer_class
1626
1627 def get_queryset(self):
1628 return PlanetStackRole.select_by_user(self.request.user)
1629
1630 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001631 obj = PlanetStackRole(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001632 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07001633 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001634 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001635 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001636 raise Exception("failed obj.can_update")
1637
1638 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
1639 if (ret.status_code%100 != 200):
1640 raise Exception(ret.data)
1641
1642 return ret
1643
Scott Baker0caeaf02014-06-19 11:12:55 -07001644
Scott Baker89a7b7c2014-10-07 00:10:17 -07001645class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1646 queryset = PlanetStackRole.objects.select_related().all()
1647 serializer_class = PlanetStackRoleSerializer
1648 id_serializer_class = PlanetStackRoleIdSerializer
1649
1650 def get_serializer_class(self):
1651 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1652 if (no_hyperlinks):
1653 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001654 else:
Scott Baker89a7b7c2014-10-07 00:10:17 -07001655 return self.serializer_class
1656
1657 def get_queryset(self):
1658 return PlanetStackRole.select_by_user(self.request.user)
1659
1660 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1661
1662 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001663
1664
1665
Scott Baker0caeaf02014-06-19 11:12:55 -07001666class NetworkSliverList(generics.ListCreateAPIView):
1667 queryset = NetworkSliver.objects.select_related().all()
1668 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001669 id_serializer_class = NetworkSliverIdSerializer
1670 filter_backends = (filters.DjangoFilterBackend,)
1671 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
1672
1673 def get_serializer_class(self):
1674 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1675 if (no_hyperlinks):
1676 return self.id_serializer_class
1677 else:
1678 return self.serializer_class
1679
Scott Baker0caeaf02014-06-19 11:12:55 -07001680 def get_queryset(self):
1681 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001682
Scott Baker0caeaf02014-06-19 11:12:55 -07001683 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001684 obj = NetworkSliver(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001685 obj.caller = request.user
1686 if obj.can_update(request.user):
1687 return super(NetworkSliverList, self).create(request, *args, **kwargs)
1688 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001689 raise Exception("failed obj.can_update")
1690
1691 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
1692 if (ret.status_code%100 != 200):
1693 raise Exception(ret.data)
1694
1695 return ret
1696
Scott Baker0caeaf02014-06-19 11:12:55 -07001697
Scott Baker89a7b7c2014-10-07 00:10:17 -07001698class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001699 queryset = NetworkSliver.objects.select_related().all()
1700 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001701 id_serializer_class = NetworkSliverIdSerializer
1702
1703 def get_serializer_class(self):
1704 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1705 if (no_hyperlinks):
1706 return self.id_serializer_class
1707 else:
1708 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001709
1710 def get_queryset(self):
1711 return NetworkSliver.select_by_user(self.request.user)
1712
Scott Baker89a7b7c2014-10-07 00:10:17 -07001713 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001714
Scott Baker89a7b7c2014-10-07 00:10:17 -07001715 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001716
1717
1718
Scott Baker0caeaf02014-06-19 11:12:55 -07001719class NetworkDeploymentsList(generics.ListCreateAPIView):
1720 queryset = NetworkDeployments.objects.select_related().all()
1721 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001722 id_serializer_class = NetworkDeploymentsIdSerializer
1723 filter_backends = (filters.DjangoFilterBackend,)
1724 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
1725
1726 def get_serializer_class(self):
1727 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1728 if (no_hyperlinks):
1729 return self.id_serializer_class
1730 else:
1731 return self.serializer_class
1732
Scott Baker0caeaf02014-06-19 11:12:55 -07001733 def get_queryset(self):
1734 return NetworkDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001735
Scott Baker0caeaf02014-06-19 11:12:55 -07001736 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001737 obj = NetworkDeployments(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001738 obj.caller = request.user
1739 if obj.can_update(request.user):
1740 return super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
1741 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001742 raise Exception("failed obj.can_update")
1743
1744 ret = super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
1745 if (ret.status_code%100 != 200):
1746 raise Exception(ret.data)
1747
1748 return ret
1749
Scott Baker0caeaf02014-06-19 11:12:55 -07001750
Scott Baker89a7b7c2014-10-07 00:10:17 -07001751class NetworkDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001752 queryset = NetworkDeployments.objects.select_related().all()
1753 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001754 id_serializer_class = NetworkDeploymentsIdSerializer
1755
1756 def get_serializer_class(self):
1757 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1758 if (no_hyperlinks):
1759 return self.id_serializer_class
1760 else:
1761 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001762
1763 def get_queryset(self):
1764 return NetworkDeployments.select_by_user(self.request.user)
1765
Scott Baker89a7b7c2014-10-07 00:10:17 -07001766 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001767
Scott Baker89a7b7c2014-10-07 00:10:17 -07001768 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001769
1770
1771
Scott Baker89a7b7c2014-10-07 00:10:17 -07001772class FlavorList(generics.ListCreateAPIView):
1773 queryset = Flavor.objects.select_related().all()
1774 serializer_class = FlavorSerializer
1775 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001776 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001777 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker46b58542014-08-11 17:26:12 -07001778
1779 def get_serializer_class(self):
1780 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1781 if (no_hyperlinks):
1782 return self.id_serializer_class
1783 else:
1784 return self.serializer_class
1785
Scott Baker0caeaf02014-06-19 11:12:55 -07001786 def get_queryset(self):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001787 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07001788
1789 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001790 obj = Flavor(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001791 obj.caller = request.user
1792 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001793 return super(FlavorList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001794 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001795 raise Exception("failed obj.can_update")
1796
1797 ret = super(FlavorList, self).create(request, *args, **kwargs)
1798 if (ret.status_code%100 != 200):
1799 raise Exception(ret.data)
1800
1801 return ret
1802
Sapan Bhatiadea39432014-06-13 03:10:36 -04001803
Scott Baker89a7b7c2014-10-07 00:10:17 -07001804class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1805 queryset = Flavor.objects.select_related().all()
1806 serializer_class = FlavorSerializer
1807 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001808
1809 def get_serializer_class(self):
1810 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1811 if (no_hyperlinks):
1812 return self.id_serializer_class
1813 else:
1814 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001815
1816 def get_queryset(self):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001817 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07001818
Scott Baker89a7b7c2014-10-07 00:10:17 -07001819 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001820
Scott Baker89a7b7c2014-10-07 00:10:17 -07001821 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001822
1823
1824
Scott Baker0caeaf02014-06-19 11:12:55 -07001825class ProjectList(generics.ListCreateAPIView):
1826 queryset = Project.objects.select_related().all()
1827 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001828 id_serializer_class = ProjectIdSerializer
1829 filter_backends = (filters.DjangoFilterBackend,)
1830 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
1831
1832 def get_serializer_class(self):
1833 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1834 if (no_hyperlinks):
1835 return self.id_serializer_class
1836 else:
1837 return self.serializer_class
1838
Scott Baker0caeaf02014-06-19 11:12:55 -07001839 def get_queryset(self):
1840 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001841
Scott Baker0caeaf02014-06-19 11:12:55 -07001842 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001843 obj = Project(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001844 obj.caller = request.user
1845 if obj.can_update(request.user):
1846 return super(ProjectList, self).create(request, *args, **kwargs)
1847 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001848 raise Exception("failed obj.can_update")
1849
1850 ret = super(ProjectList, self).create(request, *args, **kwargs)
1851 if (ret.status_code%100 != 200):
1852 raise Exception(ret.data)
1853
1854 return ret
1855
Scott Baker0caeaf02014-06-19 11:12:55 -07001856
Scott Baker89a7b7c2014-10-07 00:10:17 -07001857class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001858 queryset = Project.objects.select_related().all()
1859 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001860 id_serializer_class = ProjectIdSerializer
1861
1862 def get_serializer_class(self):
1863 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1864 if (no_hyperlinks):
1865 return self.id_serializer_class
1866 else:
1867 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001868
1869 def get_queryset(self):
1870 return Project.select_by_user(self.request.user)
1871
Scott Baker89a7b7c2014-10-07 00:10:17 -07001872 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1873
1874 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1875
1876
1877
1878class SliceList(generics.ListCreateAPIView):
1879 queryset = Slice.objects.select_related().all()
1880 serializer_class = SliceSerializer
1881 id_serializer_class = SliceIdSerializer
1882 filter_backends = (filters.DjangoFilterBackend,)
1883 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',)
1884
1885 def get_serializer_class(self):
1886 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1887 if (no_hyperlinks):
1888 return self.id_serializer_class
1889 else:
1890 return self.serializer_class
1891
1892 def get_queryset(self):
1893 return Slice.select_by_user(self.request.user)
1894
1895 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001896 obj = Slice(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001897 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07001898 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001899 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001900 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001901 raise Exception("failed obj.can_update")
1902
1903 ret = super(SliceList, self).create(request, *args, **kwargs)
1904 if (ret.status_code%100 != 200):
1905 raise Exception(ret.data)
1906
1907 return ret
1908
Scott Baker0caeaf02014-06-19 11:12:55 -07001909
Scott Baker89a7b7c2014-10-07 00:10:17 -07001910class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1911 queryset = Slice.objects.select_related().all()
1912 serializer_class = SliceSerializer
1913 id_serializer_class = SliceIdSerializer
1914
1915 def get_serializer_class(self):
1916 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1917 if (no_hyperlinks):
1918 return self.id_serializer_class
1919 else:
1920 return self.serializer_class
1921
1922 def get_queryset(self):
1923 return Slice.select_by_user(self.request.user)
1924
1925 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1926
1927 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1928
1929
1930
1931class NetworkList(generics.ListCreateAPIView):
1932 queryset = Network.objects.select_related().all()
1933 serializer_class = NetworkSerializer
1934 id_serializer_class = NetworkIdSerializer
1935 filter_backends = (filters.DjangoFilterBackend,)
1936 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',)
1937
1938 def get_serializer_class(self):
1939 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1940 if (no_hyperlinks):
1941 return self.id_serializer_class
1942 else:
1943 return self.serializer_class
1944
1945 def get_queryset(self):
1946 return Network.select_by_user(self.request.user)
1947
1948 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07001949 obj = Network(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001950 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07001951 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001952 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001953 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07001954 raise Exception("failed obj.can_update")
1955
1956 ret = super(NetworkList, self).create(request, *args, **kwargs)
1957 if (ret.status_code%100 != 200):
1958 raise Exception(ret.data)
1959
1960 return ret
1961
Scott Baker89a7b7c2014-10-07 00:10:17 -07001962
1963class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1964 queryset = Network.objects.select_related().all()
1965 serializer_class = NetworkSerializer
1966 id_serializer_class = NetworkIdSerializer
1967
1968 def get_serializer_class(self):
1969 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1970 if (no_hyperlinks):
1971 return self.id_serializer_class
1972 else:
1973 return self.serializer_class
1974
1975 def get_queryset(self):
1976 return Network.select_by_user(self.request.user)
1977
1978 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1979
1980 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1981
1982
1983
1984class ServiceList(generics.ListCreateAPIView):
1985 queryset = Service.objects.select_related().all()
1986 serializer_class = ServiceSerializer
1987 id_serializer_class = ServiceIdSerializer
1988 filter_backends = (filters.DjangoFilterBackend,)
1989 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
1990
1991 def get_serializer_class(self):
1992 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1993 if (no_hyperlinks):
1994 return self.id_serializer_class
1995 else:
1996 return self.serializer_class
1997
1998 def get_queryset(self):
1999 return Service.select_by_user(self.request.user)
2000
2001 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002002 obj = Service(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002003 obj.caller = request.user
2004 if obj.can_update(request.user):
2005 return super(ServiceList, self).create(request, *args, **kwargs)
2006 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002007 raise Exception("failed obj.can_update")
2008
2009 ret = super(ServiceList, self).create(request, *args, **kwargs)
2010 if (ret.status_code%100 != 200):
2011 raise Exception(ret.data)
2012
2013 return ret
2014
Scott Baker89a7b7c2014-10-07 00:10:17 -07002015
2016class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2017 queryset = Service.objects.select_related().all()
2018 serializer_class = ServiceSerializer
2019 id_serializer_class = ServiceIdSerializer
2020
2021 def get_serializer_class(self):
2022 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2023 if (no_hyperlinks):
2024 return self.id_serializer_class
2025 else:
2026 return self.serializer_class
2027
2028 def get_queryset(self):
2029 return Service.select_by_user(self.request.user)
2030
2031 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2032
2033 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2034
2035
2036
2037class ServiceClassList(generics.ListCreateAPIView):
2038 queryset = ServiceClass.objects.select_related().all()
2039 serializer_class = ServiceClassSerializer
2040 id_serializer_class = ServiceClassIdSerializer
2041 filter_backends = (filters.DjangoFilterBackend,)
2042 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
2043
2044 def get_serializer_class(self):
2045 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2046 if (no_hyperlinks):
2047 return self.id_serializer_class
2048 else:
2049 return self.serializer_class
2050
2051 def get_queryset(self):
2052 return ServiceClass.select_by_user(self.request.user)
2053
2054 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002055 obj = ServiceClass(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002056 obj.caller = request.user
2057 if obj.can_update(request.user):
2058 return super(ServiceClassList, self).create(request, *args, **kwargs)
2059 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002060 raise Exception("failed obj.can_update")
2061
2062 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
2063 if (ret.status_code%100 != 200):
2064 raise Exception(ret.data)
2065
2066 return ret
2067
Scott Baker89a7b7c2014-10-07 00:10:17 -07002068
2069class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2070 queryset = ServiceClass.objects.select_related().all()
2071 serializer_class = ServiceClassSerializer
2072 id_serializer_class = ServiceClassIdSerializer
2073
2074 def get_serializer_class(self):
2075 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2076 if (no_hyperlinks):
2077 return self.id_serializer_class
2078 else:
2079 return self.serializer_class
2080
2081 def get_queryset(self):
2082 return ServiceClass.select_by_user(self.request.user)
2083
2084 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2085
2086 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2087
2088
2089
2090class PaymentList(generics.ListCreateAPIView):
2091 queryset = Payment.objects.select_related().all()
2092 serializer_class = PaymentSerializer
2093 id_serializer_class = PaymentIdSerializer
2094 filter_backends = (filters.DjangoFilterBackend,)
2095 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
2096
2097 def get_serializer_class(self):
2098 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2099 if (no_hyperlinks):
2100 return self.id_serializer_class
2101 else:
2102 return self.serializer_class
2103
2104 def get_queryset(self):
2105 return Payment.select_by_user(self.request.user)
2106
2107 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002108 obj = Payment(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002109 obj.caller = request.user
2110 if obj.can_update(request.user):
2111 return super(PaymentList, self).create(request, *args, **kwargs)
2112 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002113 raise Exception("failed obj.can_update")
2114
2115 ret = super(PaymentList, self).create(request, *args, **kwargs)
2116 if (ret.status_code%100 != 200):
2117 raise Exception(ret.data)
2118
2119 return ret
2120
Scott Baker89a7b7c2014-10-07 00:10:17 -07002121
2122class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2123 queryset = Payment.objects.select_related().all()
2124 serializer_class = PaymentSerializer
2125 id_serializer_class = PaymentIdSerializer
2126
2127 def get_serializer_class(self):
2128 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2129 if (no_hyperlinks):
2130 return self.id_serializer_class
2131 else:
2132 return self.serializer_class
2133
2134 def get_queryset(self):
2135 return Payment.select_by_user(self.request.user)
2136
2137 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2138
2139 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2140
2141
2142
2143class ChargeList(generics.ListCreateAPIView):
2144 queryset = Charge.objects.select_related().all()
2145 serializer_class = ChargeSerializer
2146 id_serializer_class = ChargeIdSerializer
2147 filter_backends = (filters.DjangoFilterBackend,)
2148 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
2149
2150 def get_serializer_class(self):
2151 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2152 if (no_hyperlinks):
2153 return self.id_serializer_class
2154 else:
2155 return self.serializer_class
2156
2157 def get_queryset(self):
2158 return Charge.select_by_user(self.request.user)
2159
2160 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002161 obj = Charge(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002162 obj.caller = request.user
2163 if obj.can_update(request.user):
2164 return super(ChargeList, self).create(request, *args, **kwargs)
2165 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002166 raise Exception("failed obj.can_update")
2167
2168 ret = super(ChargeList, self).create(request, *args, **kwargs)
2169 if (ret.status_code%100 != 200):
2170 raise Exception(ret.data)
2171
2172 return ret
2173
Scott Baker89a7b7c2014-10-07 00:10:17 -07002174
2175class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2176 queryset = Charge.objects.select_related().all()
2177 serializer_class = ChargeSerializer
2178 id_serializer_class = ChargeIdSerializer
2179
2180 def get_serializer_class(self):
2181 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2182 if (no_hyperlinks):
2183 return self.id_serializer_class
2184 else:
2185 return self.serializer_class
2186
2187 def get_queryset(self):
2188 return Charge.select_by_user(self.request.user)
2189
2190 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2191
2192 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2193
2194
2195
2196class RoleList(generics.ListCreateAPIView):
2197 queryset = Role.objects.select_related().all()
2198 serializer_class = RoleSerializer
2199 id_serializer_class = RoleIdSerializer
2200 filter_backends = (filters.DjangoFilterBackend,)
2201 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
2202
2203 def get_serializer_class(self):
2204 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2205 if (no_hyperlinks):
2206 return self.id_serializer_class
2207 else:
2208 return self.serializer_class
2209
2210 def get_queryset(self):
2211 return Role.select_by_user(self.request.user)
2212
2213 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002214 obj = Role(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002215 obj.caller = request.user
2216 if obj.can_update(request.user):
2217 return super(RoleList, self).create(request, *args, **kwargs)
2218 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002219 raise Exception("failed obj.can_update")
2220
2221 ret = super(RoleList, self).create(request, *args, **kwargs)
2222 if (ret.status_code%100 != 200):
2223 raise Exception(ret.data)
2224
2225 return ret
2226
Scott Baker89a7b7c2014-10-07 00:10:17 -07002227
2228class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2229 queryset = Role.objects.select_related().all()
2230 serializer_class = RoleSerializer
2231 id_serializer_class = RoleIdSerializer
2232
2233 def get_serializer_class(self):
2234 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2235 if (no_hyperlinks):
2236 return self.id_serializer_class
2237 else:
2238 return self.serializer_class
2239
2240 def get_queryset(self):
2241 return Role.select_by_user(self.request.user)
2242
2243 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2244
2245 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2246
2247
2248
2249class UsableObjectList(generics.ListCreateAPIView):
2250 queryset = UsableObject.objects.select_related().all()
2251 serializer_class = UsableObjectSerializer
2252 id_serializer_class = UsableObjectIdSerializer
2253 filter_backends = (filters.DjangoFilterBackend,)
2254 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
2255
2256 def get_serializer_class(self):
2257 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2258 if (no_hyperlinks):
2259 return self.id_serializer_class
2260 else:
2261 return self.serializer_class
2262
2263 def get_queryset(self):
2264 return UsableObject.select_by_user(self.request.user)
2265
2266 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002267 obj = UsableObject(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002268 obj.caller = request.user
2269 if obj.can_update(request.user):
2270 return super(UsableObjectList, self).create(request, *args, **kwargs)
2271 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002272 raise Exception("failed obj.can_update")
2273
2274 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
2275 if (ret.status_code%100 != 200):
2276 raise Exception(ret.data)
2277
2278 return ret
2279
Scott Baker89a7b7c2014-10-07 00:10:17 -07002280
2281class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2282 queryset = UsableObject.objects.select_related().all()
2283 serializer_class = UsableObjectSerializer
2284 id_serializer_class = UsableObjectIdSerializer
2285
2286 def get_serializer_class(self):
2287 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2288 if (no_hyperlinks):
2289 return self.id_serializer_class
2290 else:
2291 return self.serializer_class
2292
2293 def get_queryset(self):
2294 return UsableObject.select_by_user(self.request.user)
2295
2296 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2297
2298 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2299
2300
2301
2302class SiteRoleList(generics.ListCreateAPIView):
2303 queryset = SiteRole.objects.select_related().all()
2304 serializer_class = SiteRoleSerializer
2305 id_serializer_class = SiteRoleIdSerializer
2306 filter_backends = (filters.DjangoFilterBackend,)
2307 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2308
2309 def get_serializer_class(self):
2310 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2311 if (no_hyperlinks):
2312 return self.id_serializer_class
2313 else:
2314 return self.serializer_class
2315
2316 def get_queryset(self):
2317 return SiteRole.select_by_user(self.request.user)
2318
2319 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002320 obj = SiteRole(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002321 obj.caller = request.user
2322 if obj.can_update(request.user):
2323 return super(SiteRoleList, self).create(request, *args, **kwargs)
2324 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002325 raise Exception("failed obj.can_update")
2326
2327 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
2328 if (ret.status_code%100 != 200):
2329 raise Exception(ret.data)
2330
2331 return ret
2332
Scott Baker89a7b7c2014-10-07 00:10:17 -07002333
2334class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2335 queryset = SiteRole.objects.select_related().all()
2336 serializer_class = SiteRoleSerializer
2337 id_serializer_class = SiteRoleIdSerializer
2338
2339 def get_serializer_class(self):
2340 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2341 if (no_hyperlinks):
2342 return self.id_serializer_class
2343 else:
2344 return self.serializer_class
2345
2346 def get_queryset(self):
2347 return SiteRole.select_by_user(self.request.user)
2348
2349 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2350
2351 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2352
2353
2354
2355class SliceCredentialList(generics.ListCreateAPIView):
2356 queryset = SliceCredential.objects.select_related().all()
2357 serializer_class = SliceCredentialSerializer
2358 id_serializer_class = SliceCredentialIdSerializer
2359 filter_backends = (filters.DjangoFilterBackend,)
2360 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
2361
2362 def get_serializer_class(self):
2363 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2364 if (no_hyperlinks):
2365 return self.id_serializer_class
2366 else:
2367 return self.serializer_class
2368
2369 def get_queryset(self):
2370 return SliceCredential.select_by_user(self.request.user)
2371
2372 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002373 obj = SliceCredential(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002374 obj.caller = request.user
2375 if obj.can_update(request.user):
2376 return super(SliceCredentialList, self).create(request, *args, **kwargs)
2377 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002378 raise Exception("failed obj.can_update")
2379
2380 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
2381 if (ret.status_code%100 != 200):
2382 raise Exception(ret.data)
2383
2384 return ret
2385
Scott Baker89a7b7c2014-10-07 00:10:17 -07002386
2387class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2388 queryset = SliceCredential.objects.select_related().all()
2389 serializer_class = SliceCredentialSerializer
2390 id_serializer_class = SliceCredentialIdSerializer
2391
2392 def get_serializer_class(self):
2393 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2394 if (no_hyperlinks):
2395 return self.id_serializer_class
2396 else:
2397 return self.serializer_class
2398
2399 def get_queryset(self):
2400 return SliceCredential.select_by_user(self.request.user)
2401
2402 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2403
2404 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2405
2406
2407
2408class SliverList(generics.ListCreateAPIView):
2409 queryset = Sliver.objects.select_related().all()
2410 serializer_class = SliverSerializer
2411 id_serializer_class = SliverIdSerializer
2412 filter_backends = (filters.DjangoFilterBackend,)
2413 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',)
2414
2415 def get_serializer_class(self):
2416 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2417 if (no_hyperlinks):
2418 return self.id_serializer_class
2419 else:
2420 return self.serializer_class
2421
2422 def get_queryset(self):
2423 return Sliver.select_by_user(self.request.user)
2424
2425 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002426 obj = Sliver(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002427 obj.caller = request.user
2428 if obj.can_update(request.user):
2429 return super(SliverList, self).create(request, *args, **kwargs)
2430 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002431 raise Exception("failed obj.can_update")
2432
2433 ret = super(SliverList, self).create(request, *args, **kwargs)
2434 if (ret.status_code%100 != 200):
2435 raise Exception(ret.data)
2436
2437 return ret
2438
Scott Baker89a7b7c2014-10-07 00:10:17 -07002439
2440class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2441 queryset = Sliver.objects.select_related().all()
2442 serializer_class = SliverSerializer
2443 id_serializer_class = SliverIdSerializer
2444
2445 def get_serializer_class(self):
2446 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2447 if (no_hyperlinks):
2448 return self.id_serializer_class
2449 else:
2450 return self.serializer_class
2451
2452 def get_queryset(self):
2453 return Sliver.select_by_user(self.request.user)
2454
2455 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2456
2457 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2458
2459
2460
2461class NodeList(generics.ListCreateAPIView):
2462 queryset = Node.objects.select_related().all()
2463 serializer_class = NodeSerializer
2464 id_serializer_class = NodeIdSerializer
2465 filter_backends = (filters.DjangoFilterBackend,)
2466 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
2467
2468 def get_serializer_class(self):
2469 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2470 if (no_hyperlinks):
2471 return self.id_serializer_class
2472 else:
2473 return self.serializer_class
2474
2475 def get_queryset(self):
2476 return Node.select_by_user(self.request.user)
2477
2478 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002479 obj = Node(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002480 obj.caller = request.user
2481 if obj.can_update(request.user):
2482 return super(NodeList, self).create(request, *args, **kwargs)
2483 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002484 raise Exception("failed obj.can_update")
2485
2486 ret = super(NodeList, self).create(request, *args, **kwargs)
2487 if (ret.status_code%100 != 200):
2488 raise Exception(ret.data)
2489
2490 return ret
2491
Scott Baker89a7b7c2014-10-07 00:10:17 -07002492
2493class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2494 queryset = Node.objects.select_related().all()
2495 serializer_class = NodeSerializer
2496 id_serializer_class = NodeIdSerializer
2497
2498 def get_serializer_class(self):
2499 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2500 if (no_hyperlinks):
2501 return self.id_serializer_class
2502 else:
2503 return self.serializer_class
2504
2505 def get_queryset(self):
2506 return Node.select_by_user(self.request.user)
2507
2508 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2509
2510 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2511
2512
2513
2514class DashboardViewList(generics.ListCreateAPIView):
2515 queryset = DashboardView.objects.select_related().all()
2516 serializer_class = DashboardViewSerializer
2517 id_serializer_class = DashboardViewIdSerializer
2518 filter_backends = (filters.DjangoFilterBackend,)
2519 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
2520
2521 def get_serializer_class(self):
2522 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2523 if (no_hyperlinks):
2524 return self.id_serializer_class
2525 else:
2526 return self.serializer_class
2527
2528 def get_queryset(self):
2529 return DashboardView.select_by_user(self.request.user)
2530
2531 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002532 obj = DashboardView(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002533 obj.caller = request.user
2534 if obj.can_update(request.user):
2535 return super(DashboardViewList, self).create(request, *args, **kwargs)
2536 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002537 raise Exception("failed obj.can_update")
2538
2539 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
2540 if (ret.status_code%100 != 200):
2541 raise Exception(ret.data)
2542
2543 return ret
2544
Scott Baker89a7b7c2014-10-07 00:10:17 -07002545
2546class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2547 queryset = DashboardView.objects.select_related().all()
2548 serializer_class = DashboardViewSerializer
2549 id_serializer_class = DashboardViewIdSerializer
2550
2551 def get_serializer_class(self):
2552 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2553 if (no_hyperlinks):
2554 return self.id_serializer_class
2555 else:
2556 return self.serializer_class
2557
2558 def get_queryset(self):
2559 return DashboardView.select_by_user(self.request.user)
2560
2561 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2562
2563 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2564
2565
2566
2567class ImageDeploymentsList(generics.ListCreateAPIView):
2568 queryset = ImageDeployments.objects.select_related().all()
2569 serializer_class = ImageDeploymentsSerializer
2570 id_serializer_class = ImageDeploymentsIdSerializer
2571 filter_backends = (filters.DjangoFilterBackend,)
2572 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
2573
2574 def get_serializer_class(self):
2575 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2576 if (no_hyperlinks):
2577 return self.id_serializer_class
2578 else:
2579 return self.serializer_class
2580
2581 def get_queryset(self):
2582 return ImageDeployments.select_by_user(self.request.user)
2583
2584 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002585 obj = ImageDeployments(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002586 obj.caller = request.user
2587 if obj.can_update(request.user):
2588 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
2589 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002590 raise Exception("failed obj.can_update")
2591
2592 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
2593 if (ret.status_code%100 != 200):
2594 raise Exception(ret.data)
2595
2596 return ret
2597
Scott Baker89a7b7c2014-10-07 00:10:17 -07002598
2599class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2600 queryset = ImageDeployments.objects.select_related().all()
2601 serializer_class = ImageDeploymentsSerializer
2602 id_serializer_class = ImageDeploymentsIdSerializer
2603
2604 def get_serializer_class(self):
2605 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2606 if (no_hyperlinks):
2607 return self.id_serializer_class
2608 else:
2609 return self.serializer_class
2610
2611 def get_queryset(self):
2612 return ImageDeployments.select_by_user(self.request.user)
2613
2614 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2615
2616 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2617
2618
2619
2620class ReservedResourceList(generics.ListCreateAPIView):
2621 queryset = ReservedResource.objects.select_related().all()
2622 serializer_class = ReservedResourceSerializer
2623 id_serializer_class = ReservedResourceIdSerializer
2624 filter_backends = (filters.DjangoFilterBackend,)
2625 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
2626
2627 def get_serializer_class(self):
2628 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2629 if (no_hyperlinks):
2630 return self.id_serializer_class
2631 else:
2632 return self.serializer_class
2633
2634 def get_queryset(self):
2635 return ReservedResource.select_by_user(self.request.user)
2636
2637 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002638 obj = ReservedResource(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002639 obj.caller = request.user
2640 if obj.can_update(request.user):
2641 return super(ReservedResourceList, self).create(request, *args, **kwargs)
2642 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002643 raise Exception("failed obj.can_update")
2644
2645 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
2646 if (ret.status_code%100 != 200):
2647 raise Exception(ret.data)
2648
2649 return ret
2650
Scott Baker89a7b7c2014-10-07 00:10:17 -07002651
2652class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2653 queryset = ReservedResource.objects.select_related().all()
2654 serializer_class = ReservedResourceSerializer
2655 id_serializer_class = ReservedResourceIdSerializer
2656
2657 def get_serializer_class(self):
2658 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2659 if (no_hyperlinks):
2660 return self.id_serializer_class
2661 else:
2662 return self.serializer_class
2663
2664 def get_queryset(self):
2665 return ReservedResource.select_by_user(self.request.user)
2666
2667 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2668
2669 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2670
2671
2672
2673class NetworkSliceList(generics.ListCreateAPIView):
2674 queryset = NetworkSlice.objects.select_related().all()
2675 serializer_class = NetworkSliceSerializer
2676 id_serializer_class = NetworkSliceIdSerializer
2677 filter_backends = (filters.DjangoFilterBackend,)
2678 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
2679
2680 def get_serializer_class(self):
2681 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2682 if (no_hyperlinks):
2683 return self.id_serializer_class
2684 else:
2685 return self.serializer_class
2686
2687 def get_queryset(self):
2688 return NetworkSlice.select_by_user(self.request.user)
2689
2690 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002691 obj = NetworkSlice(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002692 obj.caller = request.user
2693 if obj.can_update(request.user):
2694 return super(NetworkSliceList, self).create(request, *args, **kwargs)
2695 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002696 raise Exception("failed obj.can_update")
2697
2698 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
2699 if (ret.status_code%100 != 200):
2700 raise Exception(ret.data)
2701
2702 return ret
2703
Scott Baker89a7b7c2014-10-07 00:10:17 -07002704
2705class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2706 queryset = NetworkSlice.objects.select_related().all()
2707 serializer_class = NetworkSliceSerializer
2708 id_serializer_class = NetworkSliceIdSerializer
2709
2710 def get_serializer_class(self):
2711 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2712 if (no_hyperlinks):
2713 return self.id_serializer_class
2714 else:
2715 return self.serializer_class
2716
2717 def get_queryset(self):
2718 return NetworkSlice.select_by_user(self.request.user)
2719
2720 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2721
2722 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2723
2724
2725
2726class UserDashboardViewList(generics.ListCreateAPIView):
2727 queryset = UserDashboardView.objects.select_related().all()
2728 serializer_class = UserDashboardViewSerializer
2729 id_serializer_class = UserDashboardViewIdSerializer
2730 filter_backends = (filters.DjangoFilterBackend,)
2731 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
2732
2733 def get_serializer_class(self):
2734 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2735 if (no_hyperlinks):
2736 return self.id_serializer_class
2737 else:
2738 return self.serializer_class
2739
2740 def get_queryset(self):
2741 return UserDashboardView.select_by_user(self.request.user)
2742
2743 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002744 obj = UserDashboardView(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002745 obj.caller = request.user
2746 if obj.can_update(request.user):
2747 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
2748 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002749 raise Exception("failed obj.can_update")
2750
2751 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
2752 if (ret.status_code%100 != 200):
2753 raise Exception(ret.data)
2754
2755 return ret
2756
Scott Baker89a7b7c2014-10-07 00:10:17 -07002757
2758class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2759 queryset = UserDashboardView.objects.select_related().all()
2760 serializer_class = UserDashboardViewSerializer
2761 id_serializer_class = UserDashboardViewIdSerializer
2762
2763 def get_serializer_class(self):
2764 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2765 if (no_hyperlinks):
2766 return self.id_serializer_class
2767 else:
2768 return self.serializer_class
2769
2770 def get_queryset(self):
2771 return UserDashboardView.select_by_user(self.request.user)
2772
2773 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2774
2775 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2776
2777
2778
2779class PlanetStackPrivilegeList(generics.ListCreateAPIView):
2780 queryset = PlanetStackPrivilege.objects.select_related().all()
2781 serializer_class = PlanetStackPrivilegeSerializer
2782 id_serializer_class = PlanetStackPrivilegeIdSerializer
2783 filter_backends = (filters.DjangoFilterBackend,)
2784 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
2785
2786 def get_serializer_class(self):
2787 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2788 if (no_hyperlinks):
2789 return self.id_serializer_class
2790 else:
2791 return self.serializer_class
2792
2793 def get_queryset(self):
2794 return PlanetStackPrivilege.select_by_user(self.request.user)
2795
2796 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002797 obj = PlanetStackPrivilege(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002798 obj.caller = request.user
2799 if obj.can_update(request.user):
2800 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
2801 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002802 raise Exception("failed obj.can_update")
2803
2804 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
2805 if (ret.status_code%100 != 200):
2806 raise Exception(ret.data)
2807
2808 return ret
2809
Scott Baker89a7b7c2014-10-07 00:10:17 -07002810
2811class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2812 queryset = PlanetStackPrivilege.objects.select_related().all()
2813 serializer_class = PlanetStackPrivilegeSerializer
2814 id_serializer_class = PlanetStackPrivilegeIdSerializer
2815
2816 def get_serializer_class(self):
2817 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2818 if (no_hyperlinks):
2819 return self.id_serializer_class
2820 else:
2821 return self.serializer_class
2822
2823 def get_queryset(self):
2824 return PlanetStackPrivilege.select_by_user(self.request.user)
2825
2826 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2827
2828 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2829
2830
2831
2832class UserList(generics.ListCreateAPIView):
2833 queryset = User.objects.select_related().all()
2834 serializer_class = UserSerializer
2835 id_serializer_class = UserIdSerializer
2836 filter_backends = (filters.DjangoFilterBackend,)
2837 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',)
2838
2839 def get_serializer_class(self):
2840 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2841 if (no_hyperlinks):
2842 return self.id_serializer_class
2843 else:
2844 return self.serializer_class
2845
2846 def get_queryset(self):
2847 return User.select_by_user(self.request.user)
2848
2849 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002850 print "XXX create"
2851 obj = User(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002852 obj.caller = request.user
2853 if obj.can_update(request.user):
2854 return super(UserList, self).create(request, *args, **kwargs)
2855 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002856 raise Exception("failed obj.can_update")
2857
2858 ret = super(UserList, self).create(request, *args, **kwargs)
2859 if (ret.status_code%100 != 200):
2860 raise Exception(ret.data)
2861
2862 return ret
2863
2864 def put(self, request, *args, **kwargs):
2865 print "XXX UserList.put"
2866 return super(UserList,self).put(request,*args, **kwargs)
2867
Scott Baker89a7b7c2014-10-07 00:10:17 -07002868
2869class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2870 queryset = User.objects.select_related().all()
2871 serializer_class = UserSerializer
2872 id_serializer_class = UserIdSerializer
2873
2874 def get_serializer_class(self):
2875 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2876 if (no_hyperlinks):
2877 return self.id_serializer_class
2878 else:
2879 return self.serializer_class
2880
2881 def get_queryset(self):
2882 return User.select_by_user(self.request.user)
2883
2884 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2885
2886 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2887
2888
2889
2890class DeploymentList(generics.ListCreateAPIView):
2891 queryset = Deployment.objects.select_related().all()
2892 serializer_class = DeploymentSerializer
2893 id_serializer_class = DeploymentIdSerializer
2894 filter_backends = (filters.DjangoFilterBackend,)
2895 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',)
2896
2897 def get_serializer_class(self):
2898 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2899 if (no_hyperlinks):
2900 return self.id_serializer_class
2901 else:
2902 return self.serializer_class
2903
2904 def get_queryset(self):
2905 return Deployment.select_by_user(self.request.user)
2906
2907 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002908 obj = Deployment(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002909 obj.caller = request.user
2910 if obj.can_update(request.user):
2911 return super(DeploymentList, self).create(request, *args, **kwargs)
2912 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002913 raise Exception("failed obj.can_update")
2914
2915 ret = super(DeploymentList, self).create(request, *args, **kwargs)
2916 if (ret.status_code%100 != 200):
2917 raise Exception(ret.data)
2918
2919 return ret
2920
Scott Baker89a7b7c2014-10-07 00:10:17 -07002921
2922class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2923 queryset = Deployment.objects.select_related().all()
2924 serializer_class = DeploymentSerializer
2925 id_serializer_class = DeploymentIdSerializer
2926
2927 def get_serializer_class(self):
2928 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2929 if (no_hyperlinks):
2930 return self.id_serializer_class
2931 else:
2932 return self.serializer_class
2933
2934 def get_queryset(self):
2935 return Deployment.select_by_user(self.request.user)
2936
2937 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2938
2939 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2940
2941
2942
2943class ReservationList(generics.ListCreateAPIView):
2944 queryset = Reservation.objects.select_related().all()
2945 serializer_class = ReservationSerializer
2946 id_serializer_class = ReservationIdSerializer
2947 filter_backends = (filters.DjangoFilterBackend,)
2948 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
2949
2950 def get_serializer_class(self):
2951 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2952 if (no_hyperlinks):
2953 return self.id_serializer_class
2954 else:
2955 return self.serializer_class
2956
2957 def get_queryset(self):
2958 return Reservation.select_by_user(self.request.user)
2959
2960 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07002961 obj = Reservation(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002962 obj.caller = request.user
2963 if obj.can_update(request.user):
2964 return super(ReservationList, self).create(request, *args, **kwargs)
2965 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002966 raise Exception("failed obj.can_update")
2967
2968 ret = super(ReservationList, self).create(request, *args, **kwargs)
2969 if (ret.status_code%100 != 200):
2970 raise Exception(ret.data)
2971
2972 return ret
2973
Scott Baker89a7b7c2014-10-07 00:10:17 -07002974
2975class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2976 queryset = Reservation.objects.select_related().all()
2977 serializer_class = ReservationSerializer
2978 id_serializer_class = ReservationIdSerializer
2979
2980 def get_serializer_class(self):
2981 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2982 if (no_hyperlinks):
2983 return self.id_serializer_class
2984 else:
2985 return self.serializer_class
2986
2987 def get_queryset(self):
2988 return Reservation.select_by_user(self.request.user)
2989
2990 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2991
2992 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2993
2994
2995
2996class SliceDeploymentsList(generics.ListCreateAPIView):
2997 queryset = SliceDeployments.objects.select_related().all()
2998 serializer_class = SliceDeploymentsSerializer
2999 id_serializer_class = SliceDeploymentsIdSerializer
3000 filter_backends = (filters.DjangoFilterBackend,)
3001 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
3002
3003 def get_serializer_class(self):
3004 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3005 if (no_hyperlinks):
3006 return self.id_serializer_class
3007 else:
3008 return self.serializer_class
3009
3010 def get_queryset(self):
3011 return SliceDeployments.select_by_user(self.request.user)
3012
3013 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003014 obj = SliceDeployments(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003015 obj.caller = request.user
3016 if obj.can_update(request.user):
3017 return super(SliceDeploymentsList, self).create(request, *args, **kwargs)
3018 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003019 raise Exception("failed obj.can_update")
3020
3021 ret = super(SliceDeploymentsList, self).create(request, *args, **kwargs)
3022 if (ret.status_code%100 != 200):
3023 raise Exception(ret.data)
3024
3025 return ret
3026
Scott Baker89a7b7c2014-10-07 00:10:17 -07003027
3028class SliceDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3029 queryset = SliceDeployments.objects.select_related().all()
3030 serializer_class = SliceDeploymentsSerializer
3031 id_serializer_class = SliceDeploymentsIdSerializer
3032
3033 def get_serializer_class(self):
3034 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3035 if (no_hyperlinks):
3036 return self.id_serializer_class
3037 else:
3038 return self.serializer_class
3039
3040 def get_queryset(self):
3041 return SliceDeployments.select_by_user(self.request.user)
3042
3043 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3044
3045 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3046
3047
3048
3049class SitePrivilegeList(generics.ListCreateAPIView):
3050 queryset = SitePrivilege.objects.select_related().all()
3051 serializer_class = SitePrivilegeSerializer
3052 id_serializer_class = SitePrivilegeIdSerializer
3053 filter_backends = (filters.DjangoFilterBackend,)
3054 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
3055
3056 def get_serializer_class(self):
3057 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3058 if (no_hyperlinks):
3059 return self.id_serializer_class
3060 else:
3061 return self.serializer_class
3062
3063 def get_queryset(self):
3064 return SitePrivilege.select_by_user(self.request.user)
3065
3066 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003067 obj = SitePrivilege(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003068 obj.caller = request.user
3069 if obj.can_update(request.user):
3070 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
3071 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003072 raise Exception("failed obj.can_update")
3073
3074 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
3075 if (ret.status_code%100 != 200):
3076 raise Exception(ret.data)
3077
3078 return ret
3079
Scott Baker89a7b7c2014-10-07 00:10:17 -07003080
3081class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3082 queryset = SitePrivilege.objects.select_related().all()
3083 serializer_class = SitePrivilegeSerializer
3084 id_serializer_class = SitePrivilegeIdSerializer
3085
3086 def get_serializer_class(self):
3087 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3088 if (no_hyperlinks):
3089 return self.id_serializer_class
3090 else:
3091 return self.serializer_class
3092
3093 def get_queryset(self):
3094 return SitePrivilege.select_by_user(self.request.user)
3095
3096 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3097
3098 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3099
3100
3101
3102class PlanetStackList(generics.ListCreateAPIView):
3103 queryset = PlanetStack.objects.select_related().all()
3104 serializer_class = PlanetStackSerializer
3105 id_serializer_class = PlanetStackIdSerializer
3106 filter_backends = (filters.DjangoFilterBackend,)
3107 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
3108
3109 def get_serializer_class(self):
3110 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3111 if (no_hyperlinks):
3112 return self.id_serializer_class
3113 else:
3114 return self.serializer_class
3115
3116 def get_queryset(self):
3117 return PlanetStack.select_by_user(self.request.user)
3118
3119 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003120 obj = PlanetStack(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003121 obj.caller = request.user
3122 if obj.can_update(request.user):
3123 return super(PlanetStackList, self).create(request, *args, **kwargs)
3124 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003125 raise Exception("failed obj.can_update")
3126
3127 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
3128 if (ret.status_code%100 != 200):
3129 raise Exception(ret.data)
3130
3131 return ret
3132
Scott Baker89a7b7c2014-10-07 00:10:17 -07003133
3134class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3135 queryset = PlanetStack.objects.select_related().all()
3136 serializer_class = PlanetStackSerializer
3137 id_serializer_class = PlanetStackIdSerializer
3138
3139 def get_serializer_class(self):
3140 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3141 if (no_hyperlinks):
3142 return self.id_serializer_class
3143 else:
3144 return self.serializer_class
3145
3146 def get_queryset(self):
3147 return PlanetStack.select_by_user(self.request.user)
3148
3149 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3150
3151 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3152
3153
3154
3155class UserDeploymentsList(generics.ListCreateAPIView):
3156 queryset = UserDeployments.objects.select_related().all()
3157 serializer_class = UserDeploymentsSerializer
3158 id_serializer_class = UserDeploymentsIdSerializer
3159 filter_backends = (filters.DjangoFilterBackend,)
3160 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
3161
3162 def get_serializer_class(self):
3163 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3164 if (no_hyperlinks):
3165 return self.id_serializer_class
3166 else:
3167 return self.serializer_class
3168
3169 def get_queryset(self):
3170 return UserDeployments.select_by_user(self.request.user)
3171
3172 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003173 obj = UserDeployments(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003174 obj.caller = request.user
3175 if obj.can_update(request.user):
3176 return super(UserDeploymentsList, self).create(request, *args, **kwargs)
3177 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003178 raise Exception("failed obj.can_update")
3179
3180 ret = super(UserDeploymentsList, self).create(request, *args, **kwargs)
3181 if (ret.status_code%100 != 200):
3182 raise Exception(ret.data)
3183
3184 return ret
3185
Scott Baker89a7b7c2014-10-07 00:10:17 -07003186
3187class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3188 queryset = UserDeployments.objects.select_related().all()
3189 serializer_class = UserDeploymentsSerializer
3190 id_serializer_class = UserDeploymentsIdSerializer
3191
3192 def get_serializer_class(self):
3193 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3194 if (no_hyperlinks):
3195 return self.id_serializer_class
3196 else:
3197 return self.serializer_class
3198
3199 def get_queryset(self):
3200 return UserDeployments.select_by_user(self.request.user)
3201
3202 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3203
3204 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3205
3206
3207
3208class AccountList(generics.ListCreateAPIView):
3209 queryset = Account.objects.select_related().all()
3210 serializer_class = AccountSerializer
3211 id_serializer_class = AccountIdSerializer
3212 filter_backends = (filters.DjangoFilterBackend,)
3213 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
3214
3215 def get_serializer_class(self):
3216 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3217 if (no_hyperlinks):
3218 return self.id_serializer_class
3219 else:
3220 return self.serializer_class
3221
3222 def get_queryset(self):
3223 return Account.select_by_user(self.request.user)
3224
3225 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003226 obj = Account(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003227 obj.caller = request.user
3228 if obj.can_update(request.user):
3229 return super(AccountList, self).create(request, *args, **kwargs)
3230 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003231 raise Exception("failed obj.can_update")
3232
3233 ret = super(AccountList, self).create(request, *args, **kwargs)
3234 if (ret.status_code%100 != 200):
3235 raise Exception(ret.data)
3236
3237 return ret
3238
Scott Baker89a7b7c2014-10-07 00:10:17 -07003239
3240class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3241 queryset = Account.objects.select_related().all()
3242 serializer_class = AccountSerializer
3243 id_serializer_class = AccountIdSerializer
3244
3245 def get_serializer_class(self):
3246 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3247 if (no_hyperlinks):
3248 return self.id_serializer_class
3249 else:
3250 return self.serializer_class
3251
3252 def get_queryset(self):
3253 return Account.select_by_user(self.request.user)
3254
3255 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3256
3257 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3258
3259
3260
3261class NetworkParameterTypeList(generics.ListCreateAPIView):
3262 queryset = NetworkParameterType.objects.select_related().all()
3263 serializer_class = NetworkParameterTypeSerializer
3264 id_serializer_class = NetworkParameterTypeIdSerializer
3265 filter_backends = (filters.DjangoFilterBackend,)
3266 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
3267
3268 def get_serializer_class(self):
3269 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3270 if (no_hyperlinks):
3271 return self.id_serializer_class
3272 else:
3273 return self.serializer_class
3274
3275 def get_queryset(self):
3276 return NetworkParameterType.select_by_user(self.request.user)
3277
3278 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003279 obj = NetworkParameterType(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003280 obj.caller = request.user
3281 if obj.can_update(request.user):
3282 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
3283 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003284 raise Exception("failed obj.can_update")
3285
3286 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
3287 if (ret.status_code%100 != 200):
3288 raise Exception(ret.data)
3289
3290 return ret
3291
Scott Baker89a7b7c2014-10-07 00:10:17 -07003292
3293class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3294 queryset = NetworkParameterType.objects.select_related().all()
3295 serializer_class = NetworkParameterTypeSerializer
3296 id_serializer_class = NetworkParameterTypeIdSerializer
3297
3298 def get_serializer_class(self):
3299 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3300 if (no_hyperlinks):
3301 return self.id_serializer_class
3302 else:
3303 return self.serializer_class
3304
3305 def get_queryset(self):
3306 return NetworkParameterType.select_by_user(self.request.user)
3307
3308 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3309
3310 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3311
3312
3313
3314class SiteCredentialList(generics.ListCreateAPIView):
3315 queryset = SiteCredential.objects.select_related().all()
3316 serializer_class = SiteCredentialSerializer
3317 id_serializer_class = SiteCredentialIdSerializer
3318 filter_backends = (filters.DjangoFilterBackend,)
3319 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
3320
3321 def get_serializer_class(self):
3322 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3323 if (no_hyperlinks):
3324 return self.id_serializer_class
3325 else:
3326 return self.serializer_class
3327
3328 def get_queryset(self):
3329 return SiteCredential.select_by_user(self.request.user)
3330
3331 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003332 obj = SiteCredential(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003333 obj.caller = request.user
3334 if obj.can_update(request.user):
3335 return super(SiteCredentialList, self).create(request, *args, **kwargs)
3336 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003337 raise Exception("failed obj.can_update")
3338
3339 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
3340 if (ret.status_code%100 != 200):
3341 raise Exception(ret.data)
3342
3343 return ret
3344
Scott Baker89a7b7c2014-10-07 00:10:17 -07003345
3346class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3347 queryset = SiteCredential.objects.select_related().all()
3348 serializer_class = SiteCredentialSerializer
3349 id_serializer_class = SiteCredentialIdSerializer
3350
3351 def get_serializer_class(self):
3352 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3353 if (no_hyperlinks):
3354 return self.id_serializer_class
3355 else:
3356 return self.serializer_class
3357
3358 def get_queryset(self):
3359 return SiteCredential.select_by_user(self.request.user)
3360
3361 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3362
3363 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3364
3365
3366
3367class DeploymentPrivilegeList(generics.ListCreateAPIView):
3368 queryset = DeploymentPrivilege.objects.select_related().all()
3369 serializer_class = DeploymentPrivilegeSerializer
3370 id_serializer_class = DeploymentPrivilegeIdSerializer
3371 filter_backends = (filters.DjangoFilterBackend,)
3372 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
3373
3374 def get_serializer_class(self):
3375 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3376 if (no_hyperlinks):
3377 return self.id_serializer_class
3378 else:
3379 return self.serializer_class
3380
3381 def get_queryset(self):
3382 return DeploymentPrivilege.select_by_user(self.request.user)
3383
3384 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003385 obj = DeploymentPrivilege(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003386 obj.caller = request.user
3387 if obj.can_update(request.user):
3388 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
3389 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003390 raise Exception("failed obj.can_update")
3391
3392 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
3393 if (ret.status_code%100 != 200):
3394 raise Exception(ret.data)
3395
3396 return ret
3397
Scott Baker89a7b7c2014-10-07 00:10:17 -07003398
3399class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3400 queryset = DeploymentPrivilege.objects.select_related().all()
3401 serializer_class = DeploymentPrivilegeSerializer
3402 id_serializer_class = DeploymentPrivilegeIdSerializer
3403
3404 def get_serializer_class(self):
3405 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3406 if (no_hyperlinks):
3407 return self.id_serializer_class
3408 else:
3409 return self.serializer_class
3410
3411 def get_queryset(self):
3412 return DeploymentPrivilege.select_by_user(self.request.user)
3413
3414 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3415
3416 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3417
3418
3419
3420class DeploymentRoleList(generics.ListCreateAPIView):
3421 queryset = DeploymentRole.objects.select_related().all()
3422 serializer_class = DeploymentRoleSerializer
3423 id_serializer_class = DeploymentRoleIdSerializer
3424 filter_backends = (filters.DjangoFilterBackend,)
3425 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3426
3427 def get_serializer_class(self):
3428 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3429 if (no_hyperlinks):
3430 return self.id_serializer_class
3431 else:
3432 return self.serializer_class
3433
3434 def get_queryset(self):
3435 return DeploymentRole.select_by_user(self.request.user)
3436
3437 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003438 obj = DeploymentRole(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003439 obj.caller = request.user
3440 if obj.can_update(request.user):
3441 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
3442 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003443 raise Exception("failed obj.can_update")
3444
3445 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
3446 if (ret.status_code%100 != 200):
3447 raise Exception(ret.data)
3448
3449 return ret
3450
Scott Baker89a7b7c2014-10-07 00:10:17 -07003451
3452class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3453 queryset = DeploymentRole.objects.select_related().all()
3454 serializer_class = DeploymentRoleSerializer
3455 id_serializer_class = DeploymentRoleIdSerializer
3456
3457 def get_serializer_class(self):
3458 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3459 if (no_hyperlinks):
3460 return self.id_serializer_class
3461 else:
3462 return self.serializer_class
3463
3464 def get_queryset(self):
3465 return DeploymentRole.select_by_user(self.request.user)
3466
3467 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3468
3469 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3470
3471
3472
3473class UserCredentialList(generics.ListCreateAPIView):
3474 queryset = UserCredential.objects.select_related().all()
3475 serializer_class = UserCredentialSerializer
3476 id_serializer_class = UserCredentialIdSerializer
3477 filter_backends = (filters.DjangoFilterBackend,)
3478 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
3479
3480 def get_serializer_class(self):
3481 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3482 if (no_hyperlinks):
3483 return self.id_serializer_class
3484 else:
3485 return self.serializer_class
3486
3487 def get_queryset(self):
3488 return UserCredential.select_by_user(self.request.user)
3489
3490 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003491 obj = UserCredential(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003492 obj.caller = request.user
3493 if obj.can_update(request.user):
3494 return super(UserCredentialList, self).create(request, *args, **kwargs)
3495 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003496 raise Exception("failed obj.can_update")
3497
3498 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
3499 if (ret.status_code%100 != 200):
3500 raise Exception(ret.data)
3501
3502 return ret
3503
Scott Baker89a7b7c2014-10-07 00:10:17 -07003504
3505class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3506 queryset = UserCredential.objects.select_related().all()
3507 serializer_class = UserCredentialSerializer
3508 id_serializer_class = UserCredentialIdSerializer
3509
3510 def get_serializer_class(self):
3511 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3512 if (no_hyperlinks):
3513 return self.id_serializer_class
3514 else:
3515 return self.serializer_class
3516
3517 def get_queryset(self):
3518 return UserCredential.select_by_user(self.request.user)
3519
3520 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3521
3522 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3523
3524
3525
3526class SiteDeploymentsList(generics.ListCreateAPIView):
3527 queryset = SiteDeployments.objects.select_related().all()
3528 serializer_class = SiteDeploymentsSerializer
3529 id_serializer_class = SiteDeploymentsIdSerializer
3530 filter_backends = (filters.DjangoFilterBackend,)
3531 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
3532
3533 def get_serializer_class(self):
3534 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3535 if (no_hyperlinks):
3536 return self.id_serializer_class
3537 else:
3538 return self.serializer_class
3539
3540 def get_queryset(self):
3541 return SiteDeployments.select_by_user(self.request.user)
3542
3543 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003544 obj = SiteDeployments(**request.DATA)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003545 obj.caller = request.user
3546 if obj.can_update(request.user):
3547 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
3548 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003549 raise Exception("failed obj.can_update")
3550
3551 ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
3552 if (ret.status_code%100 != 200):
3553 raise Exception(ret.data)
3554
3555 return ret
3556
Scott Baker89a7b7c2014-10-07 00:10:17 -07003557
3558class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3559 queryset = SiteDeployments.objects.select_related().all()
3560 serializer_class = SiteDeploymentsSerializer
3561 id_serializer_class = SiteDeploymentsIdSerializer
3562
3563 def get_serializer_class(self):
3564 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3565 if (no_hyperlinks):
3566 return self.id_serializer_class
3567 else:
3568 return self.serializer_class
3569
3570 def get_queryset(self):
3571 return SiteDeployments.select_by_user(self.request.user)
3572
3573 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3574
3575 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003576
3577
3578
Scott Baker0caeaf02014-06-19 11:12:55 -07003579class SliceTagList(generics.ListCreateAPIView):
3580 queryset = SliceTag.objects.select_related().all()
3581 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003582 id_serializer_class = SliceTagIdSerializer
3583 filter_backends = (filters.DjangoFilterBackend,)
3584 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
3585
3586 def get_serializer_class(self):
3587 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3588 if (no_hyperlinks):
3589 return self.id_serializer_class
3590 else:
3591 return self.serializer_class
3592
Scott Baker0caeaf02014-06-19 11:12:55 -07003593 def get_queryset(self):
3594 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003595
Scott Baker0caeaf02014-06-19 11:12:55 -07003596 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003597 obj = SliceTag(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07003598 obj.caller = request.user
3599 if obj.can_update(request.user):
3600 return super(SliceTagList, self).create(request, *args, **kwargs)
3601 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003602 raise Exception("failed obj.can_update")
3603
3604 ret = super(SliceTagList, self).create(request, *args, **kwargs)
3605 if (ret.status_code%100 != 200):
3606 raise Exception(ret.data)
3607
3608 return ret
3609
Scott Baker0caeaf02014-06-19 11:12:55 -07003610
Scott Baker89a7b7c2014-10-07 00:10:17 -07003611class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003612 queryset = SliceTag.objects.select_related().all()
3613 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003614 id_serializer_class = SliceTagIdSerializer
3615
3616 def get_serializer_class(self):
3617 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3618 if (no_hyperlinks):
3619 return self.id_serializer_class
3620 else:
3621 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003622
3623 def get_queryset(self):
3624 return SliceTag.select_by_user(self.request.user)
3625
Scott Baker89a7b7c2014-10-07 00:10:17 -07003626 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003627
Scott Baker89a7b7c2014-10-07 00:10:17 -07003628 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003629
3630
3631
Scott Baker0caeaf02014-06-19 11:12:55 -07003632class NetworkTemplateList(generics.ListCreateAPIView):
3633 queryset = NetworkTemplate.objects.select_related().all()
3634 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003635 id_serializer_class = NetworkTemplateIdSerializer
3636 filter_backends = (filters.DjangoFilterBackend,)
3637 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
3638
3639 def get_serializer_class(self):
3640 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3641 if (no_hyperlinks):
3642 return self.id_serializer_class
3643 else:
3644 return self.serializer_class
3645
Scott Baker0caeaf02014-06-19 11:12:55 -07003646 def get_queryset(self):
3647 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003648
Scott Baker0caeaf02014-06-19 11:12:55 -07003649 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003650 obj = NetworkTemplate(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07003651 obj.caller = request.user
3652 if obj.can_update(request.user):
3653 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
3654 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003655 raise Exception("failed obj.can_update")
3656
3657 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
3658 if (ret.status_code%100 != 200):
3659 raise Exception(ret.data)
3660
3661 return ret
3662
Scott Baker0caeaf02014-06-19 11:12:55 -07003663
Scott Baker89a7b7c2014-10-07 00:10:17 -07003664class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003665 queryset = NetworkTemplate.objects.select_related().all()
3666 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003667 id_serializer_class = NetworkTemplateIdSerializer
3668
3669 def get_serializer_class(self):
3670 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3671 if (no_hyperlinks):
3672 return self.id_serializer_class
3673 else:
3674 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003675
3676 def get_queryset(self):
3677 return NetworkTemplate.select_by_user(self.request.user)
3678
Scott Baker89a7b7c2014-10-07 00:10:17 -07003679 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003680
Scott Baker89a7b7c2014-10-07 00:10:17 -07003681 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003682
3683
3684
3685class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003686 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003687 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003688 id_serializer_class = RouterIdSerializer
3689 filter_backends = (filters.DjangoFilterBackend,)
3690 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
3691
3692 def get_serializer_class(self):
3693 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3694 if (no_hyperlinks):
3695 return self.id_serializer_class
3696 else:
3697 return self.serializer_class
3698
Scott Baker0caeaf02014-06-19 11:12:55 -07003699 def get_queryset(self):
3700 return Router.select_by_user(self.request.user)
3701
3702 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003703 obj = Router(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07003704 obj.caller = request.user
3705 if obj.can_update(request.user):
3706 return super(RouterList, self).create(request, *args, **kwargs)
3707 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003708 raise Exception("failed obj.can_update")
3709
3710 ret = super(RouterList, self).create(request, *args, **kwargs)
3711 if (ret.status_code%100 != 200):
3712 raise Exception(ret.data)
3713
3714 return ret
3715
Sapan Bhatiadea39432014-06-13 03:10:36 -04003716
Scott Baker89a7b7c2014-10-07 00:10:17 -07003717class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003718 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003719 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003720 id_serializer_class = RouterIdSerializer
3721
3722 def get_serializer_class(self):
3723 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3724 if (no_hyperlinks):
3725 return self.id_serializer_class
3726 else:
3727 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003728
3729 def get_queryset(self):
3730 return Router.select_by_user(self.request.user)
3731
Scott Baker89a7b7c2014-10-07 00:10:17 -07003732 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003733
Scott Baker89a7b7c2014-10-07 00:10:17 -07003734 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003735
3736
3737
Scott Baker0caeaf02014-06-19 11:12:55 -07003738class ServiceResourceList(generics.ListCreateAPIView):
3739 queryset = ServiceResource.objects.select_related().all()
3740 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003741 id_serializer_class = ServiceResourceIdSerializer
3742 filter_backends = (filters.DjangoFilterBackend,)
3743 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
3744
3745 def get_serializer_class(self):
3746 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3747 if (no_hyperlinks):
3748 return self.id_serializer_class
3749 else:
3750 return self.serializer_class
3751
Scott Baker0caeaf02014-06-19 11:12:55 -07003752 def get_queryset(self):
3753 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003754
Scott Baker0caeaf02014-06-19 11:12:55 -07003755 def create(self, request, *args, **kwargs):
Scott Baker2bcbf372014-10-29 23:41:11 -07003756 obj = ServiceResource(**request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07003757 obj.caller = request.user
3758 if obj.can_update(request.user):
3759 return super(ServiceResourceList, self).create(request, *args, **kwargs)
3760 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003761 raise Exception("failed obj.can_update")
3762
3763 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
3764 if (ret.status_code%100 != 200):
3765 raise Exception(ret.data)
3766
3767 return ret
3768
Scott Baker0caeaf02014-06-19 11:12:55 -07003769
Scott Baker89a7b7c2014-10-07 00:10:17 -07003770class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003771 queryset = ServiceResource.objects.select_related().all()
3772 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003773 id_serializer_class = ServiceResourceIdSerializer
3774
3775 def get_serializer_class(self):
3776 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3777 if (no_hyperlinks):
3778 return self.id_serializer_class
3779 else:
3780 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003781
3782 def get_queryset(self):
3783 return ServiceResource.select_by_user(self.request.user)
3784
Scott Baker89a7b7c2014-10-07 00:10:17 -07003785 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003786
Scott Baker89a7b7c2014-10-07 00:10:17 -07003787 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003788
3789
3790