disable setting fields to readonly based on user's privilege in UserAdmin
[plstackapi.git] / planetstack / genapi.py
1 from rest_framework.decorators import api_view
2 from rest_framework.response import Response
3 from rest_framework.reverse import reverse
4 from rest_framework import serializers
5 from rest_framework import generics
6 from rest_framework import status
7 from rest_framework.generics import GenericAPIView
8 from core.models import *
9 from django.forms import widgets
10 from rest_framework import filters
11 from django.conf.urls import patterns, url
12
13 if hasattr(serializers, "ReadOnlyField"):
14     # rest_framework 3.x
15     IdField = serializers.ReadOnlyField
16 else:
17     # rest_framework 2.x
18     IdField = serializers.Field
19
20 """
21     Schema of the generator object:
22         all: Set of all Model objects
23         all_if(regex): Set of Model objects that match regex
24
25     Model object:
26         plural: English plural of object name
27         camel: CamelCase version of object name
28         refs: list of references to other Model objects
29         props: list of properties minus refs
30
31     TODO: Deal with subnets
32 """
33
34 def get_REST_patterns():
35     return patterns('',
36         url(r'^plstackapi/$', api_root),
37     
38         url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
39         url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
40     
41         url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
42         url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
43     
44         url(r'plstackapi/controllersiteprivileges/$', ControllerSitePrivilegeList.as_view(), name='controllersiteprivilege-list'),
45         url(r'plstackapi/controllersiteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSitePrivilegeDetail.as_view(), name ='controllersiteprivilege-detail'),
46     
47         url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
48         url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
49     
50         url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
51         url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
52     
53         url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
54         url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
55     
56         url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
57         url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
58     
59         url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
60         url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
61     
62         url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
63         url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
64     
65         url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
66         url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
67     
68         url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
69         url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
70     
71         url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
72         url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
73     
74         url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
75         url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
76     
77         url(r'plstackapi/controllersites/$', ControllerSiteList.as_view(), name='controllersite-list'),
78         url(r'plstackapi/controllersites/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDetail.as_view(), name ='controllersite-detail'),
79     
80         url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
81         url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
82     
83         url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
84         url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
85     
86         url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
87         url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
88     
89         url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
90         url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
91     
92         url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
93         url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
94     
95         url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
96         url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
97     
98         url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
99         url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
100     
101         url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
102         url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
103     
104         url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
105         url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
106     
107         url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
108         url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
109     
110         url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
111         url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
112     
113         url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
114         url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
115     
116         url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
117         url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
118     
119         url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
120         url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
121     
122         url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetwork-list'),
123         url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetwork-detail'),
124     
125         url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
126         url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
127     
128         url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controlleruser-list'),
129         url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controlleruser-detail'),
130     
131         url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
132         url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
133     
134         url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
135         url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
136     
137         url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
138         url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
139     
140         url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
141         url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
142     
143         url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'),
144         url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
145     
146         url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
147         url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
148     
149         url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
150         url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
151     
152         url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
153         url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
154     
155         url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
156         url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
157     
158         url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
159         url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
160     
161         url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslice-list'),
162         url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslice-detail'),
163     
164         url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'),
165         url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'),
166     
167         url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
168         url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
169     
170         url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
171         url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
172     
173         url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
174         url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
175     
176         url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
177         url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
178     
179         url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
180         url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
181     
182         url(r'plstackapi/controllersliceprivileges/$', ControllerSlicePrivilegeList.as_view(), name='controllersliceprivilege-list'),
183         url(r'plstackapi/controllersliceprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicePrivilegeDetail.as_view(), name ='controllersliceprivilege-detail'),
184     
185         url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployment-list'),
186         url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployment-detail'),
187     
188         url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
189         url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
190     
191         url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
192         url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
193     
194         url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
195         url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
196     
197         url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
198         url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
199     
200         url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
201         url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
202     
203         url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
204         url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
205     
206     )
207
208 @api_view(['GET'])
209 def api_root(request, format=None):
210     return Response({
211         'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
212         'controllerimageses': reverse('controllerimages-list', request=request, format=format),
213         'controllersiteprivileges': reverse('controllersiteprivilege-list', request=request, format=format),
214         'images': reverse('image-list', request=request, format=format),
215         'networkparameters': reverse('networkparameter-list', request=request, format=format),
216         'sites': reverse('site-list', request=request, format=format),
217         'sliceroles': reverse('slicerole-list', request=request, format=format),
218         'tags': reverse('tag-list', request=request, format=format),
219         'invoices': reverse('invoice-list', request=request, format=format),
220         'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
221         'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
222         'networkslivers': reverse('networksliver-list', request=request, format=format),
223         'flavors': reverse('flavor-list', request=request, format=format),
224         'controllersites': reverse('controllersite-list', request=request, format=format),
225         'projects': reverse('project-list', request=request, format=format),
226         'slices': reverse('slice-list', request=request, format=format),
227         'networks': reverse('network-list', request=request, format=format),
228         'services': reverse('service-list', request=request, format=format),
229         'serviceclasses': reverse('serviceclass-list', request=request, format=format),
230         'planetstacks': reverse('planetstack-list', request=request, format=format),
231         'charges': reverse('charge-list', request=request, format=format),
232         'roles': reverse('role-list', request=request, format=format),
233         'usableobjects': reverse('usableobject-list', request=request, format=format),
234         'siteroles': reverse('siterole-list', request=request, format=format),
235         'slicecredentials': reverse('slicecredential-list', request=request, format=format),
236         'slivers': reverse('sliver-list', request=request, format=format),
237         'nodes': reverse('node-list', request=request, format=format),
238         'dashboardviews': reverse('dashboardview-list', request=request, format=format),
239         'controllernetworks': reverse('controllernetwork-list', request=request, format=format),
240         'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
241         'controllerusers': reverse('controlleruser-list', request=request, format=format),
242         'reservedresources': reverse('reservedresource-list', request=request, format=format),
243         'payments': reverse('payment-list', request=request, format=format),
244         'networkslices': reverse('networkslice-list', request=request, format=format),
245         'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
246         'controllers': reverse('controller-list', request=request, format=format),
247         'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
248         'users': reverse('user-list', request=request, format=format),
249         'deployments': reverse('deployment-list', request=request, format=format),
250         'reservations': reverse('reservation-list', request=request, format=format),
251         'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
252         'controllerslices': reverse('controllerslice-list', request=request, format=format),
253         'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
254         'accounts': reverse('account-list', request=request, format=format),
255         'controllerroles': reverse('controllerrole-list', request=request, format=format),
256         'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
257         'sitecredentials': reverse('sitecredential-list', request=request, format=format),
258         'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
259         'controllersliceprivileges': reverse('controllersliceprivilege-list', request=request, format=format),
260         'sitedeployments': reverse('sitedeployment-list', request=request, format=format),
261         'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
262         'usercredentials': reverse('usercredential-list', request=request, format=format),
263         'slicetags': reverse('slicetag-list', request=request, format=format),
264         'networktemplates': reverse('networktemplate-list', request=request, format=format),
265         'routers': reverse('router-list', request=request, format=format),
266         'serviceresources': reverse('serviceresource-list', request=request, format=format),
267         
268     })
269
270 # Based on serializers.py
271
272 class XOSModelSerializer(serializers.ModelSerializer):
273     def save_object(self, obj, **kwargs):
274
275         """ rest_framework can't deal with ManyToMany relations that have a
276             through table. In plstackapi, most of the through tables we have
277             use defaults or blank fields, so there's no reason why we shouldn't
278             be able to save these objects.
279
280             So, let's strip out these m2m relations, and deal with them ourself.
281         """
282         obj._complex_m2m_data={};\r
283         if getattr(obj, '_m2m_data', None):\r
284             for relatedObject in obj._meta.get_all_related_many_to_many_objects():\r
285                 if (relatedObject.field.rel.through._meta.auto_created):\r
286                     # These are non-trough ManyToMany relations and\r
287                     # can be updated just fine\r
288                     continue\r
289                 fieldName = relatedObject.get_accessor_name()\r
290                 if fieldName in obj._m2m_data.keys():\r
291                     obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])\r
292                     del obj._m2m_data[fieldName]\r
293 \r
294         serializers.ModelSerializer.save_object(self, obj, **kwargs);
295
296         for (accessor, stuff) in obj._complex_m2m_data.items():
297             (relatedObject, data) = stuff
298             through = relatedObject.field.rel.through
299             local_fieldName = relatedObject.field.m2m_reverse_field_name()
300             remote_fieldName = relatedObject.field.m2m_field_name()
301
302             # get the current set of existing relations
303             existing = through.objects.filter(**{local_fieldName: obj});
304
305             data_ids = [item.id for item in data]
306             existing_ids = [getattr(item,remote_fieldName).id for item in existing]
307
308             #print "data_ids", data_ids
309             #print "existing_ids", existing_ids
310
311             # remove relations that are in 'existing' but not in 'data'
312             for item in list(existing):
313                if (getattr(item,remote_fieldName).id not in data_ids):
314                    print "delete", getattr(item,remote_fieldName)
315                    item.delete() #(purge=True)
316
317             # add relations that are in 'data' but not in 'existing'
318             for item in data:
319                if (item.id not in existing_ids):
320                    #print "add", item
321                    newModel = through(**{local_fieldName: obj, remote_fieldName: item})
322                    newModel.save()
323
324
325
326 class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
327     id = IdField()
328     
329     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
330     validators = serializers.SerializerMethodField("getValidators")
331     def getHumanReadableName(self, obj):\r
332         return str(obj)
333     def getValidators(self, obj):
334         try:
335             return obj.getValidators()
336         except:
337             return None
338     class Meta:
339         model = ServiceAttribute
340         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
341
342 class ServiceAttributeIdSerializer(XOSModelSerializer):
343     id = IdField()
344     
345     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
346     validators = serializers.SerializerMethodField("getValidators")
347     def getHumanReadableName(self, obj):\r
348         return str(obj)\r
349     def getValidators(self, obj):\r
350         try:
351             return obj.getValidators()
352         except:
353             return None\r
354     class Meta:\r
355         model = ServiceAttribute
356         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
357
358
359
360
361 class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
362     id = IdField()
363     
364     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
365     validators = serializers.SerializerMethodField("getValidators")
366     def getHumanReadableName(self, obj):\r
367         return str(obj)
368     def getValidators(self, obj):
369         try:
370             return obj.getValidators()
371         except:
372             return None
373     class Meta:
374         model = ControllerImages
375         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
376
377 class ControllerImagesIdSerializer(XOSModelSerializer):
378     id = IdField()
379     
380     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
381     validators = serializers.SerializerMethodField("getValidators")
382     def getHumanReadableName(self, obj):\r
383         return str(obj)\r
384     def getValidators(self, obj):\r
385         try:
386             return obj.getValidators()
387         except:
388             return None\r
389     class Meta:\r
390         model = ControllerImages
391         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
392
393
394
395
396 class ControllerSitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
397     id = IdField()
398     
399     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
400     validators = serializers.SerializerMethodField("getValidators")
401     def getHumanReadableName(self, obj):\r
402         return str(obj)
403     def getValidators(self, obj):
404         try:
405             return obj.getValidators()
406         except:
407             return None
408     class Meta:
409         model = ControllerSitePrivilege
410         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',)
411
412 class ControllerSitePrivilegeIdSerializer(XOSModelSerializer):
413     id = IdField()
414     
415     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
416     validators = serializers.SerializerMethodField("getValidators")
417     def getHumanReadableName(self, obj):\r
418         return str(obj)\r
419     def getValidators(self, obj):\r
420         try:
421             return obj.getValidators()
422         except:
423             return None\r
424     class Meta:\r
425         model = ControllerSitePrivilege
426         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',)
427
428
429
430
431 class ImageSerializer(serializers.HyperlinkedModelSerializer):
432     id = IdField()
433     
434     
435     deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
436     
437     
438     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
439     validators = serializers.SerializerMethodField("getValidators")
440     def getHumanReadableName(self, obj):\r
441         return str(obj)
442     def getValidators(self, obj):
443         try:
444             return obj.getValidators()
445         except:
446             return None
447     class Meta:
448         model = Image
449         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
450
451 class ImageIdSerializer(XOSModelSerializer):
452     id = IdField()
453     
454     
455     deployments = serializers.PrimaryKeyRelatedField(many=True,  queryset = Deployment.objects.all())
456     
457     
458     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
459     validators = serializers.SerializerMethodField("getValidators")
460     def getHumanReadableName(self, obj):\r
461         return str(obj)\r
462     def getValidators(self, obj):\r
463         try:
464             return obj.getValidators()
465         except:
466             return None\r
467     class Meta:\r
468         model = Image
469         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
470
471
472
473
474 class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
475     id = IdField()
476     
477     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
478     validators = serializers.SerializerMethodField("getValidators")
479     def getHumanReadableName(self, obj):\r
480         return str(obj)
481     def getValidators(self, obj):
482         try:
483             return obj.getValidators()
484         except:
485             return None
486     class Meta:
487         model = NetworkParameter
488         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
489
490 class NetworkParameterIdSerializer(XOSModelSerializer):
491     id = IdField()
492     
493     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
494     validators = serializers.SerializerMethodField("getValidators")
495     def getHumanReadableName(self, obj):\r
496         return str(obj)\r
497     def getValidators(self, obj):\r
498         try:
499             return obj.getValidators()
500         except:
501             return None\r
502     class Meta:\r
503         model = NetworkParameter
504         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
505
506
507
508
509 class SiteSerializer(serializers.HyperlinkedModelSerializer):
510     id = IdField()
511     
512     
513     deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
514     
515     
516     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
517     validators = serializers.SerializerMethodField("getValidators")
518     def getHumanReadableName(self, obj):\r
519         return str(obj)
520     def getValidators(self, obj):
521         try:
522             return obj.getValidators()
523         except:
524             return None
525     class Meta:
526         model = Site
527         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
528
529 class SiteIdSerializer(XOSModelSerializer):
530     id = IdField()
531     
532     
533     deployments = serializers.PrimaryKeyRelatedField(many=True,  queryset = Deployment.objects.all())
534     
535     
536     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
537     validators = serializers.SerializerMethodField("getValidators")
538     def getHumanReadableName(self, obj):\r
539         return str(obj)\r
540     def getValidators(self, obj):\r
541         try:
542             return obj.getValidators()
543         except:
544             return None\r
545     class Meta:\r
546         model = Site
547         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
548
549
550
551
552 class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
553     id = IdField()
554     
555     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
556     validators = serializers.SerializerMethodField("getValidators")
557     def getHumanReadableName(self, obj):\r
558         return str(obj)
559     def getValidators(self, obj):
560         try:
561             return obj.getValidators()
562         except:
563             return None
564     class Meta:
565         model = SliceRole
566         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
567
568 class SliceRoleIdSerializer(XOSModelSerializer):
569     id = IdField()
570     
571     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
572     validators = serializers.SerializerMethodField("getValidators")
573     def getHumanReadableName(self, obj):\r
574         return str(obj)\r
575     def getValidators(self, obj):\r
576         try:
577             return obj.getValidators()
578         except:
579             return None\r
580     class Meta:\r
581         model = SliceRole
582         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
583
584
585
586
587 class TagSerializer(serializers.HyperlinkedModelSerializer):
588     id = IdField()
589     
590     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
591     validators = serializers.SerializerMethodField("getValidators")
592     def getHumanReadableName(self, obj):\r
593         return str(obj)
594     def getValidators(self, obj):
595         try:
596             return obj.getValidators()
597         except:
598             return None
599     class Meta:
600         model = Tag
601         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
602
603 class TagIdSerializer(XOSModelSerializer):
604     id = IdField()
605     
606     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
607     validators = serializers.SerializerMethodField("getValidators")
608     def getHumanReadableName(self, obj):\r
609         return str(obj)\r
610     def getValidators(self, obj):\r
611         try:
612             return obj.getValidators()
613         except:
614             return None\r
615     class Meta:\r
616         model = Tag
617         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
618
619
620
621
622 class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
623     id = IdField()
624     
625     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
626     validators = serializers.SerializerMethodField("getValidators")
627     def getHumanReadableName(self, obj):\r
628         return str(obj)
629     def getValidators(self, obj):
630         try:
631             return obj.getValidators()
632         except:
633             return None
634     class Meta:
635         model = Invoice
636         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
637
638 class InvoiceIdSerializer(XOSModelSerializer):
639     id = IdField()
640     
641     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
642     validators = serializers.SerializerMethodField("getValidators")
643     def getHumanReadableName(self, obj):\r
644         return str(obj)\r
645     def getValidators(self, obj):\r
646         try:
647             return obj.getValidators()
648         except:
649             return None\r
650     class Meta:\r
651         model = Invoice
652         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
653
654
655
656
657 class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
658     id = IdField()
659     
660     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
661     validators = serializers.SerializerMethodField("getValidators")
662     def getHumanReadableName(self, obj):\r
663         return str(obj)
664     def getValidators(self, obj):
665         try:
666             return obj.getValidators()
667         except:
668             return None
669     class Meta:
670         model = SlicePrivilege
671         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
672
673 class SlicePrivilegeIdSerializer(XOSModelSerializer):
674     id = IdField()
675     
676     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
677     validators = serializers.SerializerMethodField("getValidators")
678     def getHumanReadableName(self, obj):\r
679         return str(obj)\r
680     def getValidators(self, obj):\r
681         try:
682             return obj.getValidators()
683         except:
684             return None\r
685     class Meta:\r
686         model = SlicePrivilege
687         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
688
689
690
691
692 class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
693     id = IdField()
694     
695     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
696     validators = serializers.SerializerMethodField("getValidators")
697     def getHumanReadableName(self, obj):\r
698         return str(obj)
699     def getValidators(self, obj):
700         try:
701             return obj.getValidators()
702         except:
703             return None
704     class Meta:
705         model = PlanetStackRole
706         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
707
708 class PlanetStackRoleIdSerializer(XOSModelSerializer):
709     id = IdField()
710     
711     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
712     validators = serializers.SerializerMethodField("getValidators")
713     def getHumanReadableName(self, obj):\r
714         return str(obj)\r
715     def getValidators(self, obj):\r
716         try:
717             return obj.getValidators()
718         except:
719             return None\r
720     class Meta:\r
721         model = PlanetStackRole
722         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
723
724
725
726
727 class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
728     id = IdField()
729     
730     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
731     validators = serializers.SerializerMethodField("getValidators")
732     def getHumanReadableName(self, obj):\r
733         return str(obj)
734     def getValidators(self, obj):
735         try:
736             return obj.getValidators()
737         except:
738             return None
739     class Meta:
740         model = NetworkSliver
741         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
742
743 class NetworkSliverIdSerializer(XOSModelSerializer):
744     id = IdField()
745     
746     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
747     validators = serializers.SerializerMethodField("getValidators")
748     def getHumanReadableName(self, obj):\r
749         return str(obj)\r
750     def getValidators(self, obj):\r
751         try:
752             return obj.getValidators()
753         except:
754             return None\r
755     class Meta:\r
756         model = NetworkSliver
757         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
758
759
760
761
762 class FlavorSerializer(serializers.HyperlinkedModelSerializer):
763     id = IdField()
764     
765     
766     deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
767     
768     
769     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
770     validators = serializers.SerializerMethodField("getValidators")
771     def getHumanReadableName(self, obj):\r
772         return str(obj)
773     def getValidators(self, obj):
774         try:
775             return obj.getValidators()
776         except:
777             return None
778     class Meta:
779         model = Flavor
780         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
781
782 class FlavorIdSerializer(XOSModelSerializer):
783     id = IdField()
784     
785     
786     deployments = serializers.PrimaryKeyRelatedField(many=True,  queryset = Deployment.objects.all())
787     
788     
789     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
790     validators = serializers.SerializerMethodField("getValidators")
791     def getHumanReadableName(self, obj):\r
792         return str(obj)\r
793     def getValidators(self, obj):\r
794         try:
795             return obj.getValidators()
796         except:
797             return None\r
798     class Meta:\r
799         model = Flavor
800         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
801
802
803
804
805 class ControllerSiteSerializer(serializers.HyperlinkedModelSerializer):
806     id = IdField()
807     
808     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
809     validators = serializers.SerializerMethodField("getValidators")
810     def getHumanReadableName(self, obj):\r
811         return str(obj)
812     def getValidators(self, obj):
813         try:
814             return obj.getValidators()
815         except:
816             return None
817     class Meta:
818         model = ControllerSite
819         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',)
820
821 class ControllerSiteIdSerializer(XOSModelSerializer):
822     id = IdField()
823     
824     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
825     validators = serializers.SerializerMethodField("getValidators")
826     def getHumanReadableName(self, obj):\r
827         return str(obj)\r
828     def getValidators(self, obj):\r
829         try:
830             return obj.getValidators()
831         except:
832             return None\r
833     class Meta:\r
834         model = ControllerSite
835         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',)
836
837
838
839
840 class ProjectSerializer(serializers.HyperlinkedModelSerializer):
841     id = IdField()
842     
843     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
844     validators = serializers.SerializerMethodField("getValidators")
845     def getHumanReadableName(self, obj):\r
846         return str(obj)
847     def getValidators(self, obj):
848         try:
849             return obj.getValidators()
850         except:
851             return None
852     class Meta:
853         model = Project
854         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
855
856 class ProjectIdSerializer(XOSModelSerializer):
857     id = IdField()
858     
859     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
860     validators = serializers.SerializerMethodField("getValidators")
861     def getHumanReadableName(self, obj):\r
862         return str(obj)\r
863     def getValidators(self, obj):\r
864         try:
865             return obj.getValidators()
866         except:
867             return None\r
868     class Meta:\r
869         model = Project
870         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
871
872
873
874
875 class SliceSerializer(serializers.HyperlinkedModelSerializer):
876     id = IdField()
877     
878     
879     networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
880     
881     
882     
883     networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
884     
885     
886     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
887     validators = serializers.SerializerMethodField("getValidators")
888     def getHumanReadableName(self, obj):\r
889         return str(obj)
890     def getValidators(self, obj):
891         try:
892             return obj.getValidators()
893         except:
894             return None
895     class Meta:
896         model = Slice
897         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
898
899 class SliceIdSerializer(XOSModelSerializer):
900     id = IdField()
901     
902     
903     networks = serializers.PrimaryKeyRelatedField(many=True,  queryset = Network.objects.all())
904     
905     
906     
907     networks = serializers.PrimaryKeyRelatedField(many=True,  queryset = Network.objects.all())
908     
909     
910     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
911     validators = serializers.SerializerMethodField("getValidators")
912     def getHumanReadableName(self, obj):\r
913         return str(obj)\r
914     def getValidators(self, obj):\r
915         try:
916             return obj.getValidators()
917         except:
918             return None\r
919     class Meta:\r
920         model = Slice
921         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
922
923
924
925
926 class NetworkSerializer(serializers.HyperlinkedModelSerializer):
927     id = IdField()
928     
929     
930     slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
931     
932     
933     
934     slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
935     
936     
937     
938     slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
939     
940     
941     
942     routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
943     
944     
945     
946     routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
947     
948     
949     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
950     validators = serializers.SerializerMethodField("getValidators")
951     def getHumanReadableName(self, obj):\r
952         return str(obj)
953     def getValidators(self, obj):
954         try:
955             return obj.getValidators()
956         except:
957             return None
958     class Meta:
959         model = Network
960         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
961
962 class NetworkIdSerializer(XOSModelSerializer):
963     id = IdField()
964     
965     
966     slices = serializers.PrimaryKeyRelatedField(many=True,  queryset = Slice.objects.all())
967     
968     
969     
970     slices = serializers.PrimaryKeyRelatedField(many=True,  queryset = Slice.objects.all())
971     
972     
973     
974     slivers = serializers.PrimaryKeyRelatedField(many=True,  queryset = Sliver.objects.all())
975     
976     
977     
978     routers = serializers.PrimaryKeyRelatedField(many=True,  queryset = Router.objects.all())
979     
980     
981     
982     routers = serializers.PrimaryKeyRelatedField(many=True,  queryset = Router.objects.all())
983     
984     
985     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
986     validators = serializers.SerializerMethodField("getValidators")
987     def getHumanReadableName(self, obj):\r
988         return str(obj)\r
989     def getValidators(self, obj):\r
990         try:
991             return obj.getValidators()
992         except:
993             return None\r
994     class Meta:\r
995         model = Network
996         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
997
998
999
1000
1001 class ServiceSerializer(serializers.HyperlinkedModelSerializer):
1002     id = IdField()
1003     
1004     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1005     validators = serializers.SerializerMethodField("getValidators")
1006     def getHumanReadableName(self, obj):\r
1007         return str(obj)
1008     def getValidators(self, obj):
1009         try:
1010             return obj.getValidators()
1011         except:
1012             return None
1013     class Meta:
1014         model = Service
1015         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
1016
1017 class ServiceIdSerializer(XOSModelSerializer):
1018     id = IdField()
1019     
1020     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1021     validators = serializers.SerializerMethodField("getValidators")
1022     def getHumanReadableName(self, obj):\r
1023         return str(obj)\r
1024     def getValidators(self, obj):\r
1025         try:
1026             return obj.getValidators()
1027         except:
1028             return None\r
1029     class Meta:\r
1030         model = Service
1031         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
1032
1033
1034
1035
1036 class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
1037     id = IdField()
1038     
1039     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1040     validators = serializers.SerializerMethodField("getValidators")
1041     def getHumanReadableName(self, obj):\r
1042         return str(obj)
1043     def getValidators(self, obj):
1044         try:
1045             return obj.getValidators()
1046         except:
1047             return None
1048     class Meta:
1049         model = ServiceClass
1050         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
1051
1052 class ServiceClassIdSerializer(XOSModelSerializer):
1053     id = IdField()
1054     
1055     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1056     validators = serializers.SerializerMethodField("getValidators")
1057     def getHumanReadableName(self, obj):\r
1058         return str(obj)\r
1059     def getValidators(self, obj):\r
1060         try:
1061             return obj.getValidators()
1062         except:
1063             return None\r
1064     class Meta:\r
1065         model = ServiceClass
1066         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
1067
1068
1069
1070
1071 class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
1072     id = IdField()
1073     
1074     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1075     validators = serializers.SerializerMethodField("getValidators")
1076     def getHumanReadableName(self, obj):\r
1077         return str(obj)
1078     def getValidators(self, obj):
1079         try:
1080             return obj.getValidators()
1081         except:
1082             return None
1083     class Meta:
1084         model = PlanetStack
1085         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
1086
1087 class PlanetStackIdSerializer(XOSModelSerializer):
1088     id = IdField()
1089     
1090     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1091     validators = serializers.SerializerMethodField("getValidators")
1092     def getHumanReadableName(self, obj):\r
1093         return str(obj)\r
1094     def getValidators(self, obj):\r
1095         try:
1096             return obj.getValidators()
1097         except:
1098             return None\r
1099     class Meta:\r
1100         model = PlanetStack
1101         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
1102
1103
1104
1105
1106 class ChargeSerializer(serializers.HyperlinkedModelSerializer):
1107     id = IdField()
1108     
1109     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1110     validators = serializers.SerializerMethodField("getValidators")
1111     def getHumanReadableName(self, obj):\r
1112         return str(obj)
1113     def getValidators(self, obj):
1114         try:
1115             return obj.getValidators()
1116         except:
1117             return None
1118     class Meta:
1119         model = Charge
1120         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
1121
1122 class ChargeIdSerializer(XOSModelSerializer):
1123     id = IdField()
1124     
1125     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1126     validators = serializers.SerializerMethodField("getValidators")
1127     def getHumanReadableName(self, obj):\r
1128         return str(obj)\r
1129     def getValidators(self, obj):\r
1130         try:
1131             return obj.getValidators()
1132         except:
1133             return None\r
1134     class Meta:\r
1135         model = Charge
1136         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
1137
1138
1139
1140
1141 class RoleSerializer(serializers.HyperlinkedModelSerializer):
1142     id = IdField()
1143     
1144     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1145     validators = serializers.SerializerMethodField("getValidators")
1146     def getHumanReadableName(self, obj):\r
1147         return str(obj)
1148     def getValidators(self, obj):
1149         try:
1150             return obj.getValidators()
1151         except:
1152             return None
1153     class Meta:
1154         model = Role
1155         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
1156
1157 class RoleIdSerializer(XOSModelSerializer):
1158     id = IdField()
1159     
1160     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1161     validators = serializers.SerializerMethodField("getValidators")
1162     def getHumanReadableName(self, obj):\r
1163         return str(obj)\r
1164     def getValidators(self, obj):\r
1165         try:
1166             return obj.getValidators()
1167         except:
1168             return None\r
1169     class Meta:\r
1170         model = Role
1171         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
1172
1173
1174
1175
1176 class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
1177     id = IdField()
1178     
1179     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1180     validators = serializers.SerializerMethodField("getValidators")
1181     def getHumanReadableName(self, obj):\r
1182         return str(obj)
1183     def getValidators(self, obj):
1184         try:
1185             return obj.getValidators()
1186         except:
1187             return None
1188     class Meta:
1189         model = UsableObject
1190         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
1191
1192 class UsableObjectIdSerializer(XOSModelSerializer):
1193     id = IdField()
1194     
1195     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1196     validators = serializers.SerializerMethodField("getValidators")
1197     def getHumanReadableName(self, obj):\r
1198         return str(obj)\r
1199     def getValidators(self, obj):\r
1200         try:
1201             return obj.getValidators()
1202         except:
1203             return None\r
1204     class Meta:\r
1205         model = UsableObject
1206         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
1207
1208
1209
1210
1211 class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
1212     id = IdField()
1213     
1214     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1215     validators = serializers.SerializerMethodField("getValidators")
1216     def getHumanReadableName(self, obj):\r
1217         return str(obj)
1218     def getValidators(self, obj):
1219         try:
1220             return obj.getValidators()
1221         except:
1222             return None
1223     class Meta:
1224         model = SiteRole
1225         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1226
1227 class SiteRoleIdSerializer(XOSModelSerializer):
1228     id = IdField()
1229     
1230     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1231     validators = serializers.SerializerMethodField("getValidators")
1232     def getHumanReadableName(self, obj):\r
1233         return str(obj)\r
1234     def getValidators(self, obj):\r
1235         try:
1236             return obj.getValidators()
1237         except:
1238             return None\r
1239     class Meta:\r
1240         model = SiteRole
1241         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1242
1243
1244
1245
1246 class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
1247     id = IdField()
1248     
1249     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1250     validators = serializers.SerializerMethodField("getValidators")
1251     def getHumanReadableName(self, obj):\r
1252         return str(obj)
1253     def getValidators(self, obj):
1254         try:
1255             return obj.getValidators()
1256         except:
1257             return None
1258     class Meta:
1259         model = SliceCredential
1260         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
1261
1262 class SliceCredentialIdSerializer(XOSModelSerializer):
1263     id = IdField()
1264     
1265     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1266     validators = serializers.SerializerMethodField("getValidators")
1267     def getHumanReadableName(self, obj):\r
1268         return str(obj)\r
1269     def getValidators(self, obj):\r
1270         try:
1271             return obj.getValidators()
1272         except:
1273             return None\r
1274     class Meta:\r
1275         model = SliceCredential
1276         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
1277
1278
1279
1280
1281 class SliverSerializer(serializers.HyperlinkedModelSerializer):
1282     id = IdField()
1283     
1284     
1285     networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1286     
1287     
1288     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1289     validators = serializers.SerializerMethodField("getValidators")
1290     def getHumanReadableName(self, obj):\r
1291         return str(obj)
1292     def getValidators(self, obj):
1293         try:
1294             return obj.getValidators()
1295         except:
1296             return None
1297     class Meta:
1298         model = Sliver
1299         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
1300
1301 class SliverIdSerializer(XOSModelSerializer):
1302     id = IdField()
1303     
1304     
1305     networks = serializers.PrimaryKeyRelatedField(many=True,  queryset = Network.objects.all())
1306     
1307     
1308     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1309     validators = serializers.SerializerMethodField("getValidators")
1310     def getHumanReadableName(self, obj):\r
1311         return str(obj)\r
1312     def getValidators(self, obj):\r
1313         try:
1314             return obj.getValidators()
1315         except:
1316             return None\r
1317     class Meta:\r
1318         model = Sliver
1319         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
1320
1321
1322
1323
1324 class NodeSerializer(serializers.HyperlinkedModelSerializer):
1325     id = IdField()
1326     
1327     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1328     validators = serializers.SerializerMethodField("getValidators")
1329     def getHumanReadableName(self, obj):\r
1330         return str(obj)
1331     def getValidators(self, obj):
1332         try:
1333             return obj.getValidators()
1334         except:
1335             return None
1336     class Meta:
1337         model = Node
1338         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
1339
1340 class NodeIdSerializer(XOSModelSerializer):
1341     id = IdField()
1342     
1343     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1344     validators = serializers.SerializerMethodField("getValidators")
1345     def getHumanReadableName(self, obj):\r
1346         return str(obj)\r
1347     def getValidators(self, obj):\r
1348         try:
1349             return obj.getValidators()
1350         except:
1351             return None\r
1352     class Meta:\r
1353         model = Node
1354         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
1355
1356
1357
1358
1359 class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
1360     id = IdField()
1361     
1362     
1363     controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1364     
1365     
1366     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1367     validators = serializers.SerializerMethodField("getValidators")
1368     def getHumanReadableName(self, obj):\r
1369         return str(obj)
1370     def getValidators(self, obj):
1371         try:
1372             return obj.getValidators()
1373         except:
1374             return None
1375     class Meta:
1376         model = DashboardView
1377         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
1378
1379 class DashboardViewIdSerializer(XOSModelSerializer):
1380     id = IdField()
1381     
1382     
1383     controllers = serializers.PrimaryKeyRelatedField(many=True,  queryset = Controller.objects.all())
1384     
1385     
1386     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1387     validators = serializers.SerializerMethodField("getValidators")
1388     def getHumanReadableName(self, obj):\r
1389         return str(obj)\r
1390     def getValidators(self, obj):\r
1391         try:
1392             return obj.getValidators()
1393         except:
1394             return None\r
1395     class Meta:\r
1396         model = DashboardView
1397         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
1398
1399
1400
1401
1402 class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer):
1403     id = IdField()
1404     
1405     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1406     validators = serializers.SerializerMethodField("getValidators")
1407     def getHumanReadableName(self, obj):\r
1408         return str(obj)
1409     def getValidators(self, obj):
1410         try:
1411             return obj.getValidators()
1412         except:
1413             return None
1414     class Meta:
1415         model = ControllerNetwork
1416         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
1417
1418 class ControllerNetworkIdSerializer(XOSModelSerializer):
1419     id = IdField()
1420     
1421     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1422     validators = serializers.SerializerMethodField("getValidators")
1423     def getHumanReadableName(self, obj):\r
1424         return str(obj)\r
1425     def getValidators(self, obj):\r
1426         try:
1427             return obj.getValidators()
1428         except:
1429             return None\r
1430     class Meta:\r
1431         model = ControllerNetwork
1432         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
1433
1434
1435
1436
1437 class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
1438     id = IdField()
1439     
1440     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1441     validators = serializers.SerializerMethodField("getValidators")
1442     def getHumanReadableName(self, obj):\r
1443         return str(obj)
1444     def getValidators(self, obj):
1445         try:
1446             return obj.getValidators()
1447         except:
1448             return None
1449     class Meta:
1450         model = ImageDeployments
1451         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
1452
1453 class ImageDeploymentsIdSerializer(XOSModelSerializer):
1454     id = IdField()
1455     
1456     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1457     validators = serializers.SerializerMethodField("getValidators")
1458     def getHumanReadableName(self, obj):\r
1459         return str(obj)\r
1460     def getValidators(self, obj):\r
1461         try:
1462             return obj.getValidators()
1463         except:
1464             return None\r
1465     class Meta:\r
1466         model = ImageDeployments
1467         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
1468
1469
1470
1471
1472 class ControllerUserSerializer(serializers.HyperlinkedModelSerializer):
1473     id = IdField()
1474     
1475     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1476     validators = serializers.SerializerMethodField("getValidators")
1477     def getHumanReadableName(self, obj):\r
1478         return str(obj)
1479     def getValidators(self, obj):
1480         try:
1481             return obj.getValidators()
1482         except:
1483             return None
1484     class Meta:
1485         model = ControllerUser
1486         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
1487
1488 class ControllerUserIdSerializer(XOSModelSerializer):
1489     id = IdField()
1490     
1491     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1492     validators = serializers.SerializerMethodField("getValidators")
1493     def getHumanReadableName(self, obj):\r
1494         return str(obj)\r
1495     def getValidators(self, obj):\r
1496         try:
1497             return obj.getValidators()
1498         except:
1499             return None\r
1500     class Meta:\r
1501         model = ControllerUser
1502         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
1503
1504
1505
1506
1507 class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
1508     id = IdField()
1509     
1510     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1511     validators = serializers.SerializerMethodField("getValidators")
1512     def getHumanReadableName(self, obj):\r
1513         return str(obj)
1514     def getValidators(self, obj):
1515         try:
1516             return obj.getValidators()
1517         except:
1518             return None
1519     class Meta:
1520         model = ReservedResource
1521         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
1522
1523 class ReservedResourceIdSerializer(XOSModelSerializer):
1524     id = IdField()
1525     
1526     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1527     validators = serializers.SerializerMethodField("getValidators")
1528     def getHumanReadableName(self, obj):\r
1529         return str(obj)\r
1530     def getValidators(self, obj):\r
1531         try:
1532             return obj.getValidators()
1533         except:
1534             return None\r
1535     class Meta:\r
1536         model = ReservedResource
1537         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
1538
1539
1540
1541
1542 class PaymentSerializer(serializers.HyperlinkedModelSerializer):
1543     id = IdField()
1544     
1545     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1546     validators = serializers.SerializerMethodField("getValidators")
1547     def getHumanReadableName(self, obj):\r
1548         return str(obj)
1549     def getValidators(self, obj):
1550         try:
1551             return obj.getValidators()
1552         except:
1553             return None
1554     class Meta:
1555         model = Payment
1556         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1557
1558 class PaymentIdSerializer(XOSModelSerializer):
1559     id = IdField()
1560     
1561     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1562     validators = serializers.SerializerMethodField("getValidators")
1563     def getHumanReadableName(self, obj):\r
1564         return str(obj)\r
1565     def getValidators(self, obj):\r
1566         try:
1567             return obj.getValidators()
1568         except:
1569             return None\r
1570     class Meta:\r
1571         model = Payment
1572         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1573
1574
1575
1576
1577 class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
1578     id = IdField()
1579     
1580     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1581     validators = serializers.SerializerMethodField("getValidators")
1582     def getHumanReadableName(self, obj):\r
1583         return str(obj)
1584     def getValidators(self, obj):
1585         try:
1586             return obj.getValidators()
1587         except:
1588             return None
1589     class Meta:
1590         model = NetworkSlice
1591         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
1592
1593 class NetworkSliceIdSerializer(XOSModelSerializer):
1594     id = IdField()
1595     
1596     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1597     validators = serializers.SerializerMethodField("getValidators")
1598     def getHumanReadableName(self, obj):\r
1599         return str(obj)\r
1600     def getValidators(self, obj):\r
1601         try:
1602             return obj.getValidators()
1603         except:
1604             return None\r
1605     class Meta:\r
1606         model = NetworkSlice
1607         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
1608
1609
1610
1611
1612 class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
1613     id = IdField()
1614     
1615     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1616     validators = serializers.SerializerMethodField("getValidators")
1617     def getHumanReadableName(self, obj):\r
1618         return str(obj)
1619     def getValidators(self, obj):
1620         try:
1621             return obj.getValidators()
1622         except:
1623             return None
1624     class Meta:
1625         model = UserDashboardView
1626         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
1627
1628 class UserDashboardViewIdSerializer(XOSModelSerializer):
1629     id = IdField()
1630     
1631     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1632     validators = serializers.SerializerMethodField("getValidators")
1633     def getHumanReadableName(self, obj):\r
1634         return str(obj)\r
1635     def getValidators(self, obj):\r
1636         try:
1637             return obj.getValidators()
1638         except:
1639             return None\r
1640     class Meta:\r
1641         model = UserDashboardView
1642         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
1643
1644
1645
1646
1647 class ControllerSerializer(serializers.HyperlinkedModelSerializer):
1648     id = IdField()
1649     
1650     
1651     dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1652     
1653     
1654     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1655     validators = serializers.SerializerMethodField("getValidators")
1656     def getHumanReadableName(self, obj):\r
1657         return str(obj)
1658     def getValidators(self, obj):
1659         try:
1660             return obj.getValidators()
1661         except:
1662             return None
1663     class Meta:
1664         model = Controller
1665         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
1666
1667 class ControllerIdSerializer(XOSModelSerializer):
1668     id = IdField()
1669     
1670     
1671     dashboardviews = serializers.PrimaryKeyRelatedField(many=True,  queryset = DashboardView.objects.all())
1672     
1673     
1674     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1675     validators = serializers.SerializerMethodField("getValidators")
1676     def getHumanReadableName(self, obj):\r
1677         return str(obj)\r
1678     def getValidators(self, obj):\r
1679         try:
1680             return obj.getValidators()
1681         except:
1682             return None\r
1683     class Meta:\r
1684         model = Controller
1685         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
1686
1687
1688
1689
1690 class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1691     id = IdField()
1692     
1693     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1694     validators = serializers.SerializerMethodField("getValidators")
1695     def getHumanReadableName(self, obj):\r
1696         return str(obj)
1697     def getValidators(self, obj):
1698         try:
1699             return obj.getValidators()
1700         except:
1701             return None
1702     class Meta:
1703         model = PlanetStackPrivilege
1704         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1705
1706 class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
1707     id = IdField()
1708     
1709     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1710     validators = serializers.SerializerMethodField("getValidators")
1711     def getHumanReadableName(self, obj):\r
1712         return str(obj)\r
1713     def getValidators(self, obj):\r
1714         try:
1715             return obj.getValidators()
1716         except:
1717             return None\r
1718     class Meta:\r
1719         model = PlanetStackPrivilege
1720         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1721
1722
1723
1724
1725 class UserSerializer(serializers.HyperlinkedModelSerializer):
1726     id = IdField()
1727     
1728     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1729     validators = serializers.SerializerMethodField("getValidators")
1730     def getHumanReadableName(self, obj):\r
1731         return str(obj)
1732     def getValidators(self, obj):
1733         try:
1734             return obj.getValidators()
1735         except:
1736             return None
1737     class Meta:
1738         model = User
1739         fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
1740
1741 class UserIdSerializer(XOSModelSerializer):
1742     id = IdField()
1743     
1744     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1745     validators = serializers.SerializerMethodField("getValidators")
1746     def getHumanReadableName(self, obj):\r
1747         return str(obj)\r
1748     def getValidators(self, obj):\r
1749         try:
1750             return obj.getValidators()
1751         except:
1752             return None\r
1753     class Meta:\r
1754         model = User
1755         fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
1756
1757
1758
1759
1760 class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
1761     id = IdField()
1762     
1763     
1764     images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1765     
1766     
1767     
1768     sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1769     
1770     
1771     
1772     flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1773     
1774     
1775     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1776     validators = serializers.SerializerMethodField("getValidators")
1777     def getHumanReadableName(self, obj):\r
1778         return str(obj)
1779     def getValidators(self, obj):
1780         try:
1781             return obj.getValidators()
1782         except:
1783             return None
1784     class Meta:
1785         model = Deployment
1786         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',)
1787
1788 class DeploymentIdSerializer(XOSModelSerializer):
1789     id = IdField()
1790     
1791     
1792     images = serializers.PrimaryKeyRelatedField(many=True,  queryset = Image.objects.all())
1793     
1794     
1795     
1796     sites = serializers.PrimaryKeyRelatedField(many=True,  queryset = Site.objects.all())
1797     
1798     
1799     
1800     flavors = serializers.PrimaryKeyRelatedField(many=True,  queryset = Flavor.objects.all())
1801     
1802     
1803     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1804     validators = serializers.SerializerMethodField("getValidators")
1805     def getHumanReadableName(self, obj):\r
1806         return str(obj)\r
1807     def getValidators(self, obj):\r
1808         try:
1809             return obj.getValidators()
1810         except:
1811             return None\r
1812     class Meta:\r
1813         model = Deployment
1814         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',)
1815
1816
1817
1818
1819 class ReservationSerializer(serializers.HyperlinkedModelSerializer):
1820     id = IdField()
1821     
1822     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1823     validators = serializers.SerializerMethodField("getValidators")
1824     def getHumanReadableName(self, obj):\r
1825         return str(obj)
1826     def getValidators(self, obj):
1827         try:
1828             return obj.getValidators()
1829         except:
1830             return None
1831     class Meta:
1832         model = Reservation
1833         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
1834
1835 class ReservationIdSerializer(XOSModelSerializer):
1836     id = IdField()
1837     
1838     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1839     validators = serializers.SerializerMethodField("getValidators")
1840     def getHumanReadableName(self, obj):\r
1841         return str(obj)\r
1842     def getValidators(self, obj):\r
1843         try:
1844             return obj.getValidators()
1845         except:
1846             return None\r
1847     class Meta:\r
1848         model = Reservation
1849         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
1850
1851
1852
1853
1854 class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1855     id = IdField()
1856     
1857     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1858     validators = serializers.SerializerMethodField("getValidators")
1859     def getHumanReadableName(self, obj):\r
1860         return str(obj)
1861     def getValidators(self, obj):
1862         try:
1863             return obj.getValidators()
1864         except:
1865             return None
1866     class Meta:
1867         model = SitePrivilege
1868         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
1869
1870 class SitePrivilegeIdSerializer(XOSModelSerializer):
1871     id = IdField()
1872     
1873     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1874     validators = serializers.SerializerMethodField("getValidators")
1875     def getHumanReadableName(self, obj):\r
1876         return str(obj)\r
1877     def getValidators(self, obj):\r
1878         try:
1879             return obj.getValidators()
1880         except:
1881             return None\r
1882     class Meta:\r
1883         model = SitePrivilege
1884         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
1885
1886
1887
1888
1889 class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer):
1890     id = IdField()
1891     
1892     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1893     validators = serializers.SerializerMethodField("getValidators")
1894     def getHumanReadableName(self, obj):\r
1895         return str(obj)
1896     def getValidators(self, obj):
1897         try:
1898             return obj.getValidators()
1899         except:
1900             return None
1901     class Meta:
1902         model = ControllerSlice
1903         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
1904
1905 class ControllerSliceIdSerializer(XOSModelSerializer):
1906     id = IdField()
1907     
1908     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1909     validators = serializers.SerializerMethodField("getValidators")
1910     def getHumanReadableName(self, obj):\r
1911         return str(obj)\r
1912     def getValidators(self, obj):\r
1913         try:
1914             return obj.getValidators()
1915         except:
1916             return None\r
1917     class Meta:\r
1918         model = ControllerSlice
1919         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
1920
1921
1922
1923
1924 class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
1925     id = IdField()
1926     
1927     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1928     validators = serializers.SerializerMethodField("getValidators")
1929     def getHumanReadableName(self, obj):\r
1930         return str(obj)
1931     def getValidators(self, obj):
1932         try:
1933             return obj.getValidators()
1934         except:
1935             return None
1936     class Meta:
1937         model = ControllerDashboardView
1938         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1939
1940 class ControllerDashboardViewIdSerializer(XOSModelSerializer):
1941     id = IdField()
1942     
1943     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1944     validators = serializers.SerializerMethodField("getValidators")
1945     def getHumanReadableName(self, obj):\r
1946         return str(obj)\r
1947     def getValidators(self, obj):\r
1948         try:
1949             return obj.getValidators()
1950         except:
1951             return None\r
1952     class Meta:\r
1953         model = ControllerDashboardView
1954         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1955
1956
1957
1958
1959 class AccountSerializer(serializers.HyperlinkedModelSerializer):
1960     id = IdField()
1961     
1962     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1963     validators = serializers.SerializerMethodField("getValidators")
1964     def getHumanReadableName(self, obj):\r
1965         return str(obj)
1966     def getValidators(self, obj):
1967         try:
1968             return obj.getValidators()
1969         except:
1970             return None
1971     class Meta:
1972         model = Account
1973         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
1974
1975 class AccountIdSerializer(XOSModelSerializer):
1976     id = IdField()
1977     
1978     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1979     validators = serializers.SerializerMethodField("getValidators")
1980     def getHumanReadableName(self, obj):\r
1981         return str(obj)\r
1982     def getValidators(self, obj):\r
1983         try:
1984             return obj.getValidators()
1985         except:
1986             return None\r
1987     class Meta:\r
1988         model = Account
1989         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
1990
1991
1992
1993
1994 class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
1995     id = IdField()
1996     
1997     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1998     validators = serializers.SerializerMethodField("getValidators")
1999     def getHumanReadableName(self, obj):\r
2000         return str(obj)
2001     def getValidators(self, obj):
2002         try:
2003             return obj.getValidators()
2004         except:
2005             return None
2006     class Meta:
2007         model = ControllerRole
2008         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
2009
2010 class ControllerRoleIdSerializer(XOSModelSerializer):
2011     id = IdField()
2012     
2013     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2014     validators = serializers.SerializerMethodField("getValidators")
2015     def getHumanReadableName(self, obj):\r
2016         return str(obj)\r
2017     def getValidators(self, obj):\r
2018         try:
2019             return obj.getValidators()
2020         except:
2021             return None\r
2022     class Meta:\r
2023         model = ControllerRole
2024         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
2025
2026
2027
2028
2029 class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
2030     id = IdField()
2031     
2032     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2033     validators = serializers.SerializerMethodField("getValidators")
2034     def getHumanReadableName(self, obj):\r
2035         return str(obj)
2036     def getValidators(self, obj):
2037         try:
2038             return obj.getValidators()
2039         except:
2040             return None
2041     class Meta:
2042         model = NetworkParameterType
2043         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
2044
2045 class NetworkParameterTypeIdSerializer(XOSModelSerializer):
2046     id = IdField()
2047     
2048     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2049     validators = serializers.SerializerMethodField("getValidators")
2050     def getHumanReadableName(self, obj):\r
2051         return str(obj)\r
2052     def getValidators(self, obj):\r
2053         try:
2054             return obj.getValidators()
2055         except:
2056             return None\r
2057     class Meta:\r
2058         model = NetworkParameterType
2059         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
2060
2061
2062
2063
2064 class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
2065     id = IdField()
2066     
2067     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2068     validators = serializers.SerializerMethodField("getValidators")
2069     def getHumanReadableName(self, obj):\r
2070         return str(obj)
2071     def getValidators(self, obj):
2072         try:
2073             return obj.getValidators()
2074         except:
2075             return None
2076     class Meta:
2077         model = SiteCredential
2078         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
2079
2080 class SiteCredentialIdSerializer(XOSModelSerializer):
2081     id = IdField()
2082     
2083     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2084     validators = serializers.SerializerMethodField("getValidators")
2085     def getHumanReadableName(self, obj):\r
2086         return str(obj)\r
2087     def getValidators(self, obj):\r
2088         try:
2089             return obj.getValidators()
2090         except:
2091             return None\r
2092     class Meta:\r
2093         model = SiteCredential
2094         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
2095
2096
2097
2098
2099 class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
2100     id = IdField()
2101     
2102     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2103     validators = serializers.SerializerMethodField("getValidators")
2104     def getHumanReadableName(self, obj):\r
2105         return str(obj)
2106     def getValidators(self, obj):
2107         try:
2108             return obj.getValidators()
2109         except:
2110             return None
2111     class Meta:
2112         model = DeploymentPrivilege
2113         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
2114
2115 class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
2116     id = IdField()
2117     
2118     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2119     validators = serializers.SerializerMethodField("getValidators")
2120     def getHumanReadableName(self, obj):\r
2121         return str(obj)\r
2122     def getValidators(self, obj):\r
2123         try:
2124             return obj.getValidators()
2125         except:
2126             return None\r
2127     class Meta:\r
2128         model = DeploymentPrivilege
2129         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
2130
2131
2132
2133
2134 class ControllerSlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
2135     id = IdField()
2136     
2137     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2138     validators = serializers.SerializerMethodField("getValidators")
2139     def getHumanReadableName(self, obj):\r
2140         return str(obj)
2141     def getValidators(self, obj):
2142         try:
2143             return obj.getValidators()
2144         except:
2145             return None
2146     class Meta:
2147         model = ControllerSlicePrivilege
2148         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',)
2149
2150 class ControllerSlicePrivilegeIdSerializer(XOSModelSerializer):
2151     id = IdField()
2152     
2153     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2154     validators = serializers.SerializerMethodField("getValidators")
2155     def getHumanReadableName(self, obj):\r
2156         return str(obj)\r
2157     def getValidators(self, obj):\r
2158         try:
2159             return obj.getValidators()
2160         except:
2161             return None\r
2162     class Meta:\r
2163         model = ControllerSlicePrivilege
2164         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',)
2165
2166
2167
2168
2169 class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer):
2170     id = IdField()
2171     
2172     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2173     validators = serializers.SerializerMethodField("getValidators")
2174     def getHumanReadableName(self, obj):\r
2175         return str(obj)
2176     def getValidators(self, obj):
2177         try:
2178             return obj.getValidators()
2179         except:
2180             return None
2181     class Meta:
2182         model = SiteDeployment
2183         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
2184
2185 class SiteDeploymentIdSerializer(XOSModelSerializer):
2186     id = IdField()
2187     
2188     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2189     validators = serializers.SerializerMethodField("getValidators")
2190     def getHumanReadableName(self, obj):\r
2191         return str(obj)\r
2192     def getValidators(self, obj):\r
2193         try:
2194             return obj.getValidators()
2195         except:
2196             return None\r
2197     class Meta:\r
2198         model = SiteDeployment
2199         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
2200
2201
2202
2203
2204 class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
2205     id = IdField()
2206     
2207     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2208     validators = serializers.SerializerMethodField("getValidators")
2209     def getHumanReadableName(self, obj):\r
2210         return str(obj)
2211     def getValidators(self, obj):
2212         try:
2213             return obj.getValidators()
2214         except:
2215             return None
2216     class Meta:
2217         model = DeploymentRole
2218         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
2219
2220 class DeploymentRoleIdSerializer(XOSModelSerializer):
2221     id = IdField()
2222     
2223     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2224     validators = serializers.SerializerMethodField("getValidators")
2225     def getHumanReadableName(self, obj):\r
2226         return str(obj)\r
2227     def getValidators(self, obj):\r
2228         try:
2229             return obj.getValidators()
2230         except:
2231             return None\r
2232     class Meta:\r
2233         model = DeploymentRole
2234         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
2235
2236
2237
2238
2239 class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
2240     id = IdField()
2241     
2242     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2243     validators = serializers.SerializerMethodField("getValidators")
2244     def getHumanReadableName(self, obj):\r
2245         return str(obj)
2246     def getValidators(self, obj):
2247         try:
2248             return obj.getValidators()
2249         except:
2250             return None
2251     class Meta:
2252         model = UserCredential
2253         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
2254
2255 class UserCredentialIdSerializer(XOSModelSerializer):
2256     id = IdField()
2257     
2258     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2259     validators = serializers.SerializerMethodField("getValidators")
2260     def getHumanReadableName(self, obj):\r
2261         return str(obj)\r
2262     def getValidators(self, obj):\r
2263         try:
2264             return obj.getValidators()
2265         except:
2266             return None\r
2267     class Meta:\r
2268         model = UserCredential
2269         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
2270
2271
2272
2273
2274 class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
2275     id = IdField()
2276     
2277     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2278     validators = serializers.SerializerMethodField("getValidators")
2279     def getHumanReadableName(self, obj):\r
2280         return str(obj)
2281     def getValidators(self, obj):
2282         try:
2283             return obj.getValidators()
2284         except:
2285             return None
2286     class Meta:
2287         model = SliceTag
2288         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
2289
2290 class SliceTagIdSerializer(XOSModelSerializer):
2291     id = IdField()
2292     
2293     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2294     validators = serializers.SerializerMethodField("getValidators")
2295     def getHumanReadableName(self, obj):\r
2296         return str(obj)\r
2297     def getValidators(self, obj):\r
2298         try:
2299             return obj.getValidators()
2300         except:
2301             return None\r
2302     class Meta:\r
2303         model = SliceTag
2304         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
2305
2306
2307
2308
2309 class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
2310     id = IdField()
2311     
2312     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2313     validators = serializers.SerializerMethodField("getValidators")
2314     def getHumanReadableName(self, obj):\r
2315         return str(obj)
2316     def getValidators(self, obj):
2317         try:
2318             return obj.getValidators()
2319         except:
2320             return None
2321     class Meta:
2322         model = NetworkTemplate
2323         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
2324
2325 class NetworkTemplateIdSerializer(XOSModelSerializer):
2326     id = IdField()
2327     
2328     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2329     validators = serializers.SerializerMethodField("getValidators")
2330     def getHumanReadableName(self, obj):\r
2331         return str(obj)\r
2332     def getValidators(self, obj):\r
2333         try:
2334             return obj.getValidators()
2335         except:
2336             return None\r
2337     class Meta:\r
2338         model = NetworkTemplate
2339         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
2340
2341
2342
2343
2344 class RouterSerializer(serializers.HyperlinkedModelSerializer):
2345     id = IdField()
2346     
2347     
2348     networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2349     
2350     
2351     
2352     networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2353     
2354     
2355     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2356     validators = serializers.SerializerMethodField("getValidators")
2357     def getHumanReadableName(self, obj):\r
2358         return str(obj)
2359     def getValidators(self, obj):
2360         try:
2361             return obj.getValidators()
2362         except:
2363             return None
2364     class Meta:
2365         model = Router
2366         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
2367
2368 class RouterIdSerializer(XOSModelSerializer):
2369     id = IdField()
2370     
2371     
2372     networks = serializers.PrimaryKeyRelatedField(many=True,  queryset = Network.objects.all())
2373     
2374     
2375     
2376     networks = serializers.PrimaryKeyRelatedField(many=True,  queryset = Network.objects.all())
2377     
2378     
2379     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2380     validators = serializers.SerializerMethodField("getValidators")
2381     def getHumanReadableName(self, obj):\r
2382         return str(obj)\r
2383     def getValidators(self, obj):\r
2384         try:
2385             return obj.getValidators()
2386         except:
2387             return None\r
2388     class Meta:\r
2389         model = Router
2390         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
2391
2392
2393
2394
2395 class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
2396     id = IdField()
2397     
2398     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2399     validators = serializers.SerializerMethodField("getValidators")
2400     def getHumanReadableName(self, obj):\r
2401         return str(obj)
2402     def getValidators(self, obj):
2403         try:
2404             return obj.getValidators()
2405         except:
2406             return None
2407     class Meta:
2408         model = ServiceResource
2409         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
2410
2411 class ServiceResourceIdSerializer(XOSModelSerializer):
2412     id = IdField()
2413     
2414     humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2415     validators = serializers.SerializerMethodField("getValidators")
2416     def getHumanReadableName(self, obj):\r
2417         return str(obj)\r
2418     def getValidators(self, obj):\r
2419         try:
2420             return obj.getValidators()
2421         except:
2422             return None\r
2423     class Meta:\r
2424         model = ServiceResource
2425         fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
2426
2427
2428
2429
2430 serializerLookUp = { 
2431
2432                  ServiceAttribute: ServiceAttributeSerializer,
2433
2434                  ControllerImages: ControllerImagesSerializer,
2435
2436                  ControllerSitePrivilege: ControllerSitePrivilegeSerializer,
2437
2438                  Image: ImageSerializer,
2439
2440                  NetworkParameter: NetworkParameterSerializer,
2441
2442                  Site: SiteSerializer,
2443
2444                  SliceRole: SliceRoleSerializer,
2445
2446                  Tag: TagSerializer,
2447
2448                  Invoice: InvoiceSerializer,
2449
2450                  SlicePrivilege: SlicePrivilegeSerializer,
2451
2452                  PlanetStackRole: PlanetStackRoleSerializer,
2453
2454                  NetworkSliver: NetworkSliverSerializer,
2455
2456                  Flavor: FlavorSerializer,
2457
2458                  ControllerSite: ControllerSiteSerializer,
2459
2460                  Project: ProjectSerializer,
2461
2462                  Slice: SliceSerializer,
2463
2464                  Network: NetworkSerializer,
2465
2466                  Service: ServiceSerializer,
2467
2468                  ServiceClass: ServiceClassSerializer,
2469
2470                  PlanetStack: PlanetStackSerializer,
2471
2472                  Charge: ChargeSerializer,
2473
2474                  Role: RoleSerializer,
2475
2476                  UsableObject: UsableObjectSerializer,
2477
2478                  SiteRole: SiteRoleSerializer,
2479
2480                  SliceCredential: SliceCredentialSerializer,
2481
2482                  Sliver: SliverSerializer,
2483
2484                  Node: NodeSerializer,
2485
2486                  DashboardView: DashboardViewSerializer,
2487
2488                  ControllerNetwork: ControllerNetworkSerializer,
2489
2490                  ImageDeployments: ImageDeploymentsSerializer,
2491
2492                  ControllerUser: ControllerUserSerializer,
2493
2494                  ReservedResource: ReservedResourceSerializer,
2495
2496                  Payment: PaymentSerializer,
2497
2498                  NetworkSlice: NetworkSliceSerializer,
2499
2500                  UserDashboardView: UserDashboardViewSerializer,
2501
2502                  Controller: ControllerSerializer,
2503
2504                  PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
2505
2506                  User: UserSerializer,
2507
2508                  Deployment: DeploymentSerializer,
2509
2510                  Reservation: ReservationSerializer,
2511
2512                  SitePrivilege: SitePrivilegeSerializer,
2513
2514                  ControllerSlice: ControllerSliceSerializer,
2515
2516                  ControllerDashboardView: ControllerDashboardViewSerializer,
2517
2518                  Account: AccountSerializer,
2519
2520                  ControllerRole: ControllerRoleSerializer,
2521
2522                  NetworkParameterType: NetworkParameterTypeSerializer,
2523
2524                  SiteCredential: SiteCredentialSerializer,
2525
2526                  DeploymentPrivilege: DeploymentPrivilegeSerializer,
2527
2528                  ControllerSlicePrivilege: ControllerSlicePrivilegeSerializer,
2529
2530                  SiteDeployment: SiteDeploymentSerializer,
2531
2532                  DeploymentRole: DeploymentRoleSerializer,
2533
2534                  UserCredential: UserCredentialSerializer,
2535
2536                  SliceTag: SliceTagSerializer,
2537
2538                  NetworkTemplate: NetworkTemplateSerializer,
2539
2540                  Router: RouterSerializer,
2541
2542                  ServiceResource: ServiceResourceSerializer,
2543
2544                  None: None,
2545                 }
2546
2547 class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2548
2549     # To handle fine-grained field permissions, we have to check can_update
2550     # the object has been updated but before it has been saved.
2551
2552     def update(self, request, *args, **kwargs):\r
2553         partial = kwargs.pop('partial', False)\r
2554         self.object = self.get_object_or_none()\r
2555 \r
2556         serializer = self.get_serializer(self.object, data=request.DATA,\r
2557                                          files=request.FILES, partial=partial)\r
2558 \r
2559         if not serializer.is_valid():\r
2560             response = {"error": "validation",\r
2561                         "specific_error": "not serializer.is_valid()",\r
2562                         "reasons": serializer.errors}\r
2563             return Response(response, status=status.HTTP_400_BAD_REQUEST)\r
2564 \r
2565         try:\r
2566             self.pre_save(serializer.object)\r
2567         except ValidationError as err:\r
2568             # full_clean on model instance may be called in pre_save,\r
2569             # so we have to handle eventual errors.\r
2570             response = {"error": "validation",\r
2571                          "specific_error": "ValidationError in pre_save",\r
2572                          "reasons": err.message_dict}\r
2573             return Response(response, status=status.HTTP_400_BAD_REQUEST)\r
2574 \r
2575         if serializer.object is not None:\r
2576             if not serializer.object.can_update(request.user):\r
2577                 return Response(status=status.HTTP_400_BAD_REQUEST)\r
2578 \r
2579         if self.object is None:\r
2580             self.object = serializer.save(force_insert=True)\r
2581             self.post_save(self.object, created=True)\r
2582             return Response(serializer.data, status=status.HTTP_201_CREATED)\r
2583 \r
2584         self.object = serializer.save(force_update=True)\r
2585         self.post_save(self.object, created=False)\r
2586         return Response(serializer.data, status=status.HTTP_200_OK)
2587
2588     def destroy(self, request, *args, **kwargs):
2589         obj = self.get_object()
2590         if obj.can_update(request.user):
2591             return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
2592         else:
2593             return Response(status=status.HTTP_400_BAD_REQUEST)
2594
2595
2596 # Based on core/views/*.py
2597
2598
2599 class ServiceAttributeList(generics.ListCreateAPIView):
2600     queryset = ServiceAttribute.objects.select_related().all()
2601     serializer_class = ServiceAttributeSerializer
2602     id_serializer_class = ServiceAttributeIdSerializer
2603     filter_backends = (filters.DjangoFilterBackend,)
2604     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2605
2606     def get_serializer_class(self):
2607         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2608         if (no_hyperlinks):
2609             return self.id_serializer_class
2610         else:
2611             return self.serializer_class
2612
2613     def get_queryset(self):
2614         return ServiceAttribute.select_by_user(self.request.user)
2615
2616     def create(self, request, *args, **kwargs):
2617         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2618         if not (serializer.is_valid()):
2619             response = {"error": "validation",
2620                         "specific_error": "not serializer.is_valid()",\r
2621                         "reasons": serializer.errors}\r
2622             return Response(response, status=status.HTTP_400_BAD_REQUEST)
2623         obj = serializer.object
2624         obj.caller = request.user
2625         if obj.can_update(request.user):
2626             return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2627         else:
2628             raise Exception("failed obj.can_update")
2629
2630         ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2631         if (ret.status_code%100 != 200):
2632             raise Exception(ret.data)
2633
2634         return ret
2635
2636
2637 class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2638     queryset = ServiceAttribute.objects.select_related().all()
2639     serializer_class = ServiceAttributeSerializer
2640     id_serializer_class = ServiceAttributeIdSerializer
2641
2642     def get_serializer_class(self):
2643         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2644         if (no_hyperlinks):
2645             return self.id_serializer_class
2646         else:
2647             return self.serializer_class
2648     
2649     def get_queryset(self):
2650         return ServiceAttribute.select_by_user(self.request.user)
2651
2652     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2653
2654     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2655
2656
2657
2658 class ControllerImagesList(generics.ListCreateAPIView):
2659     queryset = ControllerImages.objects.select_related().all()
2660     serializer_class = ControllerImagesSerializer
2661     id_serializer_class = ControllerImagesIdSerializer
2662     filter_backends = (filters.DjangoFilterBackend,)
2663     filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
2664
2665     def get_serializer_class(self):
2666         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2667         if (no_hyperlinks):
2668             return self.id_serializer_class
2669         else:
2670             return self.serializer_class
2671
2672     def get_queryset(self):
2673         return ControllerImages.select_by_user(self.request.user)
2674
2675     def create(self, request, *args, **kwargs):
2676         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2677         if not (serializer.is_valid()):
2678             response = {"error": "validation",
2679                         "specific_error": "not serializer.is_valid()",\r
2680                         "reasons": serializer.errors}\r
2681             return Response(response, status=status.HTTP_400_BAD_REQUEST)
2682         obj = serializer.object
2683         obj.caller = request.user
2684         if obj.can_update(request.user):
2685             return super(ControllerImagesList, self).create(request, *args, **kwargs)
2686         else:
2687             raise Exception("failed obj.can_update")
2688
2689         ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2690         if (ret.status_code%100 != 200):
2691             raise Exception(ret.data)
2692
2693         return ret
2694
2695
2696 class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2697     queryset = ControllerImages.objects.select_related().all()
2698     serializer_class = ControllerImagesSerializer
2699     id_serializer_class = ControllerImagesIdSerializer
2700
2701     def get_serializer_class(self):
2702         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2703         if (no_hyperlinks):
2704             return self.id_serializer_class
2705         else:
2706             return self.serializer_class
2707     
2708     def get_queryset(self):
2709         return ControllerImages.select_by_user(self.request.user)
2710
2711     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2712
2713     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2714
2715
2716
2717 class ControllerSitePrivilegeList(generics.ListCreateAPIView):
2718     queryset = ControllerSitePrivilege.objects.select_related().all()
2719     serializer_class = ControllerSitePrivilegeSerializer
2720     id_serializer_class = ControllerSitePrivilegeIdSerializer
2721     filter_backends = (filters.DjangoFilterBackend,)
2722     filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',)
2723
2724     def get_serializer_class(self):
2725         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2726         if (no_hyperlinks):
2727             return self.id_serializer_class
2728         else:
2729             return self.serializer_class
2730
2731     def get_queryset(self):
2732         return ControllerSitePrivilege.select_by_user(self.request.user)
2733
2734     def create(self, request, *args, **kwargs):
2735         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2736         if not (serializer.is_valid()):
2737             response = {"error": "validation",
2738                         "specific_error": "not serializer.is_valid()",\r
2739                         "reasons": serializer.errors}\r
2740             return Response(response, status=status.HTTP_400_BAD_REQUEST)
2741         obj = serializer.object
2742         obj.caller = request.user
2743         if obj.can_update(request.user):
2744             return super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
2745         else:
2746             raise Exception("failed obj.can_update")
2747
2748         ret = super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
2749         if (ret.status_code%100 != 200):
2750             raise Exception(ret.data)
2751
2752         return ret
2753
2754
2755 class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2756     queryset = ControllerSitePrivilege.objects.select_related().all()
2757     serializer_class = ControllerSitePrivilegeSerializer
2758     id_serializer_class = ControllerSitePrivilegeIdSerializer
2759
2760     def get_serializer_class(self):
2761         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2762         if (no_hyperlinks):
2763             return self.id_serializer_class
2764         else:
2765             return self.serializer_class
2766     
2767     def get_queryset(self):
2768         return ControllerSitePrivilege.select_by_user(self.request.user)
2769
2770     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2771
2772     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2773
2774
2775
2776 class ImageList(generics.ListCreateAPIView):
2777     queryset = Image.objects.select_related().all()
2778     serializer_class = ImageSerializer
2779     id_serializer_class = ImageIdSerializer
2780     filter_backends = (filters.DjangoFilterBackend,)
2781     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
2782
2783     def get_serializer_class(self):
2784         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2785         if (no_hyperlinks):
2786             return self.id_serializer_class
2787         else:
2788             return self.serializer_class
2789
2790     def get_queryset(self):
2791         return Image.select_by_user(self.request.user)
2792
2793     def create(self, request, *args, **kwargs):
2794         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2795         if not (serializer.is_valid()):
2796             response = {"error": "validation",
2797                         "specific_error": "not serializer.is_valid()",\r
2798                         "reasons": serializer.errors}\r
2799             return Response(response, status=status.HTTP_400_BAD_REQUEST)
2800         obj = serializer.object
2801         obj.caller = request.user
2802         if obj.can_update(request.user):
2803             return super(ImageList, self).create(request, *args, **kwargs)
2804         else:
2805             raise Exception("failed obj.can_update")
2806
2807         ret = super(ImageList, self).create(request, *args, **kwargs)
2808         if (ret.status_code%100 != 200):
2809             raise Exception(ret.data)
2810
2811         return ret
2812
2813
2814 class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2815     queryset = Image.objects.select_related().all()
2816     serializer_class = ImageSerializer
2817     id_serializer_class = ImageIdSerializer
2818
2819     def get_serializer_class(self):
2820         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2821         if (no_hyperlinks):
2822             return self.id_serializer_class
2823         else:
2824             return self.serializer_class
2825     
2826     def get_queryset(self):
2827         return Image.select_by_user(self.request.user)
2828
2829     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2830
2831     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2832
2833
2834
2835 class NetworkParameterList(generics.ListCreateAPIView):
2836     queryset = NetworkParameter.objects.select_related().all()
2837     serializer_class = NetworkParameterSerializer
2838     id_serializer_class = NetworkParameterIdSerializer
2839     filter_backends = (filters.DjangoFilterBackend,)
2840     filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2841
2842     def get_serializer_class(self):
2843         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2844         if (no_hyperlinks):
2845             return self.id_serializer_class
2846         else:
2847             return self.serializer_class
2848
2849     def get_queryset(self):
2850         return NetworkParameter.select_by_user(self.request.user)
2851
2852     def create(self, request, *args, **kwargs):
2853         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2854         if not (serializer.is_valid()):
2855             response = {"error": "validation",
2856                         "specific_error": "not serializer.is_valid()",\r
2857                         "reasons": serializer.errors}\r
2858             return Response(response, status=status.HTTP_400_BAD_REQUEST)
2859         obj = serializer.object
2860         obj.caller = request.user
2861         if obj.can_update(request.user):
2862             return super(NetworkParameterList, self).create(request, *args, **kwargs)
2863         else:
2864             raise Exception("failed obj.can_update")
2865
2866         ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2867         if (ret.status_code%100 != 200):
2868             raise Exception(ret.data)
2869
2870         return ret
2871
2872
2873 class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2874     queryset = NetworkParameter.objects.select_related().all()
2875     serializer_class = NetworkParameterSerializer
2876     id_serializer_class = NetworkParameterIdSerializer
2877
2878     def get_serializer_class(self):
2879         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2880         if (no_hyperlinks):
2881             return self.id_serializer_class
2882         else:
2883             return self.serializer_class
2884     
2885     def get_queryset(self):
2886         return NetworkParameter.select_by_user(self.request.user)
2887
2888     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2889
2890     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2891
2892
2893
2894 class SiteList(generics.ListCreateAPIView):
2895     queryset = Site.objects.select_related().all()
2896     serializer_class = SiteSerializer
2897     id_serializer_class = SiteIdSerializer
2898     filter_backends = (filters.DjangoFilterBackend,)
2899     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
2900
2901     def get_serializer_class(self):
2902         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2903         if (no_hyperlinks):
2904             return self.id_serializer_class
2905         else:
2906             return self.serializer_class
2907
2908     def get_queryset(self):
2909         return Site.select_by_user(self.request.user)
2910
2911     def create(self, request, *args, **kwargs):
2912         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2913         if not (serializer.is_valid()):
2914             response = {"error": "validation",
2915                         "specific_error": "not serializer.is_valid()",\r
2916                         "reasons": serializer.errors}\r
2917             return Response(response, status=status.HTTP_400_BAD_REQUEST)
2918         obj = serializer.object
2919         obj.caller = request.user
2920         if obj.can_update(request.user):
2921             return super(SiteList, self).create(request, *args, **kwargs)
2922         else:
2923             raise Exception("failed obj.can_update")
2924
2925         ret = super(SiteList, self).create(request, *args, **kwargs)
2926         if (ret.status_code%100 != 200):
2927             raise Exception(ret.data)
2928
2929         return ret
2930
2931
2932 class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2933     queryset = Site.objects.select_related().all()
2934     serializer_class = SiteSerializer
2935     id_serializer_class = SiteIdSerializer
2936
2937     def get_serializer_class(self):
2938         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2939         if (no_hyperlinks):
2940             return self.id_serializer_class
2941         else:
2942             return self.serializer_class
2943     
2944     def get_queryset(self):
2945         return Site.select_by_user(self.request.user)
2946
2947     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2948
2949     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2950
2951
2952
2953 class SliceRoleList(generics.ListCreateAPIView):
2954     queryset = SliceRole.objects.select_related().all()
2955     serializer_class = SliceRoleSerializer
2956     id_serializer_class = SliceRoleIdSerializer
2957     filter_backends = (filters.DjangoFilterBackend,)
2958     filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2959
2960     def get_serializer_class(self):
2961         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2962         if (no_hyperlinks):
2963             return self.id_serializer_class
2964         else:
2965             return self.serializer_class
2966
2967     def get_queryset(self):
2968         return SliceRole.select_by_user(self.request.user)
2969
2970     def create(self, request, *args, **kwargs):
2971         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2972         if not (serializer.is_valid()):
2973             response = {"error": "validation",
2974                         "specific_error": "not serializer.is_valid()",\r
2975                         "reasons": serializer.errors}\r
2976             return Response(response, status=status.HTTP_400_BAD_REQUEST)
2977         obj = serializer.object
2978         obj.caller = request.user
2979         if obj.can_update(request.user):
2980             return super(SliceRoleList, self).create(request, *args, **kwargs)
2981         else:
2982             raise Exception("failed obj.can_update")
2983
2984         ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2985         if (ret.status_code%100 != 200):
2986             raise Exception(ret.data)
2987
2988         return ret
2989
2990
2991 class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2992     queryset = SliceRole.objects.select_related().all()
2993     serializer_class = SliceRoleSerializer
2994     id_serializer_class = SliceRoleIdSerializer
2995
2996     def get_serializer_class(self):
2997         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2998         if (no_hyperlinks):
2999             return self.id_serializer_class
3000         else:
3001             return self.serializer_class
3002     
3003     def get_queryset(self):
3004         return SliceRole.select_by_user(self.request.user)
3005
3006     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3007
3008     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3009
3010
3011
3012 class TagList(generics.ListCreateAPIView):
3013     queryset = Tag.objects.select_related().all()
3014     serializer_class = TagSerializer
3015     id_serializer_class = TagIdSerializer
3016     filter_backends = (filters.DjangoFilterBackend,)
3017     filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
3018
3019     def get_serializer_class(self):
3020         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3021         if (no_hyperlinks):
3022             return self.id_serializer_class
3023         else:
3024             return self.serializer_class
3025
3026     def get_queryset(self):
3027         return Tag.select_by_user(self.request.user)
3028
3029     def create(self, request, *args, **kwargs):
3030         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3031         if not (serializer.is_valid()):
3032             response = {"error": "validation",
3033                         "specific_error": "not serializer.is_valid()",\r
3034                         "reasons": serializer.errors}\r
3035             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3036         obj = serializer.object
3037         obj.caller = request.user
3038         if obj.can_update(request.user):
3039             return super(TagList, self).create(request, *args, **kwargs)
3040         else:
3041             raise Exception("failed obj.can_update")
3042
3043         ret = super(TagList, self).create(request, *args, **kwargs)
3044         if (ret.status_code%100 != 200):
3045             raise Exception(ret.data)
3046
3047         return ret
3048
3049
3050 class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3051     queryset = Tag.objects.select_related().all()
3052     serializer_class = TagSerializer
3053     id_serializer_class = TagIdSerializer
3054
3055     def get_serializer_class(self):
3056         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3057         if (no_hyperlinks):
3058             return self.id_serializer_class
3059         else:
3060             return self.serializer_class
3061     
3062     def get_queryset(self):
3063         return Tag.select_by_user(self.request.user)
3064
3065     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3066
3067     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3068
3069
3070
3071 class InvoiceList(generics.ListCreateAPIView):
3072     queryset = Invoice.objects.select_related().all()
3073     serializer_class = InvoiceSerializer
3074     id_serializer_class = InvoiceIdSerializer
3075     filter_backends = (filters.DjangoFilterBackend,)
3076     filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
3077
3078     def get_serializer_class(self):
3079         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3080         if (no_hyperlinks):
3081             return self.id_serializer_class
3082         else:
3083             return self.serializer_class
3084
3085     def get_queryset(self):
3086         return Invoice.select_by_user(self.request.user)
3087
3088     def create(self, request, *args, **kwargs):
3089         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3090         if not (serializer.is_valid()):
3091             response = {"error": "validation",
3092                         "specific_error": "not serializer.is_valid()",\r
3093                         "reasons": serializer.errors}\r
3094             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3095         obj = serializer.object
3096         obj.caller = request.user
3097         if obj.can_update(request.user):
3098             return super(InvoiceList, self).create(request, *args, **kwargs)
3099         else:
3100             raise Exception("failed obj.can_update")
3101
3102         ret = super(InvoiceList, self).create(request, *args, **kwargs)
3103         if (ret.status_code%100 != 200):
3104             raise Exception(ret.data)
3105
3106         return ret
3107
3108
3109 class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3110     queryset = Invoice.objects.select_related().all()
3111     serializer_class = InvoiceSerializer
3112     id_serializer_class = InvoiceIdSerializer
3113
3114     def get_serializer_class(self):
3115         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3116         if (no_hyperlinks):
3117             return self.id_serializer_class
3118         else:
3119             return self.serializer_class
3120     
3121     def get_queryset(self):
3122         return Invoice.select_by_user(self.request.user)
3123
3124     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3125
3126     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3127
3128
3129
3130 class SlicePrivilegeList(generics.ListCreateAPIView):
3131     queryset = SlicePrivilege.objects.select_related().all()
3132     serializer_class = SlicePrivilegeSerializer
3133     id_serializer_class = SlicePrivilegeIdSerializer
3134     filter_backends = (filters.DjangoFilterBackend,)
3135     filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
3136
3137     def get_serializer_class(self):
3138         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3139         if (no_hyperlinks):
3140             return self.id_serializer_class
3141         else:
3142             return self.serializer_class
3143
3144     def get_queryset(self):
3145         return SlicePrivilege.select_by_user(self.request.user)
3146
3147     def create(self, request, *args, **kwargs):
3148         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3149         if not (serializer.is_valid()):
3150             response = {"error": "validation",
3151                         "specific_error": "not serializer.is_valid()",\r
3152                         "reasons": serializer.errors}\r
3153             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3154         obj = serializer.object
3155         obj.caller = request.user
3156         if obj.can_update(request.user):
3157             return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3158         else:
3159             raise Exception("failed obj.can_update")
3160
3161         ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3162         if (ret.status_code%100 != 200):
3163             raise Exception(ret.data)
3164
3165         return ret
3166
3167
3168 class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3169     queryset = SlicePrivilege.objects.select_related().all()
3170     serializer_class = SlicePrivilegeSerializer
3171     id_serializer_class = SlicePrivilegeIdSerializer
3172
3173     def get_serializer_class(self):
3174         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3175         if (no_hyperlinks):
3176             return self.id_serializer_class
3177         else:
3178             return self.serializer_class
3179     
3180     def get_queryset(self):
3181         return SlicePrivilege.select_by_user(self.request.user)
3182
3183     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3184
3185     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3186
3187
3188
3189 class PlanetStackRoleList(generics.ListCreateAPIView):
3190     queryset = PlanetStackRole.objects.select_related().all()
3191     serializer_class = PlanetStackRoleSerializer
3192     id_serializer_class = PlanetStackRoleIdSerializer
3193     filter_backends = (filters.DjangoFilterBackend,)
3194     filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3195
3196     def get_serializer_class(self):
3197         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3198         if (no_hyperlinks):
3199             return self.id_serializer_class
3200         else:
3201             return self.serializer_class
3202
3203     def get_queryset(self):
3204         return PlanetStackRole.select_by_user(self.request.user)
3205
3206     def create(self, request, *args, **kwargs):
3207         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3208         if not (serializer.is_valid()):
3209             response = {"error": "validation",
3210                         "specific_error": "not serializer.is_valid()",\r
3211                         "reasons": serializer.errors}\r
3212             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3213         obj = serializer.object
3214         obj.caller = request.user
3215         if obj.can_update(request.user):
3216             return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3217         else:
3218             raise Exception("failed obj.can_update")
3219
3220         ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3221         if (ret.status_code%100 != 200):
3222             raise Exception(ret.data)
3223
3224         return ret
3225
3226
3227 class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3228     queryset = PlanetStackRole.objects.select_related().all()
3229     serializer_class = PlanetStackRoleSerializer
3230     id_serializer_class = PlanetStackRoleIdSerializer
3231
3232     def get_serializer_class(self):
3233         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3234         if (no_hyperlinks):
3235             return self.id_serializer_class
3236         else:
3237             return self.serializer_class
3238     
3239     def get_queryset(self):
3240         return PlanetStackRole.select_by_user(self.request.user)
3241
3242     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3243
3244     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3245
3246
3247
3248 class NetworkSliverList(generics.ListCreateAPIView):
3249     queryset = NetworkSliver.objects.select_related().all()
3250     serializer_class = NetworkSliverSerializer
3251     id_serializer_class = NetworkSliverIdSerializer
3252     filter_backends = (filters.DjangoFilterBackend,)
3253     filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
3254
3255     def get_serializer_class(self):
3256         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3257         if (no_hyperlinks):
3258             return self.id_serializer_class
3259         else:
3260             return self.serializer_class
3261
3262     def get_queryset(self):
3263         return NetworkSliver.select_by_user(self.request.user)
3264
3265     def create(self, request, *args, **kwargs):
3266         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3267         if not (serializer.is_valid()):
3268             response = {"error": "validation",
3269                         "specific_error": "not serializer.is_valid()",\r
3270                         "reasons": serializer.errors}\r
3271             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3272         obj = serializer.object
3273         obj.caller = request.user
3274         if obj.can_update(request.user):
3275             return super(NetworkSliverList, self).create(request, *args, **kwargs)
3276         else:
3277             raise Exception("failed obj.can_update")
3278
3279         ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3280         if (ret.status_code%100 != 200):
3281             raise Exception(ret.data)
3282
3283         return ret
3284
3285
3286 class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3287     queryset = NetworkSliver.objects.select_related().all()
3288     serializer_class = NetworkSliverSerializer
3289     id_serializer_class = NetworkSliverIdSerializer
3290
3291     def get_serializer_class(self):
3292         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3293         if (no_hyperlinks):
3294             return self.id_serializer_class
3295         else:
3296             return self.serializer_class
3297     
3298     def get_queryset(self):
3299         return NetworkSliver.select_by_user(self.request.user)
3300
3301     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3302
3303     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3304
3305
3306
3307 class FlavorList(generics.ListCreateAPIView):
3308     queryset = Flavor.objects.select_related().all()
3309     serializer_class = FlavorSerializer
3310     id_serializer_class = FlavorIdSerializer
3311     filter_backends = (filters.DjangoFilterBackend,)
3312     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
3313
3314     def get_serializer_class(self):
3315         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3316         if (no_hyperlinks):
3317             return self.id_serializer_class
3318         else:
3319             return self.serializer_class
3320
3321     def get_queryset(self):
3322         return Flavor.select_by_user(self.request.user)
3323
3324     def create(self, request, *args, **kwargs):
3325         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3326         if not (serializer.is_valid()):
3327             response = {"error": "validation",
3328                         "specific_error": "not serializer.is_valid()",\r
3329                         "reasons": serializer.errors}\r
3330             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3331         obj = serializer.object
3332         obj.caller = request.user
3333         if obj.can_update(request.user):
3334             return super(FlavorList, self).create(request, *args, **kwargs)
3335         else:
3336             raise Exception("failed obj.can_update")
3337
3338         ret = super(FlavorList, self).create(request, *args, **kwargs)
3339         if (ret.status_code%100 != 200):
3340             raise Exception(ret.data)
3341
3342         return ret
3343
3344
3345 class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3346     queryset = Flavor.objects.select_related().all()
3347     serializer_class = FlavorSerializer
3348     id_serializer_class = FlavorIdSerializer
3349
3350     def get_serializer_class(self):
3351         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3352         if (no_hyperlinks):
3353             return self.id_serializer_class
3354         else:
3355             return self.serializer_class
3356     
3357     def get_queryset(self):
3358         return Flavor.select_by_user(self.request.user)
3359
3360     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3361
3362     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3363
3364
3365
3366 class ControllerSiteList(generics.ListCreateAPIView):
3367     queryset = ControllerSite.objects.select_related().all()
3368     serializer_class = ControllerSiteSerializer
3369     id_serializer_class = ControllerSiteIdSerializer
3370     filter_backends = (filters.DjangoFilterBackend,)
3371     filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',)
3372
3373     def get_serializer_class(self):
3374         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3375         if (no_hyperlinks):
3376             return self.id_serializer_class
3377         else:
3378             return self.serializer_class
3379
3380     def get_queryset(self):
3381         return ControllerSite.select_by_user(self.request.user)
3382
3383     def create(self, request, *args, **kwargs):
3384         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3385         if not (serializer.is_valid()):
3386             response = {"error": "validation",
3387                         "specific_error": "not serializer.is_valid()",\r
3388                         "reasons": serializer.errors}\r
3389             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3390         obj = serializer.object
3391         obj.caller = request.user
3392         if obj.can_update(request.user):
3393             return super(ControllerSiteList, self).create(request, *args, **kwargs)
3394         else:
3395             raise Exception("failed obj.can_update")
3396
3397         ret = super(ControllerSiteList, self).create(request, *args, **kwargs)
3398         if (ret.status_code%100 != 200):
3399             raise Exception(ret.data)
3400
3401         return ret
3402
3403
3404 class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3405     queryset = ControllerSite.objects.select_related().all()
3406     serializer_class = ControllerSiteSerializer
3407     id_serializer_class = ControllerSiteIdSerializer
3408
3409     def get_serializer_class(self):
3410         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3411         if (no_hyperlinks):
3412             return self.id_serializer_class
3413         else:
3414             return self.serializer_class
3415     
3416     def get_queryset(self):
3417         return ControllerSite.select_by_user(self.request.user)
3418
3419     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3420
3421     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3422
3423
3424
3425 class ProjectList(generics.ListCreateAPIView):
3426     queryset = Project.objects.select_related().all()
3427     serializer_class = ProjectSerializer
3428     id_serializer_class = ProjectIdSerializer
3429     filter_backends = (filters.DjangoFilterBackend,)
3430     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3431
3432     def get_serializer_class(self):
3433         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3434         if (no_hyperlinks):
3435             return self.id_serializer_class
3436         else:
3437             return self.serializer_class
3438
3439     def get_queryset(self):
3440         return Project.select_by_user(self.request.user)
3441
3442     def create(self, request, *args, **kwargs):
3443         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3444         if not (serializer.is_valid()):
3445             response = {"error": "validation",
3446                         "specific_error": "not serializer.is_valid()",\r
3447                         "reasons": serializer.errors}\r
3448             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3449         obj = serializer.object
3450         obj.caller = request.user
3451         if obj.can_update(request.user):
3452             return super(ProjectList, self).create(request, *args, **kwargs)
3453         else:
3454             raise Exception("failed obj.can_update")
3455
3456         ret = super(ProjectList, self).create(request, *args, **kwargs)
3457         if (ret.status_code%100 != 200):
3458             raise Exception(ret.data)
3459
3460         return ret
3461
3462
3463 class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3464     queryset = Project.objects.select_related().all()
3465     serializer_class = ProjectSerializer
3466     id_serializer_class = ProjectIdSerializer
3467
3468     def get_serializer_class(self):
3469         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3470         if (no_hyperlinks):
3471             return self.id_serializer_class
3472         else:
3473             return self.serializer_class
3474     
3475     def get_queryset(self):
3476         return Project.select_by_user(self.request.user)
3477
3478     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3479
3480     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3481
3482
3483
3484 class SliceList(generics.ListCreateAPIView):
3485     queryset = Slice.objects.select_related().all()
3486     serializer_class = SliceSerializer
3487     id_serializer_class = SliceIdSerializer
3488     filter_backends = (filters.DjangoFilterBackend,)
3489     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
3490
3491     def get_serializer_class(self):
3492         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3493         if (no_hyperlinks):
3494             return self.id_serializer_class
3495         else:
3496             return self.serializer_class
3497
3498     def get_queryset(self):
3499         return Slice.select_by_user(self.request.user)
3500
3501     def create(self, request, *args, **kwargs):
3502         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3503         if not (serializer.is_valid()):
3504             response = {"error": "validation",
3505                         "specific_error": "not serializer.is_valid()",\r
3506                         "reasons": serializer.errors}\r
3507             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3508         obj = serializer.object
3509         obj.caller = request.user
3510         if obj.can_update(request.user):
3511             return super(SliceList, self).create(request, *args, **kwargs)
3512         else:
3513             raise Exception("failed obj.can_update")
3514
3515         ret = super(SliceList, self).create(request, *args, **kwargs)
3516         if (ret.status_code%100 != 200):
3517             raise Exception(ret.data)
3518
3519         return ret
3520
3521
3522 class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3523     queryset = Slice.objects.select_related().all()
3524     serializer_class = SliceSerializer
3525     id_serializer_class = SliceIdSerializer
3526
3527     def get_serializer_class(self):
3528         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3529         if (no_hyperlinks):
3530             return self.id_serializer_class
3531         else:
3532             return self.serializer_class
3533     
3534     def get_queryset(self):
3535         return Slice.select_by_user(self.request.user)
3536
3537     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3538
3539     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3540
3541
3542
3543 class NetworkList(generics.ListCreateAPIView):
3544     queryset = Network.objects.select_related().all()
3545     serializer_class = NetworkSerializer
3546     id_serializer_class = NetworkIdSerializer
3547     filter_backends = (filters.DjangoFilterBackend,)
3548     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
3549
3550     def get_serializer_class(self):
3551         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3552         if (no_hyperlinks):
3553             return self.id_serializer_class
3554         else:
3555             return self.serializer_class
3556
3557     def get_queryset(self):
3558         return Network.select_by_user(self.request.user)
3559
3560     def create(self, request, *args, **kwargs):
3561         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3562         if not (serializer.is_valid()):
3563             response = {"error": "validation",
3564                         "specific_error": "not serializer.is_valid()",\r
3565                         "reasons": serializer.errors}\r
3566             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3567         obj = serializer.object
3568         obj.caller = request.user
3569         if obj.can_update(request.user):
3570             return super(NetworkList, self).create(request, *args, **kwargs)
3571         else:
3572             raise Exception("failed obj.can_update")
3573
3574         ret = super(NetworkList, self).create(request, *args, **kwargs)
3575         if (ret.status_code%100 != 200):
3576             raise Exception(ret.data)
3577
3578         return ret
3579
3580
3581 class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3582     queryset = Network.objects.select_related().all()
3583     serializer_class = NetworkSerializer
3584     id_serializer_class = NetworkIdSerializer
3585
3586     def get_serializer_class(self):
3587         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3588         if (no_hyperlinks):
3589             return self.id_serializer_class
3590         else:
3591             return self.serializer_class
3592     
3593     def get_queryset(self):
3594         return Network.select_by_user(self.request.user)
3595
3596     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3597
3598     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3599
3600
3601
3602 class ServiceList(generics.ListCreateAPIView):
3603     queryset = Service.objects.select_related().all()
3604     serializer_class = ServiceSerializer
3605     id_serializer_class = ServiceIdSerializer
3606     filter_backends = (filters.DjangoFilterBackend,)
3607     filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3608
3609     def get_serializer_class(self):
3610         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3611         if (no_hyperlinks):
3612             return self.id_serializer_class
3613         else:
3614             return self.serializer_class
3615
3616     def get_queryset(self):
3617         return Service.select_by_user(self.request.user)
3618
3619     def create(self, request, *args, **kwargs):
3620         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3621         if not (serializer.is_valid()):
3622             response = {"error": "validation",
3623                         "specific_error": "not serializer.is_valid()",\r
3624                         "reasons": serializer.errors}\r
3625             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3626         obj = serializer.object
3627         obj.caller = request.user
3628         if obj.can_update(request.user):
3629             return super(ServiceList, self).create(request, *args, **kwargs)
3630         else:
3631             raise Exception("failed obj.can_update")
3632
3633         ret = super(ServiceList, self).create(request, *args, **kwargs)
3634         if (ret.status_code%100 != 200):
3635             raise Exception(ret.data)
3636
3637         return ret
3638
3639
3640 class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3641     queryset = Service.objects.select_related().all()
3642     serializer_class = ServiceSerializer
3643     id_serializer_class = ServiceIdSerializer
3644
3645     def get_serializer_class(self):
3646         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3647         if (no_hyperlinks):
3648             return self.id_serializer_class
3649         else:
3650             return self.serializer_class
3651     
3652     def get_queryset(self):
3653         return Service.select_by_user(self.request.user)
3654
3655     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3656
3657     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3658
3659
3660
3661 class ServiceClassList(generics.ListCreateAPIView):
3662     queryset = ServiceClass.objects.select_related().all()
3663     serializer_class = ServiceClassSerializer
3664     id_serializer_class = ServiceClassIdSerializer
3665     filter_backends = (filters.DjangoFilterBackend,)
3666     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3667
3668     def get_serializer_class(self):
3669         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3670         if (no_hyperlinks):
3671             return self.id_serializer_class
3672         else:
3673             return self.serializer_class
3674
3675     def get_queryset(self):
3676         return ServiceClass.select_by_user(self.request.user)
3677
3678     def create(self, request, *args, **kwargs):
3679         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3680         if not (serializer.is_valid()):
3681             response = {"error": "validation",
3682                         "specific_error": "not serializer.is_valid()",\r
3683                         "reasons": serializer.errors}\r
3684             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3685         obj = serializer.object
3686         obj.caller = request.user
3687         if obj.can_update(request.user):
3688             return super(ServiceClassList, self).create(request, *args, **kwargs)
3689         else:
3690             raise Exception("failed obj.can_update")
3691
3692         ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3693         if (ret.status_code%100 != 200):
3694             raise Exception(ret.data)
3695
3696         return ret
3697
3698
3699 class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3700     queryset = ServiceClass.objects.select_related().all()
3701     serializer_class = ServiceClassSerializer
3702     id_serializer_class = ServiceClassIdSerializer
3703
3704     def get_serializer_class(self):
3705         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3706         if (no_hyperlinks):
3707             return self.id_serializer_class
3708         else:
3709             return self.serializer_class
3710     
3711     def get_queryset(self):
3712         return ServiceClass.select_by_user(self.request.user)
3713
3714     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3715
3716     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3717
3718
3719
3720 class PlanetStackList(generics.ListCreateAPIView):
3721     queryset = PlanetStack.objects.select_related().all()
3722     serializer_class = PlanetStackSerializer
3723     id_serializer_class = PlanetStackIdSerializer
3724     filter_backends = (filters.DjangoFilterBackend,)
3725     filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
3726
3727     def get_serializer_class(self):
3728         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3729         if (no_hyperlinks):
3730             return self.id_serializer_class
3731         else:
3732             return self.serializer_class
3733
3734     def get_queryset(self):
3735         return PlanetStack.select_by_user(self.request.user)
3736
3737     def create(self, request, *args, **kwargs):
3738         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3739         if not (serializer.is_valid()):
3740             response = {"error": "validation",
3741                         "specific_error": "not serializer.is_valid()",\r
3742                         "reasons": serializer.errors}\r
3743             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3744         obj = serializer.object
3745         obj.caller = request.user
3746         if obj.can_update(request.user):
3747             return super(PlanetStackList, self).create(request, *args, **kwargs)
3748         else:
3749             raise Exception("failed obj.can_update")
3750
3751         ret = super(PlanetStackList, self).create(request, *args, **kwargs)
3752         if (ret.status_code%100 != 200):
3753             raise Exception(ret.data)
3754
3755         return ret
3756
3757
3758 class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3759     queryset = PlanetStack.objects.select_related().all()
3760     serializer_class = PlanetStackSerializer
3761     id_serializer_class = PlanetStackIdSerializer
3762
3763     def get_serializer_class(self):
3764         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3765         if (no_hyperlinks):
3766             return self.id_serializer_class
3767         else:
3768             return self.serializer_class
3769     
3770     def get_queryset(self):
3771         return PlanetStack.select_by_user(self.request.user)
3772
3773     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3774
3775     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3776
3777
3778
3779 class ChargeList(generics.ListCreateAPIView):
3780     queryset = Charge.objects.select_related().all()
3781     serializer_class = ChargeSerializer
3782     id_serializer_class = ChargeIdSerializer
3783     filter_backends = (filters.DjangoFilterBackend,)
3784     filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3785
3786     def get_serializer_class(self):
3787         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3788         if (no_hyperlinks):
3789             return self.id_serializer_class
3790         else:
3791             return self.serializer_class
3792
3793     def get_queryset(self):
3794         return Charge.select_by_user(self.request.user)
3795
3796     def create(self, request, *args, **kwargs):
3797         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3798         if not (serializer.is_valid()):
3799             response = {"error": "validation",
3800                         "specific_error": "not serializer.is_valid()",\r
3801                         "reasons": serializer.errors}\r
3802             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3803         obj = serializer.object
3804         obj.caller = request.user
3805         if obj.can_update(request.user):
3806             return super(ChargeList, self).create(request, *args, **kwargs)
3807         else:
3808             raise Exception("failed obj.can_update")
3809
3810         ret = super(ChargeList, self).create(request, *args, **kwargs)
3811         if (ret.status_code%100 != 200):
3812             raise Exception(ret.data)
3813
3814         return ret
3815
3816
3817 class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3818     queryset = Charge.objects.select_related().all()
3819     serializer_class = ChargeSerializer
3820     id_serializer_class = ChargeIdSerializer
3821
3822     def get_serializer_class(self):
3823         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3824         if (no_hyperlinks):
3825             return self.id_serializer_class
3826         else:
3827             return self.serializer_class
3828     
3829     def get_queryset(self):
3830         return Charge.select_by_user(self.request.user)
3831
3832     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3833
3834     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3835
3836
3837
3838 class RoleList(generics.ListCreateAPIView):
3839     queryset = Role.objects.select_related().all()
3840     serializer_class = RoleSerializer
3841     id_serializer_class = RoleIdSerializer
3842     filter_backends = (filters.DjangoFilterBackend,)
3843     filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3844
3845     def get_serializer_class(self):
3846         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3847         if (no_hyperlinks):
3848             return self.id_serializer_class
3849         else:
3850             return self.serializer_class
3851
3852     def get_queryset(self):
3853         return Role.select_by_user(self.request.user)
3854
3855     def create(self, request, *args, **kwargs):
3856         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3857         if not (serializer.is_valid()):
3858             response = {"error": "validation",
3859                         "specific_error": "not serializer.is_valid()",\r
3860                         "reasons": serializer.errors}\r
3861             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3862         obj = serializer.object
3863         obj.caller = request.user
3864         if obj.can_update(request.user):
3865             return super(RoleList, self).create(request, *args, **kwargs)
3866         else:
3867             raise Exception("failed obj.can_update")
3868
3869         ret = super(RoleList, self).create(request, *args, **kwargs)
3870         if (ret.status_code%100 != 200):
3871             raise Exception(ret.data)
3872
3873         return ret
3874
3875
3876 class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3877     queryset = Role.objects.select_related().all()
3878     serializer_class = RoleSerializer
3879     id_serializer_class = RoleIdSerializer
3880
3881     def get_serializer_class(self):
3882         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3883         if (no_hyperlinks):
3884             return self.id_serializer_class
3885         else:
3886             return self.serializer_class
3887     
3888     def get_queryset(self):
3889         return Role.select_by_user(self.request.user)
3890
3891     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3892
3893     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3894
3895
3896
3897 class UsableObjectList(generics.ListCreateAPIView):
3898     queryset = UsableObject.objects.select_related().all()
3899     serializer_class = UsableObjectSerializer
3900     id_serializer_class = UsableObjectIdSerializer
3901     filter_backends = (filters.DjangoFilterBackend,)
3902     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3903
3904     def get_serializer_class(self):
3905         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3906         if (no_hyperlinks):
3907             return self.id_serializer_class
3908         else:
3909             return self.serializer_class
3910
3911     def get_queryset(self):
3912         return UsableObject.select_by_user(self.request.user)
3913
3914     def create(self, request, *args, **kwargs):
3915         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3916         if not (serializer.is_valid()):
3917             response = {"error": "validation",
3918                         "specific_error": "not serializer.is_valid()",\r
3919                         "reasons": serializer.errors}\r
3920             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3921         obj = serializer.object
3922         obj.caller = request.user
3923         if obj.can_update(request.user):
3924             return super(UsableObjectList, self).create(request, *args, **kwargs)
3925         else:
3926             raise Exception("failed obj.can_update")
3927
3928         ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3929         if (ret.status_code%100 != 200):
3930             raise Exception(ret.data)
3931
3932         return ret
3933
3934
3935 class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3936     queryset = UsableObject.objects.select_related().all()
3937     serializer_class = UsableObjectSerializer
3938     id_serializer_class = UsableObjectIdSerializer
3939
3940     def get_serializer_class(self):
3941         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3942         if (no_hyperlinks):
3943             return self.id_serializer_class
3944         else:
3945             return self.serializer_class
3946     
3947     def get_queryset(self):
3948         return UsableObject.select_by_user(self.request.user)
3949
3950     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3951
3952     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3953
3954
3955
3956 class SiteRoleList(generics.ListCreateAPIView):
3957     queryset = SiteRole.objects.select_related().all()
3958     serializer_class = SiteRoleSerializer
3959     id_serializer_class = SiteRoleIdSerializer
3960     filter_backends = (filters.DjangoFilterBackend,)
3961     filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3962
3963     def get_serializer_class(self):
3964         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3965         if (no_hyperlinks):
3966             return self.id_serializer_class
3967         else:
3968             return self.serializer_class
3969
3970     def get_queryset(self):
3971         return SiteRole.select_by_user(self.request.user)
3972
3973     def create(self, request, *args, **kwargs):
3974         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3975         if not (serializer.is_valid()):
3976             response = {"error": "validation",
3977                         "specific_error": "not serializer.is_valid()",\r
3978                         "reasons": serializer.errors}\r
3979             return Response(response, status=status.HTTP_400_BAD_REQUEST)
3980         obj = serializer.object
3981         obj.caller = request.user
3982         if obj.can_update(request.user):
3983             return super(SiteRoleList, self).create(request, *args, **kwargs)
3984         else:
3985             raise Exception("failed obj.can_update")
3986
3987         ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3988         if (ret.status_code%100 != 200):
3989             raise Exception(ret.data)
3990
3991         return ret
3992
3993
3994 class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3995     queryset = SiteRole.objects.select_related().all()
3996     serializer_class = SiteRoleSerializer
3997     id_serializer_class = SiteRoleIdSerializer
3998
3999     def get_serializer_class(self):
4000         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4001         if (no_hyperlinks):
4002             return self.id_serializer_class
4003         else:
4004             return self.serializer_class
4005     
4006     def get_queryset(self):
4007         return SiteRole.select_by_user(self.request.user)
4008
4009     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4010
4011     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4012
4013
4014
4015 class SliceCredentialList(generics.ListCreateAPIView):
4016     queryset = SliceCredential.objects.select_related().all()
4017     serializer_class = SliceCredentialSerializer
4018     id_serializer_class = SliceCredentialIdSerializer
4019     filter_backends = (filters.DjangoFilterBackend,)
4020     filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
4021
4022     def get_serializer_class(self):
4023         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4024         if (no_hyperlinks):
4025             return self.id_serializer_class
4026         else:
4027             return self.serializer_class
4028
4029     def get_queryset(self):
4030         return SliceCredential.select_by_user(self.request.user)
4031
4032     def create(self, request, *args, **kwargs):
4033         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4034         if not (serializer.is_valid()):
4035             response = {"error": "validation",
4036                         "specific_error": "not serializer.is_valid()",\r
4037                         "reasons": serializer.errors}\r
4038             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4039         obj = serializer.object
4040         obj.caller = request.user
4041         if obj.can_update(request.user):
4042             return super(SliceCredentialList, self).create(request, *args, **kwargs)
4043         else:
4044             raise Exception("failed obj.can_update")
4045
4046         ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
4047         if (ret.status_code%100 != 200):
4048             raise Exception(ret.data)
4049
4050         return ret
4051
4052
4053 class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4054     queryset = SliceCredential.objects.select_related().all()
4055     serializer_class = SliceCredentialSerializer
4056     id_serializer_class = SliceCredentialIdSerializer
4057
4058     def get_serializer_class(self):
4059         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4060         if (no_hyperlinks):
4061             return self.id_serializer_class
4062         else:
4063             return self.serializer_class
4064     
4065     def get_queryset(self):
4066         return SliceCredential.select_by_user(self.request.user)
4067
4068     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4069
4070     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4071
4072
4073
4074 class SliverList(generics.ListCreateAPIView):
4075     queryset = Sliver.objects.select_related().all()
4076     serializer_class = SliverSerializer
4077     id_serializer_class = SliverIdSerializer
4078     filter_backends = (filters.DjangoFilterBackend,)
4079     filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
4080
4081     def get_serializer_class(self):
4082         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4083         if (no_hyperlinks):
4084             return self.id_serializer_class
4085         else:
4086             return self.serializer_class
4087
4088     def get_queryset(self):
4089         return Sliver.select_by_user(self.request.user)
4090
4091     def create(self, request, *args, **kwargs):
4092         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4093         if not (serializer.is_valid()):
4094             response = {"error": "validation",
4095                         "specific_error": "not serializer.is_valid()",\r
4096                         "reasons": serializer.errors}\r
4097             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4098         obj = serializer.object
4099         obj.caller = request.user
4100         if obj.can_update(request.user):
4101             return super(SliverList, self).create(request, *args, **kwargs)
4102         else:
4103             raise Exception("failed obj.can_update")
4104
4105         ret = super(SliverList, self).create(request, *args, **kwargs)
4106         if (ret.status_code%100 != 200):
4107             raise Exception(ret.data)
4108
4109         return ret
4110
4111
4112 class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4113     queryset = Sliver.objects.select_related().all()
4114     serializer_class = SliverSerializer
4115     id_serializer_class = SliverIdSerializer
4116
4117     def get_serializer_class(self):
4118         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4119         if (no_hyperlinks):
4120             return self.id_serializer_class
4121         else:
4122             return self.serializer_class
4123     
4124     def get_queryset(self):
4125         return Sliver.select_by_user(self.request.user)
4126
4127     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4128
4129     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4130
4131
4132
4133 class NodeList(generics.ListCreateAPIView):
4134     queryset = Node.objects.select_related().all()
4135     serializer_class = NodeSerializer
4136     id_serializer_class = NodeIdSerializer
4137     filter_backends = (filters.DjangoFilterBackend,)
4138     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
4139
4140     def get_serializer_class(self):
4141         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4142         if (no_hyperlinks):
4143             return self.id_serializer_class
4144         else:
4145             return self.serializer_class
4146
4147     def get_queryset(self):
4148         return Node.select_by_user(self.request.user)
4149
4150     def create(self, request, *args, **kwargs):
4151         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4152         if not (serializer.is_valid()):
4153             response = {"error": "validation",
4154                         "specific_error": "not serializer.is_valid()",\r
4155                         "reasons": serializer.errors}\r
4156             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4157         obj = serializer.object
4158         obj.caller = request.user
4159         if obj.can_update(request.user):
4160             return super(NodeList, self).create(request, *args, **kwargs)
4161         else:
4162             raise Exception("failed obj.can_update")
4163
4164         ret = super(NodeList, self).create(request, *args, **kwargs)
4165         if (ret.status_code%100 != 200):
4166             raise Exception(ret.data)
4167
4168         return ret
4169
4170
4171 class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4172     queryset = Node.objects.select_related().all()
4173     serializer_class = NodeSerializer
4174     id_serializer_class = NodeIdSerializer
4175
4176     def get_serializer_class(self):
4177         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4178         if (no_hyperlinks):
4179             return self.id_serializer_class
4180         else:
4181             return self.serializer_class
4182     
4183     def get_queryset(self):
4184         return Node.select_by_user(self.request.user)
4185
4186     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4187
4188     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4189
4190
4191
4192 class DashboardViewList(generics.ListCreateAPIView):
4193     queryset = DashboardView.objects.select_related().all()
4194     serializer_class = DashboardViewSerializer
4195     id_serializer_class = DashboardViewIdSerializer
4196     filter_backends = (filters.DjangoFilterBackend,)
4197     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
4198
4199     def get_serializer_class(self):
4200         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4201         if (no_hyperlinks):
4202             return self.id_serializer_class
4203         else:
4204             return self.serializer_class
4205
4206     def get_queryset(self):
4207         return DashboardView.select_by_user(self.request.user)
4208
4209     def create(self, request, *args, **kwargs):
4210         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4211         if not (serializer.is_valid()):
4212             response = {"error": "validation",
4213                         "specific_error": "not serializer.is_valid()",\r
4214                         "reasons": serializer.errors}\r
4215             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4216         obj = serializer.object
4217         obj.caller = request.user
4218         if obj.can_update(request.user):
4219             return super(DashboardViewList, self).create(request, *args, **kwargs)
4220         else:
4221             raise Exception("failed obj.can_update")
4222
4223         ret = super(DashboardViewList, self).create(request, *args, **kwargs)
4224         if (ret.status_code%100 != 200):
4225             raise Exception(ret.data)
4226
4227         return ret
4228
4229
4230 class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4231     queryset = DashboardView.objects.select_related().all()
4232     serializer_class = DashboardViewSerializer
4233     id_serializer_class = DashboardViewIdSerializer
4234
4235     def get_serializer_class(self):
4236         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4237         if (no_hyperlinks):
4238             return self.id_serializer_class
4239         else:
4240             return self.serializer_class
4241     
4242     def get_queryset(self):
4243         return DashboardView.select_by_user(self.request.user)
4244
4245     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4246
4247     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4248
4249
4250
4251 class ControllerNetworkList(generics.ListCreateAPIView):
4252     queryset = ControllerNetwork.objects.select_related().all()
4253     serializer_class = ControllerNetworkSerializer
4254     id_serializer_class = ControllerNetworkIdSerializer
4255     filter_backends = (filters.DjangoFilterBackend,)
4256     filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
4257
4258     def get_serializer_class(self):
4259         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4260         if (no_hyperlinks):
4261             return self.id_serializer_class
4262         else:
4263             return self.serializer_class
4264
4265     def get_queryset(self):
4266         return ControllerNetwork.select_by_user(self.request.user)
4267
4268     def create(self, request, *args, **kwargs):
4269         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4270         if not (serializer.is_valid()):
4271             response = {"error": "validation",
4272                         "specific_error": "not serializer.is_valid()",\r
4273                         "reasons": serializer.errors}\r
4274             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4275         obj = serializer.object
4276         obj.caller = request.user
4277         if obj.can_update(request.user):
4278             return super(ControllerNetworkList, self).create(request, *args, **kwargs)
4279         else:
4280             raise Exception("failed obj.can_update")
4281
4282         ret = super(ControllerNetworkList, self).create(request, *args, **kwargs)
4283         if (ret.status_code%100 != 200):
4284             raise Exception(ret.data)
4285
4286         return ret
4287
4288
4289 class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4290     queryset = ControllerNetwork.objects.select_related().all()
4291     serializer_class = ControllerNetworkSerializer
4292     id_serializer_class = ControllerNetworkIdSerializer
4293
4294     def get_serializer_class(self):
4295         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4296         if (no_hyperlinks):
4297             return self.id_serializer_class
4298         else:
4299             return self.serializer_class
4300     
4301     def get_queryset(self):
4302         return ControllerNetwork.select_by_user(self.request.user)
4303
4304     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4305
4306     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4307
4308
4309
4310 class ImageDeploymentsList(generics.ListCreateAPIView):
4311     queryset = ImageDeployments.objects.select_related().all()
4312     serializer_class = ImageDeploymentsSerializer
4313     id_serializer_class = ImageDeploymentsIdSerializer
4314     filter_backends = (filters.DjangoFilterBackend,)
4315     filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',)
4316
4317     def get_serializer_class(self):
4318         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4319         if (no_hyperlinks):
4320             return self.id_serializer_class
4321         else:
4322             return self.serializer_class
4323
4324     def get_queryset(self):
4325         return ImageDeployments.select_by_user(self.request.user)
4326
4327     def create(self, request, *args, **kwargs):
4328         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4329         if not (serializer.is_valid()):
4330             response = {"error": "validation",
4331                         "specific_error": "not serializer.is_valid()",\r
4332                         "reasons": serializer.errors}\r
4333             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4334         obj = serializer.object
4335         obj.caller = request.user
4336         if obj.can_update(request.user):
4337             return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
4338         else:
4339             raise Exception("failed obj.can_update")
4340
4341         ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
4342         if (ret.status_code%100 != 200):
4343             raise Exception(ret.data)
4344
4345         return ret
4346
4347
4348 class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4349     queryset = ImageDeployments.objects.select_related().all()
4350     serializer_class = ImageDeploymentsSerializer
4351     id_serializer_class = ImageDeploymentsIdSerializer
4352
4353     def get_serializer_class(self):
4354         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4355         if (no_hyperlinks):
4356             return self.id_serializer_class
4357         else:
4358             return self.serializer_class
4359     
4360     def get_queryset(self):
4361         return ImageDeployments.select_by_user(self.request.user)
4362
4363     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4364
4365     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4366
4367
4368
4369 class ControllerUserList(generics.ListCreateAPIView):
4370     queryset = ControllerUser.objects.select_related().all()
4371     serializer_class = ControllerUserSerializer
4372     id_serializer_class = ControllerUserIdSerializer
4373     filter_backends = (filters.DjangoFilterBackend,)
4374     filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
4375
4376     def get_serializer_class(self):
4377         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4378         if (no_hyperlinks):
4379             return self.id_serializer_class
4380         else:
4381             return self.serializer_class
4382
4383     def get_queryset(self):
4384         return ControllerUser.select_by_user(self.request.user)
4385
4386     def create(self, request, *args, **kwargs):
4387         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4388         if not (serializer.is_valid()):
4389             response = {"error": "validation",
4390                         "specific_error": "not serializer.is_valid()",\r
4391                         "reasons": serializer.errors}\r
4392             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4393         obj = serializer.object
4394         obj.caller = request.user
4395         if obj.can_update(request.user):
4396             return super(ControllerUserList, self).create(request, *args, **kwargs)
4397         else:
4398             raise Exception("failed obj.can_update")
4399
4400         ret = super(ControllerUserList, self).create(request, *args, **kwargs)
4401         if (ret.status_code%100 != 200):
4402             raise Exception(ret.data)
4403
4404         return ret
4405
4406
4407 class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4408     queryset = ControllerUser.objects.select_related().all()
4409     serializer_class = ControllerUserSerializer
4410     id_serializer_class = ControllerUserIdSerializer
4411
4412     def get_serializer_class(self):
4413         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4414         if (no_hyperlinks):
4415             return self.id_serializer_class
4416         else:
4417             return self.serializer_class
4418     
4419     def get_queryset(self):
4420         return ControllerUser.select_by_user(self.request.user)
4421
4422     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4423
4424     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4425
4426
4427
4428 class ReservedResourceList(generics.ListCreateAPIView):
4429     queryset = ReservedResource.objects.select_related().all()
4430     serializer_class = ReservedResourceSerializer
4431     id_serializer_class = ReservedResourceIdSerializer
4432     filter_backends = (filters.DjangoFilterBackend,)
4433     filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
4434
4435     def get_serializer_class(self):
4436         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4437         if (no_hyperlinks):
4438             return self.id_serializer_class
4439         else:
4440             return self.serializer_class
4441
4442     def get_queryset(self):
4443         return ReservedResource.select_by_user(self.request.user)
4444
4445     def create(self, request, *args, **kwargs):
4446         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4447         if not (serializer.is_valid()):
4448             response = {"error": "validation",
4449                         "specific_error": "not serializer.is_valid()",\r
4450                         "reasons": serializer.errors}\r
4451             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4452         obj = serializer.object
4453         obj.caller = request.user
4454         if obj.can_update(request.user):
4455             return super(ReservedResourceList, self).create(request, *args, **kwargs)
4456         else:
4457             raise Exception("failed obj.can_update")
4458
4459         ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4460         if (ret.status_code%100 != 200):
4461             raise Exception(ret.data)
4462
4463         return ret
4464
4465
4466 class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4467     queryset = ReservedResource.objects.select_related().all()
4468     serializer_class = ReservedResourceSerializer
4469     id_serializer_class = ReservedResourceIdSerializer
4470
4471     def get_serializer_class(self):
4472         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4473         if (no_hyperlinks):
4474             return self.id_serializer_class
4475         else:
4476             return self.serializer_class
4477     
4478     def get_queryset(self):
4479         return ReservedResource.select_by_user(self.request.user)
4480
4481     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4482
4483     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4484
4485
4486
4487 class PaymentList(generics.ListCreateAPIView):
4488     queryset = Payment.objects.select_related().all()
4489     serializer_class = PaymentSerializer
4490     id_serializer_class = PaymentIdSerializer
4491     filter_backends = (filters.DjangoFilterBackend,)
4492     filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
4493
4494     def get_serializer_class(self):
4495         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4496         if (no_hyperlinks):
4497             return self.id_serializer_class
4498         else:
4499             return self.serializer_class
4500
4501     def get_queryset(self):
4502         return Payment.select_by_user(self.request.user)
4503
4504     def create(self, request, *args, **kwargs):
4505         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4506         if not (serializer.is_valid()):
4507             response = {"error": "validation",
4508                         "specific_error": "not serializer.is_valid()",\r
4509                         "reasons": serializer.errors}\r
4510             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4511         obj = serializer.object
4512         obj.caller = request.user
4513         if obj.can_update(request.user):
4514             return super(PaymentList, self).create(request, *args, **kwargs)
4515         else:
4516             raise Exception("failed obj.can_update")
4517
4518         ret = super(PaymentList, self).create(request, *args, **kwargs)
4519         if (ret.status_code%100 != 200):
4520             raise Exception(ret.data)
4521
4522         return ret
4523
4524
4525 class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4526     queryset = Payment.objects.select_related().all()
4527     serializer_class = PaymentSerializer
4528     id_serializer_class = PaymentIdSerializer
4529
4530     def get_serializer_class(self):
4531         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4532         if (no_hyperlinks):
4533             return self.id_serializer_class
4534         else:
4535             return self.serializer_class
4536     
4537     def get_queryset(self):
4538         return Payment.select_by_user(self.request.user)
4539
4540     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4541
4542     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4543
4544
4545
4546 class NetworkSliceList(generics.ListCreateAPIView):
4547     queryset = NetworkSlice.objects.select_related().all()
4548     serializer_class = NetworkSliceSerializer
4549     id_serializer_class = NetworkSliceIdSerializer
4550     filter_backends = (filters.DjangoFilterBackend,)
4551     filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
4552
4553     def get_serializer_class(self):
4554         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4555         if (no_hyperlinks):
4556             return self.id_serializer_class
4557         else:
4558             return self.serializer_class
4559
4560     def get_queryset(self):
4561         return NetworkSlice.select_by_user(self.request.user)
4562
4563     def create(self, request, *args, **kwargs):
4564         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4565         if not (serializer.is_valid()):
4566             response = {"error": "validation",
4567                         "specific_error": "not serializer.is_valid()",\r
4568                         "reasons": serializer.errors}\r
4569             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4570         obj = serializer.object
4571         obj.caller = request.user
4572         if obj.can_update(request.user):
4573             return super(NetworkSliceList, self).create(request, *args, **kwargs)
4574         else:
4575             raise Exception("failed obj.can_update")
4576
4577         ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4578         if (ret.status_code%100 != 200):
4579             raise Exception(ret.data)
4580
4581         return ret
4582
4583
4584 class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4585     queryset = NetworkSlice.objects.select_related().all()
4586     serializer_class = NetworkSliceSerializer
4587     id_serializer_class = NetworkSliceIdSerializer
4588
4589     def get_serializer_class(self):
4590         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4591         if (no_hyperlinks):
4592             return self.id_serializer_class
4593         else:
4594             return self.serializer_class
4595     
4596     def get_queryset(self):
4597         return NetworkSlice.select_by_user(self.request.user)
4598
4599     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4600
4601     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4602
4603
4604
4605 class UserDashboardViewList(generics.ListCreateAPIView):
4606     queryset = UserDashboardView.objects.select_related().all()
4607     serializer_class = UserDashboardViewSerializer
4608     id_serializer_class = UserDashboardViewIdSerializer
4609     filter_backends = (filters.DjangoFilterBackend,)
4610     filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4611
4612     def get_serializer_class(self):
4613         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4614         if (no_hyperlinks):
4615             return self.id_serializer_class
4616         else:
4617             return self.serializer_class
4618
4619     def get_queryset(self):
4620         return UserDashboardView.select_by_user(self.request.user)
4621
4622     def create(self, request, *args, **kwargs):
4623         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4624         if not (serializer.is_valid()):
4625             response = {"error": "validation",
4626                         "specific_error": "not serializer.is_valid()",\r
4627                         "reasons": serializer.errors}\r
4628             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4629         obj = serializer.object
4630         obj.caller = request.user
4631         if obj.can_update(request.user):
4632             return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4633         else:
4634             raise Exception("failed obj.can_update")
4635
4636         ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4637         if (ret.status_code%100 != 200):
4638             raise Exception(ret.data)
4639
4640         return ret
4641
4642
4643 class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4644     queryset = UserDashboardView.objects.select_related().all()
4645     serializer_class = UserDashboardViewSerializer
4646     id_serializer_class = UserDashboardViewIdSerializer
4647
4648     def get_serializer_class(self):
4649         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4650         if (no_hyperlinks):
4651             return self.id_serializer_class
4652         else:
4653             return self.serializer_class
4654     
4655     def get_queryset(self):
4656         return UserDashboardView.select_by_user(self.request.user)
4657
4658     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4659
4660     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4661
4662
4663
4664 class ControllerList(generics.ListCreateAPIView):
4665     queryset = Controller.objects.select_related().all()
4666     serializer_class = ControllerSerializer
4667     id_serializer_class = ControllerIdSerializer
4668     filter_backends = (filters.DjangoFilterBackend,)
4669     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
4670
4671     def get_serializer_class(self):
4672         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4673         if (no_hyperlinks):
4674             return self.id_serializer_class
4675         else:
4676             return self.serializer_class
4677
4678     def get_queryset(self):
4679         return Controller.select_by_user(self.request.user)
4680
4681     def create(self, request, *args, **kwargs):
4682         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4683         if not (serializer.is_valid()):
4684             response = {"error": "validation",
4685                         "specific_error": "not serializer.is_valid()",\r
4686                         "reasons": serializer.errors}\r
4687             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4688         obj = serializer.object
4689         obj.caller = request.user
4690         if obj.can_update(request.user):
4691             return super(ControllerList, self).create(request, *args, **kwargs)
4692         else:
4693             raise Exception("failed obj.can_update")
4694
4695         ret = super(ControllerList, self).create(request, *args, **kwargs)
4696         if (ret.status_code%100 != 200):
4697             raise Exception(ret.data)
4698
4699         return ret
4700
4701
4702 class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4703     queryset = Controller.objects.select_related().all()
4704     serializer_class = ControllerSerializer
4705     id_serializer_class = ControllerIdSerializer
4706
4707     def get_serializer_class(self):
4708         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4709         if (no_hyperlinks):
4710             return self.id_serializer_class
4711         else:
4712             return self.serializer_class
4713     
4714     def get_queryset(self):
4715         return Controller.select_by_user(self.request.user)
4716
4717     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4718
4719     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4720
4721
4722
4723 class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4724     queryset = PlanetStackPrivilege.objects.select_related().all()
4725     serializer_class = PlanetStackPrivilegeSerializer
4726     id_serializer_class = PlanetStackPrivilegeIdSerializer
4727     filter_backends = (filters.DjangoFilterBackend,)
4728     filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4729
4730     def get_serializer_class(self):
4731         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4732         if (no_hyperlinks):
4733             return self.id_serializer_class
4734         else:
4735             return self.serializer_class
4736
4737     def get_queryset(self):
4738         return PlanetStackPrivilege.select_by_user(self.request.user)
4739
4740     def create(self, request, *args, **kwargs):
4741         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4742         if not (serializer.is_valid()):
4743             response = {"error": "validation",
4744                         "specific_error": "not serializer.is_valid()",\r
4745                         "reasons": serializer.errors}\r
4746             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4747         obj = serializer.object
4748         obj.caller = request.user
4749         if obj.can_update(request.user):
4750             return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4751         else:
4752             raise Exception("failed obj.can_update")
4753
4754         ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4755         if (ret.status_code%100 != 200):
4756             raise Exception(ret.data)
4757
4758         return ret
4759
4760
4761 class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4762     queryset = PlanetStackPrivilege.objects.select_related().all()
4763     serializer_class = PlanetStackPrivilegeSerializer
4764     id_serializer_class = PlanetStackPrivilegeIdSerializer
4765
4766     def get_serializer_class(self):
4767         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4768         if (no_hyperlinks):
4769             return self.id_serializer_class
4770         else:
4771             return self.serializer_class
4772     
4773     def get_queryset(self):
4774         return PlanetStackPrivilege.select_by_user(self.request.user)
4775
4776     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4777
4778     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4779
4780
4781
4782 class UserList(generics.ListCreateAPIView):
4783     queryset = User.objects.select_related().all()
4784     serializer_class = UserSerializer
4785     id_serializer_class = UserIdSerializer
4786     filter_backends = (filters.DjangoFilterBackend,)
4787     filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
4788
4789     def get_serializer_class(self):
4790         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4791         if (no_hyperlinks):
4792             return self.id_serializer_class
4793         else:
4794             return self.serializer_class
4795
4796     def get_queryset(self):
4797         return User.select_by_user(self.request.user)
4798
4799     def create(self, request, *args, **kwargs):
4800         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4801         if not (serializer.is_valid()):
4802             response = {"error": "validation",
4803                         "specific_error": "not serializer.is_valid()",\r
4804                         "reasons": serializer.errors}\r
4805             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4806         obj = serializer.object
4807         obj.caller = request.user
4808         if obj.can_update(request.user):
4809             return super(UserList, self).create(request, *args, **kwargs)
4810         else:
4811             raise Exception("failed obj.can_update")
4812
4813         ret = super(UserList, self).create(request, *args, **kwargs)
4814         if (ret.status_code%100 != 200):
4815             raise Exception(ret.data)
4816
4817         return ret
4818
4819
4820 class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4821     queryset = User.objects.select_related().all()
4822     serializer_class = UserSerializer
4823     id_serializer_class = UserIdSerializer
4824
4825     def get_serializer_class(self):
4826         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4827         if (no_hyperlinks):
4828             return self.id_serializer_class
4829         else:
4830             return self.serializer_class
4831     
4832     def get_queryset(self):
4833         return User.select_by_user(self.request.user)
4834
4835     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4836
4837     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4838
4839
4840
4841 class DeploymentList(generics.ListCreateAPIView):
4842     queryset = Deployment.objects.select_related().all()
4843     serializer_class = DeploymentSerializer
4844     id_serializer_class = DeploymentIdSerializer
4845     filter_backends = (filters.DjangoFilterBackend,)
4846     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',)
4847
4848     def get_serializer_class(self):
4849         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4850         if (no_hyperlinks):
4851             return self.id_serializer_class
4852         else:
4853             return self.serializer_class
4854
4855     def get_queryset(self):
4856         return Deployment.select_by_user(self.request.user)
4857
4858     def create(self, request, *args, **kwargs):
4859         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4860         if not (serializer.is_valid()):
4861             response = {"error": "validation",
4862                         "specific_error": "not serializer.is_valid()",\r
4863                         "reasons": serializer.errors}\r
4864             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4865         obj = serializer.object
4866         obj.caller = request.user
4867         if obj.can_update(request.user):
4868             return super(DeploymentList, self).create(request, *args, **kwargs)
4869         else:
4870             raise Exception("failed obj.can_update")
4871
4872         ret = super(DeploymentList, self).create(request, *args, **kwargs)
4873         if (ret.status_code%100 != 200):
4874             raise Exception(ret.data)
4875
4876         return ret
4877
4878
4879 class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4880     queryset = Deployment.objects.select_related().all()
4881     serializer_class = DeploymentSerializer
4882     id_serializer_class = DeploymentIdSerializer
4883
4884     def get_serializer_class(self):
4885         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4886         if (no_hyperlinks):
4887             return self.id_serializer_class
4888         else:
4889             return self.serializer_class
4890     
4891     def get_queryset(self):
4892         return Deployment.select_by_user(self.request.user)
4893
4894     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4895
4896     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4897
4898
4899
4900 class ReservationList(generics.ListCreateAPIView):
4901     queryset = Reservation.objects.select_related().all()
4902     serializer_class = ReservationSerializer
4903     id_serializer_class = ReservationIdSerializer
4904     filter_backends = (filters.DjangoFilterBackend,)
4905     filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4906
4907     def get_serializer_class(self):
4908         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4909         if (no_hyperlinks):
4910             return self.id_serializer_class
4911         else:
4912             return self.serializer_class
4913
4914     def get_queryset(self):
4915         return Reservation.select_by_user(self.request.user)
4916
4917     def create(self, request, *args, **kwargs):
4918         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4919         if not (serializer.is_valid()):
4920             response = {"error": "validation",
4921                         "specific_error": "not serializer.is_valid()",\r
4922                         "reasons": serializer.errors}\r
4923             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4924         obj = serializer.object
4925         obj.caller = request.user
4926         if obj.can_update(request.user):
4927             return super(ReservationList, self).create(request, *args, **kwargs)
4928         else:
4929             raise Exception("failed obj.can_update")
4930
4931         ret = super(ReservationList, self).create(request, *args, **kwargs)
4932         if (ret.status_code%100 != 200):
4933             raise Exception(ret.data)
4934
4935         return ret
4936
4937
4938 class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4939     queryset = Reservation.objects.select_related().all()
4940     serializer_class = ReservationSerializer
4941     id_serializer_class = ReservationIdSerializer
4942
4943     def get_serializer_class(self):
4944         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4945         if (no_hyperlinks):
4946             return self.id_serializer_class
4947         else:
4948             return self.serializer_class
4949     
4950     def get_queryset(self):
4951         return Reservation.select_by_user(self.request.user)
4952
4953     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4954
4955     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4956
4957
4958
4959 class SitePrivilegeList(generics.ListCreateAPIView):
4960     queryset = SitePrivilege.objects.select_related().all()
4961     serializer_class = SitePrivilegeSerializer
4962     id_serializer_class = SitePrivilegeIdSerializer
4963     filter_backends = (filters.DjangoFilterBackend,)
4964     filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4965
4966     def get_serializer_class(self):
4967         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4968         if (no_hyperlinks):
4969             return self.id_serializer_class
4970         else:
4971             return self.serializer_class
4972
4973     def get_queryset(self):
4974         return SitePrivilege.select_by_user(self.request.user)
4975
4976     def create(self, request, *args, **kwargs):
4977         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4978         if not (serializer.is_valid()):
4979             response = {"error": "validation",
4980                         "specific_error": "not serializer.is_valid()",\r
4981                         "reasons": serializer.errors}\r
4982             return Response(response, status=status.HTTP_400_BAD_REQUEST)
4983         obj = serializer.object
4984         obj.caller = request.user
4985         if obj.can_update(request.user):
4986             return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4987         else:
4988             raise Exception("failed obj.can_update")
4989
4990         ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4991         if (ret.status_code%100 != 200):
4992             raise Exception(ret.data)
4993
4994         return ret
4995
4996
4997 class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4998     queryset = SitePrivilege.objects.select_related().all()
4999     serializer_class = SitePrivilegeSerializer
5000     id_serializer_class = SitePrivilegeIdSerializer
5001
5002     def get_serializer_class(self):
5003         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5004         if (no_hyperlinks):
5005             return self.id_serializer_class
5006         else:
5007             return self.serializer_class
5008     
5009     def get_queryset(self):
5010         return SitePrivilege.select_by_user(self.request.user)
5011
5012     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5013
5014     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5015
5016
5017
5018 class ControllerSliceList(generics.ListCreateAPIView):
5019     queryset = ControllerSlice.objects.select_related().all()
5020     serializer_class = ControllerSliceSerializer
5021     id_serializer_class = ControllerSliceIdSerializer
5022     filter_backends = (filters.DjangoFilterBackend,)
5023     filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
5024
5025     def get_serializer_class(self):
5026         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5027         if (no_hyperlinks):
5028             return self.id_serializer_class
5029         else:
5030             return self.serializer_class
5031
5032     def get_queryset(self):
5033         return ControllerSlice.select_by_user(self.request.user)
5034
5035     def create(self, request, *args, **kwargs):
5036         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5037         if not (serializer.is_valid()):
5038             response = {"error": "validation",
5039                         "specific_error": "not serializer.is_valid()",\r
5040                         "reasons": serializer.errors}\r
5041             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5042         obj = serializer.object
5043         obj.caller = request.user
5044         if obj.can_update(request.user):
5045             return super(ControllerSliceList, self).create(request, *args, **kwargs)
5046         else:
5047             raise Exception("failed obj.can_update")
5048
5049         ret = super(ControllerSliceList, self).create(request, *args, **kwargs)
5050         if (ret.status_code%100 != 200):
5051             raise Exception(ret.data)
5052
5053         return ret
5054
5055
5056 class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5057     queryset = ControllerSlice.objects.select_related().all()
5058     serializer_class = ControllerSliceSerializer
5059     id_serializer_class = ControllerSliceIdSerializer
5060
5061     def get_serializer_class(self):
5062         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5063         if (no_hyperlinks):
5064             return self.id_serializer_class
5065         else:
5066             return self.serializer_class
5067     
5068     def get_queryset(self):
5069         return ControllerSlice.select_by_user(self.request.user)
5070
5071     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5072
5073     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5074
5075
5076
5077 class ControllerDashboardViewList(generics.ListCreateAPIView):
5078     queryset = ControllerDashboardView.objects.select_related().all()
5079     serializer_class = ControllerDashboardViewSerializer
5080     id_serializer_class = ControllerDashboardViewIdSerializer
5081     filter_backends = (filters.DjangoFilterBackend,)
5082     filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
5083
5084     def get_serializer_class(self):
5085         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5086         if (no_hyperlinks):
5087             return self.id_serializer_class
5088         else:
5089             return self.serializer_class
5090
5091     def get_queryset(self):
5092         return ControllerDashboardView.select_by_user(self.request.user)
5093
5094     def create(self, request, *args, **kwargs):
5095         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5096         if not (serializer.is_valid()):
5097             response = {"error": "validation",
5098                         "specific_error": "not serializer.is_valid()",\r
5099                         "reasons": serializer.errors}\r
5100             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5101         obj = serializer.object
5102         obj.caller = request.user
5103         if obj.can_update(request.user):
5104             return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
5105         else:
5106             raise Exception("failed obj.can_update")
5107
5108         ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
5109         if (ret.status_code%100 != 200):
5110             raise Exception(ret.data)
5111
5112         return ret
5113
5114
5115 class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5116     queryset = ControllerDashboardView.objects.select_related().all()
5117     serializer_class = ControllerDashboardViewSerializer
5118     id_serializer_class = ControllerDashboardViewIdSerializer
5119
5120     def get_serializer_class(self):
5121         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5122         if (no_hyperlinks):
5123             return self.id_serializer_class
5124         else:
5125             return self.serializer_class
5126     
5127     def get_queryset(self):
5128         return ControllerDashboardView.select_by_user(self.request.user)
5129
5130     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5131
5132     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5133
5134
5135
5136 class AccountList(generics.ListCreateAPIView):
5137     queryset = Account.objects.select_related().all()
5138     serializer_class = AccountSerializer
5139     id_serializer_class = AccountIdSerializer
5140     filter_backends = (filters.DjangoFilterBackend,)
5141     filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
5142
5143     def get_serializer_class(self):
5144         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5145         if (no_hyperlinks):
5146             return self.id_serializer_class
5147         else:
5148             return self.serializer_class
5149
5150     def get_queryset(self):
5151         return Account.select_by_user(self.request.user)
5152
5153     def create(self, request, *args, **kwargs):
5154         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5155         if not (serializer.is_valid()):
5156             response = {"error": "validation",
5157                         "specific_error": "not serializer.is_valid()",\r
5158                         "reasons": serializer.errors}\r
5159             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5160         obj = serializer.object
5161         obj.caller = request.user
5162         if obj.can_update(request.user):
5163             return super(AccountList, self).create(request, *args, **kwargs)
5164         else:
5165             raise Exception("failed obj.can_update")
5166
5167         ret = super(AccountList, self).create(request, *args, **kwargs)
5168         if (ret.status_code%100 != 200):
5169             raise Exception(ret.data)
5170
5171         return ret
5172
5173
5174 class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5175     queryset = Account.objects.select_related().all()
5176     serializer_class = AccountSerializer
5177     id_serializer_class = AccountIdSerializer
5178
5179     def get_serializer_class(self):
5180         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5181         if (no_hyperlinks):
5182             return self.id_serializer_class
5183         else:
5184             return self.serializer_class
5185     
5186     def get_queryset(self):
5187         return Account.select_by_user(self.request.user)
5188
5189     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5190
5191     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5192
5193
5194
5195 class ControllerRoleList(generics.ListCreateAPIView):
5196     queryset = ControllerRole.objects.select_related().all()
5197     serializer_class = ControllerRoleSerializer
5198     id_serializer_class = ControllerRoleIdSerializer
5199     filter_backends = (filters.DjangoFilterBackend,)
5200     filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5201
5202     def get_serializer_class(self):
5203         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5204         if (no_hyperlinks):
5205             return self.id_serializer_class
5206         else:
5207             return self.serializer_class
5208
5209     def get_queryset(self):
5210         return ControllerRole.select_by_user(self.request.user)
5211
5212     def create(self, request, *args, **kwargs):
5213         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5214         if not (serializer.is_valid()):
5215             response = {"error": "validation",
5216                         "specific_error": "not serializer.is_valid()",\r
5217                         "reasons": serializer.errors}\r
5218             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5219         obj = serializer.object
5220         obj.caller = request.user
5221         if obj.can_update(request.user):
5222             return super(ControllerRoleList, self).create(request, *args, **kwargs)
5223         else:
5224             raise Exception("failed obj.can_update")
5225
5226         ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
5227         if (ret.status_code%100 != 200):
5228             raise Exception(ret.data)
5229
5230         return ret
5231
5232
5233 class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5234     queryset = ControllerRole.objects.select_related().all()
5235     serializer_class = ControllerRoleSerializer
5236     id_serializer_class = ControllerRoleIdSerializer
5237
5238     def get_serializer_class(self):
5239         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5240         if (no_hyperlinks):
5241             return self.id_serializer_class
5242         else:
5243             return self.serializer_class
5244     
5245     def get_queryset(self):
5246         return ControllerRole.select_by_user(self.request.user)
5247
5248     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5249
5250     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5251
5252
5253
5254 class NetworkParameterTypeList(generics.ListCreateAPIView):
5255     queryset = NetworkParameterType.objects.select_related().all()
5256     serializer_class = NetworkParameterTypeSerializer
5257     id_serializer_class = NetworkParameterTypeIdSerializer
5258     filter_backends = (filters.DjangoFilterBackend,)
5259     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
5260
5261     def get_serializer_class(self):
5262         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5263         if (no_hyperlinks):
5264             return self.id_serializer_class
5265         else:
5266             return self.serializer_class
5267
5268     def get_queryset(self):
5269         return NetworkParameterType.select_by_user(self.request.user)
5270
5271     def create(self, request, *args, **kwargs):
5272         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5273         if not (serializer.is_valid()):
5274             response = {"error": "validation",
5275                         "specific_error": "not serializer.is_valid()",\r
5276                         "reasons": serializer.errors}\r
5277             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5278         obj = serializer.object
5279         obj.caller = request.user
5280         if obj.can_update(request.user):
5281             return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5282         else:
5283             raise Exception("failed obj.can_update")
5284
5285         ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5286         if (ret.status_code%100 != 200):
5287             raise Exception(ret.data)
5288
5289         return ret
5290
5291
5292 class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5293     queryset = NetworkParameterType.objects.select_related().all()
5294     serializer_class = NetworkParameterTypeSerializer
5295     id_serializer_class = NetworkParameterTypeIdSerializer
5296
5297     def get_serializer_class(self):
5298         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5299         if (no_hyperlinks):
5300             return self.id_serializer_class
5301         else:
5302             return self.serializer_class
5303     
5304     def get_queryset(self):
5305         return NetworkParameterType.select_by_user(self.request.user)
5306
5307     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5308
5309     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5310
5311
5312
5313 class SiteCredentialList(generics.ListCreateAPIView):
5314     queryset = SiteCredential.objects.select_related().all()
5315     serializer_class = SiteCredentialSerializer
5316     id_serializer_class = SiteCredentialIdSerializer
5317     filter_backends = (filters.DjangoFilterBackend,)
5318     filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
5319
5320     def get_serializer_class(self):
5321         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5322         if (no_hyperlinks):
5323             return self.id_serializer_class
5324         else:
5325             return self.serializer_class
5326
5327     def get_queryset(self):
5328         return SiteCredential.select_by_user(self.request.user)
5329
5330     def create(self, request, *args, **kwargs):
5331         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5332         if not (serializer.is_valid()):
5333             response = {"error": "validation",
5334                         "specific_error": "not serializer.is_valid()",\r
5335                         "reasons": serializer.errors}\r
5336             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5337         obj = serializer.object
5338         obj.caller = request.user
5339         if obj.can_update(request.user):
5340             return super(SiteCredentialList, self).create(request, *args, **kwargs)
5341         else:
5342             raise Exception("failed obj.can_update")
5343
5344         ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
5345         if (ret.status_code%100 != 200):
5346             raise Exception(ret.data)
5347
5348         return ret
5349
5350
5351 class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5352     queryset = SiteCredential.objects.select_related().all()
5353     serializer_class = SiteCredentialSerializer
5354     id_serializer_class = SiteCredentialIdSerializer
5355
5356     def get_serializer_class(self):
5357         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5358         if (no_hyperlinks):
5359             return self.id_serializer_class
5360         else:
5361             return self.serializer_class
5362     
5363     def get_queryset(self):
5364         return SiteCredential.select_by_user(self.request.user)
5365
5366     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5367
5368     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5369
5370
5371
5372 class DeploymentPrivilegeList(generics.ListCreateAPIView):
5373     queryset = DeploymentPrivilege.objects.select_related().all()
5374     serializer_class = DeploymentPrivilegeSerializer
5375     id_serializer_class = DeploymentPrivilegeIdSerializer
5376     filter_backends = (filters.DjangoFilterBackend,)
5377     filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
5378
5379     def get_serializer_class(self):
5380         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5381         if (no_hyperlinks):
5382             return self.id_serializer_class
5383         else:
5384             return self.serializer_class
5385
5386     def get_queryset(self):
5387         return DeploymentPrivilege.select_by_user(self.request.user)
5388
5389     def create(self, request, *args, **kwargs):
5390         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5391         if not (serializer.is_valid()):
5392             response = {"error": "validation",
5393                         "specific_error": "not serializer.is_valid()",\r
5394                         "reasons": serializer.errors}\r
5395             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5396         obj = serializer.object
5397         obj.caller = request.user
5398         if obj.can_update(request.user):
5399             return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
5400         else:
5401             raise Exception("failed obj.can_update")
5402
5403         ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
5404         if (ret.status_code%100 != 200):
5405             raise Exception(ret.data)
5406
5407         return ret
5408
5409
5410 class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5411     queryset = DeploymentPrivilege.objects.select_related().all()
5412     serializer_class = DeploymentPrivilegeSerializer
5413     id_serializer_class = DeploymentPrivilegeIdSerializer
5414
5415     def get_serializer_class(self):
5416         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5417         if (no_hyperlinks):
5418             return self.id_serializer_class
5419         else:
5420             return self.serializer_class
5421     
5422     def get_queryset(self):
5423         return DeploymentPrivilege.select_by_user(self.request.user)
5424
5425     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5426
5427     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5428
5429
5430
5431 class ControllerSlicePrivilegeList(generics.ListCreateAPIView):
5432     queryset = ControllerSlicePrivilege.objects.select_related().all()
5433     serializer_class = ControllerSlicePrivilegeSerializer
5434     id_serializer_class = ControllerSlicePrivilegeIdSerializer
5435     filter_backends = (filters.DjangoFilterBackend,)
5436     filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',)
5437
5438     def get_serializer_class(self):
5439         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5440         if (no_hyperlinks):
5441             return self.id_serializer_class
5442         else:
5443             return self.serializer_class
5444
5445     def get_queryset(self):
5446         return ControllerSlicePrivilege.select_by_user(self.request.user)
5447
5448     def create(self, request, *args, **kwargs):
5449         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5450         if not (serializer.is_valid()):
5451             response = {"error": "validation",
5452                         "specific_error": "not serializer.is_valid()",\r
5453                         "reasons": serializer.errors}\r
5454             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5455         obj = serializer.object
5456         obj.caller = request.user
5457         if obj.can_update(request.user):
5458             return super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
5459         else:
5460             raise Exception("failed obj.can_update")
5461
5462         ret = super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
5463         if (ret.status_code%100 != 200):
5464             raise Exception(ret.data)
5465
5466         return ret
5467
5468
5469 class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5470     queryset = ControllerSlicePrivilege.objects.select_related().all()
5471     serializer_class = ControllerSlicePrivilegeSerializer
5472     id_serializer_class = ControllerSlicePrivilegeIdSerializer
5473
5474     def get_serializer_class(self):
5475         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5476         if (no_hyperlinks):
5477             return self.id_serializer_class
5478         else:
5479             return self.serializer_class
5480     
5481     def get_queryset(self):
5482         return ControllerSlicePrivilege.select_by_user(self.request.user)
5483
5484     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5485
5486     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5487
5488
5489
5490 class SiteDeploymentList(generics.ListCreateAPIView):
5491     queryset = SiteDeployment.objects.select_related().all()
5492     serializer_class = SiteDeploymentSerializer
5493     id_serializer_class = SiteDeploymentIdSerializer
5494     filter_backends = (filters.DjangoFilterBackend,)
5495     filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
5496
5497     def get_serializer_class(self):
5498         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5499         if (no_hyperlinks):
5500             return self.id_serializer_class
5501         else:
5502             return self.serializer_class
5503
5504     def get_queryset(self):
5505         return SiteDeployment.select_by_user(self.request.user)
5506
5507     def create(self, request, *args, **kwargs):
5508         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5509         if not (serializer.is_valid()):
5510             response = {"error": "validation",
5511                         "specific_error": "not serializer.is_valid()",\r
5512                         "reasons": serializer.errors}\r
5513             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5514         obj = serializer.object
5515         obj.caller = request.user
5516         if obj.can_update(request.user):
5517             return super(SiteDeploymentList, self).create(request, *args, **kwargs)
5518         else:
5519             raise Exception("failed obj.can_update")
5520
5521         ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
5522         if (ret.status_code%100 != 200):
5523             raise Exception(ret.data)
5524
5525         return ret
5526
5527
5528 class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5529     queryset = SiteDeployment.objects.select_related().all()
5530     serializer_class = SiteDeploymentSerializer
5531     id_serializer_class = SiteDeploymentIdSerializer
5532
5533     def get_serializer_class(self):
5534         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5535         if (no_hyperlinks):
5536             return self.id_serializer_class
5537         else:
5538             return self.serializer_class
5539     
5540     def get_queryset(self):
5541         return SiteDeployment.select_by_user(self.request.user)
5542
5543     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5544
5545     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5546
5547
5548
5549 class DeploymentRoleList(generics.ListCreateAPIView):
5550     queryset = DeploymentRole.objects.select_related().all()
5551     serializer_class = DeploymentRoleSerializer
5552     id_serializer_class = DeploymentRoleIdSerializer
5553     filter_backends = (filters.DjangoFilterBackend,)
5554     filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5555
5556     def get_serializer_class(self):
5557         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5558         if (no_hyperlinks):
5559             return self.id_serializer_class
5560         else:
5561             return self.serializer_class
5562
5563     def get_queryset(self):
5564         return DeploymentRole.select_by_user(self.request.user)
5565
5566     def create(self, request, *args, **kwargs):
5567         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5568         if not (serializer.is_valid()):
5569             response = {"error": "validation",
5570                         "specific_error": "not serializer.is_valid()",\r
5571                         "reasons": serializer.errors}\r
5572             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5573         obj = serializer.object
5574         obj.caller = request.user
5575         if obj.can_update(request.user):
5576             return super(DeploymentRoleList, self).create(request, *args, **kwargs)
5577         else:
5578             raise Exception("failed obj.can_update")
5579
5580         ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
5581         if (ret.status_code%100 != 200):
5582             raise Exception(ret.data)
5583
5584         return ret
5585
5586
5587 class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5588     queryset = DeploymentRole.objects.select_related().all()
5589     serializer_class = DeploymentRoleSerializer
5590     id_serializer_class = DeploymentRoleIdSerializer
5591
5592     def get_serializer_class(self):
5593         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5594         if (no_hyperlinks):
5595             return self.id_serializer_class
5596         else:
5597             return self.serializer_class
5598     
5599     def get_queryset(self):
5600         return DeploymentRole.select_by_user(self.request.user)
5601
5602     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5603
5604     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5605
5606
5607
5608 class UserCredentialList(generics.ListCreateAPIView):
5609     queryset = UserCredential.objects.select_related().all()
5610     serializer_class = UserCredentialSerializer
5611     id_serializer_class = UserCredentialIdSerializer
5612     filter_backends = (filters.DjangoFilterBackend,)
5613     filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
5614
5615     def get_serializer_class(self):
5616         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5617         if (no_hyperlinks):
5618             return self.id_serializer_class
5619         else:
5620             return self.serializer_class
5621
5622     def get_queryset(self):
5623         return UserCredential.select_by_user(self.request.user)
5624
5625     def create(self, request, *args, **kwargs):
5626         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5627         if not (serializer.is_valid()):
5628             response = {"error": "validation",
5629                         "specific_error": "not serializer.is_valid()",\r
5630                         "reasons": serializer.errors}\r
5631             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5632         obj = serializer.object
5633         obj.caller = request.user
5634         if obj.can_update(request.user):
5635             return super(UserCredentialList, self).create(request, *args, **kwargs)
5636         else:
5637             raise Exception("failed obj.can_update")
5638
5639         ret = super(UserCredentialList, self).create(request, *args, **kwargs)
5640         if (ret.status_code%100 != 200):
5641             raise Exception(ret.data)
5642
5643         return ret
5644
5645
5646 class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5647     queryset = UserCredential.objects.select_related().all()
5648     serializer_class = UserCredentialSerializer
5649     id_serializer_class = UserCredentialIdSerializer
5650
5651     def get_serializer_class(self):
5652         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5653         if (no_hyperlinks):
5654             return self.id_serializer_class
5655         else:
5656             return self.serializer_class
5657     
5658     def get_queryset(self):
5659         return UserCredential.select_by_user(self.request.user)
5660
5661     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5662
5663     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5664
5665
5666
5667 class SliceTagList(generics.ListCreateAPIView):
5668     queryset = SliceTag.objects.select_related().all()
5669     serializer_class = SliceTagSerializer
5670     id_serializer_class = SliceTagIdSerializer
5671     filter_backends = (filters.DjangoFilterBackend,)
5672     filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5673
5674     def get_serializer_class(self):
5675         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5676         if (no_hyperlinks):
5677             return self.id_serializer_class
5678         else:
5679             return self.serializer_class
5680
5681     def get_queryset(self):
5682         return SliceTag.select_by_user(self.request.user)
5683
5684     def create(self, request, *args, **kwargs):
5685         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5686         if not (serializer.is_valid()):
5687             response = {"error": "validation",
5688                         "specific_error": "not serializer.is_valid()",\r
5689                         "reasons": serializer.errors}\r
5690             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5691         obj = serializer.object
5692         obj.caller = request.user
5693         if obj.can_update(request.user):
5694             return super(SliceTagList, self).create(request, *args, **kwargs)
5695         else:
5696             raise Exception("failed obj.can_update")
5697
5698         ret = super(SliceTagList, self).create(request, *args, **kwargs)
5699         if (ret.status_code%100 != 200):
5700             raise Exception(ret.data)
5701
5702         return ret
5703
5704
5705 class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5706     queryset = SliceTag.objects.select_related().all()
5707     serializer_class = SliceTagSerializer
5708     id_serializer_class = SliceTagIdSerializer
5709
5710     def get_serializer_class(self):
5711         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5712         if (no_hyperlinks):
5713             return self.id_serializer_class
5714         else:
5715             return self.serializer_class
5716     
5717     def get_queryset(self):
5718         return SliceTag.select_by_user(self.request.user)
5719
5720     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5721
5722     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5723
5724
5725
5726 class NetworkTemplateList(generics.ListCreateAPIView):
5727     queryset = NetworkTemplate.objects.select_related().all()
5728     serializer_class = NetworkTemplateSerializer
5729     id_serializer_class = NetworkTemplateIdSerializer
5730     filter_backends = (filters.DjangoFilterBackend,)
5731     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
5732
5733     def get_serializer_class(self):
5734         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5735         if (no_hyperlinks):
5736             return self.id_serializer_class
5737         else:
5738             return self.serializer_class
5739
5740     def get_queryset(self):
5741         return NetworkTemplate.select_by_user(self.request.user)
5742
5743     def create(self, request, *args, **kwargs):
5744         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5745         if not (serializer.is_valid()):
5746             response = {"error": "validation",
5747                         "specific_error": "not serializer.is_valid()",\r
5748                         "reasons": serializer.errors}\r
5749             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5750         obj = serializer.object
5751         obj.caller = request.user
5752         if obj.can_update(request.user):
5753             return super(NetworkTemplateList, self).create(request, *args, **kwargs)
5754         else:
5755             raise Exception("failed obj.can_update")
5756
5757         ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
5758         if (ret.status_code%100 != 200):
5759             raise Exception(ret.data)
5760
5761         return ret
5762
5763
5764 class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5765     queryset = NetworkTemplate.objects.select_related().all()
5766     serializer_class = NetworkTemplateSerializer
5767     id_serializer_class = NetworkTemplateIdSerializer
5768
5769     def get_serializer_class(self):
5770         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5771         if (no_hyperlinks):
5772             return self.id_serializer_class
5773         else:
5774             return self.serializer_class
5775     
5776     def get_queryset(self):
5777         return NetworkTemplate.select_by_user(self.request.user)
5778
5779     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5780
5781     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5782
5783
5784
5785 class RouterList(generics.ListCreateAPIView):
5786     queryset = Router.objects.select_related().all()
5787     serializer_class = RouterSerializer
5788     id_serializer_class = RouterIdSerializer
5789     filter_backends = (filters.DjangoFilterBackend,)
5790     filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
5791
5792     def get_serializer_class(self):
5793         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5794         if (no_hyperlinks):
5795             return self.id_serializer_class
5796         else:
5797             return self.serializer_class
5798
5799     def get_queryset(self):
5800         return Router.select_by_user(self.request.user)
5801
5802     def create(self, request, *args, **kwargs):
5803         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5804         if not (serializer.is_valid()):
5805             response = {"error": "validation",
5806                         "specific_error": "not serializer.is_valid()",\r
5807                         "reasons": serializer.errors}\r
5808             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5809         obj = serializer.object
5810         obj.caller = request.user
5811         if obj.can_update(request.user):
5812             return super(RouterList, self).create(request, *args, **kwargs)
5813         else:
5814             raise Exception("failed obj.can_update")
5815
5816         ret = super(RouterList, self).create(request, *args, **kwargs)
5817         if (ret.status_code%100 != 200):
5818             raise Exception(ret.data)
5819
5820         return ret
5821
5822
5823 class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5824     queryset = Router.objects.select_related().all()
5825     serializer_class = RouterSerializer
5826     id_serializer_class = RouterIdSerializer
5827
5828     def get_serializer_class(self):
5829         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5830         if (no_hyperlinks):
5831             return self.id_serializer_class
5832         else:
5833             return self.serializer_class
5834     
5835     def get_queryset(self):
5836         return Router.select_by_user(self.request.user)
5837
5838     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5839
5840     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5841
5842
5843
5844 class ServiceResourceList(generics.ListCreateAPIView):
5845     queryset = ServiceResource.objects.select_related().all()
5846     serializer_class = ServiceResourceSerializer
5847     id_serializer_class = ServiceResourceIdSerializer
5848     filter_backends = (filters.DjangoFilterBackend,)
5849     filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5850
5851     def get_serializer_class(self):
5852         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5853         if (no_hyperlinks):
5854             return self.id_serializer_class
5855         else:
5856             return self.serializer_class
5857
5858     def get_queryset(self):
5859         return ServiceResource.select_by_user(self.request.user)
5860
5861     def create(self, request, *args, **kwargs):
5862         serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5863         if not (serializer.is_valid()):
5864             response = {"error": "validation",
5865                         "specific_error": "not serializer.is_valid()",\r
5866                         "reasons": serializer.errors}\r
5867             return Response(response, status=status.HTTP_400_BAD_REQUEST)
5868         obj = serializer.object
5869         obj.caller = request.user
5870         if obj.can_update(request.user):
5871             return super(ServiceResourceList, self).create(request, *args, **kwargs)
5872         else:
5873             raise Exception("failed obj.can_update")
5874
5875         ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5876         if (ret.status_code%100 != 200):
5877             raise Exception(ret.data)
5878
5879         return ret
5880
5881
5882 class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5883     queryset = ServiceResource.objects.select_related().all()
5884     serializer_class = ServiceResourceSerializer
5885     id_serializer_class = ServiceResourceIdSerializer
5886
5887     def get_serializer_class(self):
5888         no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5889         if (no_hyperlinks):
5890             return self.id_serializer_class
5891         else:
5892             return self.serializer_class
5893     
5894     def get_queryset(self):
5895         return ServiceResource.select_by_user(self.request.user)
5896
5897     # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5898
5899     # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5900
5901
5902