blob: 7791b73d2e0d525e74d56f4c35e7b8920fec6dee [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
Sapan Bhatiadea39432014-06-13 03:10:36 -04006from core.models import *
7from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -07008from rest_framework import filters
Sapan Bhatiadea39432014-06-13 03:10:36 -04009
10"""
11 Schema of the generator object:
12 all: Set of all Model objects
13 all_if(regex): Set of Model objects that match regex
14
15 Model object:
16 plural: English plural of object name
17 camel: CamelCase version of object name
18 refs: list of references to other Model objects
19 props: list of properties minus refs
20
21 TODO: Deal with subnets
22"""
23
24# Based on api_root.py
25
26@api_view(['GET'])
27def api_root(request, format=None):
28 return Response({
29 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
30 'images': reverse('image-list', request=request, format=format),
31 'networkparameters': reverse('networkparameter-list', request=request, format=format),
32 'sites': reverse('site-list', request=request, format=format),
33 'sliceroles': reverse('slicerole-list', request=request, format=format),
34 'tags': reverse('tag-list', request=request, format=format),
35 'invoices': reverse('invoice-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040036 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070037 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040038 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070039 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040040 'slices': reverse('slice-list', request=request, format=format),
41 'networks': reverse('network-list', request=request, format=format),
42 'services': reverse('service-list', request=request, format=format),
43 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070044 'payments': reverse('payment-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040045 'charges': reverse('charge-list', request=request, format=format),
46 'roles': reverse('role-list', request=request, format=format),
47 'usableobjects': reverse('usableobject-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070048 'siteroles': reverse('siterole-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040049 'slivers': reverse('sliver-list', request=request, format=format),
50 'nodes': reverse('node-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070051 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
52 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040053 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040054 'networkslices': reverse('networkslice-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070055 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040056 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
57 'users': reverse('user-list', request=request, format=format),
58 'deployments': reverse('deployment-list', request=request, format=format),
59 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070060 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040061 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040062 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070063 'userdeploymentses': reverse('userdeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040064 'accounts': reverse('account-list', request=request, format=format),
65 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
66 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
67 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
68 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070069 'projects': reverse('project-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040070 'slicetags': reverse('slicetag-list', request=request, format=format),
71 'networktemplates': reverse('networktemplate-list', request=request, format=format),
72 'routers': reverse('router-list', request=request, format=format),
73 'serviceresources': reverse('serviceresource-list', request=request, format=format),
74
75 })
76
77# Based on serializers.py
78
79
80
Scott Baker0caeaf02014-06-19 11:12:55 -070081class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -040082 id = serializers.Field()
83
Sapan Bhatiadea39432014-06-13 03:10:36 -040084 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -070085 model = ServiceAttribute
Scott Baker46b58542014-08-11 17:26:12 -070086 fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
87
88class ServiceAttributeIdSerializer(serializers.ModelSerializer):
89 id = serializers.Field()
90
91 class Meta:
92 model = ServiceAttribute
93 fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
94
95
Sapan Bhatiadea39432014-06-13 03:10:36 -040096
97
98class ImageSerializer(serializers.HyperlinkedModelSerializer):
99 id = serializers.Field()
100
101 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700102 model = Image
Scott Baker46b58542014-08-11 17:26:12 -0700103 fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
104
105class ImageIdSerializer(serializers.ModelSerializer):
106 id = serializers.Field()
107
108 class Meta:
109 model = Image
110 fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
111
112
Sapan Bhatiadea39432014-06-13 03:10:36 -0400113
114
Scott Baker0caeaf02014-06-19 11:12:55 -0700115class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400116 id = serializers.Field()
117
118 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700119 model = NetworkParameter
Scott Baker46b58542014-08-11 17:26:12 -0700120 fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
121
122class NetworkParameterIdSerializer(serializers.ModelSerializer):
123 id = serializers.Field()
124
125 class Meta:
126 model = NetworkParameter
127 fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
128
129
Sapan Bhatiadea39432014-06-13 03:10:36 -0400130
131
132class SiteSerializer(serializers.HyperlinkedModelSerializer):
133 id = serializers.Field()
134
135 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700136 model = Site
Scott Baker46b58542014-08-11 17:26:12 -0700137 fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
138
139class SiteIdSerializer(serializers.ModelSerializer):
140 id = serializers.Field()
141
142 class Meta:
143 model = Site
144 fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
145
146
Sapan Bhatiadea39432014-06-13 03:10:36 -0400147
148
Scott Baker0caeaf02014-06-19 11:12:55 -0700149class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400150 id = serializers.Field()
151
152 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700153 model = SliceRole
Scott Baker46b58542014-08-11 17:26:12 -0700154 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
155
156class SliceRoleIdSerializer(serializers.ModelSerializer):
157 id = serializers.Field()
158
159 class Meta:
160 model = SliceRole
161 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
162
163
Sapan Bhatiadea39432014-06-13 03:10:36 -0400164
165
166class TagSerializer(serializers.HyperlinkedModelSerializer):
167 id = serializers.Field()
168
Scott Baker0caeaf02014-06-19 11:12:55 -0700169
170 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
171
172
173
174 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
175
176
177
178 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
179
180
181
182 nodes = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='node-detail')
183
Sapan Bhatiadea39432014-06-13 03:10:36 -0400184
185 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700186 model = Tag
Scott Baker46b58542014-08-11 17:26:12 -0700187 fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id','sites','slices','slivers','nodes',)
188
189class TagIdSerializer(serializers.ModelSerializer):
190 id = serializers.Field()
191
192
193 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
194
195
196
197 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
198
199
200
201 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
202
203
204
205 nodes = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='node-detail')
206
207
208 class Meta:
209 model = Tag
210 fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id','sites','slices','slivers','nodes',)
211
212
Sapan Bhatiadea39432014-06-13 03:10:36 -0400213
214
215class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
216 id = serializers.Field()
217
Sapan Bhatiadea39432014-06-13 03:10:36 -0400218 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700219 model = Invoice
Scott Baker46b58542014-08-11 17:26:12 -0700220 fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
221
222class InvoiceIdSerializer(serializers.ModelSerializer):
223 id = serializers.Field()
224
225 class Meta:
226 model = Invoice
227 fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
228
229
Sapan Bhatiadea39432014-06-13 03:10:36 -0400230
231
Scott Baker0caeaf02014-06-19 11:12:55 -0700232class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400233 id = serializers.Field()
234
235 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700236 model = PlanetStackRole
Scott Baker46b58542014-08-11 17:26:12 -0700237 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
238
239class PlanetStackRoleIdSerializer(serializers.ModelSerializer):
240 id = serializers.Field()
241
242 class Meta:
243 model = PlanetStackRole
244 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
245
246
Sapan Bhatiadea39432014-06-13 03:10:36 -0400247
248
Scott Baker0caeaf02014-06-19 11:12:55 -0700249class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400250 id = serializers.Field()
251
252 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700253 model = SlicePrivilege
Scott Baker46b58542014-08-11 17:26:12 -0700254 fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
255
256class SlicePrivilegeIdSerializer(serializers.ModelSerializer):
257 id = serializers.Field()
258
259 class Meta:
260 model = SlicePrivilege
261 fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
262
263
Scott Baker0caeaf02014-06-19 11:12:55 -0700264
265
266class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
267 id = serializers.Field()
268
269 class Meta:
270 model = NetworkSliver
Scott Baker46b58542014-08-11 17:26:12 -0700271 fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
272
273class NetworkSliverIdSerializer(serializers.ModelSerializer):
274 id = serializers.Field()
275
276 class Meta:
277 model = NetworkSliver
278 fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
279
280
Scott Baker0caeaf02014-06-19 11:12:55 -0700281
282
283class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
284 id = serializers.Field()
285
286 class Meta:
287 model = NetworkDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700288 fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
289
290class NetworkDeploymentsIdSerializer(serializers.ModelSerializer):
291 id = serializers.Field()
292
293 class Meta:
294 model = NetworkDeployments
295 fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
296
297
Sapan Bhatiadea39432014-06-13 03:10:36 -0400298
299
300class SliceSerializer(serializers.HyperlinkedModelSerializer):
301 id = serializers.Field()
302
Sapan Bhatiadea39432014-06-13 03:10:36 -0400303
Scott Baker0caeaf02014-06-19 11:12:55 -0700304 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
305
306
307
308 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
309
310
311
312 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
313
314
315
316 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
317
Sapan Bhatiadea39432014-06-13 03:10:36 -0400318
319 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700320 model = Slice
Scott Baker46b58542014-08-11 17:26:12 -0700321 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',)
322
323class SliceIdSerializer(serializers.ModelSerializer):
324 id = serializers.Field()
325
326
327 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
328
329
330
331 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
332
333
334
335 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
336
337
338
339 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
340
341
342 class Meta:
343 model = Slice
344 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',)
345
346
Sapan Bhatiadea39432014-06-13 03:10:36 -0400347
348
349class NetworkSerializer(serializers.HyperlinkedModelSerializer):
350 id = serializers.Field()
351
Scott Baker0caeaf02014-06-19 11:12:55 -0700352
353 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
354
355
356
357 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
358
359
360
361 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
362
363
364
365 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
366
367
Sapan Bhatiadea39432014-06-13 03:10:36 -0400368 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700369 model = Network
Scott Baker46b58542014-08-11 17:26:12 -0700370 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',)
371
372class NetworkIdSerializer(serializers.ModelSerializer):
373 id = serializers.Field()
374
375
376 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
377
378
379
380 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
381
382
383
384 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
385
386
387
388 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
389
390
391 class Meta:
392 model = Network
393 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',)
394
395
Sapan Bhatiadea39432014-06-13 03:10:36 -0400396
397
398class ServiceSerializer(serializers.HyperlinkedModelSerializer):
399 id = serializers.Field()
400
401 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700402 model = Service
Scott Baker46b58542014-08-11 17:26:12 -0700403 fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
404
405class ServiceIdSerializer(serializers.ModelSerializer):
406 id = serializers.Field()
407
408 class Meta:
409 model = Service
410 fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
411
412
Sapan Bhatiadea39432014-06-13 03:10:36 -0400413
414
Scott Baker0caeaf02014-06-19 11:12:55 -0700415class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400416 id = serializers.Field()
417
418 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700419 model = ServiceClass
Scott Baker46b58542014-08-11 17:26:12 -0700420 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
421
422class ServiceClassIdSerializer(serializers.ModelSerializer):
423 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',)
428
429
Sapan Bhatiadea39432014-06-13 03:10:36 -0400430
431
Scott Baker0caeaf02014-06-19 11:12:55 -0700432class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400433 id = serializers.Field()
434
435 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700436 model = Payment
Scott Baker46b58542014-08-11 17:26:12 -0700437 fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
438
439class PaymentIdSerializer(serializers.ModelSerializer):
440 id = serializers.Field()
441
442 class Meta:
443 model = Payment
444 fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
445
446
Sapan Bhatiadea39432014-06-13 03:10:36 -0400447
448
449class ChargeSerializer(serializers.HyperlinkedModelSerializer):
450 id = serializers.Field()
451
Sapan Bhatiadea39432014-06-13 03:10:36 -0400452 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700453 model = Charge
Scott Baker46b58542014-08-11 17:26:12 -0700454 fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
455
456class ChargeIdSerializer(serializers.ModelSerializer):
457 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',)
462
463
Sapan Bhatiadea39432014-06-13 03:10:36 -0400464
465
466class RoleSerializer(serializers.HyperlinkedModelSerializer):
467 id = serializers.Field()
468
469 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700470 model = Role
Scott Baker46b58542014-08-11 17:26:12 -0700471 fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
472
473class RoleIdSerializer(serializers.ModelSerializer):
474 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',)
479
480
Sapan Bhatiadea39432014-06-13 03:10:36 -0400481
482
Scott Baker0caeaf02014-06-19 11:12:55 -0700483class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400484 id = serializers.Field()
485
486 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700487 model = UsableObject
Scott Baker46b58542014-08-11 17:26:12 -0700488 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
489
490class UsableObjectIdSerializer(serializers.ModelSerializer):
491 id = serializers.Field()
492
493 class Meta:
494 model = UsableObject
495 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
496
497
Sapan Bhatiadea39432014-06-13 03:10:36 -0400498
499
Scott Baker0caeaf02014-06-19 11:12:55 -0700500class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
501 id = serializers.Field()
502
503 class Meta:
504 model = SiteRole
Scott Baker46b58542014-08-11 17:26:12 -0700505 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
506
507class SiteRoleIdSerializer(serializers.ModelSerializer):
508 id = serializers.Field()
509
510 class Meta:
511 model = SiteRole
512 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
513
514
Scott Baker0caeaf02014-06-19 11:12:55 -0700515
516
Sapan Bhatiadea39432014-06-13 03:10:36 -0400517class SliverSerializer(serializers.HyperlinkedModelSerializer):
518 id = serializers.Field()
519
Sapan Bhatiadea39432014-06-13 03:10:36 -0400520
Scott Baker0caeaf02014-06-19 11:12:55 -0700521 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
Sapan Bhatiadea39432014-06-13 03:10:36 -0400522
Scott Baker0caeaf02014-06-19 11:12:55 -0700523
524
525 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
526
527
Scott Baker46b58542014-08-11 17:26:12 -0700528 class Meta:
529 model = Sliver
530 fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','userData','networks','networks',)
531
532class SliverIdSerializer(serializers.ModelSerializer):
533 id = serializers.Field()
Scott Baker0caeaf02014-06-19 11:12:55 -0700534
Scott Baker46b58542014-08-11 17:26:12 -0700535
536 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
537
538
539
540 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
Scott Baker0caeaf02014-06-19 11:12:55 -0700541
Sapan Bhatiadea39432014-06-13 03:10:36 -0400542
543 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700544 model = Sliver
Scott Baker46b58542014-08-11 17:26:12 -0700545 fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','userData','networks','networks',)
546
547
Sapan Bhatiadea39432014-06-13 03:10:36 -0400548
549
550class NodeSerializer(serializers.HyperlinkedModelSerializer):
551 id = serializers.Field()
552
Sapan Bhatiadea39432014-06-13 03:10:36 -0400553 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700554 model = Node
Scott Baker46b58542014-08-11 17:26:12 -0700555 fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
556
557class NodeIdSerializer(serializers.ModelSerializer):
558 id = serializers.Field()
559
560 class Meta:
561 model = Node
562 fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
563
564
Sapan Bhatiadea39432014-06-13 03:10:36 -0400565
566
Scott Baker0caeaf02014-06-19 11:12:55 -0700567class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400568 id = serializers.Field()
569
Sapan Bhatiadea39432014-06-13 03:10:36 -0400570 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700571 model = DashboardView
Scott Baker46b58542014-08-11 17:26:12 -0700572 fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
573
574class DashboardViewIdSerializer(serializers.ModelSerializer):
575 id = serializers.Field()
576
577 class Meta:
578 model = DashboardView
579 fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
580
581
Sapan Bhatiadea39432014-06-13 03:10:36 -0400582
583
Scott Baker0caeaf02014-06-19 11:12:55 -0700584class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400585 id = serializers.Field()
586
Sapan Bhatiadea39432014-06-13 03:10:36 -0400587 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700588 model = ImageDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700589 fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
590
591class ImageDeploymentsIdSerializer(serializers.ModelSerializer):
592 id = serializers.Field()
593
594 class Meta:
595 model = ImageDeployments
596 fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
597
598
Sapan Bhatiadea39432014-06-13 03:10:36 -0400599
600
Scott Baker0caeaf02014-06-19 11:12:55 -0700601class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400602 id = serializers.Field()
603
Sapan Bhatiadea39432014-06-13 03:10:36 -0400604 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700605 model = ReservedResource
Scott Baker46b58542014-08-11 17:26:12 -0700606 fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
607
608class ReservedResourceIdSerializer(serializers.ModelSerializer):
609 id = serializers.Field()
610
611 class Meta:
612 model = ReservedResource
613 fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
614
615
Sapan Bhatiadea39432014-06-13 03:10:36 -0400616
617
Scott Baker0caeaf02014-06-19 11:12:55 -0700618class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400619 id = serializers.Field()
620
Scott Baker0caeaf02014-06-19 11:12:55 -0700621 class Meta:
622 model = NetworkSlice
Scott Baker46b58542014-08-11 17:26:12 -0700623 fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
624
625class NetworkSliceIdSerializer(serializers.ModelSerializer):
626 id = serializers.Field()
627
628 class Meta:
629 model = NetworkSlice
630 fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
631
632
Scott Baker0caeaf02014-06-19 11:12:55 -0700633
634
635class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
636 id = serializers.Field()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400637
638 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700639 model = UserDashboardView
Scott Baker46b58542014-08-11 17:26:12 -0700640 fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
641
642class UserDashboardViewIdSerializer(serializers.ModelSerializer):
643 id = serializers.Field()
644
645 class Meta:
646 model = UserDashboardView
647 fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
648
649
Scott Baker0caeaf02014-06-19 11:12:55 -0700650
651
652class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
653 id = serializers.Field()
654
655 class Meta:
656 model = PlanetStackPrivilege
Scott Baker46b58542014-08-11 17:26:12 -0700657 fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
658
659class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer):
660 id = serializers.Field()
661
662 class Meta:
663 model = PlanetStackPrivilege
664 fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
665
666
Sapan Bhatiadea39432014-06-13 03:10:36 -0400667
668
669class UserSerializer(serializers.HyperlinkedModelSerializer):
670 id = serializers.Field()
671
Sapan Bhatiadea39432014-06-13 03:10:36 -0400672 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700673 model = User
Scott Baker46b58542014-08-11 17:26:12 -0700674 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',)
675
676class UserIdSerializer(serializers.ModelSerializer):
677 id = serializers.Field()
678
679 class Meta:
680 model = User
681 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',)
682
683
Sapan Bhatiadea39432014-06-13 03:10:36 -0400684
685
686class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
687 id = serializers.Field()
688
Scott Baker0caeaf02014-06-19 11:12:55 -0700689
690 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
691
692
693
694 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
695
696
Sapan Bhatiadea39432014-06-13 03:10:36 -0400697 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700698 model = Deployment
Scott Baker46b58542014-08-11 17:26:12 -0700699 fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','accessControl','sites','sites',)
700
701class DeploymentIdSerializer(serializers.ModelSerializer):
702 id = serializers.Field()
703
704
705 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
706
707
708
709 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
710
711
712 class Meta:
713 model = Deployment
714 fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','accessControl','sites','sites',)
715
716
Sapan Bhatiadea39432014-06-13 03:10:36 -0400717
718
719class ReservationSerializer(serializers.HyperlinkedModelSerializer):
720 id = serializers.Field()
721
Sapan Bhatiadea39432014-06-13 03:10:36 -0400722 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700723 model = Reservation
Scott Baker46b58542014-08-11 17:26:12 -0700724 fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
725
726class ReservationIdSerializer(serializers.ModelSerializer):
727 id = serializers.Field()
728
729 class Meta:
730 model = Reservation
731 fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
732
733
Sapan Bhatiadea39432014-06-13 03:10:36 -0400734
735
Scott Baker0caeaf02014-06-19 11:12:55 -0700736class SliceDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400737 id = serializers.Field()
738
739 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700740 model = SliceDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700741 fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
742
743class SliceDeploymentsIdSerializer(serializers.ModelSerializer):
744 id = serializers.Field()
745
746 class Meta:
747 model = SliceDeployments
748 fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
749
750
Sapan Bhatiadea39432014-06-13 03:10:36 -0400751
752
Scott Baker0caeaf02014-06-19 11:12:55 -0700753class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400754 id = serializers.Field()
755
756 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700757 model = SitePrivilege
Scott Baker46b58542014-08-11 17:26:12 -0700758 fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
759
760class SitePrivilegeIdSerializer(serializers.ModelSerializer):
761 id = serializers.Field()
762
763 class Meta:
764 model = SitePrivilege
765 fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
766
767
Scott Baker0caeaf02014-06-19 11:12:55 -0700768
769
770class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
771 id = serializers.Field()
772
773 class Meta:
774 model = PlanetStack
Scott Baker46b58542014-08-11 17:26:12 -0700775 fields = ('id','created','updated','enacted','backend_status','deleted','description',)
776
777class PlanetStackIdSerializer(serializers.ModelSerializer):
778 id = serializers.Field()
779
780 class Meta:
781 model = PlanetStack
782 fields = ('id','created','updated','enacted','backend_status','deleted','description',)
783
784
Sapan Bhatiadea39432014-06-13 03:10:36 -0400785
786
Scott Baker0caeaf02014-06-19 11:12:55 -0700787class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
788 id = serializers.Field()
789
790 class Meta:
791 model = UserDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700792 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
793
794class UserDeploymentsIdSerializer(serializers.ModelSerializer):
795 id = serializers.Field()
796
797 class Meta:
798 model = UserDeployments
799 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
800
801
Scott Baker0caeaf02014-06-19 11:12:55 -0700802
803
Sapan Bhatiadea39432014-06-13 03:10:36 -0400804class AccountSerializer(serializers.HyperlinkedModelSerializer):
805 id = serializers.Field()
806
Sapan Bhatiadea39432014-06-13 03:10:36 -0400807 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700808 model = Account
Scott Baker46b58542014-08-11 17:26:12 -0700809 fields = ('id','created','updated','enacted','backend_status','deleted','site',)
810
811class AccountIdSerializer(serializers.ModelSerializer):
812 id = serializers.Field()
813
814 class Meta:
815 model = Account
816 fields = ('id','created','updated','enacted','backend_status','deleted','site',)
817
818
Sapan Bhatiadea39432014-06-13 03:10:36 -0400819
820
Scott Baker0caeaf02014-06-19 11:12:55 -0700821class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400822 id = serializers.Field()
823
824 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700825 model = NetworkParameterType
Scott Baker46b58542014-08-11 17:26:12 -0700826 fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
827
828class NetworkParameterTypeIdSerializer(serializers.ModelSerializer):
829 id = serializers.Field()
830
831 class Meta:
832 model = NetworkParameterType
833 fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
834
835
Sapan Bhatiadea39432014-06-13 03:10:36 -0400836
837
Scott Baker0caeaf02014-06-19 11:12:55 -0700838class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400839 id = serializers.Field()
840
841 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700842 model = SiteDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700843 fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
844
845class SiteDeploymentsIdSerializer(serializers.ModelSerializer):
846 id = serializers.Field()
847
848 class Meta:
849 model = SiteDeployments
850 fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
851
852
Scott Baker0caeaf02014-06-19 11:12:55 -0700853
854
855class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
856 id = serializers.Field()
857
858 class Meta:
859 model = DeploymentPrivilege
Scott Baker46b58542014-08-11 17:26:12 -0700860 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
861
862class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer):
863 id = serializers.Field()
864
865 class Meta:
866 model = DeploymentPrivilege
867 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
868
869
Scott Baker0caeaf02014-06-19 11:12:55 -0700870
871
872class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
873 id = serializers.Field()
874
875 class Meta:
876 model = DeploymentRole
Scott Baker46b58542014-08-11 17:26:12 -0700877 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
878
879class DeploymentRoleIdSerializer(serializers.ModelSerializer):
880 id = serializers.Field()
881
882 class Meta:
883 model = DeploymentRole
884 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
885
886
Sapan Bhatiadea39432014-06-13 03:10:36 -0400887
888
Scott Baker0caeaf02014-06-19 11:12:55 -0700889class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400890 id = serializers.Field()
891
892 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700893 model = Project
Scott Baker46b58542014-08-11 17:26:12 -0700894 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
895
896class ProjectIdSerializer(serializers.ModelSerializer):
897 id = serializers.Field()
898
899 class Meta:
900 model = Project
901 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
902
903
Sapan Bhatiadea39432014-06-13 03:10:36 -0400904
905
Scott Baker0caeaf02014-06-19 11:12:55 -0700906class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400907 id = serializers.Field()
908
909 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700910 model = SliceTag
Scott Baker46b58542014-08-11 17:26:12 -0700911 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
912
913class SliceTagIdSerializer(serializers.ModelSerializer):
914 id = serializers.Field()
915
916 class Meta:
917 model = SliceTag
918 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
919
920
Scott Baker0caeaf02014-06-19 11:12:55 -0700921
922
923class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
924 id = serializers.Field()
925
926 class Meta:
927 model = NetworkTemplate
Scott Baker46b58542014-08-11 17:26:12 -0700928 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
929
930class NetworkTemplateIdSerializer(serializers.ModelSerializer):
931 id = serializers.Field()
932
933 class Meta:
934 model = NetworkTemplate
935 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
936
937
Sapan Bhatiadea39432014-06-13 03:10:36 -0400938
939
940class RouterSerializer(serializers.HyperlinkedModelSerializer):
941 id = serializers.Field()
942
943 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700944 model = Router
Scott Baker46b58542014-08-11 17:26:12 -0700945 fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
946
947class RouterIdSerializer(serializers.ModelSerializer):
948 id = serializers.Field()
949
950 class Meta:
951 model = Router
952 fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
953
954
Sapan Bhatiadea39432014-06-13 03:10:36 -0400955
956
Scott Baker0caeaf02014-06-19 11:12:55 -0700957class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400958 id = serializers.Field()
959
960 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700961 model = ServiceResource
Scott Baker46b58542014-08-11 17:26:12 -0700962 fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
963
964class ServiceResourceIdSerializer(serializers.ModelSerializer):
965 id = serializers.Field()
966
967 class Meta:
968 model = ServiceResource
969 fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
970
971
Sapan Bhatiadea39432014-06-13 03:10:36 -0400972
973
974serializerLookUp = {
975
Scott Baker0caeaf02014-06-19 11:12:55 -0700976 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400977
978 Image: ImageSerializer,
979
Scott Baker0caeaf02014-06-19 11:12:55 -0700980 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400981
982 Site: SiteSerializer,
983
Scott Baker0caeaf02014-06-19 11:12:55 -0700984 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400985
986 Tag: TagSerializer,
987
988 Invoice: InvoiceSerializer,
989
Scott Baker0caeaf02014-06-19 11:12:55 -0700990 PlanetStackRole: PlanetStackRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400991
Scott Baker0caeaf02014-06-19 11:12:55 -0700992 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400993
Scott Baker0caeaf02014-06-19 11:12:55 -0700994 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400995
Scott Baker0caeaf02014-06-19 11:12:55 -0700996 NetworkDeployments: NetworkDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400997
998 Slice: SliceSerializer,
999
1000 Network: NetworkSerializer,
1001
1002 Service: ServiceSerializer,
1003
Scott Baker0caeaf02014-06-19 11:12:55 -07001004 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001005
Scott Baker0caeaf02014-06-19 11:12:55 -07001006 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001007
1008 Charge: ChargeSerializer,
1009
1010 Role: RoleSerializer,
1011
Scott Baker0caeaf02014-06-19 11:12:55 -07001012 UsableObject: UsableObjectSerializer,
1013
1014 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001015
1016 Sliver: SliverSerializer,
1017
1018 Node: NodeSerializer,
1019
Scott Baker0caeaf02014-06-19 11:12:55 -07001020 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001021
Scott Baker0caeaf02014-06-19 11:12:55 -07001022 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001023
Scott Baker0caeaf02014-06-19 11:12:55 -07001024 ReservedResource: ReservedResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001025
Scott Baker0caeaf02014-06-19 11:12:55 -07001026 NetworkSlice: NetworkSliceSerializer,
1027
1028 UserDashboardView: UserDashboardViewSerializer,
1029
1030 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001031
1032 User: UserSerializer,
1033
1034 Deployment: DeploymentSerializer,
1035
1036 Reservation: ReservationSerializer,
1037
Scott Baker0caeaf02014-06-19 11:12:55 -07001038 SliceDeployments: SliceDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001039
Scott Baker0caeaf02014-06-19 11:12:55 -07001040 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001041
Scott Baker0caeaf02014-06-19 11:12:55 -07001042 PlanetStack: PlanetStackSerializer,
1043
1044 UserDeployments: UserDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001045
1046 Account: AccountSerializer,
1047
Scott Baker0caeaf02014-06-19 11:12:55 -07001048 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001049
Scott Baker0caeaf02014-06-19 11:12:55 -07001050 SiteDeployments: SiteDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001051
Scott Baker0caeaf02014-06-19 11:12:55 -07001052 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001053
Scott Baker0caeaf02014-06-19 11:12:55 -07001054 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001055
Scott Baker0caeaf02014-06-19 11:12:55 -07001056 Project: ProjectSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001057
Scott Baker0caeaf02014-06-19 11:12:55 -07001058 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001059
Scott Baker0caeaf02014-06-19 11:12:55 -07001060 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001061
1062 Router: RouterSerializer,
1063
Scott Baker0caeaf02014-06-19 11:12:55 -07001064 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001065
1066 None: None,
1067 }
1068
1069# Based on core/views/*.py
1070
1071
Scott Baker0caeaf02014-06-19 11:12:55 -07001072class ServiceAttributeList(generics.ListCreateAPIView):
1073 queryset = ServiceAttribute.objects.select_related().all()
1074 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001075 id_serializer_class = ServiceAttributeIdSerializer
1076 filter_backends = (filters.DjangoFilterBackend,)
1077 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
1078
1079 def get_serializer_class(self):
1080 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1081 if (no_hyperlinks):
1082 return self.id_serializer_class
1083 else:
1084 return self.serializer_class
1085
Scott Baker0caeaf02014-06-19 11:12:55 -07001086 def get_queryset(self):
1087 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001088
Scott Baker0caeaf02014-06-19 11:12:55 -07001089 def create(self, request, *args, **kwargs):
1090 #obj = ServiceAttribute().update(request.DATA)
1091 obj = self.get_object()
1092 obj.caller = request.user
1093 if obj.can_update(request.user):
1094 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
1095 else:
1096 return Response(status=status.HTTP_400_BAD_REQUEST)
1097
1098class ServiceAttributeDetail(generics.RetrieveUpdateDestroyAPIView):
1099 queryset = ServiceAttribute.objects.select_related().all()
1100 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001101 id_serializer_class = ServiceAttributeIdSerializer
1102
1103 def get_serializer_class(self):
1104 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1105 if (no_hyperlinks):
1106 return self.id_serializer_class
1107 else:
1108 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001109
1110 def get_queryset(self):
1111 return ServiceAttribute.select_by_user(self.request.user)
1112
1113 def update(self, request, *args, **kwargs):
1114 obj = self.get_object()
1115 if obj.can_update(request.user):
1116 return super(ServiceAttributeDetail, self).update(request, *args, **kwargs)
1117 else:
1118 return Response(status=status.HTTP_400_BAD_REQUEST)
1119
1120 def destroy(self, request, *args, **kwargs):
1121 obj = self.get_object()
1122 if obj.can_update(request.user):
1123 return super(ServiceAttributeDetail, self).destroy(request, *args, **kwargs)
1124 else:
1125 return Response(status=status.HTTP_400_BAD_REQUEST)
1126
Sapan Bhatiadea39432014-06-13 03:10:36 -04001127
1128
1129
1130class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001131 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001132 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001133 id_serializer_class = ImageIdSerializer
1134 filter_backends = (filters.DjangoFilterBackend,)
1135 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
1136
1137 def get_serializer_class(self):
1138 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1139 if (no_hyperlinks):
1140 return self.id_serializer_class
1141 else:
1142 return self.serializer_class
1143
Scott Baker0caeaf02014-06-19 11:12:55 -07001144 def get_queryset(self):
1145 return Image.select_by_user(self.request.user)
1146
1147 def create(self, request, *args, **kwargs):
1148 #obj = Image().update(request.DATA)
1149 obj = self.get_object()
1150 obj.caller = request.user
1151 if obj.can_update(request.user):
1152 return super(ImageList, self).create(request, *args, **kwargs)
1153 else:
1154 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001155
1156class ImageDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001157 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001158 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001159 id_serializer_class = ImageIdSerializer
1160
1161 def get_serializer_class(self):
1162 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1163 if (no_hyperlinks):
1164 return self.id_serializer_class
1165 else:
1166 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001167
1168 def get_queryset(self):
1169 return Image.select_by_user(self.request.user)
1170
1171 def update(self, request, *args, **kwargs):
1172 obj = self.get_object()
1173 if obj.can_update(request.user):
1174 return super(ImageDetail, self).update(request, *args, **kwargs)
1175 else:
1176 return Response(status=status.HTTP_400_BAD_REQUEST)
1177
1178 def destroy(self, request, *args, **kwargs):
1179 obj = self.get_object()
1180 if obj.can_update(request.user):
1181 return super(ImageDetail, self).destroy(request, *args, **kwargs)
1182 else:
1183 return Response(status=status.HTTP_400_BAD_REQUEST)
1184
Sapan Bhatiadea39432014-06-13 03:10:36 -04001185
1186
1187
Scott Baker0caeaf02014-06-19 11:12:55 -07001188class NetworkParameterList(generics.ListCreateAPIView):
1189 queryset = NetworkParameter.objects.select_related().all()
1190 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001191 id_serializer_class = NetworkParameterIdSerializer
1192 filter_backends = (filters.DjangoFilterBackend,)
1193 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
1194
1195 def get_serializer_class(self):
1196 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1197 if (no_hyperlinks):
1198 return self.id_serializer_class
1199 else:
1200 return self.serializer_class
1201
Scott Baker0caeaf02014-06-19 11:12:55 -07001202 def get_queryset(self):
1203 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001204
Scott Baker0caeaf02014-06-19 11:12:55 -07001205 def create(self, request, *args, **kwargs):
1206 #obj = NetworkParameter().update(request.DATA)
1207 obj = self.get_object()
1208 obj.caller = request.user
1209 if obj.can_update(request.user):
1210 return super(NetworkParameterList, self).create(request, *args, **kwargs)
1211 else:
1212 return Response(status=status.HTTP_400_BAD_REQUEST)
1213
1214class NetworkParameterDetail(generics.RetrieveUpdateDestroyAPIView):
1215 queryset = NetworkParameter.objects.select_related().all()
1216 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001217 id_serializer_class = NetworkParameterIdSerializer
1218
1219 def get_serializer_class(self):
1220 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1221 if (no_hyperlinks):
1222 return self.id_serializer_class
1223 else:
1224 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001225
1226 def get_queryset(self):
1227 return NetworkParameter.select_by_user(self.request.user)
1228
1229 def update(self, request, *args, **kwargs):
1230 obj = self.get_object()
1231 if obj.can_update(request.user):
1232 return super(NetworkParameterDetail, self).update(request, *args, **kwargs)
1233 else:
1234 return Response(status=status.HTTP_400_BAD_REQUEST)
1235
1236 def destroy(self, request, *args, **kwargs):
1237 obj = self.get_object()
1238 if obj.can_update(request.user):
1239 return super(NetworkParameterDetail, self).destroy(request, *args, **kwargs)
1240 else:
1241 return Response(status=status.HTTP_400_BAD_REQUEST)
1242
Sapan Bhatiadea39432014-06-13 03:10:36 -04001243
1244
1245
1246class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001247 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001248 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001249 id_serializer_class = SiteIdSerializer
1250 filter_backends = (filters.DjangoFilterBackend,)
1251 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
1252
1253 def get_serializer_class(self):
1254 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1255 if (no_hyperlinks):
1256 return self.id_serializer_class
1257 else:
1258 return self.serializer_class
1259
Scott Baker0caeaf02014-06-19 11:12:55 -07001260 def get_queryset(self):
1261 return Site.select_by_user(self.request.user)
1262
1263 def create(self, request, *args, **kwargs):
1264 #obj = Site().update(request.DATA)
1265 obj = self.get_object()
1266 obj.caller = request.user
1267 if obj.can_update(request.user):
1268 return super(SiteList, self).create(request, *args, **kwargs)
1269 else:
1270 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001271
1272class SiteDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001273 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001274 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001275 id_serializer_class = SiteIdSerializer
1276
1277 def get_serializer_class(self):
1278 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1279 if (no_hyperlinks):
1280 return self.id_serializer_class
1281 else:
1282 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001283
1284 def get_queryset(self):
1285 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001286
Scott Baker0caeaf02014-06-19 11:12:55 -07001287 def update(self, request, *args, **kwargs):
1288 obj = self.get_object()
1289 if obj.can_update(request.user):
1290 return super(SiteDetail, self).update(request, *args, **kwargs)
1291 else:
1292 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001293
Scott Baker0caeaf02014-06-19 11:12:55 -07001294 def destroy(self, request, *args, **kwargs):
1295 obj = self.get_object()
1296 if obj.can_update(request.user):
1297 return super(SiteDetail, self).destroy(request, *args, **kwargs)
1298 else:
1299 return Response(status=status.HTTP_400_BAD_REQUEST)
1300
1301
1302
1303
1304class SliceRoleList(generics.ListCreateAPIView):
1305 queryset = SliceRole.objects.select_related().all()
1306 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001307 id_serializer_class = SliceRoleIdSerializer
1308 filter_backends = (filters.DjangoFilterBackend,)
1309 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
1310
1311 def get_serializer_class(self):
1312 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1313 if (no_hyperlinks):
1314 return self.id_serializer_class
1315 else:
1316 return self.serializer_class
1317
Scott Baker0caeaf02014-06-19 11:12:55 -07001318 def get_queryset(self):
1319 return SliceRole.select_by_user(self.request.user)
1320
1321 def create(self, request, *args, **kwargs):
1322 #obj = SliceRole().update(request.DATA)
1323 obj = self.get_object()
1324 obj.caller = request.user
1325 if obj.can_update(request.user):
1326 return super(SliceRoleList, self).create(request, *args, **kwargs)
1327 else:
1328 return Response(status=status.HTTP_400_BAD_REQUEST)
1329
1330class SliceRoleDetail(generics.RetrieveUpdateDestroyAPIView):
1331 queryset = SliceRole.objects.select_related().all()
1332 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001333 id_serializer_class = SliceRoleIdSerializer
1334
1335 def get_serializer_class(self):
1336 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1337 if (no_hyperlinks):
1338 return self.id_serializer_class
1339 else:
1340 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001341
1342 def get_queryset(self):
1343 return SliceRole.select_by_user(self.request.user)
1344
1345 def update(self, request, *args, **kwargs):
1346 obj = self.get_object()
1347 if obj.can_update(request.user):
1348 return super(SliceRoleDetail, self).update(request, *args, **kwargs)
1349 else:
1350 return Response(status=status.HTTP_400_BAD_REQUEST)
1351
1352 def destroy(self, request, *args, **kwargs):
1353 obj = self.get_object()
1354 if obj.can_update(request.user):
1355 return super(SliceRoleDetail, self).destroy(request, *args, **kwargs)
1356 else:
1357 return Response(status=status.HTTP_400_BAD_REQUEST)
1358
Sapan Bhatiadea39432014-06-13 03:10:36 -04001359
1360
1361
1362class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001363 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001364 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001365 id_serializer_class = TagIdSerializer
1366 filter_backends = (filters.DjangoFilterBackend,)
1367 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id','sites','slices','slivers','nodes',)
1368
1369 def get_serializer_class(self):
1370 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1371 if (no_hyperlinks):
1372 return self.id_serializer_class
1373 else:
1374 return self.serializer_class
1375
Scott Baker0caeaf02014-06-19 11:12:55 -07001376 def get_queryset(self):
1377 return Tag.select_by_user(self.request.user)
1378
1379 def create(self, request, *args, **kwargs):
1380 #obj = Tag().update(request.DATA)
1381 obj = self.get_object()
1382 obj.caller = request.user
1383 if obj.can_update(request.user):
1384 return super(TagList, self).create(request, *args, **kwargs)
1385 else:
1386 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001387
1388class TagDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001389 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001390 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001391 id_serializer_class = TagIdSerializer
1392
1393 def get_serializer_class(self):
1394 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1395 if (no_hyperlinks):
1396 return self.id_serializer_class
1397 else:
1398 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001399
1400 def get_queryset(self):
1401 return Tag.select_by_user(self.request.user)
1402
1403 def update(self, request, *args, **kwargs):
1404 obj = self.get_object()
1405 if obj.can_update(request.user):
1406 return super(TagDetail, self).update(request, *args, **kwargs)
1407 else:
1408 return Response(status=status.HTTP_400_BAD_REQUEST)
1409
1410 def destroy(self, request, *args, **kwargs):
1411 obj = self.get_object()
1412 if obj.can_update(request.user):
1413 return super(TagDetail, self).destroy(request, *args, **kwargs)
1414 else:
1415 return Response(status=status.HTTP_400_BAD_REQUEST)
1416
Sapan Bhatiadea39432014-06-13 03:10:36 -04001417
1418
1419
1420class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001421 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001422 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001423 id_serializer_class = InvoiceIdSerializer
1424 filter_backends = (filters.DjangoFilterBackend,)
1425 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
1426
1427 def get_serializer_class(self):
1428 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1429 if (no_hyperlinks):
1430 return self.id_serializer_class
1431 else:
1432 return self.serializer_class
1433
Scott Baker0caeaf02014-06-19 11:12:55 -07001434 def get_queryset(self):
1435 return Invoice.select_by_user(self.request.user)
1436
1437 def create(self, request, *args, **kwargs):
1438 #obj = Invoice().update(request.DATA)
1439 obj = self.get_object()
1440 obj.caller = request.user
1441 if obj.can_update(request.user):
1442 return super(InvoiceList, self).create(request, *args, **kwargs)
1443 else:
1444 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001445
1446class InvoiceDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001447 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001448 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001449 id_serializer_class = InvoiceIdSerializer
1450
1451 def get_serializer_class(self):
1452 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1453 if (no_hyperlinks):
1454 return self.id_serializer_class
1455 else:
1456 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001457
1458 def get_queryset(self):
1459 return Invoice.select_by_user(self.request.user)
1460
1461 def update(self, request, *args, **kwargs):
1462 obj = self.get_object()
1463 if obj.can_update(request.user):
1464 return super(InvoiceDetail, self).update(request, *args, **kwargs)
1465 else:
1466 return Response(status=status.HTTP_400_BAD_REQUEST)
1467
1468 def destroy(self, request, *args, **kwargs):
1469 obj = self.get_object()
1470 if obj.can_update(request.user):
1471 return super(InvoiceDetail, self).destroy(request, *args, **kwargs)
1472 else:
1473 return Response(status=status.HTTP_400_BAD_REQUEST)
1474
Sapan Bhatiadea39432014-06-13 03:10:36 -04001475
1476
1477
Scott Baker0caeaf02014-06-19 11:12:55 -07001478class PlanetStackRoleList(generics.ListCreateAPIView):
1479 queryset = PlanetStackRole.objects.select_related().all()
1480 serializer_class = PlanetStackRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001481 id_serializer_class = PlanetStackRoleIdSerializer
1482 filter_backends = (filters.DjangoFilterBackend,)
1483 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
1484
1485 def get_serializer_class(self):
1486 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1487 if (no_hyperlinks):
1488 return self.id_serializer_class
1489 else:
1490 return self.serializer_class
1491
Scott Baker0caeaf02014-06-19 11:12:55 -07001492 def get_queryset(self):
1493 return PlanetStackRole.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001494
Scott Baker0caeaf02014-06-19 11:12:55 -07001495 def create(self, request, *args, **kwargs):
1496 #obj = PlanetStackRole().update(request.DATA)
1497 obj = self.get_object()
1498 obj.caller = request.user
1499 if obj.can_update(request.user):
1500 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
1501 else:
1502 return Response(status=status.HTTP_400_BAD_REQUEST)
1503
1504class PlanetStackRoleDetail(generics.RetrieveUpdateDestroyAPIView):
1505 queryset = PlanetStackRole.objects.select_related().all()
1506 serializer_class = PlanetStackRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001507 id_serializer_class = PlanetStackRoleIdSerializer
1508
1509 def get_serializer_class(self):
1510 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1511 if (no_hyperlinks):
1512 return self.id_serializer_class
1513 else:
1514 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001515
1516 def get_queryset(self):
1517 return PlanetStackRole.select_by_user(self.request.user)
1518
1519 def update(self, request, *args, **kwargs):
1520 obj = self.get_object()
1521 if obj.can_update(request.user):
1522 return super(PlanetStackRoleDetail, self).update(request, *args, **kwargs)
1523 else:
1524 return Response(status=status.HTTP_400_BAD_REQUEST)
1525
1526 def destroy(self, request, *args, **kwargs):
1527 obj = self.get_object()
1528 if obj.can_update(request.user):
1529 return super(PlanetStackRoleDetail, self).destroy(request, *args, **kwargs)
1530 else:
1531 return Response(status=status.HTTP_400_BAD_REQUEST)
1532
Sapan Bhatiadea39432014-06-13 03:10:36 -04001533
1534
1535
Scott Baker0caeaf02014-06-19 11:12:55 -07001536class SlicePrivilegeList(generics.ListCreateAPIView):
1537 queryset = SlicePrivilege.objects.select_related().all()
1538 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001539 id_serializer_class = SlicePrivilegeIdSerializer
1540 filter_backends = (filters.DjangoFilterBackend,)
1541 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
1542
1543 def get_serializer_class(self):
1544 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1545 if (no_hyperlinks):
1546 return self.id_serializer_class
1547 else:
1548 return self.serializer_class
1549
Scott Baker0caeaf02014-06-19 11:12:55 -07001550 def get_queryset(self):
1551 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001552
Scott Baker0caeaf02014-06-19 11:12:55 -07001553 def create(self, request, *args, **kwargs):
1554 #obj = SlicePrivilege().update(request.DATA)
1555 obj = self.get_object()
1556 obj.caller = request.user
1557 if obj.can_update(request.user):
1558 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
1559 else:
1560 return Response(status=status.HTTP_400_BAD_REQUEST)
1561
1562class SlicePrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
1563 queryset = SlicePrivilege.objects.select_related().all()
1564 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001565 id_serializer_class = SlicePrivilegeIdSerializer
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
Scott Baker0caeaf02014-06-19 11:12:55 -07001573
1574 def get_queryset(self):
1575 return SlicePrivilege.select_by_user(self.request.user)
1576
1577 def update(self, request, *args, **kwargs):
1578 obj = self.get_object()
1579 if obj.can_update(request.user):
1580 return super(SlicePrivilegeDetail, self).update(request, *args, **kwargs)
1581 else:
1582 return Response(status=status.HTTP_400_BAD_REQUEST)
1583
1584 def destroy(self, request, *args, **kwargs):
1585 obj = self.get_object()
1586 if obj.can_update(request.user):
1587 return super(SlicePrivilegeDetail, self).destroy(request, *args, **kwargs)
1588 else:
1589 return Response(status=status.HTTP_400_BAD_REQUEST)
1590
Sapan Bhatiadea39432014-06-13 03:10:36 -04001591
1592
1593
Scott Baker0caeaf02014-06-19 11:12:55 -07001594class NetworkSliverList(generics.ListCreateAPIView):
1595 queryset = NetworkSliver.objects.select_related().all()
1596 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001597 id_serializer_class = NetworkSliverIdSerializer
1598 filter_backends = (filters.DjangoFilterBackend,)
1599 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
1600
1601 def get_serializer_class(self):
1602 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1603 if (no_hyperlinks):
1604 return self.id_serializer_class
1605 else:
1606 return self.serializer_class
1607
Scott Baker0caeaf02014-06-19 11:12:55 -07001608 def get_queryset(self):
1609 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001610
Scott Baker0caeaf02014-06-19 11:12:55 -07001611 def create(self, request, *args, **kwargs):
1612 #obj = NetworkSliver().update(request.DATA)
1613 obj = self.get_object()
1614 obj.caller = request.user
1615 if obj.can_update(request.user):
1616 return super(NetworkSliverList, self).create(request, *args, **kwargs)
1617 else:
1618 return Response(status=status.HTTP_400_BAD_REQUEST)
1619
1620class NetworkSliverDetail(generics.RetrieveUpdateDestroyAPIView):
1621 queryset = NetworkSliver.objects.select_related().all()
1622 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001623 id_serializer_class = NetworkSliverIdSerializer
1624
1625 def get_serializer_class(self):
1626 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1627 if (no_hyperlinks):
1628 return self.id_serializer_class
1629 else:
1630 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001631
1632 def get_queryset(self):
1633 return NetworkSliver.select_by_user(self.request.user)
1634
1635 def update(self, request, *args, **kwargs):
1636 obj = self.get_object()
1637 if obj.can_update(request.user):
1638 return super(NetworkSliverDetail, self).update(request, *args, **kwargs)
1639 else:
1640 return Response(status=status.HTTP_400_BAD_REQUEST)
1641
1642 def destroy(self, request, *args, **kwargs):
1643 obj = self.get_object()
1644 if obj.can_update(request.user):
1645 return super(NetworkSliverDetail, self).destroy(request, *args, **kwargs)
1646 else:
1647 return Response(status=status.HTTP_400_BAD_REQUEST)
1648
Sapan Bhatiadea39432014-06-13 03:10:36 -04001649
1650
1651
Scott Baker0caeaf02014-06-19 11:12:55 -07001652class NetworkDeploymentsList(generics.ListCreateAPIView):
1653 queryset = NetworkDeployments.objects.select_related().all()
1654 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001655 id_serializer_class = NetworkDeploymentsIdSerializer
1656 filter_backends = (filters.DjangoFilterBackend,)
1657 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
1658
1659 def get_serializer_class(self):
1660 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1661 if (no_hyperlinks):
1662 return self.id_serializer_class
1663 else:
1664 return self.serializer_class
1665
Scott Baker0caeaf02014-06-19 11:12:55 -07001666 def get_queryset(self):
1667 return NetworkDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001668
Scott Baker0caeaf02014-06-19 11:12:55 -07001669 def create(self, request, *args, **kwargs):
1670 #obj = NetworkDeployments().update(request.DATA)
1671 obj = self.get_object()
1672 obj.caller = request.user
1673 if obj.can_update(request.user):
1674 return super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
1675 else:
1676 return Response(status=status.HTTP_400_BAD_REQUEST)
1677
1678class NetworkDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
1679 queryset = NetworkDeployments.objects.select_related().all()
1680 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001681 id_serializer_class = NetworkDeploymentsIdSerializer
1682
1683 def get_serializer_class(self):
1684 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1685 if (no_hyperlinks):
1686 return self.id_serializer_class
1687 else:
1688 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001689
1690 def get_queryset(self):
1691 return NetworkDeployments.select_by_user(self.request.user)
1692
1693 def update(self, request, *args, **kwargs):
1694 obj = self.get_object()
1695 if obj.can_update(request.user):
1696 return super(NetworkDeploymentsDetail, self).update(request, *args, **kwargs)
1697 else:
1698 return Response(status=status.HTTP_400_BAD_REQUEST)
1699
1700 def destroy(self, request, *args, **kwargs):
1701 obj = self.get_object()
1702 if obj.can_update(request.user):
1703 return super(NetworkDeploymentsDetail, self).destroy(request, *args, **kwargs)
1704 else:
1705 return Response(status=status.HTTP_400_BAD_REQUEST)
1706
Sapan Bhatiadea39432014-06-13 03:10:36 -04001707
1708
1709
1710class SliceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001711 queryset = Slice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001712 serializer_class = SliceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001713 id_serializer_class = SliceIdSerializer
1714 filter_backends = (filters.DjangoFilterBackend,)
1715 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',)
1716
1717 def get_serializer_class(self):
1718 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1719 if (no_hyperlinks):
1720 return self.id_serializer_class
1721 else:
1722 return self.serializer_class
1723
Scott Baker0caeaf02014-06-19 11:12:55 -07001724 def get_queryset(self):
1725 return Slice.select_by_user(self.request.user)
1726
1727 def create(self, request, *args, **kwargs):
1728 #obj = Slice().update(request.DATA)
1729 obj = self.get_object()
1730 obj.caller = request.user
1731 if obj.can_update(request.user):
1732 return super(SliceList, self).create(request, *args, **kwargs)
1733 else:
1734 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001735
1736class SliceDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001737 queryset = Slice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001738 serializer_class = SliceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001739 id_serializer_class = SliceIdSerializer
1740
1741 def get_serializer_class(self):
1742 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1743 if (no_hyperlinks):
1744 return self.id_serializer_class
1745 else:
1746 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001747
1748 def get_queryset(self):
1749 return Slice.select_by_user(self.request.user)
1750
1751 def update(self, request, *args, **kwargs):
1752 obj = self.get_object()
1753 if obj.can_update(request.user):
1754 return super(SliceDetail, self).update(request, *args, **kwargs)
1755 else:
1756 return Response(status=status.HTTP_400_BAD_REQUEST)
1757
1758 def destroy(self, request, *args, **kwargs):
1759 obj = self.get_object()
1760 if obj.can_update(request.user):
1761 return super(SliceDetail, self).destroy(request, *args, **kwargs)
1762 else:
1763 return Response(status=status.HTTP_400_BAD_REQUEST)
1764
Sapan Bhatiadea39432014-06-13 03:10:36 -04001765
1766
1767
1768class NetworkList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001769 queryset = Network.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001770 serializer_class = NetworkSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001771 id_serializer_class = NetworkIdSerializer
1772 filter_backends = (filters.DjangoFilterBackend,)
1773 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',)
1774
1775 def get_serializer_class(self):
1776 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1777 if (no_hyperlinks):
1778 return self.id_serializer_class
1779 else:
1780 return self.serializer_class
1781
Scott Baker0caeaf02014-06-19 11:12:55 -07001782 def get_queryset(self):
1783 return Network.select_by_user(self.request.user)
1784
1785 def create(self, request, *args, **kwargs):
1786 #obj = Network().update(request.DATA)
1787 obj = self.get_object()
1788 obj.caller = request.user
1789 if obj.can_update(request.user):
1790 return super(NetworkList, self).create(request, *args, **kwargs)
1791 else:
1792 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001793
1794class NetworkDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001795 queryset = Network.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001796 serializer_class = NetworkSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001797 id_serializer_class = NetworkIdSerializer
1798
1799 def get_serializer_class(self):
1800 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1801 if (no_hyperlinks):
1802 return self.id_serializer_class
1803 else:
1804 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001805
1806 def get_queryset(self):
1807 return Network.select_by_user(self.request.user)
1808
1809 def update(self, request, *args, **kwargs):
1810 obj = self.get_object()
1811 if obj.can_update(request.user):
1812 return super(NetworkDetail, self).update(request, *args, **kwargs)
1813 else:
1814 return Response(status=status.HTTP_400_BAD_REQUEST)
1815
1816 def destroy(self, request, *args, **kwargs):
1817 obj = self.get_object()
1818 if obj.can_update(request.user):
1819 return super(NetworkDetail, self).destroy(request, *args, **kwargs)
1820 else:
1821 return Response(status=status.HTTP_400_BAD_REQUEST)
1822
Sapan Bhatiadea39432014-06-13 03:10:36 -04001823
1824
1825
1826class ServiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001827 queryset = Service.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001828 serializer_class = ServiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001829 id_serializer_class = ServiceIdSerializer
1830 filter_backends = (filters.DjangoFilterBackend,)
1831 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
1832
1833 def get_serializer_class(self):
1834 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1835 if (no_hyperlinks):
1836 return self.id_serializer_class
1837 else:
1838 return self.serializer_class
1839
Scott Baker0caeaf02014-06-19 11:12:55 -07001840 def get_queryset(self):
1841 return Service.select_by_user(self.request.user)
1842
1843 def create(self, request, *args, **kwargs):
1844 #obj = Service().update(request.DATA)
1845 obj = self.get_object()
1846 obj.caller = request.user
1847 if obj.can_update(request.user):
1848 return super(ServiceList, self).create(request, *args, **kwargs)
1849 else:
1850 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001851
1852class ServiceDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001853 queryset = Service.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001854 serializer_class = ServiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001855 id_serializer_class = ServiceIdSerializer
1856
1857 def get_serializer_class(self):
1858 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1859 if (no_hyperlinks):
1860 return self.id_serializer_class
1861 else:
1862 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001863
1864 def get_queryset(self):
1865 return Service.select_by_user(self.request.user)
1866
1867 def update(self, request, *args, **kwargs):
1868 obj = self.get_object()
1869 if obj.can_update(request.user):
1870 return super(ServiceDetail, self).update(request, *args, **kwargs)
1871 else:
1872 return Response(status=status.HTTP_400_BAD_REQUEST)
1873
1874 def destroy(self, request, *args, **kwargs):
1875 obj = self.get_object()
1876 if obj.can_update(request.user):
1877 return super(ServiceDetail, self).destroy(request, *args, **kwargs)
1878 else:
1879 return Response(status=status.HTTP_400_BAD_REQUEST)
1880
Sapan Bhatiadea39432014-06-13 03:10:36 -04001881
1882
1883
Scott Baker0caeaf02014-06-19 11:12:55 -07001884class ServiceClassList(generics.ListCreateAPIView):
1885 queryset = ServiceClass.objects.select_related().all()
1886 serializer_class = ServiceClassSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001887 id_serializer_class = ServiceClassIdSerializer
1888 filter_backends = (filters.DjangoFilterBackend,)
1889 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
1890
1891 def get_serializer_class(self):
1892 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1893 if (no_hyperlinks):
1894 return self.id_serializer_class
1895 else:
1896 return self.serializer_class
1897
Scott Baker0caeaf02014-06-19 11:12:55 -07001898 def get_queryset(self):
1899 return ServiceClass.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001900
Scott Baker0caeaf02014-06-19 11:12:55 -07001901 def create(self, request, *args, **kwargs):
1902 #obj = ServiceClass().update(request.DATA)
1903 obj = self.get_object()
1904 obj.caller = request.user
1905 if obj.can_update(request.user):
1906 return super(ServiceClassList, self).create(request, *args, **kwargs)
1907 else:
1908 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001909
Scott Baker0caeaf02014-06-19 11:12:55 -07001910class ServiceClassDetail(generics.RetrieveUpdateDestroyAPIView):
1911 queryset = ServiceClass.objects.select_related().all()
1912 serializer_class = ServiceClassSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001913 id_serializer_class = ServiceClassIdSerializer
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
Scott Baker0caeaf02014-06-19 11:12:55 -07001921
1922 def get_queryset(self):
1923 return ServiceClass.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001924
Scott Baker0caeaf02014-06-19 11:12:55 -07001925 def update(self, request, *args, **kwargs):
1926 obj = self.get_object()
1927 if obj.can_update(request.user):
1928 return super(ServiceClassDetail, self).update(request, *args, **kwargs)
1929 else:
1930 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001931
Scott Baker0caeaf02014-06-19 11:12:55 -07001932 def destroy(self, request, *args, **kwargs):
1933 obj = self.get_object()
1934 if obj.can_update(request.user):
1935 return super(ServiceClassDetail, self).destroy(request, *args, **kwargs)
1936 else:
1937 return Response(status=status.HTTP_400_BAD_REQUEST)
1938
Sapan Bhatiadea39432014-06-13 03:10:36 -04001939
1940
1941
1942class PaymentList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001943 queryset = Payment.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001944 serializer_class = PaymentSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001945 id_serializer_class = PaymentIdSerializer
1946 filter_backends = (filters.DjangoFilterBackend,)
1947 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1948
1949 def get_serializer_class(self):
1950 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1951 if (no_hyperlinks):
1952 return self.id_serializer_class
1953 else:
1954 return self.serializer_class
1955
Scott Baker0caeaf02014-06-19 11:12:55 -07001956 def get_queryset(self):
1957 return Payment.select_by_user(self.request.user)
1958
1959 def create(self, request, *args, **kwargs):
1960 #obj = Payment().update(request.DATA)
1961 obj = self.get_object()
1962 obj.caller = request.user
1963 if obj.can_update(request.user):
1964 return super(PaymentList, self).create(request, *args, **kwargs)
1965 else:
1966 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001967
1968class PaymentDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001969 queryset = Payment.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001970 serializer_class = PaymentSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001971 id_serializer_class = PaymentIdSerializer
1972
1973 def get_serializer_class(self):
1974 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1975 if (no_hyperlinks):
1976 return self.id_serializer_class
1977 else:
1978 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001979
1980 def get_queryset(self):
1981 return Payment.select_by_user(self.request.user)
1982
1983 def update(self, request, *args, **kwargs):
1984 obj = self.get_object()
1985 if obj.can_update(request.user):
1986 return super(PaymentDetail, self).update(request, *args, **kwargs)
1987 else:
1988 return Response(status=status.HTTP_400_BAD_REQUEST)
1989
1990 def destroy(self, request, *args, **kwargs):
1991 obj = self.get_object()
1992 if obj.can_update(request.user):
1993 return super(PaymentDetail, self).destroy(request, *args, **kwargs)
1994 else:
1995 return Response(status=status.HTTP_400_BAD_REQUEST)
1996
Sapan Bhatiadea39432014-06-13 03:10:36 -04001997
1998
1999
Scott Baker0caeaf02014-06-19 11:12:55 -07002000class ChargeList(generics.ListCreateAPIView):
2001 queryset = Charge.objects.select_related().all()
2002 serializer_class = ChargeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002003 id_serializer_class = ChargeIdSerializer
2004 filter_backends = (filters.DjangoFilterBackend,)
2005 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
2006
2007 def get_serializer_class(self):
2008 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2009 if (no_hyperlinks):
2010 return self.id_serializer_class
2011 else:
2012 return self.serializer_class
2013
Scott Baker0caeaf02014-06-19 11:12:55 -07002014 def get_queryset(self):
2015 return Charge.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002016
Scott Baker0caeaf02014-06-19 11:12:55 -07002017 def create(self, request, *args, **kwargs):
2018 #obj = Charge().update(request.DATA)
2019 obj = self.get_object()
2020 obj.caller = request.user
2021 if obj.can_update(request.user):
2022 return super(ChargeList, self).create(request, *args, **kwargs)
2023 else:
2024 return Response(status=status.HTTP_400_BAD_REQUEST)
2025
2026class ChargeDetail(generics.RetrieveUpdateDestroyAPIView):
2027 queryset = Charge.objects.select_related().all()
2028 serializer_class = ChargeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002029 id_serializer_class = ChargeIdSerializer
2030
2031 def get_serializer_class(self):
2032 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2033 if (no_hyperlinks):
2034 return self.id_serializer_class
2035 else:
2036 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002037
2038 def get_queryset(self):
2039 return Charge.select_by_user(self.request.user)
2040
2041 def update(self, request, *args, **kwargs):
2042 obj = self.get_object()
2043 if obj.can_update(request.user):
2044 return super(ChargeDetail, self).update(request, *args, **kwargs)
2045 else:
2046 return Response(status=status.HTTP_400_BAD_REQUEST)
2047
2048 def destroy(self, request, *args, **kwargs):
2049 obj = self.get_object()
2050 if obj.can_update(request.user):
2051 return super(ChargeDetail, self).destroy(request, *args, **kwargs)
2052 else:
2053 return Response(status=status.HTTP_400_BAD_REQUEST)
2054
Sapan Bhatiadea39432014-06-13 03:10:36 -04002055
2056
2057
Scott Baker0caeaf02014-06-19 11:12:55 -07002058class RoleList(generics.ListCreateAPIView):
2059 queryset = Role.objects.select_related().all()
2060 serializer_class = RoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002061 id_serializer_class = RoleIdSerializer
2062 filter_backends = (filters.DjangoFilterBackend,)
2063 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
2064
2065 def get_serializer_class(self):
2066 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2067 if (no_hyperlinks):
2068 return self.id_serializer_class
2069 else:
2070 return self.serializer_class
2071
Scott Baker0caeaf02014-06-19 11:12:55 -07002072 def get_queryset(self):
2073 return Role.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002074
Scott Baker0caeaf02014-06-19 11:12:55 -07002075 def create(self, request, *args, **kwargs):
2076 #obj = Role().update(request.DATA)
2077 obj = self.get_object()
2078 obj.caller = request.user
2079 if obj.can_update(request.user):
2080 return super(RoleList, self).create(request, *args, **kwargs)
2081 else:
2082 return Response(status=status.HTTP_400_BAD_REQUEST)
2083
2084class RoleDetail(generics.RetrieveUpdateDestroyAPIView):
2085 queryset = Role.objects.select_related().all()
2086 serializer_class = RoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002087 id_serializer_class = RoleIdSerializer
2088
2089 def get_serializer_class(self):
2090 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2091 if (no_hyperlinks):
2092 return self.id_serializer_class
2093 else:
2094 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002095
2096 def get_queryset(self):
2097 return Role.select_by_user(self.request.user)
2098
2099 def update(self, request, *args, **kwargs):
2100 obj = self.get_object()
2101 if obj.can_update(request.user):
2102 return super(RoleDetail, self).update(request, *args, **kwargs)
2103 else:
2104 return Response(status=status.HTTP_400_BAD_REQUEST)
2105
2106 def destroy(self, request, *args, **kwargs):
2107 obj = self.get_object()
2108 if obj.can_update(request.user):
2109 return super(RoleDetail, self).destroy(request, *args, **kwargs)
2110 else:
2111 return Response(status=status.HTTP_400_BAD_REQUEST)
2112
2113
2114
2115
2116class UsableObjectList(generics.ListCreateAPIView):
2117 queryset = UsableObject.objects.select_related().all()
2118 serializer_class = UsableObjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002119 id_serializer_class = UsableObjectIdSerializer
2120 filter_backends = (filters.DjangoFilterBackend,)
2121 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
2122
2123 def get_serializer_class(self):
2124 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2125 if (no_hyperlinks):
2126 return self.id_serializer_class
2127 else:
2128 return self.serializer_class
2129
Scott Baker0caeaf02014-06-19 11:12:55 -07002130 def get_queryset(self):
2131 return UsableObject.select_by_user(self.request.user)
2132
2133 def create(self, request, *args, **kwargs):
2134 #obj = UsableObject().update(request.DATA)
2135 obj = self.get_object()
2136 obj.caller = request.user
2137 if obj.can_update(request.user):
2138 return super(UsableObjectList, self).create(request, *args, **kwargs)
2139 else:
2140 return Response(status=status.HTTP_400_BAD_REQUEST)
2141
2142class UsableObjectDetail(generics.RetrieveUpdateDestroyAPIView):
2143 queryset = UsableObject.objects.select_related().all()
2144 serializer_class = UsableObjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002145 id_serializer_class = UsableObjectIdSerializer
2146
2147 def get_serializer_class(self):
2148 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2149 if (no_hyperlinks):
2150 return self.id_serializer_class
2151 else:
2152 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002153
2154 def get_queryset(self):
2155 return UsableObject.select_by_user(self.request.user)
2156
2157 def update(self, request, *args, **kwargs):
2158 obj = self.get_object()
2159 if obj.can_update(request.user):
2160 return super(UsableObjectDetail, self).update(request, *args, **kwargs)
2161 else:
2162 return Response(status=status.HTTP_400_BAD_REQUEST)
2163
2164 def destroy(self, request, *args, **kwargs):
2165 obj = self.get_object()
2166 if obj.can_update(request.user):
2167 return super(UsableObjectDetail, self).destroy(request, *args, **kwargs)
2168 else:
2169 return Response(status=status.HTTP_400_BAD_REQUEST)
2170
2171
2172
2173
2174class SiteRoleList(generics.ListCreateAPIView):
2175 queryset = SiteRole.objects.select_related().all()
2176 serializer_class = SiteRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002177 id_serializer_class = SiteRoleIdSerializer
2178 filter_backends = (filters.DjangoFilterBackend,)
2179 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2180
2181 def get_serializer_class(self):
2182 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2183 if (no_hyperlinks):
2184 return self.id_serializer_class
2185 else:
2186 return self.serializer_class
2187
Scott Baker0caeaf02014-06-19 11:12:55 -07002188 def get_queryset(self):
2189 return SiteRole.select_by_user(self.request.user)
2190
2191 def create(self, request, *args, **kwargs):
2192 #obj = SiteRole().update(request.DATA)
2193 obj = self.get_object()
2194 obj.caller = request.user
2195 if obj.can_update(request.user):
2196 return super(SiteRoleList, self).create(request, *args, **kwargs)
2197 else:
2198 return Response(status=status.HTTP_400_BAD_REQUEST)
2199
2200class SiteRoleDetail(generics.RetrieveUpdateDestroyAPIView):
2201 queryset = SiteRole.objects.select_related().all()
2202 serializer_class = SiteRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002203 id_serializer_class = SiteRoleIdSerializer
2204
2205 def get_serializer_class(self):
2206 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2207 if (no_hyperlinks):
2208 return self.id_serializer_class
2209 else:
2210 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002211
2212 def get_queryset(self):
2213 return SiteRole.select_by_user(self.request.user)
2214
2215 def update(self, request, *args, **kwargs):
2216 obj = self.get_object()
2217 if obj.can_update(request.user):
2218 return super(SiteRoleDetail, self).update(request, *args, **kwargs)
2219 else:
2220 return Response(status=status.HTTP_400_BAD_REQUEST)
2221
2222 def destroy(self, request, *args, **kwargs):
2223 obj = self.get_object()
2224 if obj.can_update(request.user):
2225 return super(SiteRoleDetail, self).destroy(request, *args, **kwargs)
2226 else:
2227 return Response(status=status.HTTP_400_BAD_REQUEST)
2228
2229
2230
2231
2232class SliverList(generics.ListCreateAPIView):
2233 queryset = Sliver.objects.select_related().all()
2234 serializer_class = SliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002235 id_serializer_class = SliverIdSerializer
2236 filter_backends = (filters.DjangoFilterBackend,)
2237 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','userData','networks','networks',)
2238
2239 def get_serializer_class(self):
2240 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2241 if (no_hyperlinks):
2242 return self.id_serializer_class
2243 else:
2244 return self.serializer_class
2245
Scott Baker0caeaf02014-06-19 11:12:55 -07002246 def get_queryset(self):
2247 return Sliver.select_by_user(self.request.user)
2248
2249 def create(self, request, *args, **kwargs):
2250 #obj = Sliver().update(request.DATA)
2251 obj = self.get_object()
2252 obj.caller = request.user
2253 if obj.can_update(request.user):
2254 return super(SliverList, self).create(request, *args, **kwargs)
2255 else:
2256 return Response(status=status.HTTP_400_BAD_REQUEST)
2257
2258class SliverDetail(generics.RetrieveUpdateDestroyAPIView):
2259 queryset = Sliver.objects.select_related().all()
2260 serializer_class = SliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002261 id_serializer_class = SliverIdSerializer
2262
2263 def get_serializer_class(self):
2264 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2265 if (no_hyperlinks):
2266 return self.id_serializer_class
2267 else:
2268 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002269
2270 def get_queryset(self):
2271 return Sliver.select_by_user(self.request.user)
2272
2273 def update(self, request, *args, **kwargs):
2274 obj = self.get_object()
2275 if obj.can_update(request.user):
2276 return super(SliverDetail, self).update(request, *args, **kwargs)
2277 else:
2278 return Response(status=status.HTTP_400_BAD_REQUEST)
2279
2280 def destroy(self, request, *args, **kwargs):
2281 obj = self.get_object()
2282 if obj.can_update(request.user):
2283 return super(SliverDetail, self).destroy(request, *args, **kwargs)
2284 else:
2285 return Response(status=status.HTTP_400_BAD_REQUEST)
2286
2287
2288
2289
2290class NodeList(generics.ListCreateAPIView):
2291 queryset = Node.objects.select_related().all()
2292 serializer_class = NodeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002293 id_serializer_class = NodeIdSerializer
2294 filter_backends = (filters.DjangoFilterBackend,)
2295 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
2296
2297 def get_serializer_class(self):
2298 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2299 if (no_hyperlinks):
2300 return self.id_serializer_class
2301 else:
2302 return self.serializer_class
2303
Scott Baker0caeaf02014-06-19 11:12:55 -07002304 def get_queryset(self):
2305 return Node.select_by_user(self.request.user)
2306
2307 def create(self, request, *args, **kwargs):
2308 #obj = Node().update(request.DATA)
2309 obj = self.get_object()
2310 obj.caller = request.user
2311 if obj.can_update(request.user):
2312 return super(NodeList, self).create(request, *args, **kwargs)
2313 else:
2314 return Response(status=status.HTTP_400_BAD_REQUEST)
2315
2316class NodeDetail(generics.RetrieveUpdateDestroyAPIView):
2317 queryset = Node.objects.select_related().all()
2318 serializer_class = NodeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002319 id_serializer_class = NodeIdSerializer
2320
2321 def get_serializer_class(self):
2322 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2323 if (no_hyperlinks):
2324 return self.id_serializer_class
2325 else:
2326 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002327
2328 def get_queryset(self):
2329 return Node.select_by_user(self.request.user)
2330
2331 def update(self, request, *args, **kwargs):
2332 obj = self.get_object()
2333 if obj.can_update(request.user):
2334 return super(NodeDetail, self).update(request, *args, **kwargs)
2335 else:
2336 return Response(status=status.HTTP_400_BAD_REQUEST)
2337
2338 def destroy(self, request, *args, **kwargs):
2339 obj = self.get_object()
2340 if obj.can_update(request.user):
2341 return super(NodeDetail, self).destroy(request, *args, **kwargs)
2342 else:
2343 return Response(status=status.HTTP_400_BAD_REQUEST)
2344
2345
2346
2347
2348class DashboardViewList(generics.ListCreateAPIView):
2349 queryset = DashboardView.objects.select_related().all()
2350 serializer_class = DashboardViewSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002351 id_serializer_class = DashboardViewIdSerializer
2352 filter_backends = (filters.DjangoFilterBackend,)
2353 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
2354
2355 def get_serializer_class(self):
2356 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2357 if (no_hyperlinks):
2358 return self.id_serializer_class
2359 else:
2360 return self.serializer_class
2361
Scott Baker0caeaf02014-06-19 11:12:55 -07002362 def get_queryset(self):
2363 return DashboardView.select_by_user(self.request.user)
2364
2365 def create(self, request, *args, **kwargs):
2366 #obj = DashboardView().update(request.DATA)
2367 obj = self.get_object()
2368 obj.caller = request.user
2369 if obj.can_update(request.user):
2370 return super(DashboardViewList, self).create(request, *args, **kwargs)
2371 else:
2372 return Response(status=status.HTTP_400_BAD_REQUEST)
2373
2374class DashboardViewDetail(generics.RetrieveUpdateDestroyAPIView):
2375 queryset = DashboardView.objects.select_related().all()
2376 serializer_class = DashboardViewSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002377 id_serializer_class = DashboardViewIdSerializer
2378
2379 def get_serializer_class(self):
2380 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2381 if (no_hyperlinks):
2382 return self.id_serializer_class
2383 else:
2384 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002385
2386 def get_queryset(self):
2387 return DashboardView.select_by_user(self.request.user)
2388
2389 def update(self, request, *args, **kwargs):
2390 obj = self.get_object()
2391 if obj.can_update(request.user):
2392 return super(DashboardViewDetail, self).update(request, *args, **kwargs)
2393 else:
2394 return Response(status=status.HTTP_400_BAD_REQUEST)
2395
2396 def destroy(self, request, *args, **kwargs):
2397 obj = self.get_object()
2398 if obj.can_update(request.user):
2399 return super(DashboardViewDetail, self).destroy(request, *args, **kwargs)
2400 else:
2401 return Response(status=status.HTTP_400_BAD_REQUEST)
2402
2403
2404
2405
2406class ImageDeploymentsList(generics.ListCreateAPIView):
2407 queryset = ImageDeployments.objects.select_related().all()
2408 serializer_class = ImageDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002409 id_serializer_class = ImageDeploymentsIdSerializer
2410 filter_backends = (filters.DjangoFilterBackend,)
2411 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
2412
2413 def get_serializer_class(self):
2414 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2415 if (no_hyperlinks):
2416 return self.id_serializer_class
2417 else:
2418 return self.serializer_class
2419
Scott Baker0caeaf02014-06-19 11:12:55 -07002420 def get_queryset(self):
2421 return ImageDeployments.select_by_user(self.request.user)
2422
2423 def create(self, request, *args, **kwargs):
2424 #obj = ImageDeployments().update(request.DATA)
2425 obj = self.get_object()
2426 obj.caller = request.user
2427 if obj.can_update(request.user):
2428 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
2429 else:
2430 return Response(status=status.HTTP_400_BAD_REQUEST)
2431
2432class ImageDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
2433 queryset = ImageDeployments.objects.select_related().all()
2434 serializer_class = ImageDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002435 id_serializer_class = ImageDeploymentsIdSerializer
2436
2437 def get_serializer_class(self):
2438 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2439 if (no_hyperlinks):
2440 return self.id_serializer_class
2441 else:
2442 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002443
2444 def get_queryset(self):
2445 return ImageDeployments.select_by_user(self.request.user)
2446
2447 def update(self, request, *args, **kwargs):
2448 obj = self.get_object()
2449 if obj.can_update(request.user):
2450 return super(ImageDeploymentsDetail, self).update(request, *args, **kwargs)
2451 else:
2452 return Response(status=status.HTTP_400_BAD_REQUEST)
2453
2454 def destroy(self, request, *args, **kwargs):
2455 obj = self.get_object()
2456 if obj.can_update(request.user):
2457 return super(ImageDeploymentsDetail, self).destroy(request, *args, **kwargs)
2458 else:
2459 return Response(status=status.HTTP_400_BAD_REQUEST)
2460
2461
2462
2463
2464class ReservedResourceList(generics.ListCreateAPIView):
2465 queryset = ReservedResource.objects.select_related().all()
2466 serializer_class = ReservedResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002467 id_serializer_class = ReservedResourceIdSerializer
2468 filter_backends = (filters.DjangoFilterBackend,)
2469 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
2470
2471 def get_serializer_class(self):
2472 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2473 if (no_hyperlinks):
2474 return self.id_serializer_class
2475 else:
2476 return self.serializer_class
2477
Scott Baker0caeaf02014-06-19 11:12:55 -07002478 def get_queryset(self):
2479 return ReservedResource.select_by_user(self.request.user)
2480
2481 def create(self, request, *args, **kwargs):
2482 #obj = ReservedResource().update(request.DATA)
2483 obj = self.get_object()
2484 obj.caller = request.user
2485 if obj.can_update(request.user):
2486 return super(ReservedResourceList, self).create(request, *args, **kwargs)
2487 else:
2488 return Response(status=status.HTTP_400_BAD_REQUEST)
2489
2490class ReservedResourceDetail(generics.RetrieveUpdateDestroyAPIView):
2491 queryset = ReservedResource.objects.select_related().all()
2492 serializer_class = ReservedResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002493 id_serializer_class = ReservedResourceIdSerializer
2494
2495 def get_serializer_class(self):
2496 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2497 if (no_hyperlinks):
2498 return self.id_serializer_class
2499 else:
2500 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002501
2502 def get_queryset(self):
2503 return ReservedResource.select_by_user(self.request.user)
2504
2505 def update(self, request, *args, **kwargs):
2506 obj = self.get_object()
2507 if obj.can_update(request.user):
2508 return super(ReservedResourceDetail, self).update(request, *args, **kwargs)
2509 else:
2510 return Response(status=status.HTTP_400_BAD_REQUEST)
2511
2512 def destroy(self, request, *args, **kwargs):
2513 obj = self.get_object()
2514 if obj.can_update(request.user):
2515 return super(ReservedResourceDetail, self).destroy(request, *args, **kwargs)
2516 else:
2517 return Response(status=status.HTTP_400_BAD_REQUEST)
2518
2519
2520
2521
2522class NetworkSliceList(generics.ListCreateAPIView):
2523 queryset = NetworkSlice.objects.select_related().all()
2524 serializer_class = NetworkSliceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002525 id_serializer_class = NetworkSliceIdSerializer
2526 filter_backends = (filters.DjangoFilterBackend,)
2527 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
2528
2529 def get_serializer_class(self):
2530 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2531 if (no_hyperlinks):
2532 return self.id_serializer_class
2533 else:
2534 return self.serializer_class
2535
Scott Baker0caeaf02014-06-19 11:12:55 -07002536 def get_queryset(self):
2537 return NetworkSlice.select_by_user(self.request.user)
2538
2539 def create(self, request, *args, **kwargs):
2540 #obj = NetworkSlice().update(request.DATA)
2541 obj = self.get_object()
2542 obj.caller = request.user
2543 if obj.can_update(request.user):
2544 return super(NetworkSliceList, self).create(request, *args, **kwargs)
2545 else:
2546 return Response(status=status.HTTP_400_BAD_REQUEST)
2547
2548class NetworkSliceDetail(generics.RetrieveUpdateDestroyAPIView):
2549 queryset = NetworkSlice.objects.select_related().all()
2550 serializer_class = NetworkSliceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002551 id_serializer_class = NetworkSliceIdSerializer
2552
2553 def get_serializer_class(self):
2554 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2555 if (no_hyperlinks):
2556 return self.id_serializer_class
2557 else:
2558 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002559
2560 def get_queryset(self):
2561 return NetworkSlice.select_by_user(self.request.user)
2562
2563 def update(self, request, *args, **kwargs):
2564 obj = self.get_object()
2565 if obj.can_update(request.user):
2566 return super(NetworkSliceDetail, self).update(request, *args, **kwargs)
2567 else:
2568 return Response(status=status.HTTP_400_BAD_REQUEST)
2569
2570 def destroy(self, request, *args, **kwargs):
2571 obj = self.get_object()
2572 if obj.can_update(request.user):
2573 return super(NetworkSliceDetail, self).destroy(request, *args, **kwargs)
2574 else:
2575 return Response(status=status.HTTP_400_BAD_REQUEST)
2576
2577
2578
2579
2580class UserDashboardViewList(generics.ListCreateAPIView):
2581 queryset = UserDashboardView.objects.select_related().all()
2582 serializer_class = UserDashboardViewSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002583 id_serializer_class = UserDashboardViewIdSerializer
2584 filter_backends = (filters.DjangoFilterBackend,)
2585 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
2586
2587 def get_serializer_class(self):
2588 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2589 if (no_hyperlinks):
2590 return self.id_serializer_class
2591 else:
2592 return self.serializer_class
2593
Scott Baker0caeaf02014-06-19 11:12:55 -07002594 def get_queryset(self):
2595 return UserDashboardView.select_by_user(self.request.user)
2596
2597 def create(self, request, *args, **kwargs):
2598 #obj = UserDashboardView().update(request.DATA)
2599 obj = self.get_object()
2600 obj.caller = request.user
2601 if obj.can_update(request.user):
2602 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
2603 else:
2604 return Response(status=status.HTTP_400_BAD_REQUEST)
2605
2606class UserDashboardViewDetail(generics.RetrieveUpdateDestroyAPIView):
2607 queryset = UserDashboardView.objects.select_related().all()
2608 serializer_class = UserDashboardViewSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002609 id_serializer_class = UserDashboardViewIdSerializer
2610
2611 def get_serializer_class(self):
2612 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2613 if (no_hyperlinks):
2614 return self.id_serializer_class
2615 else:
2616 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002617
2618 def get_queryset(self):
2619 return UserDashboardView.select_by_user(self.request.user)
2620
2621 def update(self, request, *args, **kwargs):
2622 obj = self.get_object()
2623 if obj.can_update(request.user):
2624 return super(UserDashboardViewDetail, self).update(request, *args, **kwargs)
2625 else:
2626 return Response(status=status.HTTP_400_BAD_REQUEST)
2627
2628 def destroy(self, request, *args, **kwargs):
2629 obj = self.get_object()
2630 if obj.can_update(request.user):
2631 return super(UserDashboardViewDetail, self).destroy(request, *args, **kwargs)
2632 else:
2633 return Response(status=status.HTTP_400_BAD_REQUEST)
2634
2635
2636
2637
2638class PlanetStackPrivilegeList(generics.ListCreateAPIView):
2639 queryset = PlanetStackPrivilege.objects.select_related().all()
2640 serializer_class = PlanetStackPrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002641 id_serializer_class = PlanetStackPrivilegeIdSerializer
2642 filter_backends = (filters.DjangoFilterBackend,)
2643 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
2644
2645 def get_serializer_class(self):
2646 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2647 if (no_hyperlinks):
2648 return self.id_serializer_class
2649 else:
2650 return self.serializer_class
2651
Scott Baker0caeaf02014-06-19 11:12:55 -07002652 def get_queryset(self):
2653 return PlanetStackPrivilege.select_by_user(self.request.user)
2654
2655 def create(self, request, *args, **kwargs):
2656 #obj = PlanetStackPrivilege().update(request.DATA)
2657 obj = self.get_object()
2658 obj.caller = request.user
2659 if obj.can_update(request.user):
2660 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
2661 else:
2662 return Response(status=status.HTTP_400_BAD_REQUEST)
2663
2664class PlanetStackPrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
2665 queryset = PlanetStackPrivilege.objects.select_related().all()
2666 serializer_class = PlanetStackPrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002667 id_serializer_class = PlanetStackPrivilegeIdSerializer
2668
2669 def get_serializer_class(self):
2670 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2671 if (no_hyperlinks):
2672 return self.id_serializer_class
2673 else:
2674 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002675
2676 def get_queryset(self):
2677 return PlanetStackPrivilege.select_by_user(self.request.user)
2678
2679 def update(self, request, *args, **kwargs):
2680 obj = self.get_object()
2681 if obj.can_update(request.user):
2682 return super(PlanetStackPrivilegeDetail, self).update(request, *args, **kwargs)
2683 else:
2684 return Response(status=status.HTTP_400_BAD_REQUEST)
2685
2686 def destroy(self, request, *args, **kwargs):
2687 obj = self.get_object()
2688 if obj.can_update(request.user):
2689 return super(PlanetStackPrivilegeDetail, self).destroy(request, *args, **kwargs)
2690 else:
2691 return Response(status=status.HTTP_400_BAD_REQUEST)
2692
Sapan Bhatiadea39432014-06-13 03:10:36 -04002693
2694
2695
2696class UserList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002697 queryset = User.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002698 serializer_class = UserSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002699 id_serializer_class = UserIdSerializer
2700 filter_backends = (filters.DjangoFilterBackend,)
2701 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',)
2702
2703 def get_serializer_class(self):
2704 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2705 if (no_hyperlinks):
2706 return self.id_serializer_class
2707 else:
2708 return self.serializer_class
2709
Scott Baker0caeaf02014-06-19 11:12:55 -07002710 def get_queryset(self):
2711 return User.select_by_user(self.request.user)
2712
2713 def create(self, request, *args, **kwargs):
2714 #obj = User().update(request.DATA)
2715 obj = self.get_object()
2716 obj.caller = request.user
2717 if obj.can_update(request.user):
2718 return super(UserList, self).create(request, *args, **kwargs)
2719 else:
2720 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002721
2722class UserDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002723 queryset = User.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002724 serializer_class = UserSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002725 id_serializer_class = UserIdSerializer
2726
2727 def get_serializer_class(self):
2728 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2729 if (no_hyperlinks):
2730 return self.id_serializer_class
2731 else:
2732 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002733
2734 def get_queryset(self):
2735 return User.select_by_user(self.request.user)
2736
2737 def update(self, request, *args, **kwargs):
2738 obj = self.get_object()
2739 if obj.can_update(request.user):
2740 return super(UserDetail, self).update(request, *args, **kwargs)
2741 else:
2742 return Response(status=status.HTTP_400_BAD_REQUEST)
2743
2744 def destroy(self, request, *args, **kwargs):
2745 obj = self.get_object()
2746 if obj.can_update(request.user):
2747 return super(UserDetail, self).destroy(request, *args, **kwargs)
2748 else:
2749 return Response(status=status.HTTP_400_BAD_REQUEST)
2750
Sapan Bhatiadea39432014-06-13 03:10:36 -04002751
2752
2753
2754class DeploymentList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002755 queryset = Deployment.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002756 serializer_class = DeploymentSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002757 id_serializer_class = DeploymentIdSerializer
2758 filter_backends = (filters.DjangoFilterBackend,)
2759 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','accessControl','sites','sites',)
2760
2761 def get_serializer_class(self):
2762 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2763 if (no_hyperlinks):
2764 return self.id_serializer_class
2765 else:
2766 return self.serializer_class
2767
Scott Baker0caeaf02014-06-19 11:12:55 -07002768 def get_queryset(self):
2769 return Deployment.select_by_user(self.request.user)
2770
2771 def create(self, request, *args, **kwargs):
2772 #obj = Deployment().update(request.DATA)
2773 obj = self.get_object()
2774 obj.caller = request.user
2775 if obj.can_update(request.user):
2776 return super(DeploymentList, self).create(request, *args, **kwargs)
2777 else:
2778 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002779
2780class DeploymentDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002781 queryset = Deployment.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002782 serializer_class = DeploymentSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002783 id_serializer_class = DeploymentIdSerializer
2784
2785 def get_serializer_class(self):
2786 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2787 if (no_hyperlinks):
2788 return self.id_serializer_class
2789 else:
2790 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002791
2792 def get_queryset(self):
2793 return Deployment.select_by_user(self.request.user)
2794
2795 def update(self, request, *args, **kwargs):
2796 obj = self.get_object()
2797 if obj.can_update(request.user):
2798 return super(DeploymentDetail, self).update(request, *args, **kwargs)
2799 else:
2800 return Response(status=status.HTTP_400_BAD_REQUEST)
2801
2802 def destroy(self, request, *args, **kwargs):
2803 obj = self.get_object()
2804 if obj.can_update(request.user):
2805 return super(DeploymentDetail, self).destroy(request, *args, **kwargs)
2806 else:
2807 return Response(status=status.HTTP_400_BAD_REQUEST)
2808
Sapan Bhatiadea39432014-06-13 03:10:36 -04002809
2810
2811
2812class ReservationList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002813 queryset = Reservation.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002814 serializer_class = ReservationSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002815 id_serializer_class = ReservationIdSerializer
2816 filter_backends = (filters.DjangoFilterBackend,)
2817 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
2818
2819 def get_serializer_class(self):
2820 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2821 if (no_hyperlinks):
2822 return self.id_serializer_class
2823 else:
2824 return self.serializer_class
2825
Scott Baker0caeaf02014-06-19 11:12:55 -07002826 def get_queryset(self):
2827 return Reservation.select_by_user(self.request.user)
2828
2829 def create(self, request, *args, **kwargs):
2830 #obj = Reservation().update(request.DATA)
2831 obj = self.get_object()
2832 obj.caller = request.user
2833 if obj.can_update(request.user):
2834 return super(ReservationList, self).create(request, *args, **kwargs)
2835 else:
2836 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002837
2838class ReservationDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002839 queryset = Reservation.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002840 serializer_class = ReservationSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002841 id_serializer_class = ReservationIdSerializer
2842
2843 def get_serializer_class(self):
2844 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2845 if (no_hyperlinks):
2846 return self.id_serializer_class
2847 else:
2848 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002849
2850 def get_queryset(self):
2851 return Reservation.select_by_user(self.request.user)
2852
2853 def update(self, request, *args, **kwargs):
2854 obj = self.get_object()
2855 if obj.can_update(request.user):
2856 return super(ReservationDetail, self).update(request, *args, **kwargs)
2857 else:
2858 return Response(status=status.HTTP_400_BAD_REQUEST)
2859
2860 def destroy(self, request, *args, **kwargs):
2861 obj = self.get_object()
2862 if obj.can_update(request.user):
2863 return super(ReservationDetail, self).destroy(request, *args, **kwargs)
2864 else:
2865 return Response(status=status.HTTP_400_BAD_REQUEST)
2866
Sapan Bhatiadea39432014-06-13 03:10:36 -04002867
2868
2869
Scott Baker0caeaf02014-06-19 11:12:55 -07002870class SliceDeploymentsList(generics.ListCreateAPIView):
2871 queryset = SliceDeployments.objects.select_related().all()
2872 serializer_class = SliceDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002873 id_serializer_class = SliceDeploymentsIdSerializer
2874 filter_backends = (filters.DjangoFilterBackend,)
2875 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
2876
2877 def get_serializer_class(self):
2878 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2879 if (no_hyperlinks):
2880 return self.id_serializer_class
2881 else:
2882 return self.serializer_class
2883
Scott Baker0caeaf02014-06-19 11:12:55 -07002884 def get_queryset(self):
2885 return SliceDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002886
Scott Baker0caeaf02014-06-19 11:12:55 -07002887 def create(self, request, *args, **kwargs):
2888 #obj = SliceDeployments().update(request.DATA)
2889 obj = self.get_object()
2890 obj.caller = request.user
2891 if obj.can_update(request.user):
2892 return super(SliceDeploymentsList, self).create(request, *args, **kwargs)
2893 else:
2894 return Response(status=status.HTTP_400_BAD_REQUEST)
2895
2896class SliceDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
2897 queryset = SliceDeployments.objects.select_related().all()
2898 serializer_class = SliceDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002899 id_serializer_class = SliceDeploymentsIdSerializer
2900
2901 def get_serializer_class(self):
2902 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2903 if (no_hyperlinks):
2904 return self.id_serializer_class
2905 else:
2906 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002907
2908 def get_queryset(self):
2909 return SliceDeployments.select_by_user(self.request.user)
2910
2911 def update(self, request, *args, **kwargs):
2912 obj = self.get_object()
2913 if obj.can_update(request.user):
2914 return super(SliceDeploymentsDetail, self).update(request, *args, **kwargs)
2915 else:
2916 return Response(status=status.HTTP_400_BAD_REQUEST)
2917
2918 def destroy(self, request, *args, **kwargs):
2919 obj = self.get_object()
2920 if obj.can_update(request.user):
2921 return super(SliceDeploymentsDetail, self).destroy(request, *args, **kwargs)
2922 else:
2923 return Response(status=status.HTTP_400_BAD_REQUEST)
2924
Sapan Bhatiadea39432014-06-13 03:10:36 -04002925
2926
2927
Scott Baker0caeaf02014-06-19 11:12:55 -07002928class SitePrivilegeList(generics.ListCreateAPIView):
2929 queryset = SitePrivilege.objects.select_related().all()
2930 serializer_class = SitePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002931 id_serializer_class = SitePrivilegeIdSerializer
2932 filter_backends = (filters.DjangoFilterBackend,)
2933 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
2934
2935 def get_serializer_class(self):
2936 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2937 if (no_hyperlinks):
2938 return self.id_serializer_class
2939 else:
2940 return self.serializer_class
2941
Scott Baker0caeaf02014-06-19 11:12:55 -07002942 def get_queryset(self):
2943 return SitePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002944
Scott Baker0caeaf02014-06-19 11:12:55 -07002945 def create(self, request, *args, **kwargs):
2946 #obj = SitePrivilege().update(request.DATA)
2947 obj = self.get_object()
2948 obj.caller = request.user
2949 if obj.can_update(request.user):
2950 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
2951 else:
2952 return Response(status=status.HTTP_400_BAD_REQUEST)
2953
2954class SitePrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
2955 queryset = SitePrivilege.objects.select_related().all()
2956 serializer_class = SitePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002957 id_serializer_class = SitePrivilegeIdSerializer
2958
2959 def get_serializer_class(self):
2960 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2961 if (no_hyperlinks):
2962 return self.id_serializer_class
2963 else:
2964 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002965
2966 def get_queryset(self):
2967 return SitePrivilege.select_by_user(self.request.user)
2968
2969 def update(self, request, *args, **kwargs):
2970 obj = self.get_object()
2971 if obj.can_update(request.user):
2972 return super(SitePrivilegeDetail, self).update(request, *args, **kwargs)
2973 else:
2974 return Response(status=status.HTTP_400_BAD_REQUEST)
2975
2976 def destroy(self, request, *args, **kwargs):
2977 obj = self.get_object()
2978 if obj.can_update(request.user):
2979 return super(SitePrivilegeDetail, self).destroy(request, *args, **kwargs)
2980 else:
2981 return Response(status=status.HTTP_400_BAD_REQUEST)
2982
Sapan Bhatiadea39432014-06-13 03:10:36 -04002983
2984
2985
Scott Baker0caeaf02014-06-19 11:12:55 -07002986class PlanetStackList(generics.ListCreateAPIView):
2987 queryset = PlanetStack.objects.select_related().all()
2988 serializer_class = PlanetStackSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002989 id_serializer_class = PlanetStackIdSerializer
2990 filter_backends = (filters.DjangoFilterBackend,)
2991 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
2992
2993 def get_serializer_class(self):
2994 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2995 if (no_hyperlinks):
2996 return self.id_serializer_class
2997 else:
2998 return self.serializer_class
2999
Scott Baker0caeaf02014-06-19 11:12:55 -07003000 def get_queryset(self):
3001 return PlanetStack.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003002
Scott Baker0caeaf02014-06-19 11:12:55 -07003003 def create(self, request, *args, **kwargs):
3004 #obj = PlanetStack().update(request.DATA)
3005 obj = self.get_object()
3006 obj.caller = request.user
3007 if obj.can_update(request.user):
3008 return super(PlanetStackList, self).create(request, *args, **kwargs)
3009 else:
3010 return Response(status=status.HTTP_400_BAD_REQUEST)
3011
3012class PlanetStackDetail(generics.RetrieveUpdateDestroyAPIView):
3013 queryset = PlanetStack.objects.select_related().all()
3014 serializer_class = PlanetStackSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003015 id_serializer_class = PlanetStackIdSerializer
3016
3017 def get_serializer_class(self):
3018 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3019 if (no_hyperlinks):
3020 return self.id_serializer_class
3021 else:
3022 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003023
3024 def get_queryset(self):
3025 return PlanetStack.select_by_user(self.request.user)
3026
3027 def update(self, request, *args, **kwargs):
3028 obj = self.get_object()
3029 if obj.can_update(request.user):
3030 return super(PlanetStackDetail, self).update(request, *args, **kwargs)
3031 else:
3032 return Response(status=status.HTTP_400_BAD_REQUEST)
3033
3034 def destroy(self, request, *args, **kwargs):
3035 obj = self.get_object()
3036 if obj.can_update(request.user):
3037 return super(PlanetStackDetail, self).destroy(request, *args, **kwargs)
3038 else:
3039 return Response(status=status.HTTP_400_BAD_REQUEST)
3040
3041
3042
3043
3044class UserDeploymentsList(generics.ListCreateAPIView):
3045 queryset = UserDeployments.objects.select_related().all()
3046 serializer_class = UserDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003047 id_serializer_class = UserDeploymentsIdSerializer
3048 filter_backends = (filters.DjangoFilterBackend,)
3049 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
3050
3051 def get_serializer_class(self):
3052 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3053 if (no_hyperlinks):
3054 return self.id_serializer_class
3055 else:
3056 return self.serializer_class
3057
Scott Baker0caeaf02014-06-19 11:12:55 -07003058 def get_queryset(self):
3059 return UserDeployments.select_by_user(self.request.user)
3060
3061 def create(self, request, *args, **kwargs):
3062 #obj = UserDeployments().update(request.DATA)
3063 obj = self.get_object()
3064 obj.caller = request.user
3065 if obj.can_update(request.user):
3066 return super(UserDeploymentsList, self).create(request, *args, **kwargs)
3067 else:
3068 return Response(status=status.HTTP_400_BAD_REQUEST)
3069
3070class UserDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
3071 queryset = UserDeployments.objects.select_related().all()
3072 serializer_class = UserDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003073 id_serializer_class = UserDeploymentsIdSerializer
3074
3075 def get_serializer_class(self):
3076 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3077 if (no_hyperlinks):
3078 return self.id_serializer_class
3079 else:
3080 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003081
3082 def get_queryset(self):
3083 return UserDeployments.select_by_user(self.request.user)
3084
3085 def update(self, request, *args, **kwargs):
3086 obj = self.get_object()
3087 if obj.can_update(request.user):
3088 return super(UserDeploymentsDetail, self).update(request, *args, **kwargs)
3089 else:
3090 return Response(status=status.HTTP_400_BAD_REQUEST)
3091
3092 def destroy(self, request, *args, **kwargs):
3093 obj = self.get_object()
3094 if obj.can_update(request.user):
3095 return super(UserDeploymentsDetail, self).destroy(request, *args, **kwargs)
3096 else:
3097 return Response(status=status.HTTP_400_BAD_REQUEST)
3098
Sapan Bhatiadea39432014-06-13 03:10:36 -04003099
3100
3101
3102class AccountList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003103 queryset = Account.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003104 serializer_class = AccountSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003105 id_serializer_class = AccountIdSerializer
3106 filter_backends = (filters.DjangoFilterBackend,)
3107 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
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
Scott Baker0caeaf02014-06-19 11:12:55 -07003116 def get_queryset(self):
3117 return Account.select_by_user(self.request.user)
3118
3119 def create(self, request, *args, **kwargs):
3120 #obj = Account().update(request.DATA)
3121 obj = self.get_object()
3122 obj.caller = request.user
3123 if obj.can_update(request.user):
3124 return super(AccountList, self).create(request, *args, **kwargs)
3125 else:
3126 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003127
3128class AccountDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003129 queryset = Account.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003130 serializer_class = AccountSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003131 id_serializer_class = AccountIdSerializer
3132
3133 def get_serializer_class(self):
3134 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3135 if (no_hyperlinks):
3136 return self.id_serializer_class
3137 else:
3138 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003139
3140 def get_queryset(self):
3141 return Account.select_by_user(self.request.user)
3142
3143 def update(self, request, *args, **kwargs):
3144 obj = self.get_object()
3145 if obj.can_update(request.user):
3146 return super(AccountDetail, self).update(request, *args, **kwargs)
3147 else:
3148 return Response(status=status.HTTP_400_BAD_REQUEST)
3149
3150 def destroy(self, request, *args, **kwargs):
3151 obj = self.get_object()
3152 if obj.can_update(request.user):
3153 return super(AccountDetail, self).destroy(request, *args, **kwargs)
3154 else:
3155 return Response(status=status.HTTP_400_BAD_REQUEST)
3156
Sapan Bhatiadea39432014-06-13 03:10:36 -04003157
3158
3159
Scott Baker0caeaf02014-06-19 11:12:55 -07003160class NetworkParameterTypeList(generics.ListCreateAPIView):
3161 queryset = NetworkParameterType.objects.select_related().all()
3162 serializer_class = NetworkParameterTypeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003163 id_serializer_class = NetworkParameterTypeIdSerializer
3164 filter_backends = (filters.DjangoFilterBackend,)
3165 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
3166
3167 def get_serializer_class(self):
3168 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3169 if (no_hyperlinks):
3170 return self.id_serializer_class
3171 else:
3172 return self.serializer_class
3173
Scott Baker0caeaf02014-06-19 11:12:55 -07003174 def get_queryset(self):
3175 return NetworkParameterType.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003176
Scott Baker0caeaf02014-06-19 11:12:55 -07003177 def create(self, request, *args, **kwargs):
3178 #obj = NetworkParameterType().update(request.DATA)
3179 obj = self.get_object()
3180 obj.caller = request.user
3181 if obj.can_update(request.user):
3182 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
3183 else:
3184 return Response(status=status.HTTP_400_BAD_REQUEST)
3185
3186class NetworkParameterTypeDetail(generics.RetrieveUpdateDestroyAPIView):
3187 queryset = NetworkParameterType.objects.select_related().all()
3188 serializer_class = NetworkParameterTypeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003189 id_serializer_class = NetworkParameterTypeIdSerializer
3190
3191 def get_serializer_class(self):
3192 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3193 if (no_hyperlinks):
3194 return self.id_serializer_class
3195 else:
3196 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003197
3198 def get_queryset(self):
3199 return NetworkParameterType.select_by_user(self.request.user)
3200
3201 def update(self, request, *args, **kwargs):
3202 obj = self.get_object()
3203 if obj.can_update(request.user):
3204 return super(NetworkParameterTypeDetail, self).update(request, *args, **kwargs)
3205 else:
3206 return Response(status=status.HTTP_400_BAD_REQUEST)
3207
3208 def destroy(self, request, *args, **kwargs):
3209 obj = self.get_object()
3210 if obj.can_update(request.user):
3211 return super(NetworkParameterTypeDetail, self).destroy(request, *args, **kwargs)
3212 else:
3213 return Response(status=status.HTTP_400_BAD_REQUEST)
3214
Sapan Bhatiadea39432014-06-13 03:10:36 -04003215
3216
3217
Scott Baker0caeaf02014-06-19 11:12:55 -07003218class SiteDeploymentsList(generics.ListCreateAPIView):
3219 queryset = SiteDeployments.objects.select_related().all()
3220 serializer_class = SiteDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003221 id_serializer_class = SiteDeploymentsIdSerializer
3222 filter_backends = (filters.DjangoFilterBackend,)
3223 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
3224
3225 def get_serializer_class(self):
3226 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3227 if (no_hyperlinks):
3228 return self.id_serializer_class
3229 else:
3230 return self.serializer_class
3231
Scott Baker0caeaf02014-06-19 11:12:55 -07003232 def get_queryset(self):
3233 return SiteDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003234
Scott Baker0caeaf02014-06-19 11:12:55 -07003235 def create(self, request, *args, **kwargs):
3236 #obj = SiteDeployments().update(request.DATA)
3237 obj = self.get_object()
3238 obj.caller = request.user
3239 if obj.can_update(request.user):
3240 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
3241 else:
3242 return Response(status=status.HTTP_400_BAD_REQUEST)
3243
3244class SiteDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
3245 queryset = SiteDeployments.objects.select_related().all()
3246 serializer_class = SiteDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003247 id_serializer_class = SiteDeploymentsIdSerializer
3248
3249 def get_serializer_class(self):
3250 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3251 if (no_hyperlinks):
3252 return self.id_serializer_class
3253 else:
3254 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003255
3256 def get_queryset(self):
3257 return SiteDeployments.select_by_user(self.request.user)
3258
3259 def update(self, request, *args, **kwargs):
3260 obj = self.get_object()
3261 if obj.can_update(request.user):
3262 return super(SiteDeploymentsDetail, self).update(request, *args, **kwargs)
3263 else:
3264 return Response(status=status.HTTP_400_BAD_REQUEST)
3265
3266 def destroy(self, request, *args, **kwargs):
3267 obj = self.get_object()
3268 if obj.can_update(request.user):
3269 return super(SiteDeploymentsDetail, self).destroy(request, *args, **kwargs)
3270 else:
3271 return Response(status=status.HTTP_400_BAD_REQUEST)
3272
Sapan Bhatiadea39432014-06-13 03:10:36 -04003273
3274
3275
Scott Baker0caeaf02014-06-19 11:12:55 -07003276class DeploymentPrivilegeList(generics.ListCreateAPIView):
3277 queryset = DeploymentPrivilege.objects.select_related().all()
3278 serializer_class = DeploymentPrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003279 id_serializer_class = DeploymentPrivilegeIdSerializer
3280 filter_backends = (filters.DjangoFilterBackend,)
3281 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
3282
3283 def get_serializer_class(self):
3284 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3285 if (no_hyperlinks):
3286 return self.id_serializer_class
3287 else:
3288 return self.serializer_class
3289
Scott Baker0caeaf02014-06-19 11:12:55 -07003290 def get_queryset(self):
3291 return DeploymentPrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003292
Scott Baker0caeaf02014-06-19 11:12:55 -07003293 def create(self, request, *args, **kwargs):
3294 #obj = DeploymentPrivilege().update(request.DATA)
3295 obj = self.get_object()
3296 obj.caller = request.user
3297 if obj.can_update(request.user):
3298 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
3299 else:
3300 return Response(status=status.HTTP_400_BAD_REQUEST)
3301
3302class DeploymentPrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
3303 queryset = DeploymentPrivilege.objects.select_related().all()
3304 serializer_class = DeploymentPrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003305 id_serializer_class = DeploymentPrivilegeIdSerializer
3306
3307 def get_serializer_class(self):
3308 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3309 if (no_hyperlinks):
3310 return self.id_serializer_class
3311 else:
3312 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003313
3314 def get_queryset(self):
3315 return DeploymentPrivilege.select_by_user(self.request.user)
3316
3317 def update(self, request, *args, **kwargs):
3318 obj = self.get_object()
3319 if obj.can_update(request.user):
3320 return super(DeploymentPrivilegeDetail, self).update(request, *args, **kwargs)
3321 else:
3322 return Response(status=status.HTTP_400_BAD_REQUEST)
3323
3324 def destroy(self, request, *args, **kwargs):
3325 obj = self.get_object()
3326 if obj.can_update(request.user):
3327 return super(DeploymentPrivilegeDetail, self).destroy(request, *args, **kwargs)
3328 else:
3329 return Response(status=status.HTTP_400_BAD_REQUEST)
3330
Sapan Bhatiadea39432014-06-13 03:10:36 -04003331
3332
3333
Scott Baker0caeaf02014-06-19 11:12:55 -07003334class DeploymentRoleList(generics.ListCreateAPIView):
3335 queryset = DeploymentRole.objects.select_related().all()
3336 serializer_class = DeploymentRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003337 id_serializer_class = DeploymentRoleIdSerializer
3338 filter_backends = (filters.DjangoFilterBackend,)
3339 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3340
3341 def get_serializer_class(self):
3342 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3343 if (no_hyperlinks):
3344 return self.id_serializer_class
3345 else:
3346 return self.serializer_class
3347
Scott Baker0caeaf02014-06-19 11:12:55 -07003348 def get_queryset(self):
3349 return DeploymentRole.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003350
Scott Baker0caeaf02014-06-19 11:12:55 -07003351 def create(self, request, *args, **kwargs):
3352 #obj = DeploymentRole().update(request.DATA)
3353 obj = self.get_object()
3354 obj.caller = request.user
3355 if obj.can_update(request.user):
3356 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
3357 else:
3358 return Response(status=status.HTTP_400_BAD_REQUEST)
3359
3360class DeploymentRoleDetail(generics.RetrieveUpdateDestroyAPIView):
3361 queryset = DeploymentRole.objects.select_related().all()
3362 serializer_class = DeploymentRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003363 id_serializer_class = DeploymentRoleIdSerializer
3364
3365 def get_serializer_class(self):
3366 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3367 if (no_hyperlinks):
3368 return self.id_serializer_class
3369 else:
3370 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003371
3372 def get_queryset(self):
3373 return DeploymentRole.select_by_user(self.request.user)
3374
3375 def update(self, request, *args, **kwargs):
3376 obj = self.get_object()
3377 if obj.can_update(request.user):
3378 return super(DeploymentRoleDetail, self).update(request, *args, **kwargs)
3379 else:
3380 return Response(status=status.HTTP_400_BAD_REQUEST)
3381
3382 def destroy(self, request, *args, **kwargs):
3383 obj = self.get_object()
3384 if obj.can_update(request.user):
3385 return super(DeploymentRoleDetail, self).destroy(request, *args, **kwargs)
3386 else:
3387 return Response(status=status.HTTP_400_BAD_REQUEST)
3388
Sapan Bhatiadea39432014-06-13 03:10:36 -04003389
3390
3391
Scott Baker0caeaf02014-06-19 11:12:55 -07003392class ProjectList(generics.ListCreateAPIView):
3393 queryset = Project.objects.select_related().all()
3394 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003395 id_serializer_class = ProjectIdSerializer
3396 filter_backends = (filters.DjangoFilterBackend,)
3397 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3398
3399 def get_serializer_class(self):
3400 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3401 if (no_hyperlinks):
3402 return self.id_serializer_class
3403 else:
3404 return self.serializer_class
3405
Scott Baker0caeaf02014-06-19 11:12:55 -07003406 def get_queryset(self):
3407 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003408
Scott Baker0caeaf02014-06-19 11:12:55 -07003409 def create(self, request, *args, **kwargs):
3410 #obj = Project().update(request.DATA)
3411 obj = self.get_object()
3412 obj.caller = request.user
3413 if obj.can_update(request.user):
3414 return super(ProjectList, self).create(request, *args, **kwargs)
3415 else:
3416 return Response(status=status.HTTP_400_BAD_REQUEST)
3417
3418class ProjectDetail(generics.RetrieveUpdateDestroyAPIView):
3419 queryset = Project.objects.select_related().all()
3420 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003421 id_serializer_class = ProjectIdSerializer
3422
3423 def get_serializer_class(self):
3424 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3425 if (no_hyperlinks):
3426 return self.id_serializer_class
3427 else:
3428 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003429
3430 def get_queryset(self):
3431 return Project.select_by_user(self.request.user)
3432
3433 def update(self, request, *args, **kwargs):
3434 obj = self.get_object()
3435 if obj.can_update(request.user):
3436 return super(ProjectDetail, self).update(request, *args, **kwargs)
3437 else:
3438 return Response(status=status.HTTP_400_BAD_REQUEST)
3439
3440 def destroy(self, request, *args, **kwargs):
3441 obj = self.get_object()
3442 if obj.can_update(request.user):
3443 return super(ProjectDetail, self).destroy(request, *args, **kwargs)
3444 else:
3445 return Response(status=status.HTTP_400_BAD_REQUEST)
3446
Sapan Bhatiadea39432014-06-13 03:10:36 -04003447
3448
3449
Scott Baker0caeaf02014-06-19 11:12:55 -07003450class SliceTagList(generics.ListCreateAPIView):
3451 queryset = SliceTag.objects.select_related().all()
3452 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003453 id_serializer_class = SliceTagIdSerializer
3454 filter_backends = (filters.DjangoFilterBackend,)
3455 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
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
Scott Baker0caeaf02014-06-19 11:12:55 -07003464 def get_queryset(self):
3465 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003466
Scott Baker0caeaf02014-06-19 11:12:55 -07003467 def create(self, request, *args, **kwargs):
3468 #obj = SliceTag().update(request.DATA)
3469 obj = self.get_object()
3470 obj.caller = request.user
3471 if obj.can_update(request.user):
3472 return super(SliceTagList, self).create(request, *args, **kwargs)
3473 else:
3474 return Response(status=status.HTTP_400_BAD_REQUEST)
3475
3476class SliceTagDetail(generics.RetrieveUpdateDestroyAPIView):
3477 queryset = SliceTag.objects.select_related().all()
3478 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003479 id_serializer_class = SliceTagIdSerializer
3480
3481 def get_serializer_class(self):
3482 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3483 if (no_hyperlinks):
3484 return self.id_serializer_class
3485 else:
3486 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003487
3488 def get_queryset(self):
3489 return SliceTag.select_by_user(self.request.user)
3490
3491 def update(self, request, *args, **kwargs):
3492 obj = self.get_object()
3493 if obj.can_update(request.user):
3494 return super(SliceTagDetail, self).update(request, *args, **kwargs)
3495 else:
3496 return Response(status=status.HTTP_400_BAD_REQUEST)
3497
3498 def destroy(self, request, *args, **kwargs):
3499 obj = self.get_object()
3500 if obj.can_update(request.user):
3501 return super(SliceTagDetail, self).destroy(request, *args, **kwargs)
3502 else:
3503 return Response(status=status.HTTP_400_BAD_REQUEST)
3504
Sapan Bhatiadea39432014-06-13 03:10:36 -04003505
3506
3507
Scott Baker0caeaf02014-06-19 11:12:55 -07003508class NetworkTemplateList(generics.ListCreateAPIView):
3509 queryset = NetworkTemplate.objects.select_related().all()
3510 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003511 id_serializer_class = NetworkTemplateIdSerializer
3512 filter_backends = (filters.DjangoFilterBackend,)
3513 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
3514
3515 def get_serializer_class(self):
3516 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3517 if (no_hyperlinks):
3518 return self.id_serializer_class
3519 else:
3520 return self.serializer_class
3521
Scott Baker0caeaf02014-06-19 11:12:55 -07003522 def get_queryset(self):
3523 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003524
Scott Baker0caeaf02014-06-19 11:12:55 -07003525 def create(self, request, *args, **kwargs):
3526 #obj = NetworkTemplate().update(request.DATA)
3527 obj = self.get_object()
3528 obj.caller = request.user
3529 if obj.can_update(request.user):
3530 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
3531 else:
3532 return Response(status=status.HTTP_400_BAD_REQUEST)
3533
3534class NetworkTemplateDetail(generics.RetrieveUpdateDestroyAPIView):
3535 queryset = NetworkTemplate.objects.select_related().all()
3536 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003537 id_serializer_class = NetworkTemplateIdSerializer
3538
3539 def get_serializer_class(self):
3540 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3541 if (no_hyperlinks):
3542 return self.id_serializer_class
3543 else:
3544 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003545
3546 def get_queryset(self):
3547 return NetworkTemplate.select_by_user(self.request.user)
3548
3549 def update(self, request, *args, **kwargs):
3550 obj = self.get_object()
3551 if obj.can_update(request.user):
3552 return super(NetworkTemplateDetail, self).update(request, *args, **kwargs)
3553 else:
3554 return Response(status=status.HTTP_400_BAD_REQUEST)
3555
3556 def destroy(self, request, *args, **kwargs):
3557 obj = self.get_object()
3558 if obj.can_update(request.user):
3559 return super(NetworkTemplateDetail, self).destroy(request, *args, **kwargs)
3560 else:
3561 return Response(status=status.HTTP_400_BAD_REQUEST)
3562
Sapan Bhatiadea39432014-06-13 03:10:36 -04003563
3564
3565
3566class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003567 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003568 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003569 id_serializer_class = RouterIdSerializer
3570 filter_backends = (filters.DjangoFilterBackend,)
3571 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
3572
3573 def get_serializer_class(self):
3574 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3575 if (no_hyperlinks):
3576 return self.id_serializer_class
3577 else:
3578 return self.serializer_class
3579
Scott Baker0caeaf02014-06-19 11:12:55 -07003580 def get_queryset(self):
3581 return Router.select_by_user(self.request.user)
3582
3583 def create(self, request, *args, **kwargs):
3584 #obj = Router().update(request.DATA)
3585 obj = self.get_object()
3586 obj.caller = request.user
3587 if obj.can_update(request.user):
3588 return super(RouterList, self).create(request, *args, **kwargs)
3589 else:
3590 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003591
3592class RouterDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003593 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003594 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003595 id_serializer_class = RouterIdSerializer
3596
3597 def get_serializer_class(self):
3598 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3599 if (no_hyperlinks):
3600 return self.id_serializer_class
3601 else:
3602 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003603
3604 def get_queryset(self):
3605 return Router.select_by_user(self.request.user)
3606
3607 def update(self, request, *args, **kwargs):
3608 obj = self.get_object()
3609 if obj.can_update(request.user):
3610 return super(RouterDetail, self).update(request, *args, **kwargs)
3611 else:
3612 return Response(status=status.HTTP_400_BAD_REQUEST)
3613
3614 def destroy(self, request, *args, **kwargs):
3615 obj = self.get_object()
3616 if obj.can_update(request.user):
3617 return super(RouterDetail, self).destroy(request, *args, **kwargs)
3618 else:
3619 return Response(status=status.HTTP_400_BAD_REQUEST)
3620
Sapan Bhatiadea39432014-06-13 03:10:36 -04003621
3622
3623
Scott Baker0caeaf02014-06-19 11:12:55 -07003624class ServiceResourceList(generics.ListCreateAPIView):
3625 queryset = ServiceResource.objects.select_related().all()
3626 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003627 id_serializer_class = ServiceResourceIdSerializer
3628 filter_backends = (filters.DjangoFilterBackend,)
3629 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
3630
3631 def get_serializer_class(self):
3632 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3633 if (no_hyperlinks):
3634 return self.id_serializer_class
3635 else:
3636 return self.serializer_class
3637
Scott Baker0caeaf02014-06-19 11:12:55 -07003638 def get_queryset(self):
3639 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003640
Scott Baker0caeaf02014-06-19 11:12:55 -07003641 def create(self, request, *args, **kwargs):
3642 #obj = ServiceResource().update(request.DATA)
3643 obj = self.get_object()
3644 obj.caller = request.user
3645 if obj.can_update(request.user):
3646 return super(ServiceResourceList, self).create(request, *args, **kwargs)
3647 else:
3648 return Response(status=status.HTTP_400_BAD_REQUEST)
3649
3650class ServiceResourceDetail(generics.RetrieveUpdateDestroyAPIView):
3651 queryset = ServiceResource.objects.select_related().all()
3652 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003653 id_serializer_class = ServiceResourceIdSerializer
3654
3655 def get_serializer_class(self):
3656 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3657 if (no_hyperlinks):
3658 return self.id_serializer_class
3659 else:
3660 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003661
3662 def get_queryset(self):
3663 return ServiceResource.select_by_user(self.request.user)
3664
3665 def update(self, request, *args, **kwargs):
3666 obj = self.get_object()
3667 if obj.can_update(request.user):
3668 return super(ServiceResourceDetail, self).update(request, *args, **kwargs)
3669 else:
3670 return Response(status=status.HTTP_400_BAD_REQUEST)
3671
3672 def destroy(self, request, *args, **kwargs):
3673 obj = self.get_object()
3674 if obj.can_update(request.user):
3675 return super(ServiceResourceDetail, self).destroy(request, *args, **kwargs)
3676 else:
3677 return Response(status=status.HTTP_400_BAD_REQUEST)
3678
Sapan Bhatiadea39432014-06-13 03:10:36 -04003679
3680
3681