blob: 86a5dd3f685aadfdaadc5bf71d6f4d9157ca27bb [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Sapan Bhatiadea39432014-06-13 03:10:36 -04006from core.models import *
7from django.forms import widgets
8
9"""
10 Schema of the generator object:
11 all: Set of all Model objects
12 all_if(regex): Set of Model objects that match regex
13
14 Model object:
15 plural: English plural of object name
16 camel: CamelCase version of object name
17 refs: list of references to other Model objects
18 props: list of properties minus refs
19
20 TODO: Deal with subnets
21"""
22
23# Based on api_root.py
24
25@api_view(['GET'])
26def api_root(request, format=None):
27 return Response({
28 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
29 'images': reverse('image-list', request=request, format=format),
30 'networkparameters': reverse('networkparameter-list', request=request, format=format),
31 'sites': reverse('site-list', request=request, format=format),
32 'sliceroles': reverse('slicerole-list', request=request, format=format),
33 'tags': reverse('tag-list', request=request, format=format),
34 'invoices': reverse('invoice-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040035 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070036 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040037 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070038 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040039 'slices': reverse('slice-list', request=request, format=format),
40 'networks': reverse('network-list', request=request, format=format),
41 'services': reverse('service-list', request=request, format=format),
42 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070043 'payments': reverse('payment-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040044 'charges': reverse('charge-list', request=request, format=format),
45 'roles': reverse('role-list', request=request, format=format),
46 'usableobjects': reverse('usableobject-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070047 'siteroles': reverse('siterole-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040048 'slivers': reverse('sliver-list', request=request, format=format),
49 'nodes': reverse('node-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070050 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
51 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040052 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040053 'networkslices': reverse('networkslice-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070054 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040055 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
56 'users': reverse('user-list', request=request, format=format),
57 'deployments': reverse('deployment-list', request=request, format=format),
58 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070059 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040060 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040061 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070062 'userdeploymentses': reverse('userdeployments-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040063 'accounts': reverse('account-list', request=request, format=format),
64 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
65 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
66 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
67 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker0caeaf02014-06-19 11:12:55 -070068 'projects': reverse('project-list', request=request, format=format),
Sapan Bhatiadea39432014-06-13 03:10:36 -040069 'slicetags': reverse('slicetag-list', request=request, format=format),
70 'networktemplates': reverse('networktemplate-list', request=request, format=format),
71 'routers': reverse('router-list', request=request, format=format),
72 'serviceresources': reverse('serviceresource-list', request=request, format=format),
73
74 })
75
76# Based on serializers.py
77
78
79
Scott Baker0caeaf02014-06-19 11:12:55 -070080class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -040081 id = serializers.Field()
82
Sapan Bhatiadea39432014-06-13 03:10:36 -040083 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -070084 model = ServiceAttribute
85 fields = ('id','created','updated','enacted','name','value','service',)
Sapan Bhatiadea39432014-06-13 03:10:36 -040086
87
88class ImageSerializer(serializers.HyperlinkedModelSerializer):
89 id = serializers.Field()
90
91 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -070092 model = Image
93 fields = ('id','created','updated','enacted','name','disk_format','container_format','path',)
Sapan Bhatiadea39432014-06-13 03:10:36 -040094
95
Scott Baker0caeaf02014-06-19 11:12:55 -070096class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -040097 id = serializers.Field()
98
99 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700100 model = NetworkParameter
Sapan Bhatiadea39432014-06-13 03:10:36 -0400101 fields = ('id','created','updated','enacted','parameter','value','content_type','object_id',)
102
103
104class SiteSerializer(serializers.HyperlinkedModelSerializer):
105 id = serializers.Field()
106
107 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700108 model = Site
109 fields = ('id','created','updated','enacted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400110
111
Scott Baker0caeaf02014-06-19 11:12:55 -0700112class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400113 id = serializers.Field()
114
115 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700116 model = SliceRole
Sapan Bhatiadea39432014-06-13 03:10:36 -0400117 fields = ('id','created','updated','enacted','role',)
118
119
120class TagSerializer(serializers.HyperlinkedModelSerializer):
121 id = serializers.Field()
122
Scott Baker0caeaf02014-06-19 11:12:55 -0700123
124 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
125
126
127
128 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
129
130
131
132 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
133
134
135
136 nodes = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='node-detail')
137
Sapan Bhatiadea39432014-06-13 03:10:36 -0400138
139 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700140 model = Tag
141 fields = ('id','created','updated','enacted','service','name','value','content_type','object_id','sites','slices','slivers','nodes',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400142
143
144class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
145 id = serializers.Field()
146
Sapan Bhatiadea39432014-06-13 03:10:36 -0400147 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700148 model = Invoice
149 fields = ('id','created','updated','enacted','date','account',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400150
151
Scott Baker0caeaf02014-06-19 11:12:55 -0700152class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400153 id = serializers.Field()
154
155 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700156 model = PlanetStackRole
Sapan Bhatiadea39432014-06-13 03:10:36 -0400157 fields = ('id','created','updated','enacted','role',)
158
159
Scott Baker0caeaf02014-06-19 11:12:55 -0700160class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400161 id = serializers.Field()
162
163 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700164 model = SlicePrivilege
165 fields = ('id','created','updated','enacted','user','slice','role',)
166
167
168class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
169 id = serializers.Field()
170
171 class Meta:
172 model = NetworkSliver
173 fields = ('id','created','updated','enacted','network','sliver','ip','port_id',)
174
175
176class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
177 id = serializers.Field()
178
179 class Meta:
180 model = NetworkDeployments
181 fields = ('id','created','updated','enacted','network','deployment','net_id','router_id','subnet_id','subnet',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400182
183
184class SliceSerializer(serializers.HyperlinkedModelSerializer):
185 id = serializers.Field()
186
Sapan Bhatiadea39432014-06-13 03:10:36 -0400187
Scott Baker0caeaf02014-06-19 11:12:55 -0700188 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
189
190
191
192 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
193
194
195
196 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
197
198
199
200 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
201
Sapan Bhatiadea39432014-06-13 03:10:36 -0400202
203 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700204 model = Slice
205 fields = ('id','created','updated','enacted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400206
207
208class NetworkSerializer(serializers.HyperlinkedModelSerializer):
209 id = serializers.Field()
210
Scott Baker0caeaf02014-06-19 11:12:55 -0700211
212 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
213
214
215
216 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
217
218
219
220 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
221
222
223
224 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
225
226
Sapan Bhatiadea39432014-06-13 03:10:36 -0400227 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700228 model = Network
229 fields = ('id','created','updated','enacted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400230
231
232class ServiceSerializer(serializers.HyperlinkedModelSerializer):
233 id = serializers.Field()
234
235 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700236 model = Service
Sapan Bhatiadea39432014-06-13 03:10:36 -0400237 fields = ('id','created','updated','enacted','description','enabled','name','versionNumber','published',)
238
239
Scott Baker0caeaf02014-06-19 11:12:55 -0700240class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400241 id = serializers.Field()
242
243 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700244 model = ServiceClass
Sapan Bhatiadea39432014-06-13 03:10:36 -0400245 fields = ('id','created','updated','enacted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
246
247
Scott Baker0caeaf02014-06-19 11:12:55 -0700248class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400249 id = serializers.Field()
250
251 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700252 model = Payment
253 fields = ('id','created','updated','enacted','account','amount','date',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400254
255
256class ChargeSerializer(serializers.HyperlinkedModelSerializer):
257 id = serializers.Field()
258
Sapan Bhatiadea39432014-06-13 03:10:36 -0400259 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700260 model = Charge
261 fields = ('id','created','updated','enacted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400262
263
264class RoleSerializer(serializers.HyperlinkedModelSerializer):
265 id = serializers.Field()
266
267 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700268 model = Role
Sapan Bhatiadea39432014-06-13 03:10:36 -0400269 fields = ('id','created','updated','enacted','role_type','role','description','content_type',)
270
271
Scott Baker0caeaf02014-06-19 11:12:55 -0700272class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400273 id = serializers.Field()
274
275 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700276 model = UsableObject
Sapan Bhatiadea39432014-06-13 03:10:36 -0400277 fields = ('id','created','updated','enacted','name',)
278
279
Scott Baker0caeaf02014-06-19 11:12:55 -0700280class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
281 id = serializers.Field()
282
283 class Meta:
284 model = SiteRole
285 fields = ('id','created','updated','enacted','role',)
286
287
Sapan Bhatiadea39432014-06-13 03:10:36 -0400288class SliverSerializer(serializers.HyperlinkedModelSerializer):
289 id = serializers.Field()
290
Sapan Bhatiadea39432014-06-13 03:10:36 -0400291
Scott Baker0caeaf02014-06-19 11:12:55 -0700292 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
Sapan Bhatiadea39432014-06-13 03:10:36 -0400293
Scott Baker0caeaf02014-06-19 11:12:55 -0700294
295
296 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
297
298
299
300# upgradeFrom_rel_+ = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='serviceclass-detail')
301
Sapan Bhatiadea39432014-06-13 03:10:36 -0400302
303 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700304 model = Sliver
305 fields = ('id','created','updated','enacted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','userData','networks','networks','upgradeFrom_rel_+',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400306
307
308class NodeSerializer(serializers.HyperlinkedModelSerializer):
309 id = serializers.Field()
310
Sapan Bhatiadea39432014-06-13 03:10:36 -0400311 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700312 model = Node
313 fields = ('id','created','updated','enacted','name','site','deployment',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400314
315
Scott Baker0caeaf02014-06-19 11:12:55 -0700316class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400317 id = serializers.Field()
318
Sapan Bhatiadea39432014-06-13 03:10:36 -0400319 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700320 model = DashboardView
321 fields = ('id','created','updated','enacted','name','url',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400322
323
Scott Baker0caeaf02014-06-19 11:12:55 -0700324class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400325 id = serializers.Field()
326
Sapan Bhatiadea39432014-06-13 03:10:36 -0400327 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700328 model = ImageDeployments
329 fields = ('id','created','updated','enacted','image','deployment','glance_image_id',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400330
331
Scott Baker0caeaf02014-06-19 11:12:55 -0700332class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400333 id = serializers.Field()
334
Sapan Bhatiadea39432014-06-13 03:10:36 -0400335 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700336 model = ReservedResource
337 fields = ('id','created','updated','enacted','sliver','resource','quantity','reservationSet',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400338
339
Scott Baker0caeaf02014-06-19 11:12:55 -0700340class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400341 id = serializers.Field()
342
Scott Baker0caeaf02014-06-19 11:12:55 -0700343 class Meta:
344 model = NetworkSlice
345 fields = ('id','created','updated','enacted','network','slice',)
346
347
348class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
349 id = serializers.Field()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400350
351 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700352 model = UserDashboardView
353 fields = ('id','created','updated','enacted','user','dashboardView','order',)
354
355
356class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
357 id = serializers.Field()
358
359 class Meta:
360 model = PlanetStackPrivilege
361 fields = ('id','created','updated','enacted','user','planetstack','role',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400362
363
364class UserSerializer(serializers.HyperlinkedModelSerializer):
365 id = serializers.Field()
366
Sapan Bhatiadea39432014-06-13 03:10:36 -0400367 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700368 model = User
369 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','timezone',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400370
371
372class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
373 id = serializers.Field()
374
Scott Baker0caeaf02014-06-19 11:12:55 -0700375
376 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
377
378
379
380 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
381
382
Sapan Bhatiadea39432014-06-13 03:10:36 -0400383 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700384 model = Deployment
385 fields = ('id','created','updated','enacted','name','admin_user','admin_password','admin_tenant','auth_url','accessControl','sites','sites',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400386
387
388class ReservationSerializer(serializers.HyperlinkedModelSerializer):
389 id = serializers.Field()
390
Sapan Bhatiadea39432014-06-13 03:10:36 -0400391 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700392 model = Reservation
393 fields = ('id','created','updated','enacted','startTime','slice','duration',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400394
395
Scott Baker0caeaf02014-06-19 11:12:55 -0700396class SliceDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400397 id = serializers.Field()
398
399 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700400 model = SliceDeployments
401 fields = ('id','created','updated','enacted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400402
403
Scott Baker0caeaf02014-06-19 11:12:55 -0700404class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400405 id = serializers.Field()
406
407 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700408 model = SitePrivilege
409 fields = ('id','created','updated','enacted','user','site','role',)
410
411
412class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
413 id = serializers.Field()
414
415 class Meta:
416 model = PlanetStack
Sapan Bhatiadea39432014-06-13 03:10:36 -0400417 fields = ('id','created','updated','enacted','description',)
418
419
Scott Baker0caeaf02014-06-19 11:12:55 -0700420class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
421 id = serializers.Field()
422
423 class Meta:
424 model = UserDeployments
425 fields = ('id','created','updated','enacted','user','deployment','kuser_id',)
426
427
Sapan Bhatiadea39432014-06-13 03:10:36 -0400428class AccountSerializer(serializers.HyperlinkedModelSerializer):
429 id = serializers.Field()
430
Sapan Bhatiadea39432014-06-13 03:10:36 -0400431 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700432 model = Account
433 fields = ('id','created','updated','enacted','site',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400434
435
Scott Baker0caeaf02014-06-19 11:12:55 -0700436class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400437 id = serializers.Field()
438
439 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700440 model = NetworkParameterType
Sapan Bhatiadea39432014-06-13 03:10:36 -0400441 fields = ('id','created','updated','enacted','name','description',)
442
443
Scott Baker0caeaf02014-06-19 11:12:55 -0700444class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400445 id = serializers.Field()
446
447 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700448 model = SiteDeployments
449 fields = ('id','created','updated','enacted','site','deployment','tenant_id',)
450
451
452class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
453 id = serializers.Field()
454
455 class Meta:
456 model = DeploymentPrivilege
457 fields = ('id','created','updated','enacted','user','deployment','role',)
458
459
460class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
461 id = serializers.Field()
462
463 class Meta:
464 model = DeploymentRole
Sapan Bhatiadea39432014-06-13 03:10:36 -0400465 fields = ('id','created','updated','enacted','role',)
466
467
Scott Baker0caeaf02014-06-19 11:12:55 -0700468class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400469 id = serializers.Field()
470
471 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700472 model = Project
473 fields = ('id','created','updated','enacted','name',)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400474
475
Scott Baker0caeaf02014-06-19 11:12:55 -0700476class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400477 id = serializers.Field()
478
479 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700480 model = SliceTag
481 fields = ('id','created','updated','enacted','slice','name','value',)
482
483
484class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
485 id = serializers.Field()
486
487 class Meta:
488 model = NetworkTemplate
Sapan Bhatiadea39432014-06-13 03:10:36 -0400489 fields = ('id','created','updated','enacted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId',)
490
491
492class RouterSerializer(serializers.HyperlinkedModelSerializer):
493 id = serializers.Field()
494
495 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700496 model = Router
Sapan Bhatiadea39432014-06-13 03:10:36 -0400497 fields = ('id','created','updated','enacted','name','owner',)
498
499
Scott Baker0caeaf02014-06-19 11:12:55 -0700500class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Sapan Bhatiadea39432014-06-13 03:10:36 -0400501 id = serializers.Field()
502
503 class Meta:
Scott Baker0caeaf02014-06-19 11:12:55 -0700504 model = ServiceResource
Sapan Bhatiadea39432014-06-13 03:10:36 -0400505 fields = ('id','created','updated','enacted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
506
507
508serializerLookUp = {
509
Scott Baker0caeaf02014-06-19 11:12:55 -0700510 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400511
512 Image: ImageSerializer,
513
Scott Baker0caeaf02014-06-19 11:12:55 -0700514 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400515
516 Site: SiteSerializer,
517
Scott Baker0caeaf02014-06-19 11:12:55 -0700518 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400519
520 Tag: TagSerializer,
521
522 Invoice: InvoiceSerializer,
523
Scott Baker0caeaf02014-06-19 11:12:55 -0700524 PlanetStackRole: PlanetStackRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400525
Scott Baker0caeaf02014-06-19 11:12:55 -0700526 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400527
Scott Baker0caeaf02014-06-19 11:12:55 -0700528 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400529
Scott Baker0caeaf02014-06-19 11:12:55 -0700530 NetworkDeployments: NetworkDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400531
532 Slice: SliceSerializer,
533
534 Network: NetworkSerializer,
535
536 Service: ServiceSerializer,
537
Scott Baker0caeaf02014-06-19 11:12:55 -0700538 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400539
Scott Baker0caeaf02014-06-19 11:12:55 -0700540 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400541
542 Charge: ChargeSerializer,
543
544 Role: RoleSerializer,
545
Scott Baker0caeaf02014-06-19 11:12:55 -0700546 UsableObject: UsableObjectSerializer,
547
548 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400549
550 Sliver: SliverSerializer,
551
552 Node: NodeSerializer,
553
Scott Baker0caeaf02014-06-19 11:12:55 -0700554 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400555
Scott Baker0caeaf02014-06-19 11:12:55 -0700556 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400557
Scott Baker0caeaf02014-06-19 11:12:55 -0700558 ReservedResource: ReservedResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400559
Scott Baker0caeaf02014-06-19 11:12:55 -0700560 NetworkSlice: NetworkSliceSerializer,
561
562 UserDashboardView: UserDashboardViewSerializer,
563
564 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400565
566 User: UserSerializer,
567
568 Deployment: DeploymentSerializer,
569
570 Reservation: ReservationSerializer,
571
Scott Baker0caeaf02014-06-19 11:12:55 -0700572 SliceDeployments: SliceDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400573
Scott Baker0caeaf02014-06-19 11:12:55 -0700574 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400575
Scott Baker0caeaf02014-06-19 11:12:55 -0700576 PlanetStack: PlanetStackSerializer,
577
578 UserDeployments: UserDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400579
580 Account: AccountSerializer,
581
Scott Baker0caeaf02014-06-19 11:12:55 -0700582 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400583
Scott Baker0caeaf02014-06-19 11:12:55 -0700584 SiteDeployments: SiteDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400585
Scott Baker0caeaf02014-06-19 11:12:55 -0700586 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400587
Scott Baker0caeaf02014-06-19 11:12:55 -0700588 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400589
Scott Baker0caeaf02014-06-19 11:12:55 -0700590 Project: ProjectSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400591
Scott Baker0caeaf02014-06-19 11:12:55 -0700592 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400593
Scott Baker0caeaf02014-06-19 11:12:55 -0700594 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400595
596 Router: RouterSerializer,
597
Scott Baker0caeaf02014-06-19 11:12:55 -0700598 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -0400599
600 None: None,
601 }
602
603# Based on core/views/*.py
604
605
Scott Baker0caeaf02014-06-19 11:12:55 -0700606class ServiceAttributeList(generics.ListCreateAPIView):
607 queryset = ServiceAttribute.objects.select_related().all()
608 serializer_class = ServiceAttributeSerializer
609
610 def get_queryset(self):
611 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400612
Scott Baker0caeaf02014-06-19 11:12:55 -0700613 def create(self, request, *args, **kwargs):
614 #obj = ServiceAttribute().update(request.DATA)
615 obj = self.get_object()
616 obj.caller = request.user
617 if obj.can_update(request.user):
618 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
619 else:
620 return Response(status=status.HTTP_400_BAD_REQUEST)
621
622class ServiceAttributeDetail(generics.RetrieveUpdateDestroyAPIView):
623 queryset = ServiceAttribute.objects.select_related().all()
624 serializer_class = ServiceAttributeSerializer
625
626 def get_queryset(self):
627 return ServiceAttribute.select_by_user(self.request.user)
628
629 def update(self, request, *args, **kwargs):
630 obj = self.get_object()
631 if obj.can_update(request.user):
632 return super(ServiceAttributeDetail, self).update(request, *args, **kwargs)
633 else:
634 return Response(status=status.HTTP_400_BAD_REQUEST)
635
636 def destroy(self, request, *args, **kwargs):
637 obj = self.get_object()
638 if obj.can_update(request.user):
639 return super(ServiceAttributeDetail, self).destroy(request, *args, **kwargs)
640 else:
641 return Response(status=status.HTTP_400_BAD_REQUEST)
642
Sapan Bhatiadea39432014-06-13 03:10:36 -0400643
644
645
646class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -0700647 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400648 serializer_class = ImageSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -0700649
650 def get_queryset(self):
651 return Image.select_by_user(self.request.user)
652
653 def create(self, request, *args, **kwargs):
654 #obj = Image().update(request.DATA)
655 obj = self.get_object()
656 obj.caller = request.user
657 if obj.can_update(request.user):
658 return super(ImageList, self).create(request, *args, **kwargs)
659 else:
660 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400661
662class ImageDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -0700663 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400664 serializer_class = ImageSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -0700665
666 def get_queryset(self):
667 return Image.select_by_user(self.request.user)
668
669 def update(self, request, *args, **kwargs):
670 obj = self.get_object()
671 if obj.can_update(request.user):
672 return super(ImageDetail, self).update(request, *args, **kwargs)
673 else:
674 return Response(status=status.HTTP_400_BAD_REQUEST)
675
676 def destroy(self, request, *args, **kwargs):
677 obj = self.get_object()
678 if obj.can_update(request.user):
679 return super(ImageDetail, self).destroy(request, *args, **kwargs)
680 else:
681 return Response(status=status.HTTP_400_BAD_REQUEST)
682
Sapan Bhatiadea39432014-06-13 03:10:36 -0400683
684
685
Scott Baker0caeaf02014-06-19 11:12:55 -0700686class NetworkParameterList(generics.ListCreateAPIView):
687 queryset = NetworkParameter.objects.select_related().all()
688 serializer_class = NetworkParameterSerializer
689
690 def get_queryset(self):
691 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400692
Scott Baker0caeaf02014-06-19 11:12:55 -0700693 def create(self, request, *args, **kwargs):
694 #obj = NetworkParameter().update(request.DATA)
695 obj = self.get_object()
696 obj.caller = request.user
697 if obj.can_update(request.user):
698 return super(NetworkParameterList, self).create(request, *args, **kwargs)
699 else:
700 return Response(status=status.HTTP_400_BAD_REQUEST)
701
702class NetworkParameterDetail(generics.RetrieveUpdateDestroyAPIView):
703 queryset = NetworkParameter.objects.select_related().all()
704 serializer_class = NetworkParameterSerializer
705
706 def get_queryset(self):
707 return NetworkParameter.select_by_user(self.request.user)
708
709 def update(self, request, *args, **kwargs):
710 obj = self.get_object()
711 if obj.can_update(request.user):
712 return super(NetworkParameterDetail, self).update(request, *args, **kwargs)
713 else:
714 return Response(status=status.HTTP_400_BAD_REQUEST)
715
716 def destroy(self, request, *args, **kwargs):
717 obj = self.get_object()
718 if obj.can_update(request.user):
719 return super(NetworkParameterDetail, self).destroy(request, *args, **kwargs)
720 else:
721 return Response(status=status.HTTP_400_BAD_REQUEST)
722
Sapan Bhatiadea39432014-06-13 03:10:36 -0400723
724
725
726class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -0700727 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400728 serializer_class = SiteSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -0700729
730 def get_queryset(self):
731 return Site.select_by_user(self.request.user)
732
733 def create(self, request, *args, **kwargs):
734 #obj = Site().update(request.DATA)
735 obj = self.get_object()
736 obj.caller = request.user
737 if obj.can_update(request.user):
738 return super(SiteList, self).create(request, *args, **kwargs)
739 else:
740 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400741
742class SiteDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -0700743 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400744 serializer_class = SiteSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -0700745
746 def get_queryset(self):
747 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400748
Scott Baker0caeaf02014-06-19 11:12:55 -0700749 def update(self, request, *args, **kwargs):
750 obj = self.get_object()
751 if obj.can_update(request.user):
752 return super(SiteDetail, self).update(request, *args, **kwargs)
753 else:
754 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400755
Scott Baker0caeaf02014-06-19 11:12:55 -0700756 def destroy(self, request, *args, **kwargs):
757 obj = self.get_object()
758 if obj.can_update(request.user):
759 return super(SiteDetail, self).destroy(request, *args, **kwargs)
760 else:
761 return Response(status=status.HTTP_400_BAD_REQUEST)
762
763
764
765
766class SliceRoleList(generics.ListCreateAPIView):
767 queryset = SliceRole.objects.select_related().all()
768 serializer_class = SliceRoleSerializer
769
770 def get_queryset(self):
771 return SliceRole.select_by_user(self.request.user)
772
773 def create(self, request, *args, **kwargs):
774 #obj = SliceRole().update(request.DATA)
775 obj = self.get_object()
776 obj.caller = request.user
777 if obj.can_update(request.user):
778 return super(SliceRoleList, self).create(request, *args, **kwargs)
779 else:
780 return Response(status=status.HTTP_400_BAD_REQUEST)
781
782class SliceRoleDetail(generics.RetrieveUpdateDestroyAPIView):
783 queryset = SliceRole.objects.select_related().all()
784 serializer_class = SliceRoleSerializer
785
786 def get_queryset(self):
787 return SliceRole.select_by_user(self.request.user)
788
789 def update(self, request, *args, **kwargs):
790 obj = self.get_object()
791 if obj.can_update(request.user):
792 return super(SliceRoleDetail, self).update(request, *args, **kwargs)
793 else:
794 return Response(status=status.HTTP_400_BAD_REQUEST)
795
796 def destroy(self, request, *args, **kwargs):
797 obj = self.get_object()
798 if obj.can_update(request.user):
799 return super(SliceRoleDetail, self).destroy(request, *args, **kwargs)
800 else:
801 return Response(status=status.HTTP_400_BAD_REQUEST)
802
Sapan Bhatiadea39432014-06-13 03:10:36 -0400803
804
805
806class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -0700807 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400808 serializer_class = TagSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -0700809
810 def get_queryset(self):
811 return Tag.select_by_user(self.request.user)
812
813 def create(self, request, *args, **kwargs):
814 #obj = Tag().update(request.DATA)
815 obj = self.get_object()
816 obj.caller = request.user
817 if obj.can_update(request.user):
818 return super(TagList, self).create(request, *args, **kwargs)
819 else:
820 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400821
822class TagDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -0700823 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400824 serializer_class = TagSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -0700825
826 def get_queryset(self):
827 return Tag.select_by_user(self.request.user)
828
829 def update(self, request, *args, **kwargs):
830 obj = self.get_object()
831 if obj.can_update(request.user):
832 return super(TagDetail, self).update(request, *args, **kwargs)
833 else:
834 return Response(status=status.HTTP_400_BAD_REQUEST)
835
836 def destroy(self, request, *args, **kwargs):
837 obj = self.get_object()
838 if obj.can_update(request.user):
839 return super(TagDetail, self).destroy(request, *args, **kwargs)
840 else:
841 return Response(status=status.HTTP_400_BAD_REQUEST)
842
Sapan Bhatiadea39432014-06-13 03:10:36 -0400843
844
845
846class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -0700847 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400848 serializer_class = InvoiceSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -0700849
850 def get_queryset(self):
851 return Invoice.select_by_user(self.request.user)
852
853 def create(self, request, *args, **kwargs):
854 #obj = Invoice().update(request.DATA)
855 obj = self.get_object()
856 obj.caller = request.user
857 if obj.can_update(request.user):
858 return super(InvoiceList, self).create(request, *args, **kwargs)
859 else:
860 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400861
862class InvoiceDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -0700863 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -0400864 serializer_class = InvoiceSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -0700865
866 def get_queryset(self):
867 return Invoice.select_by_user(self.request.user)
868
869 def update(self, request, *args, **kwargs):
870 obj = self.get_object()
871 if obj.can_update(request.user):
872 return super(InvoiceDetail, self).update(request, *args, **kwargs)
873 else:
874 return Response(status=status.HTTP_400_BAD_REQUEST)
875
876 def destroy(self, request, *args, **kwargs):
877 obj = self.get_object()
878 if obj.can_update(request.user):
879 return super(InvoiceDetail, self).destroy(request, *args, **kwargs)
880 else:
881 return Response(status=status.HTTP_400_BAD_REQUEST)
882
Sapan Bhatiadea39432014-06-13 03:10:36 -0400883
884
885
Scott Baker0caeaf02014-06-19 11:12:55 -0700886class PlanetStackRoleList(generics.ListCreateAPIView):
887 queryset = PlanetStackRole.objects.select_related().all()
888 serializer_class = PlanetStackRoleSerializer
889
890 def get_queryset(self):
891 return PlanetStackRole.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400892
Scott Baker0caeaf02014-06-19 11:12:55 -0700893 def create(self, request, *args, **kwargs):
894 #obj = PlanetStackRole().update(request.DATA)
895 obj = self.get_object()
896 obj.caller = request.user
897 if obj.can_update(request.user):
898 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
899 else:
900 return Response(status=status.HTTP_400_BAD_REQUEST)
901
902class PlanetStackRoleDetail(generics.RetrieveUpdateDestroyAPIView):
903 queryset = PlanetStackRole.objects.select_related().all()
904 serializer_class = PlanetStackRoleSerializer
905
906 def get_queryset(self):
907 return PlanetStackRole.select_by_user(self.request.user)
908
909 def update(self, request, *args, **kwargs):
910 obj = self.get_object()
911 if obj.can_update(request.user):
912 return super(PlanetStackRoleDetail, self).update(request, *args, **kwargs)
913 else:
914 return Response(status=status.HTTP_400_BAD_REQUEST)
915
916 def destroy(self, request, *args, **kwargs):
917 obj = self.get_object()
918 if obj.can_update(request.user):
919 return super(PlanetStackRoleDetail, self).destroy(request, *args, **kwargs)
920 else:
921 return Response(status=status.HTTP_400_BAD_REQUEST)
922
Sapan Bhatiadea39432014-06-13 03:10:36 -0400923
924
925
Scott Baker0caeaf02014-06-19 11:12:55 -0700926class SlicePrivilegeList(generics.ListCreateAPIView):
927 queryset = SlicePrivilege.objects.select_related().all()
928 serializer_class = SlicePrivilegeSerializer
929
930 def get_queryset(self):
931 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400932
Scott Baker0caeaf02014-06-19 11:12:55 -0700933 def create(self, request, *args, **kwargs):
934 #obj = SlicePrivilege().update(request.DATA)
935 obj = self.get_object()
936 obj.caller = request.user
937 if obj.can_update(request.user):
938 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
939 else:
940 return Response(status=status.HTTP_400_BAD_REQUEST)
941
942class SlicePrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
943 queryset = SlicePrivilege.objects.select_related().all()
944 serializer_class = SlicePrivilegeSerializer
945
946 def get_queryset(self):
947 return SlicePrivilege.select_by_user(self.request.user)
948
949 def update(self, request, *args, **kwargs):
950 obj = self.get_object()
951 if obj.can_update(request.user):
952 return super(SlicePrivilegeDetail, self).update(request, *args, **kwargs)
953 else:
954 return Response(status=status.HTTP_400_BAD_REQUEST)
955
956 def destroy(self, request, *args, **kwargs):
957 obj = self.get_object()
958 if obj.can_update(request.user):
959 return super(SlicePrivilegeDetail, self).destroy(request, *args, **kwargs)
960 else:
961 return Response(status=status.HTTP_400_BAD_REQUEST)
962
Sapan Bhatiadea39432014-06-13 03:10:36 -0400963
964
965
Scott Baker0caeaf02014-06-19 11:12:55 -0700966class NetworkSliverList(generics.ListCreateAPIView):
967 queryset = NetworkSliver.objects.select_related().all()
968 serializer_class = NetworkSliverSerializer
969
970 def get_queryset(self):
971 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -0400972
Scott Baker0caeaf02014-06-19 11:12:55 -0700973 def create(self, request, *args, **kwargs):
974 #obj = NetworkSliver().update(request.DATA)
975 obj = self.get_object()
976 obj.caller = request.user
977 if obj.can_update(request.user):
978 return super(NetworkSliverList, self).create(request, *args, **kwargs)
979 else:
980 return Response(status=status.HTTP_400_BAD_REQUEST)
981
982class NetworkSliverDetail(generics.RetrieveUpdateDestroyAPIView):
983 queryset = NetworkSliver.objects.select_related().all()
984 serializer_class = NetworkSliverSerializer
985
986 def get_queryset(self):
987 return NetworkSliver.select_by_user(self.request.user)
988
989 def update(self, request, *args, **kwargs):
990 obj = self.get_object()
991 if obj.can_update(request.user):
992 return super(NetworkSliverDetail, self).update(request, *args, **kwargs)
993 else:
994 return Response(status=status.HTTP_400_BAD_REQUEST)
995
996 def destroy(self, request, *args, **kwargs):
997 obj = self.get_object()
998 if obj.can_update(request.user):
999 return super(NetworkSliverDetail, self).destroy(request, *args, **kwargs)
1000 else:
1001 return Response(status=status.HTTP_400_BAD_REQUEST)
1002
Sapan Bhatiadea39432014-06-13 03:10:36 -04001003
1004
1005
Scott Baker0caeaf02014-06-19 11:12:55 -07001006class NetworkDeploymentsList(generics.ListCreateAPIView):
1007 queryset = NetworkDeployments.objects.select_related().all()
1008 serializer_class = NetworkDeploymentsSerializer
1009
1010 def get_queryset(self):
1011 return NetworkDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001012
Scott Baker0caeaf02014-06-19 11:12:55 -07001013 def create(self, request, *args, **kwargs):
1014 #obj = NetworkDeployments().update(request.DATA)
1015 obj = self.get_object()
1016 obj.caller = request.user
1017 if obj.can_update(request.user):
1018 return super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
1019 else:
1020 return Response(status=status.HTTP_400_BAD_REQUEST)
1021
1022class NetworkDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
1023 queryset = NetworkDeployments.objects.select_related().all()
1024 serializer_class = NetworkDeploymentsSerializer
1025
1026 def get_queryset(self):
1027 return NetworkDeployments.select_by_user(self.request.user)
1028
1029 def update(self, request, *args, **kwargs):
1030 obj = self.get_object()
1031 if obj.can_update(request.user):
1032 return super(NetworkDeploymentsDetail, self).update(request, *args, **kwargs)
1033 else:
1034 return Response(status=status.HTTP_400_BAD_REQUEST)
1035
1036 def destroy(self, request, *args, **kwargs):
1037 obj = self.get_object()
1038 if obj.can_update(request.user):
1039 return super(NetworkDeploymentsDetail, self).destroy(request, *args, **kwargs)
1040 else:
1041 return Response(status=status.HTTP_400_BAD_REQUEST)
1042
Sapan Bhatiadea39432014-06-13 03:10:36 -04001043
1044
1045
1046class SliceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001047 queryset = Slice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001048 serializer_class = SliceSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001049
1050 def get_queryset(self):
1051 return Slice.select_by_user(self.request.user)
1052
1053 def create(self, request, *args, **kwargs):
1054 #obj = Slice().update(request.DATA)
1055 obj = self.get_object()
1056 obj.caller = request.user
1057 if obj.can_update(request.user):
1058 return super(SliceList, self).create(request, *args, **kwargs)
1059 else:
1060 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001061
1062class SliceDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001063 queryset = Slice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001064 serializer_class = SliceSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001065
1066 def get_queryset(self):
1067 return Slice.select_by_user(self.request.user)
1068
1069 def update(self, request, *args, **kwargs):
1070 obj = self.get_object()
1071 if obj.can_update(request.user):
1072 return super(SliceDetail, self).update(request, *args, **kwargs)
1073 else:
1074 return Response(status=status.HTTP_400_BAD_REQUEST)
1075
1076 def destroy(self, request, *args, **kwargs):
1077 obj = self.get_object()
1078 if obj.can_update(request.user):
1079 return super(SliceDetail, self).destroy(request, *args, **kwargs)
1080 else:
1081 return Response(status=status.HTTP_400_BAD_REQUEST)
1082
Sapan Bhatiadea39432014-06-13 03:10:36 -04001083
1084
1085
1086class NetworkList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001087 queryset = Network.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001088 serializer_class = NetworkSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001089
1090 def get_queryset(self):
1091 return Network.select_by_user(self.request.user)
1092
1093 def create(self, request, *args, **kwargs):
1094 #obj = Network().update(request.DATA)
1095 obj = self.get_object()
1096 obj.caller = request.user
1097 if obj.can_update(request.user):
1098 return super(NetworkList, self).create(request, *args, **kwargs)
1099 else:
1100 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001101
1102class NetworkDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001103 queryset = Network.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001104 serializer_class = NetworkSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001105
1106 def get_queryset(self):
1107 return Network.select_by_user(self.request.user)
1108
1109 def update(self, request, *args, **kwargs):
1110 obj = self.get_object()
1111 if obj.can_update(request.user):
1112 return super(NetworkDetail, self).update(request, *args, **kwargs)
1113 else:
1114 return Response(status=status.HTTP_400_BAD_REQUEST)
1115
1116 def destroy(self, request, *args, **kwargs):
1117 obj = self.get_object()
1118 if obj.can_update(request.user):
1119 return super(NetworkDetail, self).destroy(request, *args, **kwargs)
1120 else:
1121 return Response(status=status.HTTP_400_BAD_REQUEST)
1122
Sapan Bhatiadea39432014-06-13 03:10:36 -04001123
1124
1125
1126class ServiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001127 queryset = Service.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001128 serializer_class = ServiceSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001129
1130 def get_queryset(self):
1131 return Service.select_by_user(self.request.user)
1132
1133 def create(self, request, *args, **kwargs):
1134 #obj = Service().update(request.DATA)
1135 obj = self.get_object()
1136 obj.caller = request.user
1137 if obj.can_update(request.user):
1138 return super(ServiceList, self).create(request, *args, **kwargs)
1139 else:
1140 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001141
1142class ServiceDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001143 queryset = Service.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001144 serializer_class = ServiceSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001145
1146 def get_queryset(self):
1147 return Service.select_by_user(self.request.user)
1148
1149 def update(self, request, *args, **kwargs):
1150 obj = self.get_object()
1151 if obj.can_update(request.user):
1152 return super(ServiceDetail, self).update(request, *args, **kwargs)
1153 else:
1154 return Response(status=status.HTTP_400_BAD_REQUEST)
1155
1156 def destroy(self, request, *args, **kwargs):
1157 obj = self.get_object()
1158 if obj.can_update(request.user):
1159 return super(ServiceDetail, self).destroy(request, *args, **kwargs)
1160 else:
1161 return Response(status=status.HTTP_400_BAD_REQUEST)
1162
Sapan Bhatiadea39432014-06-13 03:10:36 -04001163
1164
1165
Scott Baker0caeaf02014-06-19 11:12:55 -07001166class ServiceClassList(generics.ListCreateAPIView):
1167 queryset = ServiceClass.objects.select_related().all()
1168 serializer_class = ServiceClassSerializer
1169
1170 def get_queryset(self):
1171 return ServiceClass.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001172
Scott Baker0caeaf02014-06-19 11:12:55 -07001173 def create(self, request, *args, **kwargs):
1174 #obj = ServiceClass().update(request.DATA)
1175 obj = self.get_object()
1176 obj.caller = request.user
1177 if obj.can_update(request.user):
1178 return super(ServiceClassList, self).create(request, *args, **kwargs)
1179 else:
1180 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001181
Scott Baker0caeaf02014-06-19 11:12:55 -07001182class ServiceClassDetail(generics.RetrieveUpdateDestroyAPIView):
1183 queryset = ServiceClass.objects.select_related().all()
1184 serializer_class = ServiceClassSerializer
1185
1186 def get_queryset(self):
1187 return ServiceClass.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001188
Scott Baker0caeaf02014-06-19 11:12:55 -07001189 def update(self, request, *args, **kwargs):
1190 obj = self.get_object()
1191 if obj.can_update(request.user):
1192 return super(ServiceClassDetail, self).update(request, *args, **kwargs)
1193 else:
1194 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001195
Scott Baker0caeaf02014-06-19 11:12:55 -07001196 def destroy(self, request, *args, **kwargs):
1197 obj = self.get_object()
1198 if obj.can_update(request.user):
1199 return super(ServiceClassDetail, self).destroy(request, *args, **kwargs)
1200 else:
1201 return Response(status=status.HTTP_400_BAD_REQUEST)
1202
Sapan Bhatiadea39432014-06-13 03:10:36 -04001203
1204
1205
1206class PaymentList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001207 queryset = Payment.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001208 serializer_class = PaymentSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001209
1210 def get_queryset(self):
1211 return Payment.select_by_user(self.request.user)
1212
1213 def create(self, request, *args, **kwargs):
1214 #obj = Payment().update(request.DATA)
1215 obj = self.get_object()
1216 obj.caller = request.user
1217 if obj.can_update(request.user):
1218 return super(PaymentList, self).create(request, *args, **kwargs)
1219 else:
1220 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001221
1222class PaymentDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001223 queryset = Payment.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001224 serializer_class = PaymentSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001225
1226 def get_queryset(self):
1227 return Payment.select_by_user(self.request.user)
1228
1229 def update(self, request, *args, **kwargs):
1230 obj = self.get_object()
1231 if obj.can_update(request.user):
1232 return super(PaymentDetail, self).update(request, *args, **kwargs)
1233 else:
1234 return Response(status=status.HTTP_400_BAD_REQUEST)
1235
1236 def destroy(self, request, *args, **kwargs):
1237 obj = self.get_object()
1238 if obj.can_update(request.user):
1239 return super(PaymentDetail, self).destroy(request, *args, **kwargs)
1240 else:
1241 return Response(status=status.HTTP_400_BAD_REQUEST)
1242
Sapan Bhatiadea39432014-06-13 03:10:36 -04001243
1244
1245
Scott Baker0caeaf02014-06-19 11:12:55 -07001246class ChargeList(generics.ListCreateAPIView):
1247 queryset = Charge.objects.select_related().all()
1248 serializer_class = ChargeSerializer
1249
1250 def get_queryset(self):
1251 return Charge.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001252
Scott Baker0caeaf02014-06-19 11:12:55 -07001253 def create(self, request, *args, **kwargs):
1254 #obj = Charge().update(request.DATA)
1255 obj = self.get_object()
1256 obj.caller = request.user
1257 if obj.can_update(request.user):
1258 return super(ChargeList, self).create(request, *args, **kwargs)
1259 else:
1260 return Response(status=status.HTTP_400_BAD_REQUEST)
1261
1262class ChargeDetail(generics.RetrieveUpdateDestroyAPIView):
1263 queryset = Charge.objects.select_related().all()
1264 serializer_class = ChargeSerializer
1265
1266 def get_queryset(self):
1267 return Charge.select_by_user(self.request.user)
1268
1269 def update(self, request, *args, **kwargs):
1270 obj = self.get_object()
1271 if obj.can_update(request.user):
1272 return super(ChargeDetail, self).update(request, *args, **kwargs)
1273 else:
1274 return Response(status=status.HTTP_400_BAD_REQUEST)
1275
1276 def destroy(self, request, *args, **kwargs):
1277 obj = self.get_object()
1278 if obj.can_update(request.user):
1279 return super(ChargeDetail, self).destroy(request, *args, **kwargs)
1280 else:
1281 return Response(status=status.HTTP_400_BAD_REQUEST)
1282
Sapan Bhatiadea39432014-06-13 03:10:36 -04001283
1284
1285
Scott Baker0caeaf02014-06-19 11:12:55 -07001286class RoleList(generics.ListCreateAPIView):
1287 queryset = Role.objects.select_related().all()
1288 serializer_class = RoleSerializer
1289
1290 def get_queryset(self):
1291 return Role.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 = Role().update(request.DATA)
1295 obj = self.get_object()
1296 obj.caller = request.user
1297 if obj.can_update(request.user):
1298 return super(RoleList, self).create(request, *args, **kwargs)
1299 else:
1300 return Response(status=status.HTTP_400_BAD_REQUEST)
1301
1302class RoleDetail(generics.RetrieveUpdateDestroyAPIView):
1303 queryset = Role.objects.select_related().all()
1304 serializer_class = RoleSerializer
1305
1306 def get_queryset(self):
1307 return Role.select_by_user(self.request.user)
1308
1309 def update(self, request, *args, **kwargs):
1310 obj = self.get_object()
1311 if obj.can_update(request.user):
1312 return super(RoleDetail, self).update(request, *args, **kwargs)
1313 else:
1314 return Response(status=status.HTTP_400_BAD_REQUEST)
1315
1316 def destroy(self, request, *args, **kwargs):
1317 obj = self.get_object()
1318 if obj.can_update(request.user):
1319 return super(RoleDetail, self).destroy(request, *args, **kwargs)
1320 else:
1321 return Response(status=status.HTTP_400_BAD_REQUEST)
1322
1323
1324
1325
1326class UsableObjectList(generics.ListCreateAPIView):
1327 queryset = UsableObject.objects.select_related().all()
1328 serializer_class = UsableObjectSerializer
1329
1330 def get_queryset(self):
1331 return UsableObject.select_by_user(self.request.user)
1332
1333 def create(self, request, *args, **kwargs):
1334 #obj = UsableObject().update(request.DATA)
1335 obj = self.get_object()
1336 obj.caller = request.user
1337 if obj.can_update(request.user):
1338 return super(UsableObjectList, self).create(request, *args, **kwargs)
1339 else:
1340 return Response(status=status.HTTP_400_BAD_REQUEST)
1341
1342class UsableObjectDetail(generics.RetrieveUpdateDestroyAPIView):
1343 queryset = UsableObject.objects.select_related().all()
1344 serializer_class = UsableObjectSerializer
1345
1346 def get_queryset(self):
1347 return UsableObject.select_by_user(self.request.user)
1348
1349 def update(self, request, *args, **kwargs):
1350 obj = self.get_object()
1351 if obj.can_update(request.user):
1352 return super(UsableObjectDetail, self).update(request, *args, **kwargs)
1353 else:
1354 return Response(status=status.HTTP_400_BAD_REQUEST)
1355
1356 def destroy(self, request, *args, **kwargs):
1357 obj = self.get_object()
1358 if obj.can_update(request.user):
1359 return super(UsableObjectDetail, self).destroy(request, *args, **kwargs)
1360 else:
1361 return Response(status=status.HTTP_400_BAD_REQUEST)
1362
1363
1364
1365
1366class SiteRoleList(generics.ListCreateAPIView):
1367 queryset = SiteRole.objects.select_related().all()
1368 serializer_class = SiteRoleSerializer
1369
1370 def get_queryset(self):
1371 return SiteRole.select_by_user(self.request.user)
1372
1373 def create(self, request, *args, **kwargs):
1374 #obj = SiteRole().update(request.DATA)
1375 obj = self.get_object()
1376 obj.caller = request.user
1377 if obj.can_update(request.user):
1378 return super(SiteRoleList, self).create(request, *args, **kwargs)
1379 else:
1380 return Response(status=status.HTTP_400_BAD_REQUEST)
1381
1382class SiteRoleDetail(generics.RetrieveUpdateDestroyAPIView):
1383 queryset = SiteRole.objects.select_related().all()
1384 serializer_class = SiteRoleSerializer
1385
1386 def get_queryset(self):
1387 return SiteRole.select_by_user(self.request.user)
1388
1389 def update(self, request, *args, **kwargs):
1390 obj = self.get_object()
1391 if obj.can_update(request.user):
1392 return super(SiteRoleDetail, self).update(request, *args, **kwargs)
1393 else:
1394 return Response(status=status.HTTP_400_BAD_REQUEST)
1395
1396 def destroy(self, request, *args, **kwargs):
1397 obj = self.get_object()
1398 if obj.can_update(request.user):
1399 return super(SiteRoleDetail, self).destroy(request, *args, **kwargs)
1400 else:
1401 return Response(status=status.HTTP_400_BAD_REQUEST)
1402
1403
1404
1405
1406class SliverList(generics.ListCreateAPIView):
1407 queryset = Sliver.objects.select_related().all()
1408 serializer_class = SliverSerializer
1409
1410 def get_queryset(self):
1411 return Sliver.select_by_user(self.request.user)
1412
1413 def create(self, request, *args, **kwargs):
1414 #obj = Sliver().update(request.DATA)
1415 obj = self.get_object()
1416 obj.caller = request.user
1417 if obj.can_update(request.user):
1418 return super(SliverList, self).create(request, *args, **kwargs)
1419 else:
1420 return Response(status=status.HTTP_400_BAD_REQUEST)
1421
1422class SliverDetail(generics.RetrieveUpdateDestroyAPIView):
1423 queryset = Sliver.objects.select_related().all()
1424 serializer_class = SliverSerializer
1425
1426 def get_queryset(self):
1427 return Sliver.select_by_user(self.request.user)
1428
1429 def update(self, request, *args, **kwargs):
1430 obj = self.get_object()
1431 if obj.can_update(request.user):
1432 return super(SliverDetail, self).update(request, *args, **kwargs)
1433 else:
1434 return Response(status=status.HTTP_400_BAD_REQUEST)
1435
1436 def destroy(self, request, *args, **kwargs):
1437 obj = self.get_object()
1438 if obj.can_update(request.user):
1439 return super(SliverDetail, self).destroy(request, *args, **kwargs)
1440 else:
1441 return Response(status=status.HTTP_400_BAD_REQUEST)
1442
1443
1444
1445
1446class NodeList(generics.ListCreateAPIView):
1447 queryset = Node.objects.select_related().all()
1448 serializer_class = NodeSerializer
1449
1450 def get_queryset(self):
1451 return Node.select_by_user(self.request.user)
1452
1453 def create(self, request, *args, **kwargs):
1454 #obj = Node().update(request.DATA)
1455 obj = self.get_object()
1456 obj.caller = request.user
1457 if obj.can_update(request.user):
1458 return super(NodeList, self).create(request, *args, **kwargs)
1459 else:
1460 return Response(status=status.HTTP_400_BAD_REQUEST)
1461
1462class NodeDetail(generics.RetrieveUpdateDestroyAPIView):
1463 queryset = Node.objects.select_related().all()
1464 serializer_class = NodeSerializer
1465
1466 def get_queryset(self):
1467 return Node.select_by_user(self.request.user)
1468
1469 def update(self, request, *args, **kwargs):
1470 obj = self.get_object()
1471 if obj.can_update(request.user):
1472 return super(NodeDetail, self).update(request, *args, **kwargs)
1473 else:
1474 return Response(status=status.HTTP_400_BAD_REQUEST)
1475
1476 def destroy(self, request, *args, **kwargs):
1477 obj = self.get_object()
1478 if obj.can_update(request.user):
1479 return super(NodeDetail, self).destroy(request, *args, **kwargs)
1480 else:
1481 return Response(status=status.HTTP_400_BAD_REQUEST)
1482
1483
1484
1485
1486class DashboardViewList(generics.ListCreateAPIView):
1487 queryset = DashboardView.objects.select_related().all()
1488 serializer_class = DashboardViewSerializer
1489
1490 def get_queryset(self):
1491 return DashboardView.select_by_user(self.request.user)
1492
1493 def create(self, request, *args, **kwargs):
1494 #obj = DashboardView().update(request.DATA)
1495 obj = self.get_object()
1496 obj.caller = request.user
1497 if obj.can_update(request.user):
1498 return super(DashboardViewList, self).create(request, *args, **kwargs)
1499 else:
1500 return Response(status=status.HTTP_400_BAD_REQUEST)
1501
1502class DashboardViewDetail(generics.RetrieveUpdateDestroyAPIView):
1503 queryset = DashboardView.objects.select_related().all()
1504 serializer_class = DashboardViewSerializer
1505
1506 def get_queryset(self):
1507 return DashboardView.select_by_user(self.request.user)
1508
1509 def update(self, request, *args, **kwargs):
1510 obj = self.get_object()
1511 if obj.can_update(request.user):
1512 return super(DashboardViewDetail, self).update(request, *args, **kwargs)
1513 else:
1514 return Response(status=status.HTTP_400_BAD_REQUEST)
1515
1516 def destroy(self, request, *args, **kwargs):
1517 obj = self.get_object()
1518 if obj.can_update(request.user):
1519 return super(DashboardViewDetail, self).destroy(request, *args, **kwargs)
1520 else:
1521 return Response(status=status.HTTP_400_BAD_REQUEST)
1522
1523
1524
1525
1526class ImageDeploymentsList(generics.ListCreateAPIView):
1527 queryset = ImageDeployments.objects.select_related().all()
1528 serializer_class = ImageDeploymentsSerializer
1529
1530 def get_queryset(self):
1531 return ImageDeployments.select_by_user(self.request.user)
1532
1533 def create(self, request, *args, **kwargs):
1534 #obj = ImageDeployments().update(request.DATA)
1535 obj = self.get_object()
1536 obj.caller = request.user
1537 if obj.can_update(request.user):
1538 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
1539 else:
1540 return Response(status=status.HTTP_400_BAD_REQUEST)
1541
1542class ImageDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
1543 queryset = ImageDeployments.objects.select_related().all()
1544 serializer_class = ImageDeploymentsSerializer
1545
1546 def get_queryset(self):
1547 return ImageDeployments.select_by_user(self.request.user)
1548
1549 def update(self, request, *args, **kwargs):
1550 obj = self.get_object()
1551 if obj.can_update(request.user):
1552 return super(ImageDeploymentsDetail, self).update(request, *args, **kwargs)
1553 else:
1554 return Response(status=status.HTTP_400_BAD_REQUEST)
1555
1556 def destroy(self, request, *args, **kwargs):
1557 obj = self.get_object()
1558 if obj.can_update(request.user):
1559 return super(ImageDeploymentsDetail, self).destroy(request, *args, **kwargs)
1560 else:
1561 return Response(status=status.HTTP_400_BAD_REQUEST)
1562
1563
1564
1565
1566class ReservedResourceList(generics.ListCreateAPIView):
1567 queryset = ReservedResource.objects.select_related().all()
1568 serializer_class = ReservedResourceSerializer
1569
1570 def get_queryset(self):
1571 return ReservedResource.select_by_user(self.request.user)
1572
1573 def create(self, request, *args, **kwargs):
1574 #obj = ReservedResource().update(request.DATA)
1575 obj = self.get_object()
1576 obj.caller = request.user
1577 if obj.can_update(request.user):
1578 return super(ReservedResourceList, self).create(request, *args, **kwargs)
1579 else:
1580 return Response(status=status.HTTP_400_BAD_REQUEST)
1581
1582class ReservedResourceDetail(generics.RetrieveUpdateDestroyAPIView):
1583 queryset = ReservedResource.objects.select_related().all()
1584 serializer_class = ReservedResourceSerializer
1585
1586 def get_queryset(self):
1587 return ReservedResource.select_by_user(self.request.user)
1588
1589 def update(self, request, *args, **kwargs):
1590 obj = self.get_object()
1591 if obj.can_update(request.user):
1592 return super(ReservedResourceDetail, self).update(request, *args, **kwargs)
1593 else:
1594 return Response(status=status.HTTP_400_BAD_REQUEST)
1595
1596 def destroy(self, request, *args, **kwargs):
1597 obj = self.get_object()
1598 if obj.can_update(request.user):
1599 return super(ReservedResourceDetail, self).destroy(request, *args, **kwargs)
1600 else:
1601 return Response(status=status.HTTP_400_BAD_REQUEST)
1602
1603
1604
1605
1606class NetworkSliceList(generics.ListCreateAPIView):
1607 queryset = NetworkSlice.objects.select_related().all()
1608 serializer_class = NetworkSliceSerializer
1609
1610 def get_queryset(self):
1611 return NetworkSlice.select_by_user(self.request.user)
1612
1613 def create(self, request, *args, **kwargs):
1614 #obj = NetworkSlice().update(request.DATA)
1615 obj = self.get_object()
1616 obj.caller = request.user
1617 if obj.can_update(request.user):
1618 return super(NetworkSliceList, self).create(request, *args, **kwargs)
1619 else:
1620 return Response(status=status.HTTP_400_BAD_REQUEST)
1621
1622class NetworkSliceDetail(generics.RetrieveUpdateDestroyAPIView):
1623 queryset = NetworkSlice.objects.select_related().all()
1624 serializer_class = NetworkSliceSerializer
1625
1626 def get_queryset(self):
1627 return NetworkSlice.select_by_user(self.request.user)
1628
1629 def update(self, request, *args, **kwargs):
1630 obj = self.get_object()
1631 if obj.can_update(request.user):
1632 return super(NetworkSliceDetail, self).update(request, *args, **kwargs)
1633 else:
1634 return Response(status=status.HTTP_400_BAD_REQUEST)
1635
1636 def destroy(self, request, *args, **kwargs):
1637 obj = self.get_object()
1638 if obj.can_update(request.user):
1639 return super(NetworkSliceDetail, self).destroy(request, *args, **kwargs)
1640 else:
1641 return Response(status=status.HTTP_400_BAD_REQUEST)
1642
1643
1644
1645
1646class UserDashboardViewList(generics.ListCreateAPIView):
1647 queryset = UserDashboardView.objects.select_related().all()
1648 serializer_class = UserDashboardViewSerializer
1649
1650 def get_queryset(self):
1651 return UserDashboardView.select_by_user(self.request.user)
1652
1653 def create(self, request, *args, **kwargs):
1654 #obj = UserDashboardView().update(request.DATA)
1655 obj = self.get_object()
1656 obj.caller = request.user
1657 if obj.can_update(request.user):
1658 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
1659 else:
1660 return Response(status=status.HTTP_400_BAD_REQUEST)
1661
1662class UserDashboardViewDetail(generics.RetrieveUpdateDestroyAPIView):
1663 queryset = UserDashboardView.objects.select_related().all()
1664 serializer_class = UserDashboardViewSerializer
1665
1666 def get_queryset(self):
1667 return UserDashboardView.select_by_user(self.request.user)
1668
1669 def update(self, request, *args, **kwargs):
1670 obj = self.get_object()
1671 if obj.can_update(request.user):
1672 return super(UserDashboardViewDetail, self).update(request, *args, **kwargs)
1673 else:
1674 return Response(status=status.HTTP_400_BAD_REQUEST)
1675
1676 def destroy(self, request, *args, **kwargs):
1677 obj = self.get_object()
1678 if obj.can_update(request.user):
1679 return super(UserDashboardViewDetail, self).destroy(request, *args, **kwargs)
1680 else:
1681 return Response(status=status.HTTP_400_BAD_REQUEST)
1682
1683
1684
1685
1686class PlanetStackPrivilegeList(generics.ListCreateAPIView):
1687 queryset = PlanetStackPrivilege.objects.select_related().all()
1688 serializer_class = PlanetStackPrivilegeSerializer
1689
1690 def get_queryset(self):
1691 return PlanetStackPrivilege.select_by_user(self.request.user)
1692
1693 def create(self, request, *args, **kwargs):
1694 #obj = PlanetStackPrivilege().update(request.DATA)
1695 obj = self.get_object()
1696 obj.caller = request.user
1697 if obj.can_update(request.user):
1698 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
1699 else:
1700 return Response(status=status.HTTP_400_BAD_REQUEST)
1701
1702class PlanetStackPrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
1703 queryset = PlanetStackPrivilege.objects.select_related().all()
1704 serializer_class = PlanetStackPrivilegeSerializer
1705
1706 def get_queryset(self):
1707 return PlanetStackPrivilege.select_by_user(self.request.user)
1708
1709 def update(self, request, *args, **kwargs):
1710 obj = self.get_object()
1711 if obj.can_update(request.user):
1712 return super(PlanetStackPrivilegeDetail, self).update(request, *args, **kwargs)
1713 else:
1714 return Response(status=status.HTTP_400_BAD_REQUEST)
1715
1716 def destroy(self, request, *args, **kwargs):
1717 obj = self.get_object()
1718 if obj.can_update(request.user):
1719 return super(PlanetStackPrivilegeDetail, self).destroy(request, *args, **kwargs)
1720 else:
1721 return Response(status=status.HTTP_400_BAD_REQUEST)
1722
Sapan Bhatiadea39432014-06-13 03:10:36 -04001723
1724
1725
1726class UserList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001727 queryset = User.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001728 serializer_class = UserSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001729
1730 def get_queryset(self):
1731 return User.select_by_user(self.request.user)
1732
1733 def create(self, request, *args, **kwargs):
1734 #obj = User().update(request.DATA)
1735 obj = self.get_object()
1736 obj.caller = request.user
1737 if obj.can_update(request.user):
1738 return super(UserList, self).create(request, *args, **kwargs)
1739 else:
1740 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001741
1742class UserDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001743 queryset = User.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001744 serializer_class = UserSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001745
1746 def get_queryset(self):
1747 return User.select_by_user(self.request.user)
1748
1749 def update(self, request, *args, **kwargs):
1750 obj = self.get_object()
1751 if obj.can_update(request.user):
1752 return super(UserDetail, self).update(request, *args, **kwargs)
1753 else:
1754 return Response(status=status.HTTP_400_BAD_REQUEST)
1755
1756 def destroy(self, request, *args, **kwargs):
1757 obj = self.get_object()
1758 if obj.can_update(request.user):
1759 return super(UserDetail, self).destroy(request, *args, **kwargs)
1760 else:
1761 return Response(status=status.HTTP_400_BAD_REQUEST)
1762
Sapan Bhatiadea39432014-06-13 03:10:36 -04001763
1764
1765
1766class DeploymentList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001767 queryset = Deployment.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001768 serializer_class = DeploymentSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001769
1770 def get_queryset(self):
1771 return Deployment.select_by_user(self.request.user)
1772
1773 def create(self, request, *args, **kwargs):
1774 #obj = Deployment().update(request.DATA)
1775 obj = self.get_object()
1776 obj.caller = request.user
1777 if obj.can_update(request.user):
1778 return super(DeploymentList, self).create(request, *args, **kwargs)
1779 else:
1780 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001781
1782class DeploymentDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001783 queryset = Deployment.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001784 serializer_class = DeploymentSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001785
1786 def get_queryset(self):
1787 return Deployment.select_by_user(self.request.user)
1788
1789 def update(self, request, *args, **kwargs):
1790 obj = self.get_object()
1791 if obj.can_update(request.user):
1792 return super(DeploymentDetail, self).update(request, *args, **kwargs)
1793 else:
1794 return Response(status=status.HTTP_400_BAD_REQUEST)
1795
1796 def destroy(self, request, *args, **kwargs):
1797 obj = self.get_object()
1798 if obj.can_update(request.user):
1799 return super(DeploymentDetail, self).destroy(request, *args, **kwargs)
1800 else:
1801 return Response(status=status.HTTP_400_BAD_REQUEST)
1802
Sapan Bhatiadea39432014-06-13 03:10:36 -04001803
1804
1805
1806class ReservationList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001807 queryset = Reservation.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001808 serializer_class = ReservationSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001809
1810 def get_queryset(self):
1811 return Reservation.select_by_user(self.request.user)
1812
1813 def create(self, request, *args, **kwargs):
1814 #obj = Reservation().update(request.DATA)
1815 obj = self.get_object()
1816 obj.caller = request.user
1817 if obj.can_update(request.user):
1818 return super(ReservationList, self).create(request, *args, **kwargs)
1819 else:
1820 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001821
1822class ReservationDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001823 queryset = Reservation.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001824 serializer_class = ReservationSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07001825
1826 def get_queryset(self):
1827 return Reservation.select_by_user(self.request.user)
1828
1829 def update(self, request, *args, **kwargs):
1830 obj = self.get_object()
1831 if obj.can_update(request.user):
1832 return super(ReservationDetail, self).update(request, *args, **kwargs)
1833 else:
1834 return Response(status=status.HTTP_400_BAD_REQUEST)
1835
1836 def destroy(self, request, *args, **kwargs):
1837 obj = self.get_object()
1838 if obj.can_update(request.user):
1839 return super(ReservationDetail, self).destroy(request, *args, **kwargs)
1840 else:
1841 return Response(status=status.HTTP_400_BAD_REQUEST)
1842
Sapan Bhatiadea39432014-06-13 03:10:36 -04001843
1844
1845
Scott Baker0caeaf02014-06-19 11:12:55 -07001846class SliceDeploymentsList(generics.ListCreateAPIView):
1847 queryset = SliceDeployments.objects.select_related().all()
1848 serializer_class = SliceDeploymentsSerializer
1849
1850 def get_queryset(self):
1851 return SliceDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001852
Scott Baker0caeaf02014-06-19 11:12:55 -07001853 def create(self, request, *args, **kwargs):
1854 #obj = SliceDeployments().update(request.DATA)
1855 obj = self.get_object()
1856 obj.caller = request.user
1857 if obj.can_update(request.user):
1858 return super(SliceDeploymentsList, self).create(request, *args, **kwargs)
1859 else:
1860 return Response(status=status.HTTP_400_BAD_REQUEST)
1861
1862class SliceDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
1863 queryset = SliceDeployments.objects.select_related().all()
1864 serializer_class = SliceDeploymentsSerializer
1865
1866 def get_queryset(self):
1867 return SliceDeployments.select_by_user(self.request.user)
1868
1869 def update(self, request, *args, **kwargs):
1870 obj = self.get_object()
1871 if obj.can_update(request.user):
1872 return super(SliceDeploymentsDetail, self).update(request, *args, **kwargs)
1873 else:
1874 return Response(status=status.HTTP_400_BAD_REQUEST)
1875
1876 def destroy(self, request, *args, **kwargs):
1877 obj = self.get_object()
1878 if obj.can_update(request.user):
1879 return super(SliceDeploymentsDetail, self).destroy(request, *args, **kwargs)
1880 else:
1881 return Response(status=status.HTTP_400_BAD_REQUEST)
1882
Sapan Bhatiadea39432014-06-13 03:10:36 -04001883
1884
1885
Scott Baker0caeaf02014-06-19 11:12:55 -07001886class SitePrivilegeList(generics.ListCreateAPIView):
1887 queryset = SitePrivilege.objects.select_related().all()
1888 serializer_class = SitePrivilegeSerializer
1889
1890 def get_queryset(self):
1891 return SitePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001892
Scott Baker0caeaf02014-06-19 11:12:55 -07001893 def create(self, request, *args, **kwargs):
1894 #obj = SitePrivilege().update(request.DATA)
1895 obj = self.get_object()
1896 obj.caller = request.user
1897 if obj.can_update(request.user):
1898 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
1899 else:
1900 return Response(status=status.HTTP_400_BAD_REQUEST)
1901
1902class SitePrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
1903 queryset = SitePrivilege.objects.select_related().all()
1904 serializer_class = SitePrivilegeSerializer
1905
1906 def get_queryset(self):
1907 return SitePrivilege.select_by_user(self.request.user)
1908
1909 def update(self, request, *args, **kwargs):
1910 obj = self.get_object()
1911 if obj.can_update(request.user):
1912 return super(SitePrivilegeDetail, self).update(request, *args, **kwargs)
1913 else:
1914 return Response(status=status.HTTP_400_BAD_REQUEST)
1915
1916 def destroy(self, request, *args, **kwargs):
1917 obj = self.get_object()
1918 if obj.can_update(request.user):
1919 return super(SitePrivilegeDetail, self).destroy(request, *args, **kwargs)
1920 else:
1921 return Response(status=status.HTTP_400_BAD_REQUEST)
1922
Sapan Bhatiadea39432014-06-13 03:10:36 -04001923
1924
1925
Scott Baker0caeaf02014-06-19 11:12:55 -07001926class PlanetStackList(generics.ListCreateAPIView):
1927 queryset = PlanetStack.objects.select_related().all()
1928 serializer_class = PlanetStackSerializer
1929
1930 def get_queryset(self):
1931 return PlanetStack.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001932
Scott Baker0caeaf02014-06-19 11:12:55 -07001933 def create(self, request, *args, **kwargs):
1934 #obj = PlanetStack().update(request.DATA)
1935 obj = self.get_object()
1936 obj.caller = request.user
1937 if obj.can_update(request.user):
1938 return super(PlanetStackList, self).create(request, *args, **kwargs)
1939 else:
1940 return Response(status=status.HTTP_400_BAD_REQUEST)
1941
1942class PlanetStackDetail(generics.RetrieveUpdateDestroyAPIView):
1943 queryset = PlanetStack.objects.select_related().all()
1944 serializer_class = PlanetStackSerializer
1945
1946 def get_queryset(self):
1947 return PlanetStack.select_by_user(self.request.user)
1948
1949 def update(self, request, *args, **kwargs):
1950 obj = self.get_object()
1951 if obj.can_update(request.user):
1952 return super(PlanetStackDetail, self).update(request, *args, **kwargs)
1953 else:
1954 return Response(status=status.HTTP_400_BAD_REQUEST)
1955
1956 def destroy(self, request, *args, **kwargs):
1957 obj = self.get_object()
1958 if obj.can_update(request.user):
1959 return super(PlanetStackDetail, self).destroy(request, *args, **kwargs)
1960 else:
1961 return Response(status=status.HTTP_400_BAD_REQUEST)
1962
1963
1964
1965
1966class UserDeploymentsList(generics.ListCreateAPIView):
1967 queryset = UserDeployments.objects.select_related().all()
1968 serializer_class = UserDeploymentsSerializer
1969
1970 def get_queryset(self):
1971 return UserDeployments.select_by_user(self.request.user)
1972
1973 def create(self, request, *args, **kwargs):
1974 #obj = UserDeployments().update(request.DATA)
1975 obj = self.get_object()
1976 obj.caller = request.user
1977 if obj.can_update(request.user):
1978 return super(UserDeploymentsList, self).create(request, *args, **kwargs)
1979 else:
1980 return Response(status=status.HTTP_400_BAD_REQUEST)
1981
1982class UserDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
1983 queryset = UserDeployments.objects.select_related().all()
1984 serializer_class = UserDeploymentsSerializer
1985
1986 def get_queryset(self):
1987 return UserDeployments.select_by_user(self.request.user)
1988
1989 def update(self, request, *args, **kwargs):
1990 obj = self.get_object()
1991 if obj.can_update(request.user):
1992 return super(UserDeploymentsDetail, self).update(request, *args, **kwargs)
1993 else:
1994 return Response(status=status.HTTP_400_BAD_REQUEST)
1995
1996 def destroy(self, request, *args, **kwargs):
1997 obj = self.get_object()
1998 if obj.can_update(request.user):
1999 return super(UserDeploymentsDetail, self).destroy(request, *args, **kwargs)
2000 else:
2001 return Response(status=status.HTTP_400_BAD_REQUEST)
2002
Sapan Bhatiadea39432014-06-13 03:10:36 -04002003
2004
2005
2006class AccountList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002007 queryset = Account.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002008 serializer_class = AccountSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07002009
2010 def get_queryset(self):
2011 return Account.select_by_user(self.request.user)
2012
2013 def create(self, request, *args, **kwargs):
2014 #obj = Account().update(request.DATA)
2015 obj = self.get_object()
2016 obj.caller = request.user
2017 if obj.can_update(request.user):
2018 return super(AccountList, self).create(request, *args, **kwargs)
2019 else:
2020 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002021
2022class AccountDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002023 queryset = Account.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002024 serializer_class = AccountSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07002025
2026 def get_queryset(self):
2027 return Account.select_by_user(self.request.user)
2028
2029 def update(self, request, *args, **kwargs):
2030 obj = self.get_object()
2031 if obj.can_update(request.user):
2032 return super(AccountDetail, self).update(request, *args, **kwargs)
2033 else:
2034 return Response(status=status.HTTP_400_BAD_REQUEST)
2035
2036 def destroy(self, request, *args, **kwargs):
2037 obj = self.get_object()
2038 if obj.can_update(request.user):
2039 return super(AccountDetail, self).destroy(request, *args, **kwargs)
2040 else:
2041 return Response(status=status.HTTP_400_BAD_REQUEST)
2042
Sapan Bhatiadea39432014-06-13 03:10:36 -04002043
2044
2045
Scott Baker0caeaf02014-06-19 11:12:55 -07002046class NetworkParameterTypeList(generics.ListCreateAPIView):
2047 queryset = NetworkParameterType.objects.select_related().all()
2048 serializer_class = NetworkParameterTypeSerializer
2049
2050 def get_queryset(self):
2051 return NetworkParameterType.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002052
Scott Baker0caeaf02014-06-19 11:12:55 -07002053 def create(self, request, *args, **kwargs):
2054 #obj = NetworkParameterType().update(request.DATA)
2055 obj = self.get_object()
2056 obj.caller = request.user
2057 if obj.can_update(request.user):
2058 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
2059 else:
2060 return Response(status=status.HTTP_400_BAD_REQUEST)
2061
2062class NetworkParameterTypeDetail(generics.RetrieveUpdateDestroyAPIView):
2063 queryset = NetworkParameterType.objects.select_related().all()
2064 serializer_class = NetworkParameterTypeSerializer
2065
2066 def get_queryset(self):
2067 return NetworkParameterType.select_by_user(self.request.user)
2068
2069 def update(self, request, *args, **kwargs):
2070 obj = self.get_object()
2071 if obj.can_update(request.user):
2072 return super(NetworkParameterTypeDetail, self).update(request, *args, **kwargs)
2073 else:
2074 return Response(status=status.HTTP_400_BAD_REQUEST)
2075
2076 def destroy(self, request, *args, **kwargs):
2077 obj = self.get_object()
2078 if obj.can_update(request.user):
2079 return super(NetworkParameterTypeDetail, self).destroy(request, *args, **kwargs)
2080 else:
2081 return Response(status=status.HTTP_400_BAD_REQUEST)
2082
Sapan Bhatiadea39432014-06-13 03:10:36 -04002083
2084
2085
Scott Baker0caeaf02014-06-19 11:12:55 -07002086class SiteDeploymentsList(generics.ListCreateAPIView):
2087 queryset = SiteDeployments.objects.select_related().all()
2088 serializer_class = SiteDeploymentsSerializer
2089
2090 def get_queryset(self):
2091 return SiteDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002092
Scott Baker0caeaf02014-06-19 11:12:55 -07002093 def create(self, request, *args, **kwargs):
2094 #obj = SiteDeployments().update(request.DATA)
2095 obj = self.get_object()
2096 obj.caller = request.user
2097 if obj.can_update(request.user):
2098 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
2099 else:
2100 return Response(status=status.HTTP_400_BAD_REQUEST)
2101
2102class SiteDeploymentsDetail(generics.RetrieveUpdateDestroyAPIView):
2103 queryset = SiteDeployments.objects.select_related().all()
2104 serializer_class = SiteDeploymentsSerializer
2105
2106 def get_queryset(self):
2107 return SiteDeployments.select_by_user(self.request.user)
2108
2109 def update(self, request, *args, **kwargs):
2110 obj = self.get_object()
2111 if obj.can_update(request.user):
2112 return super(SiteDeploymentsDetail, self).update(request, *args, **kwargs)
2113 else:
2114 return Response(status=status.HTTP_400_BAD_REQUEST)
2115
2116 def destroy(self, request, *args, **kwargs):
2117 obj = self.get_object()
2118 if obj.can_update(request.user):
2119 return super(SiteDeploymentsDetail, self).destroy(request, *args, **kwargs)
2120 else:
2121 return Response(status=status.HTTP_400_BAD_REQUEST)
2122
Sapan Bhatiadea39432014-06-13 03:10:36 -04002123
2124
2125
Scott Baker0caeaf02014-06-19 11:12:55 -07002126class DeploymentPrivilegeList(generics.ListCreateAPIView):
2127 queryset = DeploymentPrivilege.objects.select_related().all()
2128 serializer_class = DeploymentPrivilegeSerializer
2129
2130 def get_queryset(self):
2131 return DeploymentPrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002132
Scott Baker0caeaf02014-06-19 11:12:55 -07002133 def create(self, request, *args, **kwargs):
2134 #obj = DeploymentPrivilege().update(request.DATA)
2135 obj = self.get_object()
2136 obj.caller = request.user
2137 if obj.can_update(request.user):
2138 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
2139 else:
2140 return Response(status=status.HTTP_400_BAD_REQUEST)
2141
2142class DeploymentPrivilegeDetail(generics.RetrieveUpdateDestroyAPIView):
2143 queryset = DeploymentPrivilege.objects.select_related().all()
2144 serializer_class = DeploymentPrivilegeSerializer
2145
2146 def get_queryset(self):
2147 return DeploymentPrivilege.select_by_user(self.request.user)
2148
2149 def update(self, request, *args, **kwargs):
2150 obj = self.get_object()
2151 if obj.can_update(request.user):
2152 return super(DeploymentPrivilegeDetail, self).update(request, *args, **kwargs)
2153 else:
2154 return Response(status=status.HTTP_400_BAD_REQUEST)
2155
2156 def destroy(self, request, *args, **kwargs):
2157 obj = self.get_object()
2158 if obj.can_update(request.user):
2159 return super(DeploymentPrivilegeDetail, self).destroy(request, *args, **kwargs)
2160 else:
2161 return Response(status=status.HTTP_400_BAD_REQUEST)
2162
Sapan Bhatiadea39432014-06-13 03:10:36 -04002163
2164
2165
Scott Baker0caeaf02014-06-19 11:12:55 -07002166class DeploymentRoleList(generics.ListCreateAPIView):
2167 queryset = DeploymentRole.objects.select_related().all()
2168 serializer_class = DeploymentRoleSerializer
2169
2170 def get_queryset(self):
2171 return DeploymentRole.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002172
Scott Baker0caeaf02014-06-19 11:12:55 -07002173 def create(self, request, *args, **kwargs):
2174 #obj = DeploymentRole().update(request.DATA)
2175 obj = self.get_object()
2176 obj.caller = request.user
2177 if obj.can_update(request.user):
2178 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
2179 else:
2180 return Response(status=status.HTTP_400_BAD_REQUEST)
2181
2182class DeploymentRoleDetail(generics.RetrieveUpdateDestroyAPIView):
2183 queryset = DeploymentRole.objects.select_related().all()
2184 serializer_class = DeploymentRoleSerializer
2185
2186 def get_queryset(self):
2187 return DeploymentRole.select_by_user(self.request.user)
2188
2189 def update(self, request, *args, **kwargs):
2190 obj = self.get_object()
2191 if obj.can_update(request.user):
2192 return super(DeploymentRoleDetail, self).update(request, *args, **kwargs)
2193 else:
2194 return Response(status=status.HTTP_400_BAD_REQUEST)
2195
2196 def destroy(self, request, *args, **kwargs):
2197 obj = self.get_object()
2198 if obj.can_update(request.user):
2199 return super(DeploymentRoleDetail, self).destroy(request, *args, **kwargs)
2200 else:
2201 return Response(status=status.HTTP_400_BAD_REQUEST)
2202
Sapan Bhatiadea39432014-06-13 03:10:36 -04002203
2204
2205
Scott Baker0caeaf02014-06-19 11:12:55 -07002206class ProjectList(generics.ListCreateAPIView):
2207 queryset = Project.objects.select_related().all()
2208 serializer_class = ProjectSerializer
2209
2210 def get_queryset(self):
2211 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002212
Scott Baker0caeaf02014-06-19 11:12:55 -07002213 def create(self, request, *args, **kwargs):
2214 #obj = Project().update(request.DATA)
2215 obj = self.get_object()
2216 obj.caller = request.user
2217 if obj.can_update(request.user):
2218 return super(ProjectList, self).create(request, *args, **kwargs)
2219 else:
2220 return Response(status=status.HTTP_400_BAD_REQUEST)
2221
2222class ProjectDetail(generics.RetrieveUpdateDestroyAPIView):
2223 queryset = Project.objects.select_related().all()
2224 serializer_class = ProjectSerializer
2225
2226 def get_queryset(self):
2227 return Project.select_by_user(self.request.user)
2228
2229 def update(self, request, *args, **kwargs):
2230 obj = self.get_object()
2231 if obj.can_update(request.user):
2232 return super(ProjectDetail, self).update(request, *args, **kwargs)
2233 else:
2234 return Response(status=status.HTTP_400_BAD_REQUEST)
2235
2236 def destroy(self, request, *args, **kwargs):
2237 obj = self.get_object()
2238 if obj.can_update(request.user):
2239 return super(ProjectDetail, self).destroy(request, *args, **kwargs)
2240 else:
2241 return Response(status=status.HTTP_400_BAD_REQUEST)
2242
Sapan Bhatiadea39432014-06-13 03:10:36 -04002243
2244
2245
Scott Baker0caeaf02014-06-19 11:12:55 -07002246class SliceTagList(generics.ListCreateAPIView):
2247 queryset = SliceTag.objects.select_related().all()
2248 serializer_class = SliceTagSerializer
2249
2250 def get_queryset(self):
2251 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002252
Scott Baker0caeaf02014-06-19 11:12:55 -07002253 def create(self, request, *args, **kwargs):
2254 #obj = SliceTag().update(request.DATA)
2255 obj = self.get_object()
2256 obj.caller = request.user
2257 if obj.can_update(request.user):
2258 return super(SliceTagList, self).create(request, *args, **kwargs)
2259 else:
2260 return Response(status=status.HTTP_400_BAD_REQUEST)
2261
2262class SliceTagDetail(generics.RetrieveUpdateDestroyAPIView):
2263 queryset = SliceTag.objects.select_related().all()
2264 serializer_class = SliceTagSerializer
2265
2266 def get_queryset(self):
2267 return SliceTag.select_by_user(self.request.user)
2268
2269 def update(self, request, *args, **kwargs):
2270 obj = self.get_object()
2271 if obj.can_update(request.user):
2272 return super(SliceTagDetail, self).update(request, *args, **kwargs)
2273 else:
2274 return Response(status=status.HTTP_400_BAD_REQUEST)
2275
2276 def destroy(self, request, *args, **kwargs):
2277 obj = self.get_object()
2278 if obj.can_update(request.user):
2279 return super(SliceTagDetail, self).destroy(request, *args, **kwargs)
2280 else:
2281 return Response(status=status.HTTP_400_BAD_REQUEST)
2282
Sapan Bhatiadea39432014-06-13 03:10:36 -04002283
2284
2285
Scott Baker0caeaf02014-06-19 11:12:55 -07002286class NetworkTemplateList(generics.ListCreateAPIView):
2287 queryset = NetworkTemplate.objects.select_related().all()
2288 serializer_class = NetworkTemplateSerializer
2289
2290 def get_queryset(self):
2291 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002292
Scott Baker0caeaf02014-06-19 11:12:55 -07002293 def create(self, request, *args, **kwargs):
2294 #obj = NetworkTemplate().update(request.DATA)
2295 obj = self.get_object()
2296 obj.caller = request.user
2297 if obj.can_update(request.user):
2298 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
2299 else:
2300 return Response(status=status.HTTP_400_BAD_REQUEST)
2301
2302class NetworkTemplateDetail(generics.RetrieveUpdateDestroyAPIView):
2303 queryset = NetworkTemplate.objects.select_related().all()
2304 serializer_class = NetworkTemplateSerializer
2305
2306 def get_queryset(self):
2307 return NetworkTemplate.select_by_user(self.request.user)
2308
2309 def update(self, request, *args, **kwargs):
2310 obj = self.get_object()
2311 if obj.can_update(request.user):
2312 return super(NetworkTemplateDetail, self).update(request, *args, **kwargs)
2313 else:
2314 return Response(status=status.HTTP_400_BAD_REQUEST)
2315
2316 def destroy(self, request, *args, **kwargs):
2317 obj = self.get_object()
2318 if obj.can_update(request.user):
2319 return super(NetworkTemplateDetail, self).destroy(request, *args, **kwargs)
2320 else:
2321 return Response(status=status.HTTP_400_BAD_REQUEST)
2322
Sapan Bhatiadea39432014-06-13 03:10:36 -04002323
2324
2325
2326class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002327 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002328 serializer_class = RouterSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07002329
2330 def get_queryset(self):
2331 return Router.select_by_user(self.request.user)
2332
2333 def create(self, request, *args, **kwargs):
2334 #obj = Router().update(request.DATA)
2335 obj = self.get_object()
2336 obj.caller = request.user
2337 if obj.can_update(request.user):
2338 return super(RouterList, self).create(request, *args, **kwargs)
2339 else:
2340 return Response(status=status.HTTP_400_BAD_REQUEST)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002341
2342class RouterDetail(generics.RetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002343 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002344 serializer_class = RouterSerializer
Scott Baker0caeaf02014-06-19 11:12:55 -07002345
2346 def get_queryset(self):
2347 return Router.select_by_user(self.request.user)
2348
2349 def update(self, request, *args, **kwargs):
2350 obj = self.get_object()
2351 if obj.can_update(request.user):
2352 return super(RouterDetail, self).update(request, *args, **kwargs)
2353 else:
2354 return Response(status=status.HTTP_400_BAD_REQUEST)
2355
2356 def destroy(self, request, *args, **kwargs):
2357 obj = self.get_object()
2358 if obj.can_update(request.user):
2359 return super(RouterDetail, self).destroy(request, *args, **kwargs)
2360 else:
2361 return Response(status=status.HTTP_400_BAD_REQUEST)
2362
Sapan Bhatiadea39432014-06-13 03:10:36 -04002363
2364
2365
Scott Baker0caeaf02014-06-19 11:12:55 -07002366class ServiceResourceList(generics.ListCreateAPIView):
2367 queryset = ServiceResource.objects.select_related().all()
2368 serializer_class = ServiceResourceSerializer
2369
2370 def get_queryset(self):
2371 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002372
Scott Baker0caeaf02014-06-19 11:12:55 -07002373 def create(self, request, *args, **kwargs):
2374 #obj = ServiceResource().update(request.DATA)
2375 obj = self.get_object()
2376 obj.caller = request.user
2377 if obj.can_update(request.user):
2378 return super(ServiceResourceList, self).create(request, *args, **kwargs)
2379 else:
2380 return Response(status=status.HTTP_400_BAD_REQUEST)
2381
2382class ServiceResourceDetail(generics.RetrieveUpdateDestroyAPIView):
2383 queryset = ServiceResource.objects.select_related().all()
2384 serializer_class = ServiceResourceSerializer
2385
2386 def get_queryset(self):
2387 return ServiceResource.select_by_user(self.request.user)
2388
2389 def update(self, request, *args, **kwargs):
2390 obj = self.get_object()
2391 if obj.can_update(request.user):
2392 return super(ServiceResourceDetail, self).update(request, *args, **kwargs)
2393 else:
2394 return Response(status=status.HTTP_400_BAD_REQUEST)
2395
2396 def destroy(self, request, *args, **kwargs):
2397 obj = self.get_object()
2398 if obj.can_update(request.user):
2399 return super(ServiceResourceDetail, self).destroy(request, *args, **kwargs)
2400 else:
2401 return Response(status=status.HTTP_400_BAD_REQUEST)
2402
Sapan Bhatiadea39432014-06-13 03:10:36 -04002403
2404
2405