blob: d633b2d5b09c85af6eebbd1693e19629b34cbdd9 [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Baker89a7b7c2014-10-07 00:10:17 -07006from rest_framework import status
Sapan Bhatiadea39432014-06-13 03:10:36 -04007from core.models import *
8from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -07009from rest_framework import filters
Sapan Bhatiadea39432014-06-13 03:10:36 -040010
11"""
12 Schema of the generator object:
13 all: Set of all Model objects
14 all_if(regex): Set of Model objects that match regex
15
16 Model object:
17 plural: English plural of object name
18 camel: CamelCase version of object name
19 refs: list of references to other Model objects
20 props: list of properties minus refs
21
22 TODO: Deal with subnets
23"""
24
25# Based on api_root.py
26
27@api_view(['GET'])
28def api_root(request, format=None):
29 return Response({
30 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
31 'images': reverse('image-list', request=request, format=format),
32 'networkparameters': reverse('networkparameter-list', request=request, format=format),
33 'sites': reverse('site-list', request=request, format=format),
34 'sliceroles': reverse('slicerole-list', request=request, format=format),
35 'tags': reverse('tag-list', request=request, format=format),
36 'invoices': reverse('invoice-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070037 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
Scott Baker89a7b7c2014-10-07 00:10:17 -070038 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040039 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070040 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format),
Scott Baker89a7b7c2014-10-07 00:10:17 -070041 'flavors': reverse('flavor-list', request=request, format=format),
42 'projects': reverse('project-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040043 'slices': reverse('slice-list', request=request, format=format),
44 'networks': reverse('network-list', request=request, format=format),
45 'services': reverse('service-list', request=request, format=format),
46 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070047 'payments': reverse('payment-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040048 'charges': reverse('charge-list', request=request, format=format),
49 'roles': reverse('role-list', request=request, format=format),
50 'usableobjects': reverse('usableobject-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070051 'siteroles': reverse('siterole-list', request=request, format=format),
Scott Baker89a7b7c2014-10-07 00:10:17 -070052 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040053 'slivers': reverse('sliver-list', request=request, format=format),
54 'nodes': reverse('node-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070055 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
56 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040057 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040058 'networkslices': reverse('networkslice-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070059 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040060 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
61 'users': reverse('user-list', request=request, format=format),
62 'deployments': reverse('deployment-list', request=request, format=format),
63 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070064 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040065 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040066 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070067 'userdeploymentses': reverse('userdeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040068 'accounts': reverse('account-list', request=request, format=format),
69 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
Scott Baker89a7b7c2014-10-07 00:10:17 -070070 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040071 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
72 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker89a7b7c2014-10-07 00:10:17 -070073 'usercredentials': reverse('usercredential-list', request=request, format=format),
74 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040075 'slicetags': reverse('slicetag-list', request=request, format=format),
76 'networktemplates': reverse('networktemplate-list', request=request, format=format),
77 'routers': reverse('router-list', request=request, format=format),
78 'serviceresources': reverse('serviceresource-list', request=request, format=format),
79
80 })
81
82# Based on serializers.py
83
84
85
Scott Baker0caeaf02014-06-19 11:12:55 -070086class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -040087 id = serializers.Field()
88
Sapan Bhatiadea39432014-06-13 03:10:36 -040089 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -070090 model = ServiceAttribute
Scott Baker46b58542014-08-11 17:26:12 -070091 fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
92
93class ServiceAttributeIdSerializer(serializers.ModelSerializer):
94 id = serializers.Field()
95
96 class Meta:
97 model = ServiceAttribute
98 fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
99
100
Sapan Bhatiadea39432014-06-13 03:10:36 -0400101
102
103class ImageSerializer(serializers.HyperlinkedModelSerializer):
104 id = serializers.Field()
105
106 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700107 model = Image
Scott Baker46b58542014-08-11 17:26:12 -0700108 fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
109
110class ImageIdSerializer(serializers.ModelSerializer):
111 id = serializers.Field()
112
113 class Meta:
114 model = Image
115 fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
116
117
Sapan Bhatiadea39432014-06-13 03:10:36 -0400118
119
Scott Baker0caeaf02014-06-19 11:12:55 -0700120class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400121 id = serializers.Field()
122
123 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700124 model = NetworkParameter
Scott Baker46b58542014-08-11 17:26:12 -0700125 fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
126
127class NetworkParameterIdSerializer(serializers.ModelSerializer):
128 id = serializers.Field()
129
130 class Meta:
131 model = NetworkParameter
132 fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
133
134
Sapan Bhatiadea39432014-06-13 03:10:36 -0400135
136
137class SiteSerializer(serializers.HyperlinkedModelSerializer):
138 id = serializers.Field()
139
140 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700141 model = Site
Scott Baker46b58542014-08-11 17:26:12 -0700142 fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
143
144class SiteIdSerializer(serializers.ModelSerializer):
145 id = serializers.Field()
146
147 class Meta:
148 model = Site
149 fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
150
151
Sapan Bhatiadea39432014-06-13 03:10:36 -0400152
153
Scott Baker0caeaf02014-06-19 11:12:55 -0700154class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400155 id = serializers.Field()
156
157 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700158 model = SliceRole
Scott Baker46b58542014-08-11 17:26:12 -0700159 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
160
161class SliceRoleIdSerializer(serializers.ModelSerializer):
162 id = serializers.Field()
163
164 class Meta:
165 model = SliceRole
166 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
167
168
Sapan Bhatiadea39432014-06-13 03:10:36 -0400169
170
171class TagSerializer(serializers.HyperlinkedModelSerializer):
172 id = serializers.Field()
173
Sapan Bhatiadea39432014-06-13 03:10:36 -0400174 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700175 model = Tag
Scott Baker89a7b7c2014-10-07 00:10:17 -0700176 fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700177
178class TagIdSerializer(serializers.ModelSerializer):
179 id = serializers.Field()
180
Scott Baker46b58542014-08-11 17:26:12 -0700181 class Meta:
182 model = Tag
Scott Baker89a7b7c2014-10-07 00:10:17 -0700183 fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700184
185
Sapan Bhatiadea39432014-06-13 03:10:36 -0400186
187
188class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
189 id = serializers.Field()
190
Sapan Bhatiadea39432014-06-13 03:10:36 -0400191 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700192 model = Invoice
Scott Baker46b58542014-08-11 17:26:12 -0700193 fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
194
195class InvoiceIdSerializer(serializers.ModelSerializer):
196 id = serializers.Field()
197
198 class Meta:
199 model = Invoice
200 fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
201
202
Sapan Bhatiadea39432014-06-13 03:10:36 -0400203
204
Scott Baker0caeaf02014-06-19 11:12:55 -0700205class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400206 id = serializers.Field()
207
208 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700209 model = SlicePrivilege
Scott Baker46b58542014-08-11 17:26:12 -0700210 fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
211
212class SlicePrivilegeIdSerializer(serializers.ModelSerializer):
213 id = serializers.Field()
214
215 class Meta:
216 model = SlicePrivilege
217 fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
218
219
Scott Baker0caeaf02014-06-19 11:12:55 -0700220
221
Scott Baker89a7b7c2014-10-07 00:10:17 -0700222class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
223 id = serializers.Field()
224
225 class Meta:
226 model = PlanetStackRole
227 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
228
229class PlanetStackRoleIdSerializer(serializers.ModelSerializer):
230 id = serializers.Field()
231
232 class Meta:
233 model = PlanetStackRole
234 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
235
236
237
238
Scott Baker0caeaf02014-06-19 11:12:55 -0700239class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
240 id = serializers.Field()
241
242 class Meta:
243 model = NetworkSliver
Scott Baker46b58542014-08-11 17:26:12 -0700244 fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
245
246class NetworkSliverIdSerializer(serializers.ModelSerializer):
247 id = serializers.Field()
248
249 class Meta:
250 model = NetworkSliver
251 fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
252
253
Scott Baker0caeaf02014-06-19 11:12:55 -0700254
255
256class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
257 id = serializers.Field()
258
259 class Meta:
260 model = NetworkDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700261 fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
262
263class NetworkDeploymentsIdSerializer(serializers.ModelSerializer):
264 id = serializers.Field()
265
266 class Meta:
267 model = NetworkDeployments
268 fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
269
270
Sapan Bhatiadea39432014-06-13 03:10:36 -0400271
272
Scott Baker89a7b7c2014-10-07 00:10:17 -0700273class FlavorSerializer(serializers.HyperlinkedModelSerializer):
274 id = serializers.Field()
275
276 class Meta:
277 model = Flavor
278 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
279
280class FlavorIdSerializer(serializers.ModelSerializer):
281 id = serializers.Field()
282
283 class Meta:
284 model = Flavor
285 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
286
287
288
289
290class ProjectSerializer(serializers.HyperlinkedModelSerializer):
291 id = serializers.Field()
292
293 class Meta:
294 model = Project
295 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
296
297class ProjectIdSerializer(serializers.ModelSerializer):
298 id = serializers.Field()
299
300 class Meta:
301 model = Project
302 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
303
304
305
306
Sapan Bhatiadea39432014-06-13 03:10:36 -0400307class SliceSerializer(serializers.HyperlinkedModelSerializer):
308 id = serializers.Field()
309
Sapan Bhatiadea39432014-06-13 03:10:36 -0400310
Scott Baker0caeaf02014-06-19 11:12:55 -0700311 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
312
313
314
315 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
316
317
318
319 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
320
321
322
323 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
324
Sapan Bhatiadea39432014-06-13 03:10:36 -0400325
326 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700327 model = Slice
Scott Baker46b58542014-08-11 17:26:12 -0700328 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',)
329
330class SliceIdSerializer(serializers.ModelSerializer):
331 id = serializers.Field()
332
333
334 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
335
336
337
338 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
339
340
341
342 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
343
344
345
346 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
347
348
349 class Meta:
350 model = Slice
351 fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
352
353
Sapan Bhatiadea39432014-06-13 03:10:36 -0400354
355
356class NetworkSerializer(serializers.HyperlinkedModelSerializer):
357 id = serializers.Field()
358
Scott Baker0caeaf02014-06-19 11:12:55 -0700359
360 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
361
362
363
364 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
365
366
367
368 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
369
370
371
372 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
373
374
Sapan Bhatiadea39432014-06-13 03:10:36 -0400375 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700376 model = Network
Scott Baker46b58542014-08-11 17:26:12 -0700377 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',)
378
379class NetworkIdSerializer(serializers.ModelSerializer):
380 id = serializers.Field()
381
382
383 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
384
385
386
387 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
388
389
390
391 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
392
393
394
395 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
396
397
398 class Meta:
399 model = Network
400 fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
401
402
Sapan Bhatiadea39432014-06-13 03:10:36 -0400403
404
405class ServiceSerializer(serializers.HyperlinkedModelSerializer):
406 id = serializers.Field()
407
408 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700409 model = Service
Scott Baker46b58542014-08-11 17:26:12 -0700410 fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
411
412class ServiceIdSerializer(serializers.ModelSerializer):
413 id = serializers.Field()
414
415 class Meta:
416 model = Service
417 fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
418
419
Sapan Bhatiadea39432014-06-13 03:10:36 -0400420
421
Scott Baker0caeaf02014-06-19 11:12:55 -0700422class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400423 id = serializers.Field()
424
425 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700426 model = ServiceClass
Scott Baker46b58542014-08-11 17:26:12 -0700427 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
428
429class ServiceClassIdSerializer(serializers.ModelSerializer):
430 id = serializers.Field()
431
432 class Meta:
433 model = ServiceClass
434 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
435
436
Sapan Bhatiadea39432014-06-13 03:10:36 -0400437
438
Scott Baker0caeaf02014-06-19 11:12:55 -0700439class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400440 id = serializers.Field()
441
442 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700443 model = Payment
Scott Baker46b58542014-08-11 17:26:12 -0700444 fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
445
446class PaymentIdSerializer(serializers.ModelSerializer):
447 id = serializers.Field()
448
449 class Meta:
450 model = Payment
451 fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
452
453
Sapan Bhatiadea39432014-06-13 03:10:36 -0400454
455
456class ChargeSerializer(serializers.HyperlinkedModelSerializer):
457 id = serializers.Field()
458
Sapan Bhatiadea39432014-06-13 03:10:36 -0400459 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700460 model = Charge
Scott Baker46b58542014-08-11 17:26:12 -0700461 fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
462
463class ChargeIdSerializer(serializers.ModelSerializer):
464 id = serializers.Field()
465
466 class Meta:
467 model = Charge
468 fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
469
470
Sapan Bhatiadea39432014-06-13 03:10:36 -0400471
472
473class RoleSerializer(serializers.HyperlinkedModelSerializer):
474 id = serializers.Field()
475
476 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700477 model = Role
Scott Baker46b58542014-08-11 17:26:12 -0700478 fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
479
480class RoleIdSerializer(serializers.ModelSerializer):
481 id = serializers.Field()
482
483 class Meta:
484 model = Role
485 fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
486
487
Sapan Bhatiadea39432014-06-13 03:10:36 -0400488
489
Scott Baker0caeaf02014-06-19 11:12:55 -0700490class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400491 id = serializers.Field()
492
493 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700494 model = UsableObject
Scott Baker46b58542014-08-11 17:26:12 -0700495 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
496
497class UsableObjectIdSerializer(serializers.ModelSerializer):
498 id = serializers.Field()
499
500 class Meta:
501 model = UsableObject
502 fields = ('id','created','updated','enacted','backend_status','deleted','name',)
503
504
Sapan Bhatiadea39432014-06-13 03:10:36 -0400505
506
Scott Baker0caeaf02014-06-19 11:12:55 -0700507class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
508 id = serializers.Field()
509
510 class Meta:
511 model = SiteRole
Scott Baker46b58542014-08-11 17:26:12 -0700512 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
513
514class SiteRoleIdSerializer(serializers.ModelSerializer):
515 id = serializers.Field()
516
517 class Meta:
518 model = SiteRole
519 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
520
521
Scott Baker0caeaf02014-06-19 11:12:55 -0700522
523
Scott Baker89a7b7c2014-10-07 00:10:17 -0700524class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
525 id = serializers.Field()
526
527 class Meta:
528 model = SliceCredential
529 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
530
531class SliceCredentialIdSerializer(serializers.ModelSerializer):
532 id = serializers.Field()
533
534 class Meta:
535 model = SliceCredential
536 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
537
538
539
540
Sapan Bhatiadea39432014-06-13 03:10:36 -0400541class SliverSerializer(serializers.HyperlinkedModelSerializer):
542 id = serializers.Field()
543
Sapan Bhatiadea39432014-06-13 03:10:36 -0400544
Scott Baker0caeaf02014-06-19 11:12:55 -0700545 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
Sapan Bhatiadea39432014-06-13 03:10:36 -0400546
Scott Baker0caeaf02014-06-19 11:12:55 -0700547
548
549 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
550
551
Scott Baker46b58542014-08-11 17:26:12 -0700552 class Meta:
553 model = Sliver
Scott Baker89a7b7c2014-10-07 00:10:17 -0700554 fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700555
556class SliverIdSerializer(serializers.ModelSerializer):
557 id = serializers.Field()
Scott Baker0caeaf02014-06-19 11:12:55 -0700558
Scott Baker46b58542014-08-11 17:26:12 -0700559
560 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
561
562
563
564 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
Scott Baker0caeaf02014-06-19 11:12:55 -0700565
Sapan Bhatiadea39432014-06-13 03:10:36 -0400566
567 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700568 model = Sliver
Scott Baker89a7b7c2014-10-07 00:10:17 -0700569 fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700570
571
Sapan Bhatiadea39432014-06-13 03:10:36 -0400572
573
574class NodeSerializer(serializers.HyperlinkedModelSerializer):
575 id = serializers.Field()
576
Sapan Bhatiadea39432014-06-13 03:10:36 -0400577 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700578 model = Node
Scott Baker46b58542014-08-11 17:26:12 -0700579 fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
580
581class NodeIdSerializer(serializers.ModelSerializer):
582 id = serializers.Field()
583
584 class Meta:
585 model = Node
586 fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
587
588
Sapan Bhatiadea39432014-06-13 03:10:36 -0400589
590
Scott Baker0caeaf02014-06-19 11:12:55 -0700591class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400592 id = serializers.Field()
593
Sapan Bhatiadea39432014-06-13 03:10:36 -0400594 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700595 model = DashboardView
Scott Baker46b58542014-08-11 17:26:12 -0700596 fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
597
598class DashboardViewIdSerializer(serializers.ModelSerializer):
599 id = serializers.Field()
600
601 class Meta:
602 model = DashboardView
603 fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
604
605
Sapan Bhatiadea39432014-06-13 03:10:36 -0400606
607
Scott Baker0caeaf02014-06-19 11:12:55 -0700608class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400609 id = serializers.Field()
610
Sapan Bhatiadea39432014-06-13 03:10:36 -0400611 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700612 model = ImageDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700613 fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
614
615class ImageDeploymentsIdSerializer(serializers.ModelSerializer):
616 id = serializers.Field()
617
618 class Meta:
619 model = ImageDeployments
620 fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
621
622
Sapan Bhatiadea39432014-06-13 03:10:36 -0400623
624
Scott Baker0caeaf02014-06-19 11:12:55 -0700625class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400626 id = serializers.Field()
627
Sapan Bhatiadea39432014-06-13 03:10:36 -0400628 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700629 model = ReservedResource
Scott Baker46b58542014-08-11 17:26:12 -0700630 fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
631
632class ReservedResourceIdSerializer(serializers.ModelSerializer):
633 id = serializers.Field()
634
635 class Meta:
636 model = ReservedResource
637 fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
638
639
Sapan Bhatiadea39432014-06-13 03:10:36 -0400640
641
Scott Baker0caeaf02014-06-19 11:12:55 -0700642class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400643 id = serializers.Field()
644
Scott Baker0caeaf02014-06-19 11:12:55 -0700645 class Meta:
646 model = NetworkSlice
Scott Baker46b58542014-08-11 17:26:12 -0700647 fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
648
649class NetworkSliceIdSerializer(serializers.ModelSerializer):
650 id = serializers.Field()
651
652 class Meta:
653 model = NetworkSlice
654 fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
655
656
Scott Baker0caeaf02014-06-19 11:12:55 -0700657
658
659class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
660 id = serializers.Field()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400661
662 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700663 model = UserDashboardView
Scott Baker46b58542014-08-11 17:26:12 -0700664 fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
665
666class UserDashboardViewIdSerializer(serializers.ModelSerializer):
667 id = serializers.Field()
668
669 class Meta:
670 model = UserDashboardView
671 fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
672
673
Scott Baker0caeaf02014-06-19 11:12:55 -0700674
675
676class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
677 id = serializers.Field()
678
679 class Meta:
680 model = PlanetStackPrivilege
Scott Baker46b58542014-08-11 17:26:12 -0700681 fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
682
683class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer):
684 id = serializers.Field()
685
686 class Meta:
687 model = PlanetStackPrivilege
688 fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
689
690
Sapan Bhatiadea39432014-06-13 03:10:36 -0400691
692
693class UserSerializer(serializers.HyperlinkedModelSerializer):
694 id = serializers.Field()
695
Sapan Bhatiadea39432014-06-13 03:10:36 -0400696 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700697 model = User
Scott Baker46b58542014-08-11 17:26:12 -0700698 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',)
699
700class UserIdSerializer(serializers.ModelSerializer):
701 id = serializers.Field()
702
703 class Meta:
704 model = User
705 fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
706
707
Sapan Bhatiadea39432014-06-13 03:10:36 -0400708
709
710class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
711 id = serializers.Field()
712
Scott Baker0caeaf02014-06-19 11:12:55 -0700713
714 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
715
716
717
718 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
719
720
Scott Baker89a7b7c2014-10-07 00:10:17 -0700721
722 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
723
724
725
726 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
727
728
Sapan Bhatiadea39432014-06-13 03:10:36 -0400729 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700730 model = Deployment
Scott Baker89a7b7c2014-10-07 00:10:17 -0700731 fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -0700732
733class DeploymentIdSerializer(serializers.ModelSerializer):
734 id = serializers.Field()
735
736
737 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
738
739
740
741 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
742
743
Scott Baker89a7b7c2014-10-07 00:10:17 -0700744
745 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
746
747
748
749 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
750
751
Scott Baker46b58542014-08-11 17:26:12 -0700752 class Meta:
753 model = Deployment
Scott Baker89a7b7c2014-10-07 00:10:17 -0700754 fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -0700755
756
Sapan Bhatiadea39432014-06-13 03:10:36 -0400757
758
759class ReservationSerializer(serializers.HyperlinkedModelSerializer):
760 id = serializers.Field()
761
Sapan Bhatiadea39432014-06-13 03:10:36 -0400762 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700763 model = Reservation
Scott Baker46b58542014-08-11 17:26:12 -0700764 fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
765
766class ReservationIdSerializer(serializers.ModelSerializer):
767 id = serializers.Field()
768
769 class Meta:
770 model = Reservation
771 fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
772
773
Sapan Bhatiadea39432014-06-13 03:10:36 -0400774
775
Scott Baker0caeaf02014-06-19 11:12:55 -0700776class SliceDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400777 id = serializers.Field()
778
779 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700780 model = SliceDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700781 fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
782
783class SliceDeploymentsIdSerializer(serializers.ModelSerializer):
784 id = serializers.Field()
785
786 class Meta:
787 model = SliceDeployments
788 fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
789
790
Sapan Bhatiadea39432014-06-13 03:10:36 -0400791
792
Scott Baker0caeaf02014-06-19 11:12:55 -0700793class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400794 id = serializers.Field()
795
796 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700797 model = SitePrivilege
Scott Baker46b58542014-08-11 17:26:12 -0700798 fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
799
800class SitePrivilegeIdSerializer(serializers.ModelSerializer):
801 id = serializers.Field()
802
803 class Meta:
804 model = SitePrivilege
805 fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
806
807
Scott Baker0caeaf02014-06-19 11:12:55 -0700808
809
810class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
811 id = serializers.Field()
812
813 class Meta:
814 model = PlanetStack
Scott Baker46b58542014-08-11 17:26:12 -0700815 fields = ('id','created','updated','enacted','backend_status','deleted','description',)
816
817class PlanetStackIdSerializer(serializers.ModelSerializer):
818 id = serializers.Field()
819
820 class Meta:
821 model = PlanetStack
822 fields = ('id','created','updated','enacted','backend_status','deleted','description',)
823
824
Sapan Bhatiadea39432014-06-13 03:10:36 -0400825
826
Scott Baker0caeaf02014-06-19 11:12:55 -0700827class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
828 id = serializers.Field()
829
830 class Meta:
831 model = UserDeployments
Scott Baker46b58542014-08-11 17:26:12 -0700832 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
833
834class UserDeploymentsIdSerializer(serializers.ModelSerializer):
835 id = serializers.Field()
836
837 class Meta:
838 model = UserDeployments
839 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
840
841
Scott Baker0caeaf02014-06-19 11:12:55 -0700842
843
Sapan Bhatiadea39432014-06-13 03:10:36 -0400844class AccountSerializer(serializers.HyperlinkedModelSerializer):
845 id = serializers.Field()
846
Sapan Bhatiadea39432014-06-13 03:10:36 -0400847 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700848 model = Account
Scott Baker46b58542014-08-11 17:26:12 -0700849 fields = ('id','created','updated','enacted','backend_status','deleted','site',)
850
851class AccountIdSerializer(serializers.ModelSerializer):
852 id = serializers.Field()
853
854 class Meta:
855 model = Account
856 fields = ('id','created','updated','enacted','backend_status','deleted','site',)
857
858
Sapan Bhatiadea39432014-06-13 03:10:36 -0400859
860
Scott Baker0caeaf02014-06-19 11:12:55 -0700861class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400862 id = serializers.Field()
863
864 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700865 model = NetworkParameterType
Scott Baker46b58542014-08-11 17:26:12 -0700866 fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
867
868class NetworkParameterTypeIdSerializer(serializers.ModelSerializer):
869 id = serializers.Field()
870
871 class Meta:
872 model = NetworkParameterType
873 fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
874
875
Sapan Bhatiadea39432014-06-13 03:10:36 -0400876
877
Scott Baker89a7b7c2014-10-07 00:10:17 -0700878class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400879 id = serializers.Field()
880
881 class Meta:
Scott Baker89a7b7c2014-10-07 00:10:17 -0700882 model = SiteCredential
883 fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -0700884
Scott Baker89a7b7c2014-10-07 00:10:17 -0700885class SiteCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker46b58542014-08-11 17:26:12 -0700886 id = serializers.Field()
887
888 class Meta:
Scott Baker89a7b7c2014-10-07 00:10:17 -0700889 model = SiteCredential
890 fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -0700891
892
Scott Baker0caeaf02014-06-19 11:12:55 -0700893
894
895class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
896 id = serializers.Field()
897
898 class Meta:
899 model = DeploymentPrivilege
Scott Baker46b58542014-08-11 17:26:12 -0700900 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
901
902class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer):
903 id = serializers.Field()
904
905 class Meta:
906 model = DeploymentPrivilege
907 fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
908
909
Scott Baker0caeaf02014-06-19 11:12:55 -0700910
911
912class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
913 id = serializers.Field()
914
915 class Meta:
916 model = DeploymentRole
Scott Baker46b58542014-08-11 17:26:12 -0700917 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
918
919class DeploymentRoleIdSerializer(serializers.ModelSerializer):
920 id = serializers.Field()
921
922 class Meta:
923 model = DeploymentRole
924 fields = ('id','created','updated','enacted','backend_status','deleted','role',)
925
926
Sapan Bhatiadea39432014-06-13 03:10:36 -0400927
928
Scott Baker89a7b7c2014-10-07 00:10:17 -0700929class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400930 id = serializers.Field()
931
932 class Meta:
Scott Baker89a7b7c2014-10-07 00:10:17 -0700933 model = UserCredential
934 fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -0700935
Scott Baker89a7b7c2014-10-07 00:10:17 -0700936class UserCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker46b58542014-08-11 17:26:12 -0700937 id = serializers.Field()
938
939 class Meta:
Scott Baker89a7b7c2014-10-07 00:10:17 -0700940 model = UserCredential
941 fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
942
943
944
945
946class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
947 id = serializers.Field()
948
949 class Meta:
950 model = SiteDeployments
951 fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
952
953class SiteDeploymentsIdSerializer(serializers.ModelSerializer):
954 id = serializers.Field()
955
956 class Meta:
957 model = SiteDeployments
958 fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700959
960
Sapan Bhatiadea39432014-06-13 03:10:36 -0400961
962
Scott Baker0caeaf02014-06-19 11:12:55 -0700963class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400964 id = serializers.Field()
965
966 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700967 model = SliceTag
Scott Baker46b58542014-08-11 17:26:12 -0700968 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
969
970class SliceTagIdSerializer(serializers.ModelSerializer):
971 id = serializers.Field()
972
973 class Meta:
974 model = SliceTag
975 fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
976
977
Scott Baker0caeaf02014-06-19 11:12:55 -0700978
979
980class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
981 id = serializers.Field()
982
983 class Meta:
984 model = NetworkTemplate
Scott Baker46b58542014-08-11 17:26:12 -0700985 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
986
987class NetworkTemplateIdSerializer(serializers.ModelSerializer):
988 id = serializers.Field()
989
990 class Meta:
991 model = NetworkTemplate
992 fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
993
994
Sapan Bhatiadea39432014-06-13 03:10:36 -0400995
996
997class RouterSerializer(serializers.HyperlinkedModelSerializer):
998 id = serializers.Field()
999
1000 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -07001001 model = Router
Scott Baker46b58542014-08-11 17:26:12 -07001002 fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
1003
1004class RouterIdSerializer(serializers.ModelSerializer):
1005 id = serializers.Field()
1006
1007 class Meta:
1008 model = Router
1009 fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
1010
1011
Sapan Bhatiadea39432014-06-13 03:10:36 -04001012
1013
Scott Baker0caeaf02014-06-19 11:12:55 -07001014class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -04001015 id = serializers.Field()
1016
1017 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -07001018 model = ServiceResource
Scott Baker46b58542014-08-11 17:26:12 -07001019 fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
1020
1021class ServiceResourceIdSerializer(serializers.ModelSerializer):
1022 id = serializers.Field()
1023
1024 class Meta:
1025 model = ServiceResource
1026 fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
1027
1028
Sapan Bhatiadea39432014-06-13 03:10:36 -04001029
1030
1031serializerLookUp = {
1032
Scott Baker0caeaf02014-06-19 11:12:55 -07001033 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001034
1035 Image: ImageSerializer,
1036
Scott Baker0caeaf02014-06-19 11:12:55 -07001037 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001038
1039 Site: SiteSerializer,
1040
Scott Baker0caeaf02014-06-19 11:12:55 -07001041 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001042
1043 Tag: TagSerializer,
1044
1045 Invoice: InvoiceSerializer,
1046
Scott Baker0caeaf02014-06-19 11:12:55 -07001047 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001048
Scott Baker89a7b7c2014-10-07 00:10:17 -07001049 PlanetStackRole: PlanetStackRoleSerializer,
1050
Scott Baker0caeaf02014-06-19 11:12:55 -07001051 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001052
Scott Baker0caeaf02014-06-19 11:12:55 -07001053 NetworkDeployments: NetworkDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001054
Scott Baker89a7b7c2014-10-07 00:10:17 -07001055 Flavor: FlavorSerializer,
1056
1057 Project: ProjectSerializer,
1058
Sapan Bhatiadea39432014-06-13 03:10:36 -04001059 Slice: SliceSerializer,
1060
1061 Network: NetworkSerializer,
1062
1063 Service: ServiceSerializer,
1064
Scott Baker0caeaf02014-06-19 11:12:55 -07001065 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001066
Scott Baker0caeaf02014-06-19 11:12:55 -07001067 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001068
1069 Charge: ChargeSerializer,
1070
1071 Role: RoleSerializer,
1072
Scott Baker0caeaf02014-06-19 11:12:55 -07001073 UsableObject: UsableObjectSerializer,
1074
1075 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001076
Scott Baker89a7b7c2014-10-07 00:10:17 -07001077 SliceCredential: SliceCredentialSerializer,
1078
Sapan Bhatiadea39432014-06-13 03:10:36 -04001079 Sliver: SliverSerializer,
1080
1081 Node: NodeSerializer,
1082
Scott Baker0caeaf02014-06-19 11:12:55 -07001083 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001084
Scott Baker0caeaf02014-06-19 11:12:55 -07001085 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001086
Scott Baker0caeaf02014-06-19 11:12:55 -07001087 ReservedResource: ReservedResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001088
Scott Baker0caeaf02014-06-19 11:12:55 -07001089 NetworkSlice: NetworkSliceSerializer,
1090
1091 UserDashboardView: UserDashboardViewSerializer,
1092
1093 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001094
1095 User: UserSerializer,
1096
1097 Deployment: DeploymentSerializer,
1098
1099 Reservation: ReservationSerializer,
1100
Scott Baker0caeaf02014-06-19 11:12:55 -07001101 SliceDeployments: SliceDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001102
Scott Baker0caeaf02014-06-19 11:12:55 -07001103 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001104
Scott Baker0caeaf02014-06-19 11:12:55 -07001105 PlanetStack: PlanetStackSerializer,
1106
1107 UserDeployments: UserDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001108
1109 Account: AccountSerializer,
1110
Scott Baker0caeaf02014-06-19 11:12:55 -07001111 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001112
Scott Baker89a7b7c2014-10-07 00:10:17 -07001113 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001114
Scott Baker0caeaf02014-06-19 11:12:55 -07001115 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001116
Scott Baker0caeaf02014-06-19 11:12:55 -07001117 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001118
Scott Baker89a7b7c2014-10-07 00:10:17 -07001119 UserCredential: UserCredentialSerializer,
1120
1121 SiteDeployments: SiteDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001122
Scott Baker0caeaf02014-06-19 11:12:55 -07001123 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001124
Scott Baker0caeaf02014-06-19 11:12:55 -07001125 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001126
1127 Router: RouterSerializer,
1128
Scott Baker0caeaf02014-06-19 11:12:55 -07001129 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001130
1131 None: None,
1132 }
1133
Scott Baker89a7b7c2014-10-07 00:10:17 -07001134class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
1135
1136 # To handle fine-grained field permissions, we have to check can_update
1137 # the object has been updated but before it has been saved.
1138
1139 def update(self, request, *args, **kwargs):
1140 partial = kwargs.pop('partial', False)
1141 self.object = self.get_object_or_none()
1142
1143 serializer = self.get_serializer(self.object, data=request.DATA,
1144 files=request.FILES, partial=partial)
1145
1146 if not serializer.is_valid():
1147 print "UpdateModelMixin: not serializer.is_valid"
1148 print serializer.errors
1149 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
1150
1151 try:
1152 self.pre_save(serializer.object)
1153 except ValidationError as err:
1154 # full_clean on model instance may be called in pre_save,
1155 # so we have to handle eventual errors.
1156 return Response(err.message_dict, status=status.HTTP_400_BAD_REQUEST)
1157
1158 if serializer.object is not None:
1159 if not serializer.object.can_update(request.user):
1160 return Response(status=status.HTTP_400_BAD_REQUEST)
1161
1162 if self.object is None:
1163 self.object = serializer.save(force_insert=True)
1164 self.post_save(self.object, created=True)
1165 return Response(serializer.data, status=status.HTTP_201_CREATED)
1166
1167 self.object = serializer.save(force_update=True)
1168 self.post_save(self.object, created=False)
1169 return Response(serializer.data, status=status.HTTP_200_OK)
1170
1171 def destroy(self, request, *args, **kwargs):
1172 obj = self.get_object()
1173 if obj.can_update(request.user):
1174 return super(Detail, self).destroy(request, *args, **kwargs)
1175 else:
1176 return Response(status=status.HTTP_400_BAD_REQUEST)
1177
1178
Sapan Bhatiadea39432014-06-13 03:10:36 -04001179# Based on core/views/*.py
1180
1181
Scott Baker0caeaf02014-06-19 11:12:55 -07001182class ServiceAttributeList(generics.ListCreateAPIView):
1183 queryset = ServiceAttribute.objects.select_related().all()
1184 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001185 id_serializer_class = ServiceAttributeIdSerializer
1186 filter_backends = (filters.DjangoFilterBackend,)
1187 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
1188
1189 def get_serializer_class(self):
1190 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1191 if (no_hyperlinks):
1192 return self.id_serializer_class
1193 else:
1194 return self.serializer_class
1195
Scott Baker0caeaf02014-06-19 11:12:55 -07001196 def get_queryset(self):
1197 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001198
Scott Baker0caeaf02014-06-19 11:12:55 -07001199 def create(self, request, *args, **kwargs):
1200 #obj = ServiceAttribute().update(request.DATA)
1201 obj = self.get_object()
1202 obj.caller = request.user
1203 if obj.can_update(request.user):
1204 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
1205 else:
1206 return Response(status=status.HTTP_400_BAD_REQUEST)
1207
Scott Baker89a7b7c2014-10-07 00:10:17 -07001208class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001209 queryset = ServiceAttribute.objects.select_related().all()
1210 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001211 id_serializer_class = ServiceAttributeIdSerializer
1212
1213 def get_serializer_class(self):
1214 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1215 if (no_hyperlinks):
1216 return self.id_serializer_class
1217 else:
1218 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001219
1220 def get_queryset(self):
1221 return ServiceAttribute.select_by_user(self.request.user)
1222
Scott Baker89a7b7c2014-10-07 00:10:17 -07001223 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001224
Scott Baker89a7b7c2014-10-07 00:10:17 -07001225 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001226
1227
1228
1229class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001230 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001231 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001232 id_serializer_class = ImageIdSerializer
1233 filter_backends = (filters.DjangoFilterBackend,)
1234 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
1235
1236 def get_serializer_class(self):
1237 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1238 if (no_hyperlinks):
1239 return self.id_serializer_class
1240 else:
1241 return self.serializer_class
1242
Scott Baker0caeaf02014-06-19 11:12:55 -07001243 def get_queryset(self):
1244 return Image.select_by_user(self.request.user)
1245
1246 def create(self, request, *args, **kwargs):
1247 #obj = Image().update(request.DATA)
1248 obj = self.get_object()
1249 obj.caller = request.user
1250 if obj.can_update(request.user):
1251 return super(ImageList, self).create(request, *args, **kwargs)
1252 else:
1253 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001254
Scott Baker89a7b7c2014-10-07 00:10:17 -07001255class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001256 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001257 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001258 id_serializer_class = ImageIdSerializer
1259
1260 def get_serializer_class(self):
1261 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1262 if (no_hyperlinks):
1263 return self.id_serializer_class
1264 else:
1265 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001266
1267 def get_queryset(self):
1268 return Image.select_by_user(self.request.user)
1269
Scott Baker89a7b7c2014-10-07 00:10:17 -07001270 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001271
Scott Baker89a7b7c2014-10-07 00:10:17 -07001272 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001273
1274
1275
Scott Baker0caeaf02014-06-19 11:12:55 -07001276class NetworkParameterList(generics.ListCreateAPIView):
1277 queryset = NetworkParameter.objects.select_related().all()
1278 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001279 id_serializer_class = NetworkParameterIdSerializer
1280 filter_backends = (filters.DjangoFilterBackend,)
1281 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
1282
1283 def get_serializer_class(self):
1284 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1285 if (no_hyperlinks):
1286 return self.id_serializer_class
1287 else:
1288 return self.serializer_class
1289
Scott Baker0caeaf02014-06-19 11:12:55 -07001290 def get_queryset(self):
1291 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001292
Scott Baker0caeaf02014-06-19 11:12:55 -07001293 def create(self, request, *args, **kwargs):
1294 #obj = NetworkParameter().update(request.DATA)
1295 obj = self.get_object()
1296 obj.caller = request.user
1297 if obj.can_update(request.user):
1298 return super(NetworkParameterList, self).create(request, *args, **kwargs)
1299 else:
1300 return Response(status=status.HTTP_400_BAD_REQUEST)
1301
Scott Baker89a7b7c2014-10-07 00:10:17 -07001302class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001303 queryset = NetworkParameter.objects.select_related().all()
1304 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001305 id_serializer_class = NetworkParameterIdSerializer
1306
1307 def get_serializer_class(self):
1308 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1309 if (no_hyperlinks):
1310 return self.id_serializer_class
1311 else:
1312 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001313
1314 def get_queryset(self):
1315 return NetworkParameter.select_by_user(self.request.user)
1316
Scott Baker89a7b7c2014-10-07 00:10:17 -07001317 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001318
Scott Baker89a7b7c2014-10-07 00:10:17 -07001319 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001320
1321
1322
1323class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001324 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001325 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001326 id_serializer_class = SiteIdSerializer
1327 filter_backends = (filters.DjangoFilterBackend,)
1328 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
1329
1330 def get_serializer_class(self):
1331 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1332 if (no_hyperlinks):
1333 return self.id_serializer_class
1334 else:
1335 return self.serializer_class
1336
Scott Baker0caeaf02014-06-19 11:12:55 -07001337 def get_queryset(self):
1338 return Site.select_by_user(self.request.user)
1339
1340 def create(self, request, *args, **kwargs):
1341 #obj = Site().update(request.DATA)
1342 obj = self.get_object()
1343 obj.caller = request.user
1344 if obj.can_update(request.user):
1345 return super(SiteList, self).create(request, *args, **kwargs)
1346 else:
1347 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001348
Scott Baker89a7b7c2014-10-07 00:10:17 -07001349class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001350 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001351 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001352 id_serializer_class = SiteIdSerializer
1353
1354 def get_serializer_class(self):
1355 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1356 if (no_hyperlinks):
1357 return self.id_serializer_class
1358 else:
1359 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001360
1361 def get_queryset(self):
1362 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001363
Scott Baker89a7b7c2014-10-07 00:10:17 -07001364 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001365
Scott Baker89a7b7c2014-10-07 00:10:17 -07001366 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001367
1368
1369
1370class SliceRoleList(generics.ListCreateAPIView):
1371 queryset = SliceRole.objects.select_related().all()
1372 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001373 id_serializer_class = SliceRoleIdSerializer
1374 filter_backends = (filters.DjangoFilterBackend,)
1375 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
1376
1377 def get_serializer_class(self):
1378 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1379 if (no_hyperlinks):
1380 return self.id_serializer_class
1381 else:
1382 return self.serializer_class
1383
Scott Baker0caeaf02014-06-19 11:12:55 -07001384 def get_queryset(self):
1385 return SliceRole.select_by_user(self.request.user)
1386
1387 def create(self, request, *args, **kwargs):
1388 #obj = SliceRole().update(request.DATA)
1389 obj = self.get_object()
1390 obj.caller = request.user
1391 if obj.can_update(request.user):
1392 return super(SliceRoleList, self).create(request, *args, **kwargs)
1393 else:
1394 return Response(status=status.HTTP_400_BAD_REQUEST)
1395
Scott Baker89a7b7c2014-10-07 00:10:17 -07001396class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001397 queryset = SliceRole.objects.select_related().all()
1398 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001399 id_serializer_class = SliceRoleIdSerializer
1400
1401 def get_serializer_class(self):
1402 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1403 if (no_hyperlinks):
1404 return self.id_serializer_class
1405 else:
1406 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001407
1408 def get_queryset(self):
1409 return SliceRole.select_by_user(self.request.user)
1410
Scott Baker89a7b7c2014-10-07 00:10:17 -07001411 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001412
Scott Baker89a7b7c2014-10-07 00:10:17 -07001413 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001414
1415
1416
1417class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001418 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001419 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001420 id_serializer_class = TagIdSerializer
1421 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001422 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001423
1424 def get_serializer_class(self):
1425 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1426 if (no_hyperlinks):
1427 return self.id_serializer_class
1428 else:
1429 return self.serializer_class
1430
Scott Baker0caeaf02014-06-19 11:12:55 -07001431 def get_queryset(self):
1432 return Tag.select_by_user(self.request.user)
1433
1434 def create(self, request, *args, **kwargs):
1435 #obj = Tag().update(request.DATA)
1436 obj = self.get_object()
1437 obj.caller = request.user
1438 if obj.can_update(request.user):
1439 return super(TagList, self).create(request, *args, **kwargs)
1440 else:
1441 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001442
Scott Baker89a7b7c2014-10-07 00:10:17 -07001443class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001444 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001445 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001446 id_serializer_class = TagIdSerializer
1447
1448 def get_serializer_class(self):
1449 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1450 if (no_hyperlinks):
1451 return self.id_serializer_class
1452 else:
1453 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001454
1455 def get_queryset(self):
1456 return Tag.select_by_user(self.request.user)
1457
Scott Baker89a7b7c2014-10-07 00:10:17 -07001458 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001459
Scott Baker89a7b7c2014-10-07 00:10:17 -07001460 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001461
1462
1463
1464class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001465 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001466 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001467 id_serializer_class = InvoiceIdSerializer
1468 filter_backends = (filters.DjangoFilterBackend,)
1469 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
1470
1471 def get_serializer_class(self):
1472 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1473 if (no_hyperlinks):
1474 return self.id_serializer_class
1475 else:
1476 return self.serializer_class
1477
Scott Baker0caeaf02014-06-19 11:12:55 -07001478 def get_queryset(self):
1479 return Invoice.select_by_user(self.request.user)
1480
1481 def create(self, request, *args, **kwargs):
1482 #obj = Invoice().update(request.DATA)
1483 obj = self.get_object()
1484 obj.caller = request.user
1485 if obj.can_update(request.user):
1486 return super(InvoiceList, self).create(request, *args, **kwargs)
1487 else:
1488 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001489
Scott Baker89a7b7c2014-10-07 00:10:17 -07001490class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001491 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001492 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001493 id_serializer_class = InvoiceIdSerializer
1494
1495 def get_serializer_class(self):
1496 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1497 if (no_hyperlinks):
1498 return self.id_serializer_class
1499 else:
1500 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001501
1502 def get_queryset(self):
1503 return Invoice.select_by_user(self.request.user)
1504
Scott Baker89a7b7c2014-10-07 00:10:17 -07001505 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001506
Scott Baker89a7b7c2014-10-07 00:10:17 -07001507 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001508
1509
1510
Scott Baker0caeaf02014-06-19 11:12:55 -07001511class SlicePrivilegeList(generics.ListCreateAPIView):
1512 queryset = SlicePrivilege.objects.select_related().all()
1513 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001514 id_serializer_class = SlicePrivilegeIdSerializer
1515 filter_backends = (filters.DjangoFilterBackend,)
1516 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
1517
1518 def get_serializer_class(self):
1519 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1520 if (no_hyperlinks):
1521 return self.id_serializer_class
1522 else:
1523 return self.serializer_class
1524
Scott Baker0caeaf02014-06-19 11:12:55 -07001525 def get_queryset(self):
1526 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001527
Scott Baker0caeaf02014-06-19 11:12:55 -07001528 def create(self, request, *args, **kwargs):
1529 #obj = SlicePrivilege().update(request.DATA)
1530 obj = self.get_object()
1531 obj.caller = request.user
1532 if obj.can_update(request.user):
1533 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
1534 else:
1535 return Response(status=status.HTTP_400_BAD_REQUEST)
1536
Scott Baker89a7b7c2014-10-07 00:10:17 -07001537class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001538 queryset = SlicePrivilege.objects.select_related().all()
1539 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001540 id_serializer_class = SlicePrivilegeIdSerializer
1541
1542 def get_serializer_class(self):
1543 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1544 if (no_hyperlinks):
1545 return self.id_serializer_class
1546 else:
1547 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001548
1549 def get_queryset(self):
1550 return SlicePrivilege.select_by_user(self.request.user)
1551
Scott Baker89a7b7c2014-10-07 00:10:17 -07001552 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1553
1554 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1555
1556
1557
1558class PlanetStackRoleList(generics.ListCreateAPIView):
1559 queryset = PlanetStackRole.objects.select_related().all()
1560 serializer_class = PlanetStackRoleSerializer
1561 id_serializer_class = PlanetStackRoleIdSerializer
1562 filter_backends = (filters.DjangoFilterBackend,)
1563 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
1564
1565 def get_serializer_class(self):
1566 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1567 if (no_hyperlinks):
1568 return self.id_serializer_class
1569 else:
1570 return self.serializer_class
1571
1572 def get_queryset(self):
1573 return PlanetStackRole.select_by_user(self.request.user)
1574
1575 def create(self, request, *args, **kwargs):
1576 #obj = PlanetStackRole().update(request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001577 obj = self.get_object()
Scott Baker89a7b7c2014-10-07 00:10:17 -07001578 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07001579 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001580 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001581 else:
1582 return Response(status=status.HTTP_400_BAD_REQUEST)
1583
Scott Baker89a7b7c2014-10-07 00:10:17 -07001584class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1585 queryset = PlanetStackRole.objects.select_related().all()
1586 serializer_class = PlanetStackRoleSerializer
1587 id_serializer_class = PlanetStackRoleIdSerializer
1588
1589 def get_serializer_class(self):
1590 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1591 if (no_hyperlinks):
1592 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001593 else:
Scott Baker89a7b7c2014-10-07 00:10:17 -07001594 return self.serializer_class
1595
1596 def get_queryset(self):
1597 return PlanetStackRole.select_by_user(self.request.user)
1598
1599 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1600
1601 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001602
1603
1604
Scott Baker0caeaf02014-06-19 11:12:55 -07001605class NetworkSliverList(generics.ListCreateAPIView):
1606 queryset = NetworkSliver.objects.select_related().all()
1607 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001608 id_serializer_class = NetworkSliverIdSerializer
1609 filter_backends = (filters.DjangoFilterBackend,)
1610 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
1611
1612 def get_serializer_class(self):
1613 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1614 if (no_hyperlinks):
1615 return self.id_serializer_class
1616 else:
1617 return self.serializer_class
1618
Scott Baker0caeaf02014-06-19 11:12:55 -07001619 def get_queryset(self):
1620 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001621
Scott Baker0caeaf02014-06-19 11:12:55 -07001622 def create(self, request, *args, **kwargs):
1623 #obj = NetworkSliver().update(request.DATA)
1624 obj = self.get_object()
1625 obj.caller = request.user
1626 if obj.can_update(request.user):
1627 return super(NetworkSliverList, self).create(request, *args, **kwargs)
1628 else:
1629 return Response(status=status.HTTP_400_BAD_REQUEST)
1630
Scott Baker89a7b7c2014-10-07 00:10:17 -07001631class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001632 queryset = NetworkSliver.objects.select_related().all()
1633 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001634 id_serializer_class = NetworkSliverIdSerializer
1635
1636 def get_serializer_class(self):
1637 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1638 if (no_hyperlinks):
1639 return self.id_serializer_class
1640 else:
1641 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001642
1643 def get_queryset(self):
1644 return NetworkSliver.select_by_user(self.request.user)
1645
Scott Baker89a7b7c2014-10-07 00:10:17 -07001646 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001647
Scott Baker89a7b7c2014-10-07 00:10:17 -07001648 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
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
Scott Baker89a7b7c2014-10-07 00:10:17 -07001678class NetworkDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001679 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
Scott Baker89a7b7c2014-10-07 00:10:17 -07001693 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001694
Scott Baker89a7b7c2014-10-07 00:10:17 -07001695 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001696
1697
1698
Scott Baker89a7b7c2014-10-07 00:10:17 -07001699class FlavorList(generics.ListCreateAPIView):
1700 queryset = Flavor.objects.select_related().all()
1701 serializer_class = FlavorSerializer
1702 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001703 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001704 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker46b58542014-08-11 17:26:12 -07001705
1706 def get_serializer_class(self):
1707 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1708 if (no_hyperlinks):
1709 return self.id_serializer_class
1710 else:
1711 return self.serializer_class
1712
Scott Baker0caeaf02014-06-19 11:12:55 -07001713 def get_queryset(self):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001714 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07001715
1716 def create(self, request, *args, **kwargs):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001717 #obj = Flavor().update(request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001718 obj = self.get_object()
1719 obj.caller = request.user
1720 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001721 return super(FlavorList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001722 else:
1723 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001724
Scott Baker89a7b7c2014-10-07 00:10:17 -07001725class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1726 queryset = Flavor.objects.select_related().all()
1727 serializer_class = FlavorSerializer
1728 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001729
1730 def get_serializer_class(self):
1731 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1732 if (no_hyperlinks):
1733 return self.id_serializer_class
1734 else:
1735 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001736
1737 def get_queryset(self):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001738 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07001739
Scott Baker89a7b7c2014-10-07 00:10:17 -07001740 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001741
Scott Baker89a7b7c2014-10-07 00:10:17 -07001742 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001743
1744
1745
Scott Baker0caeaf02014-06-19 11:12:55 -07001746class ProjectList(generics.ListCreateAPIView):
1747 queryset = Project.objects.select_related().all()
1748 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001749 id_serializer_class = ProjectIdSerializer
1750 filter_backends = (filters.DjangoFilterBackend,)
1751 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
1752
1753 def get_serializer_class(self):
1754 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1755 if (no_hyperlinks):
1756 return self.id_serializer_class
1757 else:
1758 return self.serializer_class
1759
Scott Baker0caeaf02014-06-19 11:12:55 -07001760 def get_queryset(self):
1761 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001762
Scott Baker0caeaf02014-06-19 11:12:55 -07001763 def create(self, request, *args, **kwargs):
1764 #obj = Project().update(request.DATA)
1765 obj = self.get_object()
1766 obj.caller = request.user
1767 if obj.can_update(request.user):
1768 return super(ProjectList, self).create(request, *args, **kwargs)
1769 else:
1770 return Response(status=status.HTTP_400_BAD_REQUEST)
1771
Scott Baker89a7b7c2014-10-07 00:10:17 -07001772class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001773 queryset = Project.objects.select_related().all()
1774 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001775 id_serializer_class = ProjectIdSerializer
1776
1777 def get_serializer_class(self):
1778 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1779 if (no_hyperlinks):
1780 return self.id_serializer_class
1781 else:
1782 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001783
1784 def get_queryset(self):
1785 return Project.select_by_user(self.request.user)
1786
Scott Baker89a7b7c2014-10-07 00:10:17 -07001787 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1788
1789 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1790
1791
1792
1793class SliceList(generics.ListCreateAPIView):
1794 queryset = Slice.objects.select_related().all()
1795 serializer_class = SliceSerializer
1796 id_serializer_class = SliceIdSerializer
1797 filter_backends = (filters.DjangoFilterBackend,)
1798 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',)
1799
1800 def get_serializer_class(self):
1801 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1802 if (no_hyperlinks):
1803 return self.id_serializer_class
1804 else:
1805 return self.serializer_class
1806
1807 def get_queryset(self):
1808 return Slice.select_by_user(self.request.user)
1809
1810 def create(self, request, *args, **kwargs):
1811 #obj = Slice().update(request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001812 obj = self.get_object()
Scott Baker89a7b7c2014-10-07 00:10:17 -07001813 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07001814 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001815 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001816 else:
1817 return Response(status=status.HTTP_400_BAD_REQUEST)
1818
Scott Baker89a7b7c2014-10-07 00:10:17 -07001819class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1820 queryset = Slice.objects.select_related().all()
1821 serializer_class = SliceSerializer
1822 id_serializer_class = SliceIdSerializer
1823
1824 def get_serializer_class(self):
1825 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1826 if (no_hyperlinks):
1827 return self.id_serializer_class
1828 else:
1829 return self.serializer_class
1830
1831 def get_queryset(self):
1832 return Slice.select_by_user(self.request.user)
1833
1834 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1835
1836 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1837
1838
1839
1840class NetworkList(generics.ListCreateAPIView):
1841 queryset = Network.objects.select_related().all()
1842 serializer_class = NetworkSerializer
1843 id_serializer_class = NetworkIdSerializer
1844 filter_backends = (filters.DjangoFilterBackend,)
1845 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',)
1846
1847 def get_serializer_class(self):
1848 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1849 if (no_hyperlinks):
1850 return self.id_serializer_class
1851 else:
1852 return self.serializer_class
1853
1854 def get_queryset(self):
1855 return Network.select_by_user(self.request.user)
1856
1857 def create(self, request, *args, **kwargs):
1858 #obj = Network().update(request.DATA)
Scott Baker0caeaf02014-06-19 11:12:55 -07001859 obj = self.get_object()
Scott Baker89a7b7c2014-10-07 00:10:17 -07001860 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07001861 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07001862 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07001863 else:
1864 return Response(status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001865
1866class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1867 queryset = Network.objects.select_related().all()
1868 serializer_class = NetworkSerializer
1869 id_serializer_class = NetworkIdSerializer
1870
1871 def get_serializer_class(self):
1872 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1873 if (no_hyperlinks):
1874 return self.id_serializer_class
1875 else:
1876 return self.serializer_class
1877
1878 def get_queryset(self):
1879 return Network.select_by_user(self.request.user)
1880
1881 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1882
1883 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1884
1885
1886
1887class ServiceList(generics.ListCreateAPIView):
1888 queryset = Service.objects.select_related().all()
1889 serializer_class = ServiceSerializer
1890 id_serializer_class = ServiceIdSerializer
1891 filter_backends = (filters.DjangoFilterBackend,)
1892 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
1893
1894 def get_serializer_class(self):
1895 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1896 if (no_hyperlinks):
1897 return self.id_serializer_class
1898 else:
1899 return self.serializer_class
1900
1901 def get_queryset(self):
1902 return Service.select_by_user(self.request.user)
1903
1904 def create(self, request, *args, **kwargs):
1905 #obj = Service().update(request.DATA)
1906 obj = self.get_object()
1907 obj.caller = request.user
1908 if obj.can_update(request.user):
1909 return super(ServiceList, self).create(request, *args, **kwargs)
1910 else:
1911 return Response(status=status.HTTP_400_BAD_REQUEST)
1912
1913class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1914 queryset = Service.objects.select_related().all()
1915 serializer_class = ServiceSerializer
1916 id_serializer_class = ServiceIdSerializer
1917
1918 def get_serializer_class(self):
1919 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1920 if (no_hyperlinks):
1921 return self.id_serializer_class
1922 else:
1923 return self.serializer_class
1924
1925 def get_queryset(self):
1926 return Service.select_by_user(self.request.user)
1927
1928 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1929
1930 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1931
1932
1933
1934class ServiceClassList(generics.ListCreateAPIView):
1935 queryset = ServiceClass.objects.select_related().all()
1936 serializer_class = ServiceClassSerializer
1937 id_serializer_class = ServiceClassIdSerializer
1938 filter_backends = (filters.DjangoFilterBackend,)
1939 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
1940
1941 def get_serializer_class(self):
1942 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1943 if (no_hyperlinks):
1944 return self.id_serializer_class
1945 else:
1946 return self.serializer_class
1947
1948 def get_queryset(self):
1949 return ServiceClass.select_by_user(self.request.user)
1950
1951 def create(self, request, *args, **kwargs):
1952 #obj = ServiceClass().update(request.DATA)
1953 obj = self.get_object()
1954 obj.caller = request.user
1955 if obj.can_update(request.user):
1956 return super(ServiceClassList, self).create(request, *args, **kwargs)
1957 else:
1958 return Response(status=status.HTTP_400_BAD_REQUEST)
1959
1960class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
1961 queryset = ServiceClass.objects.select_related().all()
1962 serializer_class = ServiceClassSerializer
1963 id_serializer_class = ServiceClassIdSerializer
1964
1965 def get_serializer_class(self):
1966 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1967 if (no_hyperlinks):
1968 return self.id_serializer_class
1969 else:
1970 return self.serializer_class
1971
1972 def get_queryset(self):
1973 return ServiceClass.select_by_user(self.request.user)
1974
1975 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1976
1977 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
1978
1979
1980
1981class PaymentList(generics.ListCreateAPIView):
1982 queryset = Payment.objects.select_related().all()
1983 serializer_class = PaymentSerializer
1984 id_serializer_class = PaymentIdSerializer
1985 filter_backends = (filters.DjangoFilterBackend,)
1986 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1987
1988 def get_serializer_class(self):
1989 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1990 if (no_hyperlinks):
1991 return self.id_serializer_class
1992 else:
1993 return self.serializer_class
1994
1995 def get_queryset(self):
1996 return Payment.select_by_user(self.request.user)
1997
1998 def create(self, request, *args, **kwargs):
1999 #obj = Payment().update(request.DATA)
2000 obj = self.get_object()
2001 obj.caller = request.user
2002 if obj.can_update(request.user):
2003 return super(PaymentList, self).create(request, *args, **kwargs)
2004 else:
2005 return Response(status=status.HTTP_400_BAD_REQUEST)
2006
2007class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2008 queryset = Payment.objects.select_related().all()
2009 serializer_class = PaymentSerializer
2010 id_serializer_class = PaymentIdSerializer
2011
2012 def get_serializer_class(self):
2013 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2014 if (no_hyperlinks):
2015 return self.id_serializer_class
2016 else:
2017 return self.serializer_class
2018
2019 def get_queryset(self):
2020 return Payment.select_by_user(self.request.user)
2021
2022 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2023
2024 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2025
2026
2027
2028class ChargeList(generics.ListCreateAPIView):
2029 queryset = Charge.objects.select_related().all()
2030 serializer_class = ChargeSerializer
2031 id_serializer_class = ChargeIdSerializer
2032 filter_backends = (filters.DjangoFilterBackend,)
2033 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
2034
2035 def get_serializer_class(self):
2036 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2037 if (no_hyperlinks):
2038 return self.id_serializer_class
2039 else:
2040 return self.serializer_class
2041
2042 def get_queryset(self):
2043 return Charge.select_by_user(self.request.user)
2044
2045 def create(self, request, *args, **kwargs):
2046 #obj = Charge().update(request.DATA)
2047 obj = self.get_object()
2048 obj.caller = request.user
2049 if obj.can_update(request.user):
2050 return super(ChargeList, self).create(request, *args, **kwargs)
2051 else:
2052 return Response(status=status.HTTP_400_BAD_REQUEST)
2053
2054class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2055 queryset = Charge.objects.select_related().all()
2056 serializer_class = ChargeSerializer
2057 id_serializer_class = ChargeIdSerializer
2058
2059 def get_serializer_class(self):
2060 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2061 if (no_hyperlinks):
2062 return self.id_serializer_class
2063 else:
2064 return self.serializer_class
2065
2066 def get_queryset(self):
2067 return Charge.select_by_user(self.request.user)
2068
2069 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2070
2071 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2072
2073
2074
2075class RoleList(generics.ListCreateAPIView):
2076 queryset = Role.objects.select_related().all()
2077 serializer_class = RoleSerializer
2078 id_serializer_class = RoleIdSerializer
2079 filter_backends = (filters.DjangoFilterBackend,)
2080 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
2081
2082 def get_serializer_class(self):
2083 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2084 if (no_hyperlinks):
2085 return self.id_serializer_class
2086 else:
2087 return self.serializer_class
2088
2089 def get_queryset(self):
2090 return Role.select_by_user(self.request.user)
2091
2092 def create(self, request, *args, **kwargs):
2093 #obj = Role().update(request.DATA)
2094 obj = self.get_object()
2095 obj.caller = request.user
2096 if obj.can_update(request.user):
2097 return super(RoleList, self).create(request, *args, **kwargs)
2098 else:
2099 return Response(status=status.HTTP_400_BAD_REQUEST)
2100
2101class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2102 queryset = Role.objects.select_related().all()
2103 serializer_class = RoleSerializer
2104 id_serializer_class = RoleIdSerializer
2105
2106 def get_serializer_class(self):
2107 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2108 if (no_hyperlinks):
2109 return self.id_serializer_class
2110 else:
2111 return self.serializer_class
2112
2113 def get_queryset(self):
2114 return Role.select_by_user(self.request.user)
2115
2116 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2117
2118 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2119
2120
2121
2122class UsableObjectList(generics.ListCreateAPIView):
2123 queryset = UsableObject.objects.select_related().all()
2124 serializer_class = UsableObjectSerializer
2125 id_serializer_class = UsableObjectIdSerializer
2126 filter_backends = (filters.DjangoFilterBackend,)
2127 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
2128
2129 def get_serializer_class(self):
2130 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2131 if (no_hyperlinks):
2132 return self.id_serializer_class
2133 else:
2134 return self.serializer_class
2135
2136 def get_queryset(self):
2137 return UsableObject.select_by_user(self.request.user)
2138
2139 def create(self, request, *args, **kwargs):
2140 #obj = UsableObject().update(request.DATA)
2141 obj = self.get_object()
2142 obj.caller = request.user
2143 if obj.can_update(request.user):
2144 return super(UsableObjectList, self).create(request, *args, **kwargs)
2145 else:
2146 return Response(status=status.HTTP_400_BAD_REQUEST)
2147
2148class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2149 queryset = UsableObject.objects.select_related().all()
2150 serializer_class = UsableObjectSerializer
2151 id_serializer_class = UsableObjectIdSerializer
2152
2153 def get_serializer_class(self):
2154 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2155 if (no_hyperlinks):
2156 return self.id_serializer_class
2157 else:
2158 return self.serializer_class
2159
2160 def get_queryset(self):
2161 return UsableObject.select_by_user(self.request.user)
2162
2163 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2164
2165 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2166
2167
2168
2169class SiteRoleList(generics.ListCreateAPIView):
2170 queryset = SiteRole.objects.select_related().all()
2171 serializer_class = SiteRoleSerializer
2172 id_serializer_class = SiteRoleIdSerializer
2173 filter_backends = (filters.DjangoFilterBackend,)
2174 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2175
2176 def get_serializer_class(self):
2177 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2178 if (no_hyperlinks):
2179 return self.id_serializer_class
2180 else:
2181 return self.serializer_class
2182
2183 def get_queryset(self):
2184 return SiteRole.select_by_user(self.request.user)
2185
2186 def create(self, request, *args, **kwargs):
2187 #obj = SiteRole().update(request.DATA)
2188 obj = self.get_object()
2189 obj.caller = request.user
2190 if obj.can_update(request.user):
2191 return super(SiteRoleList, self).create(request, *args, **kwargs)
2192 else:
2193 return Response(status=status.HTTP_400_BAD_REQUEST)
2194
2195class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2196 queryset = SiteRole.objects.select_related().all()
2197 serializer_class = SiteRoleSerializer
2198 id_serializer_class = SiteRoleIdSerializer
2199
2200 def get_serializer_class(self):
2201 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2202 if (no_hyperlinks):
2203 return self.id_serializer_class
2204 else:
2205 return self.serializer_class
2206
2207 def get_queryset(self):
2208 return SiteRole.select_by_user(self.request.user)
2209
2210 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2211
2212 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2213
2214
2215
2216class SliceCredentialList(generics.ListCreateAPIView):
2217 queryset = SliceCredential.objects.select_related().all()
2218 serializer_class = SliceCredentialSerializer
2219 id_serializer_class = SliceCredentialIdSerializer
2220 filter_backends = (filters.DjangoFilterBackend,)
2221 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
2222
2223 def get_serializer_class(self):
2224 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2225 if (no_hyperlinks):
2226 return self.id_serializer_class
2227 else:
2228 return self.serializer_class
2229
2230 def get_queryset(self):
2231 return SliceCredential.select_by_user(self.request.user)
2232
2233 def create(self, request, *args, **kwargs):
2234 #obj = SliceCredential().update(request.DATA)
2235 obj = self.get_object()
2236 obj.caller = request.user
2237 if obj.can_update(request.user):
2238 return super(SliceCredentialList, self).create(request, *args, **kwargs)
2239 else:
2240 return Response(status=status.HTTP_400_BAD_REQUEST)
2241
2242class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2243 queryset = SliceCredential.objects.select_related().all()
2244 serializer_class = SliceCredentialSerializer
2245 id_serializer_class = SliceCredentialIdSerializer
2246
2247 def get_serializer_class(self):
2248 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2249 if (no_hyperlinks):
2250 return self.id_serializer_class
2251 else:
2252 return self.serializer_class
2253
2254 def get_queryset(self):
2255 return SliceCredential.select_by_user(self.request.user)
2256
2257 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2258
2259 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2260
2261
2262
2263class SliverList(generics.ListCreateAPIView):
2264 queryset = Sliver.objects.select_related().all()
2265 serializer_class = SliverSerializer
2266 id_serializer_class = SliverIdSerializer
2267 filter_backends = (filters.DjangoFilterBackend,)
2268 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
2269
2270 def get_serializer_class(self):
2271 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2272 if (no_hyperlinks):
2273 return self.id_serializer_class
2274 else:
2275 return self.serializer_class
2276
2277 def get_queryset(self):
2278 return Sliver.select_by_user(self.request.user)
2279
2280 def create(self, request, *args, **kwargs):
2281 #obj = Sliver().update(request.DATA)
2282 obj = self.get_object()
2283 obj.caller = request.user
2284 if obj.can_update(request.user):
2285 return super(SliverList, self).create(request, *args, **kwargs)
2286 else:
2287 return Response(status=status.HTTP_400_BAD_REQUEST)
2288
2289class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2290 queryset = Sliver.objects.select_related().all()
2291 serializer_class = SliverSerializer
2292 id_serializer_class = SliverIdSerializer
2293
2294 def get_serializer_class(self):
2295 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2296 if (no_hyperlinks):
2297 return self.id_serializer_class
2298 else:
2299 return self.serializer_class
2300
2301 def get_queryset(self):
2302 return Sliver.select_by_user(self.request.user)
2303
2304 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2305
2306 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2307
2308
2309
2310class NodeList(generics.ListCreateAPIView):
2311 queryset = Node.objects.select_related().all()
2312 serializer_class = NodeSerializer
2313 id_serializer_class = NodeIdSerializer
2314 filter_backends = (filters.DjangoFilterBackend,)
2315 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
2316
2317 def get_serializer_class(self):
2318 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2319 if (no_hyperlinks):
2320 return self.id_serializer_class
2321 else:
2322 return self.serializer_class
2323
2324 def get_queryset(self):
2325 return Node.select_by_user(self.request.user)
2326
2327 def create(self, request, *args, **kwargs):
2328 #obj = Node().update(request.DATA)
2329 obj = self.get_object()
2330 obj.caller = request.user
2331 if obj.can_update(request.user):
2332 return super(NodeList, self).create(request, *args, **kwargs)
2333 else:
2334 return Response(status=status.HTTP_400_BAD_REQUEST)
2335
2336class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2337 queryset = Node.objects.select_related().all()
2338 serializer_class = NodeSerializer
2339 id_serializer_class = NodeIdSerializer
2340
2341 def get_serializer_class(self):
2342 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2343 if (no_hyperlinks):
2344 return self.id_serializer_class
2345 else:
2346 return self.serializer_class
2347
2348 def get_queryset(self):
2349 return Node.select_by_user(self.request.user)
2350
2351 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2352
2353 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2354
2355
2356
2357class DashboardViewList(generics.ListCreateAPIView):
2358 queryset = DashboardView.objects.select_related().all()
2359 serializer_class = DashboardViewSerializer
2360 id_serializer_class = DashboardViewIdSerializer
2361 filter_backends = (filters.DjangoFilterBackend,)
2362 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
2363
2364 def get_serializer_class(self):
2365 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2366 if (no_hyperlinks):
2367 return self.id_serializer_class
2368 else:
2369 return self.serializer_class
2370
2371 def get_queryset(self):
2372 return DashboardView.select_by_user(self.request.user)
2373
2374 def create(self, request, *args, **kwargs):
2375 #obj = DashboardView().update(request.DATA)
2376 obj = self.get_object()
2377 obj.caller = request.user
2378 if obj.can_update(request.user):
2379 return super(DashboardViewList, self).create(request, *args, **kwargs)
2380 else:
2381 return Response(status=status.HTTP_400_BAD_REQUEST)
2382
2383class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2384 queryset = DashboardView.objects.select_related().all()
2385 serializer_class = DashboardViewSerializer
2386 id_serializer_class = DashboardViewIdSerializer
2387
2388 def get_serializer_class(self):
2389 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2390 if (no_hyperlinks):
2391 return self.id_serializer_class
2392 else:
2393 return self.serializer_class
2394
2395 def get_queryset(self):
2396 return DashboardView.select_by_user(self.request.user)
2397
2398 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2399
2400 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2401
2402
2403
2404class ImageDeploymentsList(generics.ListCreateAPIView):
2405 queryset = ImageDeployments.objects.select_related().all()
2406 serializer_class = ImageDeploymentsSerializer
2407 id_serializer_class = ImageDeploymentsIdSerializer
2408 filter_backends = (filters.DjangoFilterBackend,)
2409 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
2410
2411 def get_serializer_class(self):
2412 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2413 if (no_hyperlinks):
2414 return self.id_serializer_class
2415 else:
2416 return self.serializer_class
2417
2418 def get_queryset(self):
2419 return ImageDeployments.select_by_user(self.request.user)
2420
2421 def create(self, request, *args, **kwargs):
2422 #obj = ImageDeployments().update(request.DATA)
2423 obj = self.get_object()
2424 obj.caller = request.user
2425 if obj.can_update(request.user):
2426 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
2427 else:
2428 return Response(status=status.HTTP_400_BAD_REQUEST)
2429
2430class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2431 queryset = ImageDeployments.objects.select_related().all()
2432 serializer_class = ImageDeploymentsSerializer
2433 id_serializer_class = ImageDeploymentsIdSerializer
2434
2435 def get_serializer_class(self):
2436 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2437 if (no_hyperlinks):
2438 return self.id_serializer_class
2439 else:
2440 return self.serializer_class
2441
2442 def get_queryset(self):
2443 return ImageDeployments.select_by_user(self.request.user)
2444
2445 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2446
2447 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2448
2449
2450
2451class ReservedResourceList(generics.ListCreateAPIView):
2452 queryset = ReservedResource.objects.select_related().all()
2453 serializer_class = ReservedResourceSerializer
2454 id_serializer_class = ReservedResourceIdSerializer
2455 filter_backends = (filters.DjangoFilterBackend,)
2456 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
2457
2458 def get_serializer_class(self):
2459 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2460 if (no_hyperlinks):
2461 return self.id_serializer_class
2462 else:
2463 return self.serializer_class
2464
2465 def get_queryset(self):
2466 return ReservedResource.select_by_user(self.request.user)
2467
2468 def create(self, request, *args, **kwargs):
2469 #obj = ReservedResource().update(request.DATA)
2470 obj = self.get_object()
2471 obj.caller = request.user
2472 if obj.can_update(request.user):
2473 return super(ReservedResourceList, self).create(request, *args, **kwargs)
2474 else:
2475 return Response(status=status.HTTP_400_BAD_REQUEST)
2476
2477class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2478 queryset = ReservedResource.objects.select_related().all()
2479 serializer_class = ReservedResourceSerializer
2480 id_serializer_class = ReservedResourceIdSerializer
2481
2482 def get_serializer_class(self):
2483 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2484 if (no_hyperlinks):
2485 return self.id_serializer_class
2486 else:
2487 return self.serializer_class
2488
2489 def get_queryset(self):
2490 return ReservedResource.select_by_user(self.request.user)
2491
2492 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2493
2494 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2495
2496
2497
2498class NetworkSliceList(generics.ListCreateAPIView):
2499 queryset = NetworkSlice.objects.select_related().all()
2500 serializer_class = NetworkSliceSerializer
2501 id_serializer_class = NetworkSliceIdSerializer
2502 filter_backends = (filters.DjangoFilterBackend,)
2503 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
2504
2505 def get_serializer_class(self):
2506 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2507 if (no_hyperlinks):
2508 return self.id_serializer_class
2509 else:
2510 return self.serializer_class
2511
2512 def get_queryset(self):
2513 return NetworkSlice.select_by_user(self.request.user)
2514
2515 def create(self, request, *args, **kwargs):
2516 #obj = NetworkSlice().update(request.DATA)
2517 obj = self.get_object()
2518 obj.caller = request.user
2519 if obj.can_update(request.user):
2520 return super(NetworkSliceList, self).create(request, *args, **kwargs)
2521 else:
2522 return Response(status=status.HTTP_400_BAD_REQUEST)
2523
2524class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2525 queryset = NetworkSlice.objects.select_related().all()
2526 serializer_class = NetworkSliceSerializer
2527 id_serializer_class = NetworkSliceIdSerializer
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
2536 def get_queryset(self):
2537 return NetworkSlice.select_by_user(self.request.user)
2538
2539 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2540
2541 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2542
2543
2544
2545class UserDashboardViewList(generics.ListCreateAPIView):
2546 queryset = UserDashboardView.objects.select_related().all()
2547 serializer_class = UserDashboardViewSerializer
2548 id_serializer_class = UserDashboardViewIdSerializer
2549 filter_backends = (filters.DjangoFilterBackend,)
2550 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
2551
2552 def get_serializer_class(self):
2553 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2554 if (no_hyperlinks):
2555 return self.id_serializer_class
2556 else:
2557 return self.serializer_class
2558
2559 def get_queryset(self):
2560 return UserDashboardView.select_by_user(self.request.user)
2561
2562 def create(self, request, *args, **kwargs):
2563 #obj = UserDashboardView().update(request.DATA)
2564 obj = self.get_object()
2565 obj.caller = request.user
2566 if obj.can_update(request.user):
2567 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
2568 else:
2569 return Response(status=status.HTTP_400_BAD_REQUEST)
2570
2571class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2572 queryset = UserDashboardView.objects.select_related().all()
2573 serializer_class = UserDashboardViewSerializer
2574 id_serializer_class = UserDashboardViewIdSerializer
2575
2576 def get_serializer_class(self):
2577 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2578 if (no_hyperlinks):
2579 return self.id_serializer_class
2580 else:
2581 return self.serializer_class
2582
2583 def get_queryset(self):
2584 return UserDashboardView.select_by_user(self.request.user)
2585
2586 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2587
2588 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2589
2590
2591
2592class PlanetStackPrivilegeList(generics.ListCreateAPIView):
2593 queryset = PlanetStackPrivilege.objects.select_related().all()
2594 serializer_class = PlanetStackPrivilegeSerializer
2595 id_serializer_class = PlanetStackPrivilegeIdSerializer
2596 filter_backends = (filters.DjangoFilterBackend,)
2597 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
2598
2599 def get_serializer_class(self):
2600 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2601 if (no_hyperlinks):
2602 return self.id_serializer_class
2603 else:
2604 return self.serializer_class
2605
2606 def get_queryset(self):
2607 return PlanetStackPrivilege.select_by_user(self.request.user)
2608
2609 def create(self, request, *args, **kwargs):
2610 #obj = PlanetStackPrivilege().update(request.DATA)
2611 obj = self.get_object()
2612 obj.caller = request.user
2613 if obj.can_update(request.user):
2614 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
2615 else:
2616 return Response(status=status.HTTP_400_BAD_REQUEST)
2617
2618class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2619 queryset = PlanetStackPrivilege.objects.select_related().all()
2620 serializer_class = PlanetStackPrivilegeSerializer
2621 id_serializer_class = PlanetStackPrivilegeIdSerializer
2622
2623 def get_serializer_class(self):
2624 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2625 if (no_hyperlinks):
2626 return self.id_serializer_class
2627 else:
2628 return self.serializer_class
2629
2630 def get_queryset(self):
2631 return PlanetStackPrivilege.select_by_user(self.request.user)
2632
2633 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2634
2635 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2636
2637
2638
2639class UserList(generics.ListCreateAPIView):
2640 queryset = User.objects.select_related().all()
2641 serializer_class = UserSerializer
2642 id_serializer_class = UserIdSerializer
2643 filter_backends = (filters.DjangoFilterBackend,)
2644 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',)
2645
2646 def get_serializer_class(self):
2647 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2648 if (no_hyperlinks):
2649 return self.id_serializer_class
2650 else:
2651 return self.serializer_class
2652
2653 def get_queryset(self):
2654 return User.select_by_user(self.request.user)
2655
2656 def create(self, request, *args, **kwargs):
2657 #obj = User().update(request.DATA)
2658 obj = self.get_object()
2659 obj.caller = request.user
2660 if obj.can_update(request.user):
2661 return super(UserList, self).create(request, *args, **kwargs)
2662 else:
2663 return Response(status=status.HTTP_400_BAD_REQUEST)
2664
2665class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2666 queryset = User.objects.select_related().all()
2667 serializer_class = UserSerializer
2668 id_serializer_class = UserIdSerializer
2669
2670 def get_serializer_class(self):
2671 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2672 if (no_hyperlinks):
2673 return self.id_serializer_class
2674 else:
2675 return self.serializer_class
2676
2677 def get_queryset(self):
2678 return User.select_by_user(self.request.user)
2679
2680 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2681
2682 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2683
2684
2685
2686class DeploymentList(generics.ListCreateAPIView):
2687 queryset = Deployment.objects.select_related().all()
2688 serializer_class = DeploymentSerializer
2689 id_serializer_class = DeploymentIdSerializer
2690 filter_backends = (filters.DjangoFilterBackend,)
2691 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
2692
2693 def get_serializer_class(self):
2694 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2695 if (no_hyperlinks):
2696 return self.id_serializer_class
2697 else:
2698 return self.serializer_class
2699
2700 def get_queryset(self):
2701 return Deployment.select_by_user(self.request.user)
2702
2703 def create(self, request, *args, **kwargs):
2704 #obj = Deployment().update(request.DATA)
2705 obj = self.get_object()
2706 obj.caller = request.user
2707 if obj.can_update(request.user):
2708 return super(DeploymentList, self).create(request, *args, **kwargs)
2709 else:
2710 return Response(status=status.HTTP_400_BAD_REQUEST)
2711
2712class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2713 queryset = Deployment.objects.select_related().all()
2714 serializer_class = DeploymentSerializer
2715 id_serializer_class = DeploymentIdSerializer
2716
2717 def get_serializer_class(self):
2718 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2719 if (no_hyperlinks):
2720 return self.id_serializer_class
2721 else:
2722 return self.serializer_class
2723
2724 def get_queryset(self):
2725 return Deployment.select_by_user(self.request.user)
2726
2727 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2728
2729 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2730
2731
2732
2733class ReservationList(generics.ListCreateAPIView):
2734 queryset = Reservation.objects.select_related().all()
2735 serializer_class = ReservationSerializer
2736 id_serializer_class = ReservationIdSerializer
2737 filter_backends = (filters.DjangoFilterBackend,)
2738 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
2739
2740 def get_serializer_class(self):
2741 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2742 if (no_hyperlinks):
2743 return self.id_serializer_class
2744 else:
2745 return self.serializer_class
2746
2747 def get_queryset(self):
2748 return Reservation.select_by_user(self.request.user)
2749
2750 def create(self, request, *args, **kwargs):
2751 #obj = Reservation().update(request.DATA)
2752 obj = self.get_object()
2753 obj.caller = request.user
2754 if obj.can_update(request.user):
2755 return super(ReservationList, self).create(request, *args, **kwargs)
2756 else:
2757 return Response(status=status.HTTP_400_BAD_REQUEST)
2758
2759class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2760 queryset = Reservation.objects.select_related().all()
2761 serializer_class = ReservationSerializer
2762 id_serializer_class = ReservationIdSerializer
2763
2764 def get_serializer_class(self):
2765 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2766 if (no_hyperlinks):
2767 return self.id_serializer_class
2768 else:
2769 return self.serializer_class
2770
2771 def get_queryset(self):
2772 return Reservation.select_by_user(self.request.user)
2773
2774 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2775
2776 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2777
2778
2779
2780class SliceDeploymentsList(generics.ListCreateAPIView):
2781 queryset = SliceDeployments.objects.select_related().all()
2782 serializer_class = SliceDeploymentsSerializer
2783 id_serializer_class = SliceDeploymentsIdSerializer
2784 filter_backends = (filters.DjangoFilterBackend,)
2785 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
2786
2787 def get_serializer_class(self):
2788 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2789 if (no_hyperlinks):
2790 return self.id_serializer_class
2791 else:
2792 return self.serializer_class
2793
2794 def get_queryset(self):
2795 return SliceDeployments.select_by_user(self.request.user)
2796
2797 def create(self, request, *args, **kwargs):
2798 #obj = SliceDeployments().update(request.DATA)
2799 obj = self.get_object()
2800 obj.caller = request.user
2801 if obj.can_update(request.user):
2802 return super(SliceDeploymentsList, self).create(request, *args, **kwargs)
2803 else:
2804 return Response(status=status.HTTP_400_BAD_REQUEST)
2805
2806class SliceDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2807 queryset = SliceDeployments.objects.select_related().all()
2808 serializer_class = SliceDeploymentsSerializer
2809 id_serializer_class = SliceDeploymentsIdSerializer
2810
2811 def get_serializer_class(self):
2812 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2813 if (no_hyperlinks):
2814 return self.id_serializer_class
2815 else:
2816 return self.serializer_class
2817
2818 def get_queryset(self):
2819 return SliceDeployments.select_by_user(self.request.user)
2820
2821 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2822
2823 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2824
2825
2826
2827class SitePrivilegeList(generics.ListCreateAPIView):
2828 queryset = SitePrivilege.objects.select_related().all()
2829 serializer_class = SitePrivilegeSerializer
2830 id_serializer_class = SitePrivilegeIdSerializer
2831 filter_backends = (filters.DjangoFilterBackend,)
2832 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
2833
2834 def get_serializer_class(self):
2835 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2836 if (no_hyperlinks):
2837 return self.id_serializer_class
2838 else:
2839 return self.serializer_class
2840
2841 def get_queryset(self):
2842 return SitePrivilege.select_by_user(self.request.user)
2843
2844 def create(self, request, *args, **kwargs):
2845 #obj = SitePrivilege().update(request.DATA)
2846 obj = self.get_object()
2847 obj.caller = request.user
2848 if obj.can_update(request.user):
2849 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
2850 else:
2851 return Response(status=status.HTTP_400_BAD_REQUEST)
2852
2853class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2854 queryset = SitePrivilege.objects.select_related().all()
2855 serializer_class = SitePrivilegeSerializer
2856 id_serializer_class = SitePrivilegeIdSerializer
2857
2858 def get_serializer_class(self):
2859 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2860 if (no_hyperlinks):
2861 return self.id_serializer_class
2862 else:
2863 return self.serializer_class
2864
2865 def get_queryset(self):
2866 return SitePrivilege.select_by_user(self.request.user)
2867
2868 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2869
2870 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2871
2872
2873
2874class PlanetStackList(generics.ListCreateAPIView):
2875 queryset = PlanetStack.objects.select_related().all()
2876 serializer_class = PlanetStackSerializer
2877 id_serializer_class = PlanetStackIdSerializer
2878 filter_backends = (filters.DjangoFilterBackend,)
2879 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
2880
2881 def get_serializer_class(self):
2882 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2883 if (no_hyperlinks):
2884 return self.id_serializer_class
2885 else:
2886 return self.serializer_class
2887
2888 def get_queryset(self):
2889 return PlanetStack.select_by_user(self.request.user)
2890
2891 def create(self, request, *args, **kwargs):
2892 #obj = PlanetStack().update(request.DATA)
2893 obj = self.get_object()
2894 obj.caller = request.user
2895 if obj.can_update(request.user):
2896 return super(PlanetStackList, self).create(request, *args, **kwargs)
2897 else:
2898 return Response(status=status.HTTP_400_BAD_REQUEST)
2899
2900class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2901 queryset = PlanetStack.objects.select_related().all()
2902 serializer_class = PlanetStackSerializer
2903 id_serializer_class = PlanetStackIdSerializer
2904
2905 def get_serializer_class(self):
2906 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2907 if (no_hyperlinks):
2908 return self.id_serializer_class
2909 else:
2910 return self.serializer_class
2911
2912 def get_queryset(self):
2913 return PlanetStack.select_by_user(self.request.user)
2914
2915 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2916
2917 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2918
2919
2920
2921class UserDeploymentsList(generics.ListCreateAPIView):
2922 queryset = UserDeployments.objects.select_related().all()
2923 serializer_class = UserDeploymentsSerializer
2924 id_serializer_class = UserDeploymentsIdSerializer
2925 filter_backends = (filters.DjangoFilterBackend,)
2926 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
2927
2928 def get_serializer_class(self):
2929 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2930 if (no_hyperlinks):
2931 return self.id_serializer_class
2932 else:
2933 return self.serializer_class
2934
2935 def get_queryset(self):
2936 return UserDeployments.select_by_user(self.request.user)
2937
2938 def create(self, request, *args, **kwargs):
2939 #obj = UserDeployments().update(request.DATA)
2940 obj = self.get_object()
2941 obj.caller = request.user
2942 if obj.can_update(request.user):
2943 return super(UserDeploymentsList, self).create(request, *args, **kwargs)
2944 else:
2945 return Response(status=status.HTTP_400_BAD_REQUEST)
2946
2947class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2948 queryset = UserDeployments.objects.select_related().all()
2949 serializer_class = UserDeploymentsSerializer
2950 id_serializer_class = UserDeploymentsIdSerializer
2951
2952 def get_serializer_class(self):
2953 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2954 if (no_hyperlinks):
2955 return self.id_serializer_class
2956 else:
2957 return self.serializer_class
2958
2959 def get_queryset(self):
2960 return UserDeployments.select_by_user(self.request.user)
2961
2962 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2963
2964 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2965
2966
2967
2968class AccountList(generics.ListCreateAPIView):
2969 queryset = Account.objects.select_related().all()
2970 serializer_class = AccountSerializer
2971 id_serializer_class = AccountIdSerializer
2972 filter_backends = (filters.DjangoFilterBackend,)
2973 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
2974
2975 def get_serializer_class(self):
2976 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2977 if (no_hyperlinks):
2978 return self.id_serializer_class
2979 else:
2980 return self.serializer_class
2981
2982 def get_queryset(self):
2983 return Account.select_by_user(self.request.user)
2984
2985 def create(self, request, *args, **kwargs):
2986 #obj = Account().update(request.DATA)
2987 obj = self.get_object()
2988 obj.caller = request.user
2989 if obj.can_update(request.user):
2990 return super(AccountList, self).create(request, *args, **kwargs)
2991 else:
2992 return Response(status=status.HTTP_400_BAD_REQUEST)
2993
2994class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2995 queryset = Account.objects.select_related().all()
2996 serializer_class = AccountSerializer
2997 id_serializer_class = AccountIdSerializer
2998
2999 def get_serializer_class(self):
3000 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3001 if (no_hyperlinks):
3002 return self.id_serializer_class
3003 else:
3004 return self.serializer_class
3005
3006 def get_queryset(self):
3007 return Account.select_by_user(self.request.user)
3008
3009 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3010
3011 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3012
3013
3014
3015class NetworkParameterTypeList(generics.ListCreateAPIView):
3016 queryset = NetworkParameterType.objects.select_related().all()
3017 serializer_class = NetworkParameterTypeSerializer
3018 id_serializer_class = NetworkParameterTypeIdSerializer
3019 filter_backends = (filters.DjangoFilterBackend,)
3020 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
3021
3022 def get_serializer_class(self):
3023 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3024 if (no_hyperlinks):
3025 return self.id_serializer_class
3026 else:
3027 return self.serializer_class
3028
3029 def get_queryset(self):
3030 return NetworkParameterType.select_by_user(self.request.user)
3031
3032 def create(self, request, *args, **kwargs):
3033 #obj = NetworkParameterType().update(request.DATA)
3034 obj = self.get_object()
3035 obj.caller = request.user
3036 if obj.can_update(request.user):
3037 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
3038 else:
3039 return Response(status=status.HTTP_400_BAD_REQUEST)
3040
3041class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3042 queryset = NetworkParameterType.objects.select_related().all()
3043 serializer_class = NetworkParameterTypeSerializer
3044 id_serializer_class = NetworkParameterTypeIdSerializer
3045
3046 def get_serializer_class(self):
3047 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3048 if (no_hyperlinks):
3049 return self.id_serializer_class
3050 else:
3051 return self.serializer_class
3052
3053 def get_queryset(self):
3054 return NetworkParameterType.select_by_user(self.request.user)
3055
3056 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3057
3058 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3059
3060
3061
3062class SiteCredentialList(generics.ListCreateAPIView):
3063 queryset = SiteCredential.objects.select_related().all()
3064 serializer_class = SiteCredentialSerializer
3065 id_serializer_class = SiteCredentialIdSerializer
3066 filter_backends = (filters.DjangoFilterBackend,)
3067 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
3068
3069 def get_serializer_class(self):
3070 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3071 if (no_hyperlinks):
3072 return self.id_serializer_class
3073 else:
3074 return self.serializer_class
3075
3076 def get_queryset(self):
3077 return SiteCredential.select_by_user(self.request.user)
3078
3079 def create(self, request, *args, **kwargs):
3080 #obj = SiteCredential().update(request.DATA)
3081 obj = self.get_object()
3082 obj.caller = request.user
3083 if obj.can_update(request.user):
3084 return super(SiteCredentialList, self).create(request, *args, **kwargs)
3085 else:
3086 return Response(status=status.HTTP_400_BAD_REQUEST)
3087
3088class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3089 queryset = SiteCredential.objects.select_related().all()
3090 serializer_class = SiteCredentialSerializer
3091 id_serializer_class = SiteCredentialIdSerializer
3092
3093 def get_serializer_class(self):
3094 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3095 if (no_hyperlinks):
3096 return self.id_serializer_class
3097 else:
3098 return self.serializer_class
3099
3100 def get_queryset(self):
3101 return SiteCredential.select_by_user(self.request.user)
3102
3103 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3104
3105 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3106
3107
3108
3109class DeploymentPrivilegeList(generics.ListCreateAPIView):
3110 queryset = DeploymentPrivilege.objects.select_related().all()
3111 serializer_class = DeploymentPrivilegeSerializer
3112 id_serializer_class = DeploymentPrivilegeIdSerializer
3113 filter_backends = (filters.DjangoFilterBackend,)
3114 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
3115
3116 def get_serializer_class(self):
3117 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3118 if (no_hyperlinks):
3119 return self.id_serializer_class
3120 else:
3121 return self.serializer_class
3122
3123 def get_queryset(self):
3124 return DeploymentPrivilege.select_by_user(self.request.user)
3125
3126 def create(self, request, *args, **kwargs):
3127 #obj = DeploymentPrivilege().update(request.DATA)
3128 obj = self.get_object()
3129 obj.caller = request.user
3130 if obj.can_update(request.user):
3131 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
3132 else:
3133 return Response(status=status.HTTP_400_BAD_REQUEST)
3134
3135class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3136 queryset = DeploymentPrivilege.objects.select_related().all()
3137 serializer_class = DeploymentPrivilegeSerializer
3138 id_serializer_class = DeploymentPrivilegeIdSerializer
3139
3140 def get_serializer_class(self):
3141 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3142 if (no_hyperlinks):
3143 return self.id_serializer_class
3144 else:
3145 return self.serializer_class
3146
3147 def get_queryset(self):
3148 return DeploymentPrivilege.select_by_user(self.request.user)
3149
3150 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3151
3152 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3153
3154
3155
3156class DeploymentRoleList(generics.ListCreateAPIView):
3157 queryset = DeploymentRole.objects.select_related().all()
3158 serializer_class = DeploymentRoleSerializer
3159 id_serializer_class = DeploymentRoleIdSerializer
3160 filter_backends = (filters.DjangoFilterBackend,)
3161 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3162
3163 def get_serializer_class(self):
3164 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3165 if (no_hyperlinks):
3166 return self.id_serializer_class
3167 else:
3168 return self.serializer_class
3169
3170 def get_queryset(self):
3171 return DeploymentRole.select_by_user(self.request.user)
3172
3173 def create(self, request, *args, **kwargs):
3174 #obj = DeploymentRole().update(request.DATA)
3175 obj = self.get_object()
3176 obj.caller = request.user
3177 if obj.can_update(request.user):
3178 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
3179 else:
3180 return Response(status=status.HTTP_400_BAD_REQUEST)
3181
3182class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3183 queryset = DeploymentRole.objects.select_related().all()
3184 serializer_class = DeploymentRoleSerializer
3185 id_serializer_class = DeploymentRoleIdSerializer
3186
3187 def get_serializer_class(self):
3188 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3189 if (no_hyperlinks):
3190 return self.id_serializer_class
3191 else:
3192 return self.serializer_class
3193
3194 def get_queryset(self):
3195 return DeploymentRole.select_by_user(self.request.user)
3196
3197 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3198
3199 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3200
3201
3202
3203class UserCredentialList(generics.ListCreateAPIView):
3204 queryset = UserCredential.objects.select_related().all()
3205 serializer_class = UserCredentialSerializer
3206 id_serializer_class = UserCredentialIdSerializer
3207 filter_backends = (filters.DjangoFilterBackend,)
3208 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
3209
3210 def get_serializer_class(self):
3211 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3212 if (no_hyperlinks):
3213 return self.id_serializer_class
3214 else:
3215 return self.serializer_class
3216
3217 def get_queryset(self):
3218 return UserCredential.select_by_user(self.request.user)
3219
3220 def create(self, request, *args, **kwargs):
3221 #obj = UserCredential().update(request.DATA)
3222 obj = self.get_object()
3223 obj.caller = request.user
3224 if obj.can_update(request.user):
3225 return super(UserCredentialList, self).create(request, *args, **kwargs)
3226 else:
3227 return Response(status=status.HTTP_400_BAD_REQUEST)
3228
3229class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3230 queryset = UserCredential.objects.select_related().all()
3231 serializer_class = UserCredentialSerializer
3232 id_serializer_class = UserCredentialIdSerializer
3233
3234 def get_serializer_class(self):
3235 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3236 if (no_hyperlinks):
3237 return self.id_serializer_class
3238 else:
3239 return self.serializer_class
3240
3241 def get_queryset(self):
3242 return UserCredential.select_by_user(self.request.user)
3243
3244 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3245
3246 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3247
3248
3249
3250class SiteDeploymentsList(generics.ListCreateAPIView):
3251 queryset = SiteDeployments.objects.select_related().all()
3252 serializer_class = SiteDeploymentsSerializer
3253 id_serializer_class = SiteDeploymentsIdSerializer
3254 filter_backends = (filters.DjangoFilterBackend,)
3255 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
3256
3257 def get_serializer_class(self):
3258 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3259 if (no_hyperlinks):
3260 return self.id_serializer_class
3261 else:
3262 return self.serializer_class
3263
3264 def get_queryset(self):
3265 return SiteDeployments.select_by_user(self.request.user)
3266
3267 def create(self, request, *args, **kwargs):
3268 #obj = SiteDeployments().update(request.DATA)
3269 obj = self.get_object()
3270 obj.caller = request.user
3271 if obj.can_update(request.user):
3272 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
3273 else:
3274 return Response(status=status.HTTP_400_BAD_REQUEST)
3275
3276class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3277 queryset = SiteDeployments.objects.select_related().all()
3278 serializer_class = SiteDeploymentsSerializer
3279 id_serializer_class = SiteDeploymentsIdSerializer
3280
3281 def get_serializer_class(self):
3282 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3283 if (no_hyperlinks):
3284 return self.id_serializer_class
3285 else:
3286 return self.serializer_class
3287
3288 def get_queryset(self):
3289 return SiteDeployments.select_by_user(self.request.user)
3290
3291 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3292
3293 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003294
3295
3296
Scott Baker0caeaf02014-06-19 11:12:55 -07003297class SliceTagList(generics.ListCreateAPIView):
3298 queryset = SliceTag.objects.select_related().all()
3299 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003300 id_serializer_class = SliceTagIdSerializer
3301 filter_backends = (filters.DjangoFilterBackend,)
3302 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
3303
3304 def get_serializer_class(self):
3305 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3306 if (no_hyperlinks):
3307 return self.id_serializer_class
3308 else:
3309 return self.serializer_class
3310
Scott Baker0caeaf02014-06-19 11:12:55 -07003311 def get_queryset(self):
3312 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003313
Scott Baker0caeaf02014-06-19 11:12:55 -07003314 def create(self, request, *args, **kwargs):
3315 #obj = SliceTag().update(request.DATA)
3316 obj = self.get_object()
3317 obj.caller = request.user
3318 if obj.can_update(request.user):
3319 return super(SliceTagList, self).create(request, *args, **kwargs)
3320 else:
3321 return Response(status=status.HTTP_400_BAD_REQUEST)
3322
Scott Baker89a7b7c2014-10-07 00:10:17 -07003323class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003324 queryset = SliceTag.objects.select_related().all()
3325 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003326 id_serializer_class = SliceTagIdSerializer
3327
3328 def get_serializer_class(self):
3329 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3330 if (no_hyperlinks):
3331 return self.id_serializer_class
3332 else:
3333 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003334
3335 def get_queryset(self):
3336 return SliceTag.select_by_user(self.request.user)
3337
Scott Baker89a7b7c2014-10-07 00:10:17 -07003338 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003339
Scott Baker89a7b7c2014-10-07 00:10:17 -07003340 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003341
3342
3343
Scott Baker0caeaf02014-06-19 11:12:55 -07003344class NetworkTemplateList(generics.ListCreateAPIView):
3345 queryset = NetworkTemplate.objects.select_related().all()
3346 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003347 id_serializer_class = NetworkTemplateIdSerializer
3348 filter_backends = (filters.DjangoFilterBackend,)
3349 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
3350
3351 def get_serializer_class(self):
3352 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3353 if (no_hyperlinks):
3354 return self.id_serializer_class
3355 else:
3356 return self.serializer_class
3357
Scott Baker0caeaf02014-06-19 11:12:55 -07003358 def get_queryset(self):
3359 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003360
Scott Baker0caeaf02014-06-19 11:12:55 -07003361 def create(self, request, *args, **kwargs):
3362 #obj = NetworkTemplate().update(request.DATA)
3363 obj = self.get_object()
3364 obj.caller = request.user
3365 if obj.can_update(request.user):
3366 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
3367 else:
3368 return Response(status=status.HTTP_400_BAD_REQUEST)
3369
Scott Baker89a7b7c2014-10-07 00:10:17 -07003370class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003371 queryset = NetworkTemplate.objects.select_related().all()
3372 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003373 id_serializer_class = NetworkTemplateIdSerializer
3374
3375 def get_serializer_class(self):
3376 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3377 if (no_hyperlinks):
3378 return self.id_serializer_class
3379 else:
3380 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003381
3382 def get_queryset(self):
3383 return NetworkTemplate.select_by_user(self.request.user)
3384
Scott Baker89a7b7c2014-10-07 00:10:17 -07003385 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003386
Scott Baker89a7b7c2014-10-07 00:10:17 -07003387 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003388
3389
3390
3391class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003392 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003393 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003394 id_serializer_class = RouterIdSerializer
3395 filter_backends = (filters.DjangoFilterBackend,)
3396 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
3397
3398 def get_serializer_class(self):
3399 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3400 if (no_hyperlinks):
3401 return self.id_serializer_class
3402 else:
3403 return self.serializer_class
3404
Scott Baker0caeaf02014-06-19 11:12:55 -07003405 def get_queryset(self):
3406 return Router.select_by_user(self.request.user)
3407
3408 def create(self, request, *args, **kwargs):
3409 #obj = Router().update(request.DATA)
3410 obj = self.get_object()
3411 obj.caller = request.user
3412 if obj.can_update(request.user):
3413 return super(RouterList, self).create(request, *args, **kwargs)
3414 else:
3415 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003416
Scott Baker89a7b7c2014-10-07 00:10:17 -07003417class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003418 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003419 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003420 id_serializer_class = RouterIdSerializer
3421
3422 def get_serializer_class(self):
3423 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3424 if (no_hyperlinks):
3425 return self.id_serializer_class
3426 else:
3427 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003428
3429 def get_queryset(self):
3430 return Router.select_by_user(self.request.user)
3431
Scott Baker89a7b7c2014-10-07 00:10:17 -07003432 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003433
Scott Baker89a7b7c2014-10-07 00:10:17 -07003434 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003435
3436
3437
Scott Baker0caeaf02014-06-19 11:12:55 -07003438class ServiceResourceList(generics.ListCreateAPIView):
3439 queryset = ServiceResource.objects.select_related().all()
3440 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003441 id_serializer_class = ServiceResourceIdSerializer
3442 filter_backends = (filters.DjangoFilterBackend,)
3443 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
3444
3445 def get_serializer_class(self):
3446 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3447 if (no_hyperlinks):
3448 return self.id_serializer_class
3449 else:
3450 return self.serializer_class
3451
Scott Baker0caeaf02014-06-19 11:12:55 -07003452 def get_queryset(self):
3453 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003454
Scott Baker0caeaf02014-06-19 11:12:55 -07003455 def create(self, request, *args, **kwargs):
3456 #obj = ServiceResource().update(request.DATA)
3457 obj = self.get_object()
3458 obj.caller = request.user
3459 if obj.can_update(request.user):
3460 return super(ServiceResourceList, self).create(request, *args, **kwargs)
3461 else:
3462 return Response(status=status.HTTP_400_BAD_REQUEST)
3463
Scott Baker89a7b7c2014-10-07 00:10:17 -07003464class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003465 queryset = ServiceResource.objects.select_related().all()
3466 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003467 id_serializer_class = ServiceResourceIdSerializer
3468
3469 def get_serializer_class(self):
3470 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3471 if (no_hyperlinks):
3472 return self.id_serializer_class
3473 else:
3474 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003475
3476 def get_queryset(self):
3477 return ServiceResource.select_by_user(self.request.user)
3478
Scott Baker89a7b7c2014-10-07 00:10:17 -07003479 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003480
Scott Baker89a7b7c2014-10-07 00:10:17 -07003481 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003482
3483
3484