blob: 880587cbd8e206248c6c9599cf09dc7d35a293f6 [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Baker89a7b7c2014-10-07 00:10:17 -07006from rest_framework import status
Scott Baker57c725c2014-11-12 01:13:53 -08007from rest_framework.generics import GenericAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04008from core.models import *
9from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -070010from rest_framework import filters
Scott Bakerd51d0bd2014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Sapan Bhatiadea39432014-06-13 03:10:36 -040012
13"""
Scott Baker2bcbf372014-10-29 23:41:11 -070014 Schema of the generator object:
15 all: Set of all Model objects
16 all_if(regex): Set of Model objects that match regex
Scott Baker57c725c2014-11-12 01:13:53 -080017
Scott Baker2bcbf372014-10-29 23:41:11 -070018 Model object:
19 plural: English plural of object name
20 camel: CamelCase version of object name
21 refs: list of references to other Model objects
22 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040023
Scott Baker2bcbf372014-10-29 23:41:11 -070024 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040025"""
26
Scott Bakerd51d0bd2014-11-10 16:31:15 -080027def get_REST_patterns():
28 return patterns('',
29 url(r'^plstackapi/$', api_root),
30
31 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
32 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
33
34 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
35 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
36
37 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
38 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
39
40 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
41 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
42
43 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
44 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
45
46 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
47 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
48
49 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
50 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
51
52 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
53 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
54
55 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
56 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
57
58 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
59 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
60
Tony Mack06c8e472014-11-30 15:53:08 -050061 url(r'plstackapi/controllernetworks/$', ControllerNetworksList.as_view(), name='controllernetworks-list'),
62 url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworksDetail.as_view(), name ='controllernetworks-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080063
64 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
65 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
66
67 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
68 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
69
70 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
71 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
72
73 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
74 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
75
76 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
77 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
78
79 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
80 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
81
Scott Bakerb744f1c2014-11-21 11:32:24 -080082 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
83 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080084
85 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
86 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
87
88 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
89 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
90
91 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
92 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
93
94 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
95 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
96
97 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
98 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
99
100 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
101 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
102
103 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
104 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
105
106 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
107 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
108
Tony Mack06c8e472014-11-30 15:53:08 -0500109 url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
110 url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800111
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800112 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
113 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
114
115 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
116 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
117
118 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
119 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
120
121 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
122 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
123
124 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
125 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
126
127 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
128 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
Tony Mack06c8e472014-11-30 15:53:08 -0500129 url(r'plstackapi/Controller/$', ControllerList.as_view(), name='controller-list'),
130 url(r'plstackapi/Controller/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800131
132 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
133 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
134
Tony Mack06c8e472014-11-30 15:53:08 -0500135 url(r'plstackapi/controllerslices/$', ControllerSlicesList.as_view(), name='controllerslices-list'),
136 url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicesDetail.as_view(), name ='controllerslices-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800137
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800138 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
139 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
140
Scott Bakerb744f1c2014-11-21 11:32:24 -0800141 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
142 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800143
Tony Mack06c8e472014-11-30 15:53:08 -0500144 url(r'plstackapi/controllerusers/$', ControllerUsersList.as_view(), name='controllerusers-list'),
145 url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUsersDetail.as_view(), name ='controllerusers-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800146
147 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
148 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
149
150 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
151 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
152
153 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
154 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
155
Tony Mack06c8e472014-11-30 15:53:08 -0500156 url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'),
157 url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800158
Tony Mack06c8e472014-11-30 15:53:08 -0500159 url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
160 url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800161
162 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
163 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
164
Scott Bakerb744f1c2014-11-21 11:32:24 -0800165 url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'),
166 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800167
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800168 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
169 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
170
171 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
172 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
173
174 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
175 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
176
177 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
178 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
179
180 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400181
182@api_view(['GET'])
183def api_root(request, format=None):
184 return Response({
Scott Baker2bcbf372014-10-29 23:41:11 -0700185 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
186 'images': reverse('image-list', request=request, format=format),
187 'networkparameters': reverse('networkparameter-list', request=request, format=format),
188 'sites': reverse('site-list', request=request, format=format),
189 'sliceroles': reverse('slicerole-list', request=request, format=format),
190 'tags': reverse('tag-list', request=request, format=format),
191 'invoices': reverse('invoice-list', request=request, format=format),
192 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
193 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
194 'networkslivers': reverse('networksliver-list', request=request, format=format),
Tony Mack06c8e472014-11-30 15:53:08 -0500195 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700196 'flavors': reverse('flavor-list', request=request, format=format),
197 'projects': reverse('project-list', request=request, format=format),
198 'slices': reverse('slice-list', request=request, format=format),
199 'networks': reverse('network-list', request=request, format=format),
200 'services': reverse('service-list', request=request, format=format),
201 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800202 'payments': reverse('payment-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700203 'charges': reverse('charge-list', request=request, format=format),
204 'roles': reverse('role-list', request=request, format=format),
205 'usableobjects': reverse('usableobject-list', request=request, format=format),
206 'siteroles': reverse('siterole-list', request=request, format=format),
207 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
208 'slivers': reverse('sliver-list', request=request, format=format),
209 'nodes': reverse('node-list', request=request, format=format),
210 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Tony Mack06c8e472014-11-30 15:53:08 -0500211 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700212 'reservedresources': reverse('reservedresource-list', request=request, format=format),
213 'networkslices': reverse('networkslice-list', request=request, format=format),
214 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
215 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
216 'users': reverse('user-list', request=request, format=format),
217 'deployments': reverse('deployment-list', request=request, format=format),
Tony Mack06c8e472014-11-30 15:53:08 -0500218 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700219 'reservations': reverse('reservation-list', request=request, format=format),
Tony Mack06c8e472014-11-30 15:53:08 -0500220 'controllersliceses': reverse('controllerslices-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700221 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800222 'planetstacks': reverse('planetstack-list', request=request, format=format),
Tony Mack06c8e472014-11-30 15:53:08 -0500223 'controlleruserses': reverse('controllerusers-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700224 'accounts': reverse('account-list', request=request, format=format),
225 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
226 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Tony Mack06c8e472014-11-30 15:53:08 -0500227 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format),
228 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700229 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800230 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Tony Mack06c8e472014-11-30 15:53:08 -0500231 'controllersiteses': reverse('controllersites-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700232 'slicetags': reverse('slicetag-list', request=request, format=format),
233 'networktemplates': reverse('networktemplate-list', request=request, format=format),
234 'routers': reverse('router-list', request=request, format=format),
235 'serviceresources': reverse('serviceresource-list', request=request, format=format),
236
Sapan Bhatiadea39432014-06-13 03:10:36 -0400237 })
238
239# Based on serializers.py
240
241
242
Scott Baker0caeaf02014-06-19 11:12:55 -0700243class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700244 id = serializers.Field()
245
Scott Bakerb744f1c2014-11-21 11:32:24 -0800246 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800247 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800248 def getHumanReadableName(self, obj):
249 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800250 def getValidators(self, obj):
251 try:
252 return obj.getValidators()
253 except:
254 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700255 class Meta:
256 model = ServiceAttribute
Scott Baker96eb3fd2014-11-25 00:53:25 -0800257 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700258
259class ServiceAttributeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700260 id = serializers.Field()
261
Scott Bakerb744f1c2014-11-21 11:32:24 -0800262 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800263 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800264 def getHumanReadableName(self, obj):
265 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800266 def getValidators(self, obj):
267 try:
268 return obj.getValidators()
269 except:
270 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700271 class Meta:
272 model = ServiceAttribute
Scott Baker96eb3fd2014-11-25 00:53:25 -0800273 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700274
275
Sapan Bhatiadea39432014-06-13 03:10:36 -0400276
277
278class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700279 id = serializers.Field()
280
Scott Bakerb744f1c2014-11-21 11:32:24 -0800281 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800282 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800283 def getHumanReadableName(self, obj):
284 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800285 def getValidators(self, obj):
286 try:
287 return obj.getValidators()
288 except:
289 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700290 class Meta:
291 model = Image
Scott Baker96eb3fd2014-11-25 00:53:25 -0800292 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700293
294class ImageIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700295 id = serializers.Field()
296
Scott Bakerb744f1c2014-11-21 11:32:24 -0800297 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800298 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800299 def getHumanReadableName(self, obj):
300 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800301 def getValidators(self, obj):
302 try:
303 return obj.getValidators()
304 except:
305 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700306 class Meta:
307 model = Image
Scott Baker96eb3fd2014-11-25 00:53:25 -0800308 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700309
310
Sapan Bhatiadea39432014-06-13 03:10:36 -0400311
312
Scott Baker0caeaf02014-06-19 11:12:55 -0700313class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700314 id = serializers.Field()
315
Scott Bakerb744f1c2014-11-21 11:32:24 -0800316 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800317 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800318 def getHumanReadableName(self, obj):
319 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800320 def getValidators(self, obj):
321 try:
322 return obj.getValidators()
323 except:
324 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700325 class Meta:
326 model = NetworkParameter
Scott Baker96eb3fd2014-11-25 00:53:25 -0800327 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700328
329class NetworkParameterIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700330 id = serializers.Field()
331
Scott Bakerb744f1c2014-11-21 11:32:24 -0800332 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800333 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800334 def getHumanReadableName(self, obj):
335 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800336 def getValidators(self, obj):
337 try:
338 return obj.getValidators()
339 except:
340 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700341 class Meta:
342 model = NetworkParameter
Scott Baker96eb3fd2014-11-25 00:53:25 -0800343 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700344
345
Sapan Bhatiadea39432014-06-13 03:10:36 -0400346
347
348class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700349 id = serializers.Field()
350
Scott Bakerb744f1c2014-11-21 11:32:24 -0800351 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800352 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800353 def getHumanReadableName(self, obj):
354 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800355 def getValidators(self, obj):
356 try:
357 return obj.getValidators()
358 except:
359 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700360 class Meta:
361 model = Site
Scott Baker96eb3fd2014-11-25 00:53:25 -0800362 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Scott Baker46b58542014-08-11 17:26:12 -0700363
364class SiteIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700365 id = serializers.Field()
366
Scott Bakerb744f1c2014-11-21 11:32:24 -0800367 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800368 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800369 def getHumanReadableName(self, obj):
370 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800371 def getValidators(self, obj):
372 try:
373 return obj.getValidators()
374 except:
375 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700376 class Meta:
377 model = Site
Scott Baker96eb3fd2014-11-25 00:53:25 -0800378 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Scott Baker46b58542014-08-11 17:26:12 -0700379
380
Sapan Bhatiadea39432014-06-13 03:10:36 -0400381
382
Scott Baker0caeaf02014-06-19 11:12:55 -0700383class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700384 id = serializers.Field()
385
Scott Bakerb744f1c2014-11-21 11:32:24 -0800386 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800387 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800388 def getHumanReadableName(self, obj):
389 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800390 def getValidators(self, obj):
391 try:
392 return obj.getValidators()
393 except:
394 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700395 class Meta:
396 model = SliceRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800397 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700398
399class SliceRoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700400 id = serializers.Field()
401
Scott Bakerb744f1c2014-11-21 11:32:24 -0800402 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800403 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800404 def getHumanReadableName(self, obj):
405 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800406 def getValidators(self, obj):
407 try:
408 return obj.getValidators()
409 except:
410 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700411 class Meta:
412 model = SliceRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800413 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700414
415
Sapan Bhatiadea39432014-06-13 03:10:36 -0400416
417
418class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700419 id = serializers.Field()
420
Scott Bakerb744f1c2014-11-21 11:32:24 -0800421 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800422 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800423 def getHumanReadableName(self, obj):
424 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800425 def getValidators(self, obj):
426 try:
427 return obj.getValidators()
428 except:
429 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700430 class Meta:
431 model = Tag
Scott Baker96eb3fd2014-11-25 00:53:25 -0800432 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700433
434class TagIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700435 id = serializers.Field()
436
Scott Bakerb744f1c2014-11-21 11:32:24 -0800437 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800438 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800439 def getHumanReadableName(self, obj):
440 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800441 def getValidators(self, obj):
442 try:
443 return obj.getValidators()
444 except:
445 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700446 class Meta:
447 model = Tag
Scott Baker96eb3fd2014-11-25 00:53:25 -0800448 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700449
450
Sapan Bhatiadea39432014-06-13 03:10:36 -0400451
452
453class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700454 id = serializers.Field()
455
Scott Bakerb744f1c2014-11-21 11:32:24 -0800456 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800457 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800458 def getHumanReadableName(self, obj):
459 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800460 def getValidators(self, obj):
461 try:
462 return obj.getValidators()
463 except:
464 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700465 class Meta:
466 model = Invoice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800467 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700468
469class InvoiceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700470 id = serializers.Field()
471
Scott Bakerb744f1c2014-11-21 11:32:24 -0800472 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800473 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800474 def getHumanReadableName(self, obj):
475 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800476 def getValidators(self, obj):
477 try:
478 return obj.getValidators()
479 except:
480 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700481 class Meta:
482 model = Invoice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800483 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700484
485
Sapan Bhatiadea39432014-06-13 03:10:36 -0400486
487
Scott Baker0caeaf02014-06-19 11:12:55 -0700488class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700489 id = serializers.Field()
490
Scott Bakerb744f1c2014-11-21 11:32:24 -0800491 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800492 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800493 def getHumanReadableName(self, obj):
494 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800495 def getValidators(self, obj):
496 try:
497 return obj.getValidators()
498 except:
499 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700500 class Meta:
501 model = SlicePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -0800502 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700503
504class SlicePrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700505 id = serializers.Field()
506
Scott Bakerb744f1c2014-11-21 11:32:24 -0800507 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800508 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800509 def getHumanReadableName(self, obj):
510 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800511 def getValidators(self, obj):
512 try:
513 return obj.getValidators()
514 except:
515 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700516 class Meta:
517 model = SlicePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -0800518 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700519
520
Scott Baker0caeaf02014-06-19 11:12:55 -0700521
522
Scott Baker89a7b7c2014-10-07 00:10:17 -0700523class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700524 id = serializers.Field()
525
Scott Bakerb744f1c2014-11-21 11:32:24 -0800526 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800527 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800528 def getHumanReadableName(self, obj):
529 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800530 def getValidators(self, obj):
531 try:
532 return obj.getValidators()
533 except:
534 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700535 class Meta:
536 model = PlanetStackRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800537 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700538
539class PlanetStackRoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700540 id = serializers.Field()
541
Scott Bakerb744f1c2014-11-21 11:32:24 -0800542 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800543 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800544 def getHumanReadableName(self, obj):
545 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800546 def getValidators(self, obj):
547 try:
548 return obj.getValidators()
549 except:
550 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700551 class Meta:
552 model = PlanetStackRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800553 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700554
555
556
557
Scott Baker0caeaf02014-06-19 11:12:55 -0700558class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700559 id = serializers.Field()
560
Scott Bakerb744f1c2014-11-21 11:32:24 -0800561 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800562 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800563 def getHumanReadableName(self, obj):
564 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800565 def getValidators(self, obj):
566 try:
567 return obj.getValidators()
568 except:
569 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700570 class Meta:
571 model = NetworkSliver
Scott Baker96eb3fd2014-11-25 00:53:25 -0800572 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700573
574class NetworkSliverIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700575 id = serializers.Field()
576
Scott Bakerb744f1c2014-11-21 11:32:24 -0800577 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800578 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800579 def getHumanReadableName(self, obj):
580 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800581 def getValidators(self, obj):
582 try:
583 return obj.getValidators()
584 except:
585 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700586 class Meta:
587 model = NetworkSliver
Scott Baker96eb3fd2014-11-25 00:53:25 -0800588 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700589
590
Scott Baker0caeaf02014-06-19 11:12:55 -0700591
592
Tony Mack06c8e472014-11-30 15:53:08 -0500593class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700594 id = serializers.Field()
595
Scott Bakerb744f1c2014-11-21 11:32:24 -0800596 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800597 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800598 def getHumanReadableName(self, obj):
599 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800600 def getValidators(self, obj):
601 try:
602 return obj.getValidators()
603 except:
604 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700605 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -0500606 model = ControllerNetworks
Scott Baker96eb3fd2014-11-25 00:53:25 -0800607 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700608
Tony Mack06c8e472014-11-30 15:53:08 -0500609class ControllerNetworksIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700610 id = serializers.Field()
611
Scott Bakerb744f1c2014-11-21 11:32:24 -0800612 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800613 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800614 def getHumanReadableName(self, obj):
615 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800616 def getValidators(self, obj):
617 try:
618 return obj.getValidators()
619 except:
620 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700621 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -0500622 model = ControllerNetworks
Scott Baker96eb3fd2014-11-25 00:53:25 -0800623 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700624
625
Sapan Bhatiadea39432014-06-13 03:10:36 -0400626
627
Scott Baker89a7b7c2014-10-07 00:10:17 -0700628class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700629 id = serializers.Field()
630
Scott Bakerb744f1c2014-11-21 11:32:24 -0800631 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800632 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800633 def getHumanReadableName(self, obj):
634 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800635 def getValidators(self, obj):
636 try:
637 return obj.getValidators()
638 except:
639 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700640 class Meta:
641 model = Flavor
Scott Baker96eb3fd2014-11-25 00:53:25 -0800642 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700643
644class FlavorIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700645 id = serializers.Field()
646
Scott Bakerb744f1c2014-11-21 11:32:24 -0800647 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800648 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800649 def getHumanReadableName(self, obj):
650 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800651 def getValidators(self, obj):
652 try:
653 return obj.getValidators()
654 except:
655 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700656 class Meta:
657 model = Flavor
Scott Baker96eb3fd2014-11-25 00:53:25 -0800658 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700659
660
661
662
663class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700664 id = serializers.Field()
665
Scott Bakerb744f1c2014-11-21 11:32:24 -0800666 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800667 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800668 def getHumanReadableName(self, obj):
669 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800670 def getValidators(self, obj):
671 try:
672 return obj.getValidators()
673 except:
674 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700675 class Meta:
676 model = Project
Scott Baker96eb3fd2014-11-25 00:53:25 -0800677 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700678
679class ProjectIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700680 id = serializers.Field()
681
Scott Bakerb744f1c2014-11-21 11:32:24 -0800682 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800683 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800684 def getHumanReadableName(self, obj):
685 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800686 def getValidators(self, obj):
687 try:
688 return obj.getValidators()
689 except:
690 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700691 class Meta:
692 model = Project
Scott Baker96eb3fd2014-11-25 00:53:25 -0800693 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700694
695
696
697
Sapan Bhatiadea39432014-06-13 03:10:36 -0400698class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700699 id = serializers.Field()
700
701
702 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
703
704
705
706 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
707
708
709
710 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
711
712
713
714 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
715
716
Scott Bakerb744f1c2014-11-21 11:32:24 -0800717 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800718 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800719 def getHumanReadableName(self, obj):
720 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800721 def getValidators(self, obj):
722 try:
723 return obj.getValidators()
724 except:
725 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700726 class Meta:
727 model = Slice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800728 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700729
730class SliceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700731 id = serializers.Field()
732
733
734 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
735
736
737
738 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
739
740
741
742 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
743
744
745
746 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
747
748
Scott Bakerb744f1c2014-11-21 11:32:24 -0800749 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800750 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800751 def getHumanReadableName(self, obj):
752 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800753 def getValidators(self, obj):
754 try:
755 return obj.getValidators()
756 except:
757 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700758 class Meta:
759 model = Slice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800760 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700761
762
Sapan Bhatiadea39432014-06-13 03:10:36 -0400763
764
765class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700766 id = serializers.Field()
767
768
769 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
770
771
772
773 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
774
775
776
777 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
778
779
780
781 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
782
783
Scott Bakerb744f1c2014-11-21 11:32:24 -0800784 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800785 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800786 def getHumanReadableName(self, obj):
787 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800788 def getValidators(self, obj):
789 try:
790 return obj.getValidators()
791 except:
792 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700793 class Meta:
794 model = Network
Scott Baker96eb3fd2014-11-25 00:53:25 -0800795 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700796
797class NetworkIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700798 id = serializers.Field()
799
800
801 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
802
803
804
805 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
806
807
808
809 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
810
811
812
813 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
814
815
Scott Bakerb744f1c2014-11-21 11:32:24 -0800816 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800817 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800818 def getHumanReadableName(self, obj):
819 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800820 def getValidators(self, obj):
821 try:
822 return obj.getValidators()
823 except:
824 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700825 class Meta:
826 model = Network
Scott Baker96eb3fd2014-11-25 00:53:25 -0800827 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700828
829
Sapan Bhatiadea39432014-06-13 03:10:36 -0400830
831
832class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700833 id = serializers.Field()
834
Scott Bakerb744f1c2014-11-21 11:32:24 -0800835 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800836 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800837 def getHumanReadableName(self, obj):
838 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800839 def getValidators(self, obj):
840 try:
841 return obj.getValidators()
842 except:
843 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700844 class Meta:
845 model = Service
Scott Baker96eb3fd2014-11-25 00:53:25 -0800846 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700847
848class ServiceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700849 id = serializers.Field()
850
Scott Bakerb744f1c2014-11-21 11:32:24 -0800851 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800852 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800853 def getHumanReadableName(self, obj):
854 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800855 def getValidators(self, obj):
856 try:
857 return obj.getValidators()
858 except:
859 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700860 class Meta:
861 model = Service
Scott Baker96eb3fd2014-11-25 00:53:25 -0800862 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700863
864
Sapan Bhatiadea39432014-06-13 03:10:36 -0400865
866
Scott Baker0caeaf02014-06-19 11:12:55 -0700867class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700868 id = serializers.Field()
869
Scott Bakerb744f1c2014-11-21 11:32:24 -0800870 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800871 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800872 def getHumanReadableName(self, obj):
873 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800874 def getValidators(self, obj):
875 try:
876 return obj.getValidators()
877 except:
878 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700879 class Meta:
880 model = ServiceClass
Scott Baker96eb3fd2014-11-25 00:53:25 -0800881 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700882
883class ServiceClassIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700884 id = serializers.Field()
885
Scott Bakerb744f1c2014-11-21 11:32:24 -0800886 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800887 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800888 def getHumanReadableName(self, obj):
889 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800890 def getValidators(self, obj):
891 try:
892 return obj.getValidators()
893 except:
894 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700895 class Meta:
896 model = ServiceClass
Scott Baker96eb3fd2014-11-25 00:53:25 -0800897 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700898
899
Sapan Bhatiadea39432014-06-13 03:10:36 -0400900
901
Scott Bakerb744f1c2014-11-21 11:32:24 -0800902class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700903 id = serializers.Field()
904
Scott Bakerb744f1c2014-11-21 11:32:24 -0800905 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800906 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800907 def getHumanReadableName(self, obj):
908 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800909 def getValidators(self, obj):
910 try:
911 return obj.getValidators()
912 except:
913 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700914 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -0800915 model = Payment
Scott Baker96eb3fd2014-11-25 00:53:25 -0800916 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700917
Scott Bakerb744f1c2014-11-21 11:32:24 -0800918class PaymentIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700919 id = serializers.Field()
920
Scott Bakerb744f1c2014-11-21 11:32:24 -0800921 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800922 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800923 def getHumanReadableName(self, obj):
924 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800925 def getValidators(self, obj):
926 try:
927 return obj.getValidators()
928 except:
929 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700930 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -0800931 model = Payment
Scott Baker96eb3fd2014-11-25 00:53:25 -0800932 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700933
934
Sapan Bhatiadea39432014-06-13 03:10:36 -0400935
936
937class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700938 id = serializers.Field()
939
Scott Bakerb744f1c2014-11-21 11:32:24 -0800940 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800941 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800942 def getHumanReadableName(self, obj):
943 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800944 def getValidators(self, obj):
945 try:
946 return obj.getValidators()
947 except:
948 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700949 class Meta:
950 model = Charge
Scott Baker96eb3fd2014-11-25 00:53:25 -0800951 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700952
953class ChargeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700954 id = serializers.Field()
955
Scott Bakerb744f1c2014-11-21 11:32:24 -0800956 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800957 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800958 def getHumanReadableName(self, obj):
959 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800960 def getValidators(self, obj):
961 try:
962 return obj.getValidators()
963 except:
964 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700965 class Meta:
966 model = Charge
Scott Baker96eb3fd2014-11-25 00:53:25 -0800967 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700968
969
Sapan Bhatiadea39432014-06-13 03:10:36 -0400970
971
972class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700973 id = serializers.Field()
974
Scott Bakerb744f1c2014-11-21 11:32:24 -0800975 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800976 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800977 def getHumanReadableName(self, obj):
978 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800979 def getValidators(self, obj):
980 try:
981 return obj.getValidators()
982 except:
983 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700984 class Meta:
985 model = Role
Scott Baker96eb3fd2014-11-25 00:53:25 -0800986 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700987
988class RoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700989 id = serializers.Field()
990
Scott Bakerb744f1c2014-11-21 11:32:24 -0800991 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800992 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800993 def getHumanReadableName(self, obj):
994 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800995 def getValidators(self, obj):
996 try:
997 return obj.getValidators()
998 except:
999 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001000 class Meta:
1001 model = Role
Scott Baker96eb3fd2014-11-25 00:53:25 -08001002 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001003
1004
Sapan Bhatiadea39432014-06-13 03:10:36 -04001005
1006
Scott Baker0caeaf02014-06-19 11:12:55 -07001007class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001008 id = serializers.Field()
1009
Scott Bakerb744f1c2014-11-21 11:32:24 -08001010 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001011 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001012 def getHumanReadableName(self, obj):
1013 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001014 def getValidators(self, obj):
1015 try:
1016 return obj.getValidators()
1017 except:
1018 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001019 class Meta:
1020 model = UsableObject
Scott Baker96eb3fd2014-11-25 00:53:25 -08001021 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001022
1023class UsableObjectIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001024 id = serializers.Field()
1025
Scott Bakerb744f1c2014-11-21 11:32:24 -08001026 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001027 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001028 def getHumanReadableName(self, obj):
1029 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001030 def getValidators(self, obj):
1031 try:
1032 return obj.getValidators()
1033 except:
1034 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001035 class Meta:
1036 model = UsableObject
Scott Baker96eb3fd2014-11-25 00:53:25 -08001037 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001038
1039
Sapan Bhatiadea39432014-06-13 03:10:36 -04001040
1041
Scott Baker0caeaf02014-06-19 11:12:55 -07001042class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001043 id = serializers.Field()
1044
Scott Bakerb744f1c2014-11-21 11:32:24 -08001045 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001046 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001047 def getHumanReadableName(self, obj):
1048 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001049 def getValidators(self, obj):
1050 try:
1051 return obj.getValidators()
1052 except:
1053 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001054 class Meta:
1055 model = SiteRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001056 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001057
1058class SiteRoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001059 id = serializers.Field()
1060
Scott Bakerb744f1c2014-11-21 11:32:24 -08001061 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001062 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001063 def getHumanReadableName(self, obj):
1064 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001065 def getValidators(self, obj):
1066 try:
1067 return obj.getValidators()
1068 except:
1069 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001070 class Meta:
1071 model = SiteRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001072 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001073
1074
Scott Baker0caeaf02014-06-19 11:12:55 -07001075
1076
Scott Baker89a7b7c2014-10-07 00:10:17 -07001077class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001078 id = serializers.Field()
1079
Scott Bakerb744f1c2014-11-21 11:32:24 -08001080 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001081 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001082 def getHumanReadableName(self, obj):
1083 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001084 def getValidators(self, obj):
1085 try:
1086 return obj.getValidators()
1087 except:
1088 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001089 class Meta:
1090 model = SliceCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001091 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001092
1093class SliceCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001094 id = serializers.Field()
1095
Scott Bakerb744f1c2014-11-21 11:32:24 -08001096 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001097 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001098 def getHumanReadableName(self, obj):
1099 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001100 def getValidators(self, obj):
1101 try:
1102 return obj.getValidators()
1103 except:
1104 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001105 class Meta:
1106 model = SliceCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001107 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001108
1109
1110
1111
Sapan Bhatiadea39432014-06-13 03:10:36 -04001112class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001113 id = serializers.Field()
1114
1115
1116 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1117
1118
1119
1120 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1121
1122
Scott Bakerb744f1c2014-11-21 11:32:24 -08001123 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001124 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001125 def getHumanReadableName(self, obj):
1126 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001127 def getValidators(self, obj):
1128 try:
1129 return obj.getValidators()
1130 except:
1131 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001132 class Meta:
1133 model = Sliver
Scott Baker96eb3fd2014-11-25 00:53:25 -08001134 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001135
1136class SliverIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001137 id = serializers.Field()
1138
1139
1140 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1141
1142
1143
1144 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1145
1146
Scott Bakerb744f1c2014-11-21 11:32:24 -08001147 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001148 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001149 def getHumanReadableName(self, obj):
1150 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001151 def getValidators(self, obj):
1152 try:
1153 return obj.getValidators()
1154 except:
1155 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001156 class Meta:
1157 model = Sliver
Scott Baker96eb3fd2014-11-25 00:53:25 -08001158 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001159
1160
Sapan Bhatiadea39432014-06-13 03:10:36 -04001161
1162
1163class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001164 id = serializers.Field()
1165
Scott Bakerb744f1c2014-11-21 11:32:24 -08001166 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001167 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001168 def getHumanReadableName(self, obj):
1169 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001170 def getValidators(self, obj):
1171 try:
1172 return obj.getValidators()
1173 except:
1174 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001175 class Meta:
1176 model = Node
Scott Baker96eb3fd2014-11-25 00:53:25 -08001177 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001178
1179class NodeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001180 id = serializers.Field()
1181
Scott Bakerb744f1c2014-11-21 11:32:24 -08001182 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001183 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001184 def getHumanReadableName(self, obj):
1185 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001186 def getValidators(self, obj):
1187 try:
1188 return obj.getValidators()
1189 except:
1190 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001191 class Meta:
1192 model = Node
Scott Baker96eb3fd2014-11-25 00:53:25 -08001193 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001194
1195
Sapan Bhatiadea39432014-06-13 03:10:36 -04001196
1197
Scott Baker0caeaf02014-06-19 11:12:55 -07001198class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001199 id = serializers.Field()
1200
Scott Bakerb744f1c2014-11-21 11:32:24 -08001201 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001202 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001203 def getHumanReadableName(self, obj):
1204 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001205 def getValidators(self, obj):
1206 try:
1207 return obj.getValidators()
1208 except:
1209 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001210 class Meta:
1211 model = DashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001212 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker46b58542014-08-11 17:26:12 -07001213
1214class DashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001215 id = serializers.Field()
1216
Scott Bakerb744f1c2014-11-21 11:32:24 -08001217 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001218 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001219 def getHumanReadableName(self, obj):
1220 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001221 def getValidators(self, obj):
1222 try:
1223 return obj.getValidators()
1224 except:
1225 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001226 class Meta:
1227 model = DashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001228 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001229
1230
1231
1232
Tony Mack06c8e472014-11-30 15:53:08 -05001233class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001234 id = serializers.Field()
1235
1236 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001237 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001238 def getHumanReadableName(self, obj):
1239 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001240 def getValidators(self, obj):
1241 try:
1242 return obj.getValidators()
1243 except:
1244 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001245 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001246 model = ControllerImages
Scott Baker96eb3fd2014-11-25 00:53:25 -08001247 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001248
Tony Mack06c8e472014-11-30 15:53:08 -05001249class ControllerImagesIdSerializer(serializers.ModelSerializer):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001250 id = serializers.Field()
1251
1252 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001253 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001254 def getHumanReadableName(self, obj):
1255 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001256 def getValidators(self, obj):
1257 try:
1258 return obj.getValidators()
1259 except:
1260 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001261 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001262 model = ControllerImages
Scott Baker96eb3fd2014-11-25 00:53:25 -08001263 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001264
1265
Sapan Bhatiadea39432014-06-13 03:10:36 -04001266
1267
Scott Baker0caeaf02014-06-19 11:12:55 -07001268class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001269 id = serializers.Field()
1270
Scott Bakerb744f1c2014-11-21 11:32:24 -08001271 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001272 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001273 def getHumanReadableName(self, obj):
1274 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001275 def getValidators(self, obj):
1276 try:
1277 return obj.getValidators()
1278 except:
1279 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001280 class Meta:
1281 model = ReservedResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08001282 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001283
1284class ReservedResourceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001285 id = serializers.Field()
1286
Scott Bakerb744f1c2014-11-21 11:32:24 -08001287 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001288 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001289 def getHumanReadableName(self, obj):
1290 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001291 def getValidators(self, obj):
1292 try:
1293 return obj.getValidators()
1294 except:
1295 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001296 class Meta:
1297 model = ReservedResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08001298 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker8b533192014-11-17 22:32:19 -08001299
1300
1301
1302
Scott Baker0caeaf02014-06-19 11:12:55 -07001303class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001304 id = serializers.Field()
1305
Scott Bakerb744f1c2014-11-21 11:32:24 -08001306 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001307 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001308 def getHumanReadableName(self, obj):
1309 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001310 def getValidators(self, obj):
1311 try:
1312 return obj.getValidators()
1313 except:
1314 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001315 class Meta:
1316 model = NetworkSlice
Scott Baker96eb3fd2014-11-25 00:53:25 -08001317 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001318
1319class NetworkSliceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001320 id = serializers.Field()
1321
Scott Bakerb744f1c2014-11-21 11:32:24 -08001322 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001323 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001324 def getHumanReadableName(self, obj):
1325 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001326 def getValidators(self, obj):
1327 try:
1328 return obj.getValidators()
1329 except:
1330 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001331 class Meta:
1332 model = NetworkSlice
Scott Baker96eb3fd2014-11-25 00:53:25 -08001333 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001334
1335
Scott Baker0caeaf02014-06-19 11:12:55 -07001336
1337
1338class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001339 id = serializers.Field()
1340
Scott Bakerb744f1c2014-11-21 11:32:24 -08001341 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001342 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001343 def getHumanReadableName(self, obj):
1344 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001345 def getValidators(self, obj):
1346 try:
1347 return obj.getValidators()
1348 except:
1349 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001350 class Meta:
1351 model = UserDashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001352 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001353
1354class UserDashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001355 id = serializers.Field()
1356
Scott Bakerb744f1c2014-11-21 11:32:24 -08001357 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001358 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001359 def getHumanReadableName(self, obj):
1360 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001361 def getValidators(self, obj):
1362 try:
1363 return obj.getValidators()
1364 except:
Tony Mack06c8e472014-11-30 15:53:08 -05001365 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001366 class Meta:
1367 model = UserDashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001368 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker8b533192014-11-17 22:32:19 -08001369
1370
1371
1372
Scott Baker0caeaf02014-06-19 11:12:55 -07001373class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001374 id = serializers.Field()
1375
Scott Bakerb744f1c2014-11-21 11:32:24 -08001376 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001377 validators = serializers.SerializerMethodField("getValidators")
Tony Mack06c8e472014-11-30 15:53:08 -05001378 def getHumanReadableName(self, obj):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001379 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001380 def getValidators(self, obj):
1381 try:
1382 return obj.getValidators()
1383 except:
1384 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001385 class Meta:
1386 model = PlanetStackPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001387 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001388
1389class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001390 id = serializers.Field()
1391
Scott Bakerb744f1c2014-11-21 11:32:24 -08001392 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001393 validators = serializers.SerializerMethodField("getValidators")
Tony Mack06c8e472014-11-30 15:53:08 -05001394 def getHumanReadableName(self, obj):
1395 return str(obj)
1396 def getValidators(self, obj):
Scott Baker96eb3fd2014-11-25 00:53:25 -08001397 try:
1398 return obj.getValidators()
1399 except:
Tony Mack06c8e472014-11-30 15:53:08 -05001400 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001401 class Meta:
1402 model = PlanetStackPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001403 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001404
1405
Sapan Bhatiadea39432014-06-13 03:10:36 -04001406
1407
1408class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001409 id = serializers.Field()
1410
Scott Bakerb744f1c2014-11-21 11:32:24 -08001411 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001412 validators = serializers.SerializerMethodField("getValidators")
Tony Mack06c8e472014-11-30 15:53:08 -05001413 def getHumanReadableName(self, obj):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001414 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001415 def getValidators(self, obj):
1416 try:
1417 return obj.getValidators()
1418 except:
1419 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001420 class Meta:
1421 model = User
Scott Baker96eb3fd2014-11-25 00:53:25 -08001422 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',)
Scott Baker46b58542014-08-11 17:26:12 -07001423
1424class UserIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001425 id = serializers.Field()
1426
Scott Bakerb744f1c2014-11-21 11:32:24 -08001427 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001428 validators = serializers.SerializerMethodField("getValidators")
Tony Mack06c8e472014-11-30 15:53:08 -05001429 def getHumanReadableName(self, obj):
1430 return str(obj)
1431 def getValidators(self, obj):
Scott Baker96eb3fd2014-11-25 00:53:25 -08001432 try:
1433 return obj.getValidators()
1434 except:
Tony Mack06c8e472014-11-30 15:53:08 -05001435 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001436 class Meta:
1437 model = User
Scott Baker96eb3fd2014-11-25 00:53:25 -08001438 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',)
Scott Baker46b58542014-08-11 17:26:12 -07001439
1440
Sapan Bhatiadea39432014-06-13 03:10:36 -04001441
1442
1443class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001444 id = serializers.Field()
1445
1446
1447 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1448
1449
1450
1451 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1452
1453
1454
1455 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1456
1457
1458
1459 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1460
1461
Scott Bakerb744f1c2014-11-21 11:32:24 -08001462 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001463 validators = serializers.SerializerMethodField("getValidators")
Tony Mack06c8e472014-11-30 15:53:08 -05001464 def getHumanReadableName(self, obj):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001465 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001466 def getValidators(self, obj):
1467 try:
1468 return obj.getValidators()
1469 except:
1470 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001471 class Meta:
1472 model = Deployment
Tony Mack06c8e472014-11-30 15:53:08 -05001473 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','sites','sites','flavors','flavors',)
1474
Scott Baker46b58542014-08-11 17:26:12 -07001475class DeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001476 id = serializers.Field()
1477
1478
1479 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1480
1481
1482
1483 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1484
1485
1486
1487 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1488
1489
1490
1491 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1492
1493
Scott Bakerb744f1c2014-11-21 11:32:24 -08001494 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001495 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001496 def getHumanReadableName(self, obj):
1497 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001498 def getValidators(self, obj):
1499 try:
1500 return obj.getValidators()
1501 except:
1502 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001503 class Meta:
1504 model = Deployment
Scott Baker96eb3fd2014-11-25 00:53:25 -08001505 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001506
1507
Tony Mack06c8e472014-11-30 15:53:08 -05001508class ControllerSerializer(serializers.HyperlinkedModelSerializer):
1509 id = serializers.Field()
1510 site_deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sitedeployment-detail')
1511 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1512 validators = serializers.SerializerMethodField("getValidators")
1513 def getHumanReadableName(self, obj):
1514 return str(obj)
1515 def getValidators(self, obj):
1516 try:
1517 return obj.getValidators()
1518 except:
1519 return None
1520 class Meta:
1521 model = Controller
1522 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','admin_user','admin_password','admin_tenant','auth_url','backend_type')
1523
1524
1525class ControllerIdSerializer(serializers.ModelSerializer):
1526 id = serializers.Field()
Tony Mackd14d48f2014-12-05 17:13:08 -05001527 site_deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sitedeployment-detail')
Tony Mack06c8e472014-11-30 15:53:08 -05001528 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1529 validators = serializers.SerializerMethodField("getValidators")
1530 def getHumanReadableName(self, obj):
1531 return str(obj)
1532 def getValidators(self, obj):
1533 try:
1534 return obj.getValidators()
1535 except:
1536 return None
1537 class Meta:
1538 model = Controller
1539 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','admin_user','admin_password','admin_tenant','auth_url','backend_type')
Sapan Bhatiadea39432014-06-13 03:10:36 -04001540
1541
1542class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001543 id = serializers.Field()
1544
Scott Bakerb744f1c2014-11-21 11:32:24 -08001545 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001546 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001547 def getHumanReadableName(self, obj):
1548 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001549 def getValidators(self, obj):
1550 try:
1551 return obj.getValidators()
1552 except:
1553 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001554 class Meta:
1555 model = Reservation
Scott Baker96eb3fd2014-11-25 00:53:25 -08001556 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001557
1558class ReservationIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001559 id = serializers.Field()
1560
Scott Bakerb744f1c2014-11-21 11:32:24 -08001561 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001562 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001563 def getHumanReadableName(self, obj):
1564 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001565 def getValidators(self, obj):
1566 try:
1567 return obj.getValidators()
1568 except:
1569 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001570 class Meta:
1571 model = Reservation
Scott Baker96eb3fd2014-11-25 00:53:25 -08001572 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001573
1574
Scott Baker0caeaf02014-06-19 11:12:55 -07001575
1576
Tony Mack06c8e472014-11-30 15:53:08 -05001577class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001578 id = serializers.Field()
1579
Scott Bakerb744f1c2014-11-21 11:32:24 -08001580 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001581 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001582 def getHumanReadableName(self, obj):
1583 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001584 def getValidators(self, obj):
1585 try:
1586 return obj.getValidators()
1587 except:
1588 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001589 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001590 model = ControllerSlices
Scott Baker96eb3fd2014-11-25 00:53:25 -08001591 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001592
Tony Mack06c8e472014-11-30 15:53:08 -05001593class ControllerSlicesIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001594 id = serializers.Field()
1595
Scott Bakerb744f1c2014-11-21 11:32:24 -08001596 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001597 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001598 def getHumanReadableName(self, obj):
1599 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001600 def getValidators(self, obj):
1601 try:
1602 return obj.getValidators()
1603 except:
1604 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001605 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001606 model = ControllerSlices
Scott Baker96eb3fd2014-11-25 00:53:25 -08001607 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001608
1609
1610
1611
1612class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1613 id = serializers.Field()
1614
1615 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001616 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001617 def getHumanReadableName(self, obj):
1618 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001619 def getValidators(self, obj):
1620 try:
1621 return obj.getValidators()
1622 except:
1623 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001624 class Meta:
1625 model = SitePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001626 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001627
1628class SitePrivilegeIdSerializer(serializers.ModelSerializer):
1629 id = serializers.Field()
1630
1631 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001632 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001633 def getHumanReadableName(self, obj):
1634 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001635 def getValidators(self, obj):
1636 try:
1637 return obj.getValidators()
1638 except:
1639 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001640 class Meta:
1641 model = SitePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001642 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001643
1644
1645
1646
1647class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
1648 id = serializers.Field()
1649
1650 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001651 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001652 def getHumanReadableName(self, obj):
1653 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001654 def getValidators(self, obj):
1655 try:
1656 return obj.getValidators()
1657 except:
1658 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001659 class Meta:
1660 model = PlanetStack
Scott Baker96eb3fd2014-11-25 00:53:25 -08001661 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001662
1663class PlanetStackIdSerializer(serializers.ModelSerializer):
1664 id = serializers.Field()
1665
1666 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001667 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001668 def getHumanReadableName(self, obj):
1669 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001670 def getValidators(self, obj):
1671 try:
1672 return obj.getValidators()
1673 except:
1674 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001675 class Meta:
1676 model = PlanetStack
Scott Baker96eb3fd2014-11-25 00:53:25 -08001677 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001678
1679
Sapan Bhatiadea39432014-06-13 03:10:36 -04001680
1681
Tony Mack06c8e472014-11-30 15:53:08 -05001682class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001683 id = serializers.Field()
1684
Scott Bakerb744f1c2014-11-21 11:32:24 -08001685 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001686 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001687 def getHumanReadableName(self, obj):
1688 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001689 def getValidators(self, obj):
1690 try:
1691 return obj.getValidators()
1692 except:
1693 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001694 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001695 model = ControllerUsers
Scott Baker96eb3fd2014-11-25 00:53:25 -08001696 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001697
Tony Mack06c8e472014-11-30 15:53:08 -05001698class ControllerUsersIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001699 id = serializers.Field()
1700
Scott Bakerb744f1c2014-11-21 11:32:24 -08001701 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001702 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001703 def getHumanReadableName(self, obj):
1704 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001705 def getValidators(self, obj):
1706 try:
1707 return obj.getValidators()
1708 except:
1709 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001710 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001711 model = ControllerUsers
Scott Baker96eb3fd2014-11-25 00:53:25 -08001712 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001713
1714
Scott Baker0caeaf02014-06-19 11:12:55 -07001715
1716
Sapan Bhatiadea39432014-06-13 03:10:36 -04001717class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001718 id = serializers.Field()
1719
Scott Bakerb744f1c2014-11-21 11:32:24 -08001720 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001721 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001722 def getHumanReadableName(self, obj):
1723 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001724 def getValidators(self, obj):
1725 try:
1726 return obj.getValidators()
1727 except:
1728 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001729 class Meta:
1730 model = Account
Scott Baker96eb3fd2014-11-25 00:53:25 -08001731 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001732
1733class AccountIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001734 id = serializers.Field()
1735
Scott Bakerb744f1c2014-11-21 11:32:24 -08001736 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001737 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001738 def getHumanReadableName(self, obj):
1739 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001740 def getValidators(self, obj):
1741 try:
1742 return obj.getValidators()
1743 except:
1744 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001745 class Meta:
1746 model = Account
Scott Baker96eb3fd2014-11-25 00:53:25 -08001747 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001748
1749
Sapan Bhatiadea39432014-06-13 03:10:36 -04001750
1751
Scott Baker0caeaf02014-06-19 11:12:55 -07001752class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001753 id = serializers.Field()
1754
Scott Bakerb744f1c2014-11-21 11:32:24 -08001755 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001756 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001757 def getHumanReadableName(self, obj):
1758 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001759 def getValidators(self, obj):
1760 try:
1761 return obj.getValidators()
1762 except:
1763 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001764 class Meta:
1765 model = NetworkParameterType
Scott Baker96eb3fd2014-11-25 00:53:25 -08001766 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001767
1768class NetworkParameterTypeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001769 id = serializers.Field()
1770
Scott Bakerb744f1c2014-11-21 11:32:24 -08001771 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001772 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001773 def getHumanReadableName(self, obj):
1774 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001775 def getValidators(self, obj):
1776 try:
1777 return obj.getValidators()
1778 except:
1779 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001780 class Meta:
1781 model = NetworkParameterType
Scott Baker96eb3fd2014-11-25 00:53:25 -08001782 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001783
1784
Sapan Bhatiadea39432014-06-13 03:10:36 -04001785
1786
Scott Baker89a7b7c2014-10-07 00:10:17 -07001787class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001788 id = serializers.Field()
1789
Scott Bakerb744f1c2014-11-21 11:32:24 -08001790 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001791 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001792 def getHumanReadableName(self, obj):
1793 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001794 def getValidators(self, obj):
1795 try:
1796 return obj.getValidators()
1797 except:
1798 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001799 class Meta:
1800 model = SiteCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001801 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001802
Scott Baker89a7b7c2014-10-07 00:10:17 -07001803class SiteCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001804 id = serializers.Field()
1805
Scott Bakerb744f1c2014-11-21 11:32:24 -08001806 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001807 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001808 def getHumanReadableName(self, obj):
1809 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001810 def getValidators(self, obj):
1811 try:
1812 return obj.getValidators()
1813 except:
1814 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001815 class Meta:
1816 model = SiteCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001817 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001818
1819
Scott Baker0caeaf02014-06-19 11:12:55 -07001820
1821
Tony Mack06c8e472014-11-30 15:53:08 -05001822class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001823 id = serializers.Field()
1824
Scott Bakerb744f1c2014-11-21 11:32:24 -08001825 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001826 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001827 def getHumanReadableName(self, obj):
1828 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001829 def getValidators(self, obj):
1830 try:
1831 return obj.getValidators()
1832 except:
1833 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001834 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001835 model = ControllerPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001836 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001837
Tony Mack06c8e472014-11-30 15:53:08 -05001838class ControllerPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001839 id = serializers.Field()
1840
Scott Bakerb744f1c2014-11-21 11:32:24 -08001841 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001842 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001843 def getHumanReadableName(self, obj):
1844 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001845 def getValidators(self, obj):
1846 try:
1847 return obj.getValidators()
1848 except:
1849 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001850 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001851 model = ControllerPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001852 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker8b533192014-11-17 22:32:19 -08001853
1854
1855
1856
Tony Mack06c8e472014-11-30 15:53:08 -05001857class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001858 id = serializers.Field()
1859
Scott Bakerb744f1c2014-11-21 11:32:24 -08001860 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001861 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001862 def getHumanReadableName(self, obj):
1863 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001864 def getValidators(self, obj):
1865 try:
1866 return obj.getValidators()
1867 except:
1868 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001869 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001870 model = ControllerRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001871 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001872
Tony Mack06c8e472014-11-30 15:53:08 -05001873class ControllerRoleIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001874 id = serializers.Field()
1875
Scott Bakerb744f1c2014-11-21 11:32:24 -08001876 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001877 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001878 def getHumanReadableName(self, obj):
1879 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001880 def getValidators(self, obj):
1881 try:
1882 return obj.getValidators()
1883 except:
1884 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001885 class Meta:
Tony Mack06c8e472014-11-30 15:53:08 -05001886 model = ControllerRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001887 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001888
1889
Sapan Bhatiadea39432014-06-13 03:10:36 -04001890
1891
Scott Baker89a7b7c2014-10-07 00:10:17 -07001892class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001893 id = serializers.Field()
1894
Scott Bakerb744f1c2014-11-21 11:32:24 -08001895 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001896 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001897 def getHumanReadableName(self, obj):
1898 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001899 def getValidators(self, obj):
1900 try:
1901 return obj.getValidators()
1902 except:
1903 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001904 class Meta:
1905 model = UserCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001906 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001907
Scott Baker89a7b7c2014-10-07 00:10:17 -07001908class UserCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001909 id = serializers.Field()
1910
Scott Bakerb744f1c2014-11-21 11:32:24 -08001911 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001912 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001913 def getHumanReadableName(self, obj):
1914 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001915 def getValidators(self, obj):
1916 try:
1917 return obj.getValidators()
1918 except:
1919 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001920 class Meta:
1921 model = UserCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001922 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001923
1924
1925
1926
1927class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
1928 id = serializers.Field()
1929
1930 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001931 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001932 def getHumanReadableName(self, obj):
1933 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001934 def getValidators(self, obj):
1935 try:
1936 return obj.getValidators()
1937 except:
1938 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001939 class Meta:
1940 model = SiteDeployments
Scott Baker96eb3fd2014-11-25 00:53:25 -08001941 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001942
1943class SiteDeploymentsIdSerializer(serializers.ModelSerializer):
1944 id = serializers.Field()
1945
1946 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001947 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001948 def getHumanReadableName(self, obj):
1949 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001950 def getValidators(self, obj):
1951 try:
1952 return obj.getValidators()
1953 except:
1954 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001955 class Meta:
1956 model = SiteDeployments
Tony Mack06c8e472014-11-30 15:53:08 -05001957 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment')
Scott Baker89a7b7c2014-10-07 00:10:17 -07001958
1959
Scott Baker0caeaf02014-06-19 11:12:55 -07001960class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001961 id = serializers.Field()
1962
Scott Bakerb744f1c2014-11-21 11:32:24 -08001963 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001964 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001965 def getHumanReadableName(self, obj):
1966 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001967 def getValidators(self, obj):
1968 try:
1969 return obj.getValidators()
1970 except:
1971 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001972 class Meta:
1973 model = SliceTag
Scott Baker96eb3fd2014-11-25 00:53:25 -08001974 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07001975
1976class SliceTagIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001977 id = serializers.Field()
1978
Scott Bakerb744f1c2014-11-21 11:32:24 -08001979 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001980 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001981 def getHumanReadableName(self, obj):
1982 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001983 def getValidators(self, obj):
1984 try:
1985 return obj.getValidators()
1986 except:
1987 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001988 class Meta:
1989 model = SliceTag
Scott Baker96eb3fd2014-11-25 00:53:25 -08001990 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07001991
1992
Scott Baker0caeaf02014-06-19 11:12:55 -07001993
1994
1995class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001996 id = serializers.Field()
1997
Scott Bakerb744f1c2014-11-21 11:32:24 -08001998 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001999 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002000 def getHumanReadableName(self, obj):
2001 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002002 def getValidators(self, obj):
2003 try:
2004 return obj.getValidators()
2005 except:
2006 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002007 class Meta:
2008 model = NetworkTemplate
Scott Baker96eb3fd2014-11-25 00:53:25 -08002009 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07002010
2011class NetworkTemplateIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002012 id = serializers.Field()
2013
Scott Bakerb744f1c2014-11-21 11:32:24 -08002014 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002015 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002016 def getHumanReadableName(self, obj):
2017 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002018 def getValidators(self, obj):
2019 try:
2020 return obj.getValidators()
2021 except:
2022 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002023 class Meta:
2024 model = NetworkTemplate
Scott Baker96eb3fd2014-11-25 00:53:25 -08002025 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07002026
2027
Sapan Bhatiadea39432014-06-13 03:10:36 -04002028
2029
2030class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002031 id = serializers.Field()
2032
Scott Bakerb744f1c2014-11-21 11:32:24 -08002033 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002034 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002035 def getHumanReadableName(self, obj):
2036 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002037 def getValidators(self, obj):
2038 try:
2039 return obj.getValidators()
2040 except:
2041 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002042 class Meta:
2043 model = Router
Scott Baker96eb3fd2014-11-25 00:53:25 -08002044 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07002045
2046class RouterIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002047 id = serializers.Field()
2048
Scott Bakerb744f1c2014-11-21 11:32:24 -08002049 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002050 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002051 def getHumanReadableName(self, obj):
2052 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002053 def getValidators(self, obj):
2054 try:
2055 return obj.getValidators()
2056 except:
2057 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002058 class Meta:
2059 model = Router
Scott Baker96eb3fd2014-11-25 00:53:25 -08002060 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07002061
2062
Sapan Bhatiadea39432014-06-13 03:10:36 -04002063
2064
Scott Baker0caeaf02014-06-19 11:12:55 -07002065class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002066 id = serializers.Field()
2067
Scott Bakerb744f1c2014-11-21 11:32:24 -08002068 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002069 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002070 def getHumanReadableName(self, obj):
2071 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002072 def getValidators(self, obj):
2073 try:
2074 return obj.getValidators()
2075 except:
2076 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002077 class Meta:
2078 model = ServiceResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08002079 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002080
2081class ServiceResourceIdSerializer(serializers.ModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002082 id = serializers.Field()
2083
Scott Bakerb744f1c2014-11-21 11:32:24 -08002084 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002085 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002086 def getHumanReadableName(self, obj):
2087 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002088 def getValidators(self, obj):
2089 try:
2090 return obj.getValidators()
2091 except:
2092 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002093 class Meta:
2094 model = ServiceResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08002095 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002096
2097
Sapan Bhatiadea39432014-06-13 03:10:36 -04002098
2099
2100serializerLookUp = {
2101
Scott Baker0caeaf02014-06-19 11:12:55 -07002102 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002103
2104 Image: ImageSerializer,
2105
Scott Baker0caeaf02014-06-19 11:12:55 -07002106 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002107
2108 Site: SiteSerializer,
2109
Scott Baker0caeaf02014-06-19 11:12:55 -07002110 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002111
2112 Tag: TagSerializer,
2113
2114 Invoice: InvoiceSerializer,
2115
Scott Baker0caeaf02014-06-19 11:12:55 -07002116 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002117
Scott Baker89a7b7c2014-10-07 00:10:17 -07002118 PlanetStackRole: PlanetStackRoleSerializer,
2119
Scott Baker0caeaf02014-06-19 11:12:55 -07002120 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002121
Tony Mack06c8e472014-11-30 15:53:08 -05002122 ControllerNetworks: ControllerNetworksSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002123
Scott Baker89a7b7c2014-10-07 00:10:17 -07002124 Flavor: FlavorSerializer,
2125
2126 Project: ProjectSerializer,
2127
Sapan Bhatiadea39432014-06-13 03:10:36 -04002128 Slice: SliceSerializer,
2129
2130 Network: NetworkSerializer,
2131
2132 Service: ServiceSerializer,
2133
Scott Baker0caeaf02014-06-19 11:12:55 -07002134 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002135
Scott Bakerb744f1c2014-11-21 11:32:24 -08002136 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002137
2138 Charge: ChargeSerializer,
2139
2140 Role: RoleSerializer,
2141
Scott Baker0caeaf02014-06-19 11:12:55 -07002142 UsableObject: UsableObjectSerializer,
2143
2144 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002145
Scott Baker89a7b7c2014-10-07 00:10:17 -07002146 SliceCredential: SliceCredentialSerializer,
2147
Sapan Bhatiadea39432014-06-13 03:10:36 -04002148 Sliver: SliverSerializer,
2149
2150 Node: NodeSerializer,
2151
Scott Baker0caeaf02014-06-19 11:12:55 -07002152 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002153
Tony Mack06c8e472014-11-30 15:53:08 -05002154 ControllerImages: ControllerImagesSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002155
Scott Bakerb744f1c2014-11-21 11:32:24 -08002156 ReservedResource: ReservedResourceSerializer,
Scott Baker8b533192014-11-17 22:32:19 -08002157
Scott Baker0caeaf02014-06-19 11:12:55 -07002158 NetworkSlice: NetworkSliceSerializer,
2159
2160 UserDashboardView: UserDashboardViewSerializer,
2161
2162 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002163
2164 User: UserSerializer,
2165
2166 Deployment: DeploymentSerializer,
2167
2168 Reservation: ReservationSerializer,
2169
Tony Mack06c8e472014-11-30 15:53:08 -05002170 ControllerSlices: ControllerSlicesSerializer,
Scott Bakerb744f1c2014-11-21 11:32:24 -08002171
Scott Baker0caeaf02014-06-19 11:12:55 -07002172 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002173
Scott Bakerb744f1c2014-11-21 11:32:24 -08002174 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002175
Tony Mack06c8e472014-11-30 15:53:08 -05002176 ControllerUsers: ControllerUsersSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002177
2178 Account: AccountSerializer,
2179
Scott Baker0caeaf02014-06-19 11:12:55 -07002180 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002181
Scott Baker89a7b7c2014-10-07 00:10:17 -07002182 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002183
Tony Mack06c8e472014-11-30 15:53:08 -05002184 ControllerPrivilege: ControllerPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002185
Tony Mack06c8e472014-11-30 15:53:08 -05002186 ControllerRole: ControllerRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002187
Scott Baker89a7b7c2014-10-07 00:10:17 -07002188 UserCredential: UserCredentialSerializer,
2189
Scott Bakerb744f1c2014-11-21 11:32:24 -08002190 SiteDeployments: SiteDeploymentsSerializer,
2191
Scott Baker0caeaf02014-06-19 11:12:55 -07002192 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002193
Scott Baker0caeaf02014-06-19 11:12:55 -07002194 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002195
2196 Router: RouterSerializer,
2197
Scott Baker0caeaf02014-06-19 11:12:55 -07002198 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002199
2200 None: None,
2201 }
2202
Scott Baker89a7b7c2014-10-07 00:10:17 -07002203class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2204
2205 # To handle fine-grained field permissions, we have to check can_update
2206 # the object has been updated but before it has been saved.
2207
2208 def update(self, request, *args, **kwargs):
2209 partial = kwargs.pop('partial', False)
2210 self.object = self.get_object_or_none()
2211
2212 serializer = self.get_serializer(self.object, data=request.DATA,
2213 files=request.FILES, partial=partial)
2214
2215 if not serializer.is_valid():
Scott Baker96eb3fd2014-11-25 00:53:25 -08002216 response = {"error": "validation",
2217 "specific_error": "not serializer.is_valid()",
2218 "reasons": serializer.errors}
2219 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002220
2221 try:
2222 self.pre_save(serializer.object)
2223 except ValidationError as err:
2224 # full_clean on model instance may be called in pre_save,
2225 # so we have to handle eventual errors.
Scott Baker96eb3fd2014-11-25 00:53:25 -08002226 response = {"error": "validation",
2227 "specific_error": "ValidationError in pre_save",
2228 "reasons": err.message_dict}
2229 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002230
2231 if serializer.object is not None:
2232 if not serializer.object.can_update(request.user):
2233 return Response(status=status.HTTP_400_BAD_REQUEST)
2234
2235 if self.object is None:
2236 self.object = serializer.save(force_insert=True)
2237 self.post_save(self.object, created=True)
2238 return Response(serializer.data, status=status.HTTP_201_CREATED)
2239
2240 self.object = serializer.save(force_update=True)
2241 self.post_save(self.object, created=False)
2242 return Response(serializer.data, status=status.HTTP_200_OK)
2243
2244 def destroy(self, request, *args, **kwargs):
2245 obj = self.get_object()
2246 if obj.can_update(request.user):
Scott Baker2bcbf372014-10-29 23:41:11 -07002247 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002248 else:
2249 return Response(status=status.HTTP_400_BAD_REQUEST)
2250
2251
Sapan Bhatiadea39432014-06-13 03:10:36 -04002252# Based on core/views/*.py
2253
2254
Scott Baker0caeaf02014-06-19 11:12:55 -07002255class ServiceAttributeList(generics.ListCreateAPIView):
2256 queryset = ServiceAttribute.objects.select_related().all()
2257 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002258 id_serializer_class = ServiceAttributeIdSerializer
2259 filter_backends = (filters.DjangoFilterBackend,)
2260 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2261
2262 def get_serializer_class(self):
2263 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2264 if (no_hyperlinks):
2265 return self.id_serializer_class
2266 else:
2267 return self.serializer_class
2268
Scott Baker0caeaf02014-06-19 11:12:55 -07002269 def get_queryset(self):
2270 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002271
Scott Baker0caeaf02014-06-19 11:12:55 -07002272 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002273 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2274 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002275 response = {"error": "validation",
2276 "specific_error": "not serializer.is_valid()",
2277 "reasons": serializer.errors}
2278 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002279 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002280 obj.caller = request.user
2281 if obj.can_update(request.user):
2282 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2283 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002284 raise Exception("failed obj.can_update")
2285
2286 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2287 if (ret.status_code%100 != 200):
2288 raise Exception(ret.data)
2289
2290 return ret
2291
Scott Baker0caeaf02014-06-19 11:12:55 -07002292
Scott Baker89a7b7c2014-10-07 00:10:17 -07002293class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002294 queryset = ServiceAttribute.objects.select_related().all()
2295 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002296 id_serializer_class = ServiceAttributeIdSerializer
2297
2298 def get_serializer_class(self):
2299 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2300 if (no_hyperlinks):
2301 return self.id_serializer_class
2302 else:
2303 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002304
2305 def get_queryset(self):
2306 return ServiceAttribute.select_by_user(self.request.user)
2307
Scott Baker89a7b7c2014-10-07 00:10:17 -07002308 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002309
Scott Baker89a7b7c2014-10-07 00:10:17 -07002310 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002311
2312
2313
2314class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002315 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002316 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002317 id_serializer_class = ImageIdSerializer
2318 filter_backends = (filters.DjangoFilterBackend,)
2319 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
2320
2321 def get_serializer_class(self):
2322 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2323 if (no_hyperlinks):
2324 return self.id_serializer_class
2325 else:
2326 return self.serializer_class
2327
Scott Baker0caeaf02014-06-19 11:12:55 -07002328 def get_queryset(self):
2329 return Image.select_by_user(self.request.user)
2330
2331 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002332 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2333 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002334 response = {"error": "validation",
2335 "specific_error": "not serializer.is_valid()",
2336 "reasons": serializer.errors}
2337 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002338 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002339 obj.caller = request.user
2340 if obj.can_update(request.user):
2341 return super(ImageList, self).create(request, *args, **kwargs)
2342 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002343 raise Exception("failed obj.can_update")
2344
2345 ret = super(ImageList, self).create(request, *args, **kwargs)
2346 if (ret.status_code%100 != 200):
2347 raise Exception(ret.data)
2348
2349 return ret
2350
Sapan Bhatiadea39432014-06-13 03:10:36 -04002351
Scott Baker89a7b7c2014-10-07 00:10:17 -07002352class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002353 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002354 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002355 id_serializer_class = ImageIdSerializer
2356
2357 def get_serializer_class(self):
2358 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2359 if (no_hyperlinks):
2360 return self.id_serializer_class
2361 else:
2362 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002363
2364 def get_queryset(self):
2365 return Image.select_by_user(self.request.user)
2366
Scott Baker89a7b7c2014-10-07 00:10:17 -07002367 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002368
Scott Baker89a7b7c2014-10-07 00:10:17 -07002369 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002370
2371
2372
Scott Baker0caeaf02014-06-19 11:12:55 -07002373class NetworkParameterList(generics.ListCreateAPIView):
2374 queryset = NetworkParameter.objects.select_related().all()
2375 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002376 id_serializer_class = NetworkParameterIdSerializer
2377 filter_backends = (filters.DjangoFilterBackend,)
2378 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2379
2380 def get_serializer_class(self):
2381 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2382 if (no_hyperlinks):
2383 return self.id_serializer_class
2384 else:
2385 return self.serializer_class
2386
Scott Baker0caeaf02014-06-19 11:12:55 -07002387 def get_queryset(self):
2388 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002389
Scott Baker0caeaf02014-06-19 11:12:55 -07002390 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002391 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2392 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002393 response = {"error": "validation",
2394 "specific_error": "not serializer.is_valid()",
2395 "reasons": serializer.errors}
2396 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002397 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002398 obj.caller = request.user
2399 if obj.can_update(request.user):
2400 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2401 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002402 raise Exception("failed obj.can_update")
2403
2404 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2405 if (ret.status_code%100 != 200):
2406 raise Exception(ret.data)
2407
2408 return ret
2409
Scott Baker0caeaf02014-06-19 11:12:55 -07002410
Scott Baker89a7b7c2014-10-07 00:10:17 -07002411class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002412 queryset = NetworkParameter.objects.select_related().all()
2413 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002414 id_serializer_class = NetworkParameterIdSerializer
2415
2416 def get_serializer_class(self):
2417 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2418 if (no_hyperlinks):
2419 return self.id_serializer_class
2420 else:
2421 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002422
2423 def get_queryset(self):
2424 return NetworkParameter.select_by_user(self.request.user)
2425
Scott Baker89a7b7c2014-10-07 00:10:17 -07002426 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002427
Scott Baker89a7b7c2014-10-07 00:10:17 -07002428 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002429
2430
2431
2432class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002433 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002434 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002435 id_serializer_class = SiteIdSerializer
2436 filter_backends = (filters.DjangoFilterBackend,)
2437 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
2438
2439 def get_serializer_class(self):
2440 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2441 if (no_hyperlinks):
2442 return self.id_serializer_class
2443 else:
2444 return self.serializer_class
2445
Scott Baker0caeaf02014-06-19 11:12:55 -07002446 def get_queryset(self):
2447 return Site.select_by_user(self.request.user)
2448
2449 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002450 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2451 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002452 response = {"error": "validation",
2453 "specific_error": "not serializer.is_valid()",
2454 "reasons": serializer.errors}
2455 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002456 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002457 obj.caller = request.user
2458 if obj.can_update(request.user):
2459 return super(SiteList, self).create(request, *args, **kwargs)
2460 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002461 raise Exception("failed obj.can_update")
2462
2463 ret = super(SiteList, self).create(request, *args, **kwargs)
2464 if (ret.status_code%100 != 200):
2465 raise Exception(ret.data)
2466
2467 return ret
2468
Sapan Bhatiadea39432014-06-13 03:10:36 -04002469
Scott Baker89a7b7c2014-10-07 00:10:17 -07002470class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002471 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002472 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002473 id_serializer_class = SiteIdSerializer
2474
2475 def get_serializer_class(self):
2476 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2477 if (no_hyperlinks):
2478 return self.id_serializer_class
2479 else:
2480 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002481
2482 def get_queryset(self):
2483 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002484
Scott Baker89a7b7c2014-10-07 00:10:17 -07002485 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002486
Scott Baker89a7b7c2014-10-07 00:10:17 -07002487 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002488
2489
2490
2491class SliceRoleList(generics.ListCreateAPIView):
2492 queryset = SliceRole.objects.select_related().all()
2493 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002494 id_serializer_class = SliceRoleIdSerializer
2495 filter_backends = (filters.DjangoFilterBackend,)
2496 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2497
2498 def get_serializer_class(self):
2499 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2500 if (no_hyperlinks):
2501 return self.id_serializer_class
2502 else:
2503 return self.serializer_class
2504
Scott Baker0caeaf02014-06-19 11:12:55 -07002505 def get_queryset(self):
2506 return SliceRole.select_by_user(self.request.user)
2507
2508 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002509 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2510 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002511 response = {"error": "validation",
2512 "specific_error": "not serializer.is_valid()",
2513 "reasons": serializer.errors}
2514 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002515 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002516 obj.caller = request.user
2517 if obj.can_update(request.user):
2518 return super(SliceRoleList, self).create(request, *args, **kwargs)
2519 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002520 raise Exception("failed obj.can_update")
2521
2522 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2523 if (ret.status_code%100 != 200):
2524 raise Exception(ret.data)
2525
2526 return ret
2527
Scott Baker0caeaf02014-06-19 11:12:55 -07002528
Scott Baker89a7b7c2014-10-07 00:10:17 -07002529class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002530 queryset = SliceRole.objects.select_related().all()
2531 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002532 id_serializer_class = SliceRoleIdSerializer
2533
2534 def get_serializer_class(self):
2535 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2536 if (no_hyperlinks):
2537 return self.id_serializer_class
2538 else:
2539 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002540
2541 def get_queryset(self):
2542 return SliceRole.select_by_user(self.request.user)
2543
Scott Baker89a7b7c2014-10-07 00:10:17 -07002544 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002545
Scott Baker89a7b7c2014-10-07 00:10:17 -07002546 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002547
2548
2549
2550class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002551 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002552 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002553 id_serializer_class = TagIdSerializer
2554 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002555 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002556
2557 def get_serializer_class(self):
2558 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2559 if (no_hyperlinks):
2560 return self.id_serializer_class
2561 else:
2562 return self.serializer_class
2563
Scott Baker0caeaf02014-06-19 11:12:55 -07002564 def get_queryset(self):
2565 return Tag.select_by_user(self.request.user)
2566
2567 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002568 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2569 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002570 response = {"error": "validation",
2571 "specific_error": "not serializer.is_valid()",
2572 "reasons": serializer.errors}
2573 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002574 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002575 obj.caller = request.user
2576 if obj.can_update(request.user):
2577 return super(TagList, self).create(request, *args, **kwargs)
2578 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002579 raise Exception("failed obj.can_update")
2580
2581 ret = super(TagList, self).create(request, *args, **kwargs)
2582 if (ret.status_code%100 != 200):
2583 raise Exception(ret.data)
2584
2585 return ret
2586
Sapan Bhatiadea39432014-06-13 03:10:36 -04002587
Scott Baker89a7b7c2014-10-07 00:10:17 -07002588class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002589 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002590 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002591 id_serializer_class = TagIdSerializer
2592
2593 def get_serializer_class(self):
2594 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2595 if (no_hyperlinks):
2596 return self.id_serializer_class
2597 else:
2598 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002599
2600 def get_queryset(self):
2601 return Tag.select_by_user(self.request.user)
2602
Scott Baker89a7b7c2014-10-07 00:10:17 -07002603 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002604
Scott Baker89a7b7c2014-10-07 00:10:17 -07002605 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002606
2607
2608
2609class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002610 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002611 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002612 id_serializer_class = InvoiceIdSerializer
2613 filter_backends = (filters.DjangoFilterBackend,)
2614 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
2615
2616 def get_serializer_class(self):
2617 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2618 if (no_hyperlinks):
2619 return self.id_serializer_class
2620 else:
2621 return self.serializer_class
2622
Scott Baker0caeaf02014-06-19 11:12:55 -07002623 def get_queryset(self):
2624 return Invoice.select_by_user(self.request.user)
2625
2626 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002627 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2628 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002629 response = {"error": "validation",
2630 "specific_error": "not serializer.is_valid()",
2631 "reasons": serializer.errors}
2632 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002633 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002634 obj.caller = request.user
2635 if obj.can_update(request.user):
2636 return super(InvoiceList, self).create(request, *args, **kwargs)
2637 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002638 raise Exception("failed obj.can_update")
2639
2640 ret = super(InvoiceList, self).create(request, *args, **kwargs)
2641 if (ret.status_code%100 != 200):
2642 raise Exception(ret.data)
2643
2644 return ret
2645
Sapan Bhatiadea39432014-06-13 03:10:36 -04002646
Scott Baker89a7b7c2014-10-07 00:10:17 -07002647class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002648 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002649 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002650 id_serializer_class = InvoiceIdSerializer
2651
2652 def get_serializer_class(self):
2653 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2654 if (no_hyperlinks):
2655 return self.id_serializer_class
2656 else:
2657 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002658
2659 def get_queryset(self):
2660 return Invoice.select_by_user(self.request.user)
2661
Scott Baker89a7b7c2014-10-07 00:10:17 -07002662 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002663
Scott Baker89a7b7c2014-10-07 00:10:17 -07002664 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002665
2666
2667
Scott Baker0caeaf02014-06-19 11:12:55 -07002668class SlicePrivilegeList(generics.ListCreateAPIView):
2669 queryset = SlicePrivilege.objects.select_related().all()
2670 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002671 id_serializer_class = SlicePrivilegeIdSerializer
2672 filter_backends = (filters.DjangoFilterBackend,)
2673 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
2674
2675 def get_serializer_class(self):
2676 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2677 if (no_hyperlinks):
2678 return self.id_serializer_class
2679 else:
2680 return self.serializer_class
2681
Scott Baker0caeaf02014-06-19 11:12:55 -07002682 def get_queryset(self):
2683 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002684
Scott Baker0caeaf02014-06-19 11:12:55 -07002685 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002686 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2687 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002688 response = {"error": "validation",
2689 "specific_error": "not serializer.is_valid()",
2690 "reasons": serializer.errors}
2691 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002692 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002693 obj.caller = request.user
2694 if obj.can_update(request.user):
2695 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
2696 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002697 raise Exception("failed obj.can_update")
2698
2699 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
2700 if (ret.status_code%100 != 200):
2701 raise Exception(ret.data)
2702
2703 return ret
2704
Scott Baker0caeaf02014-06-19 11:12:55 -07002705
Scott Baker89a7b7c2014-10-07 00:10:17 -07002706class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002707 queryset = SlicePrivilege.objects.select_related().all()
2708 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002709 id_serializer_class = SlicePrivilegeIdSerializer
2710
2711 def get_serializer_class(self):
2712 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2713 if (no_hyperlinks):
2714 return self.id_serializer_class
2715 else:
2716 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002717
2718 def get_queryset(self):
2719 return SlicePrivilege.select_by_user(self.request.user)
2720
Scott Baker89a7b7c2014-10-07 00:10:17 -07002721 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2722
2723 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2724
2725
2726
2727class PlanetStackRoleList(generics.ListCreateAPIView):
2728 queryset = PlanetStackRole.objects.select_related().all()
2729 serializer_class = PlanetStackRoleSerializer
2730 id_serializer_class = PlanetStackRoleIdSerializer
2731 filter_backends = (filters.DjangoFilterBackend,)
2732 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2733
2734 def get_serializer_class(self):
2735 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2736 if (no_hyperlinks):
2737 return self.id_serializer_class
2738 else:
2739 return self.serializer_class
2740
2741 def get_queryset(self):
2742 return PlanetStackRole.select_by_user(self.request.user)
2743
2744 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002745 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2746 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002747 response = {"error": "validation",
2748 "specific_error": "not serializer.is_valid()",
2749 "reasons": serializer.errors}
2750 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002751 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07002752 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07002753 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07002754 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002755 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002756 raise Exception("failed obj.can_update")
2757
2758 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
2759 if (ret.status_code%100 != 200):
2760 raise Exception(ret.data)
2761
2762 return ret
2763
Scott Baker0caeaf02014-06-19 11:12:55 -07002764
Scott Baker89a7b7c2014-10-07 00:10:17 -07002765class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2766 queryset = PlanetStackRole.objects.select_related().all()
2767 serializer_class = PlanetStackRoleSerializer
2768 id_serializer_class = PlanetStackRoleIdSerializer
2769
2770 def get_serializer_class(self):
2771 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2772 if (no_hyperlinks):
2773 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002774 else:
Scott Baker89a7b7c2014-10-07 00:10:17 -07002775 return self.serializer_class
2776
2777 def get_queryset(self):
2778 return PlanetStackRole.select_by_user(self.request.user)
2779
2780 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2781
2782 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002783
2784
2785
Scott Baker0caeaf02014-06-19 11:12:55 -07002786class NetworkSliverList(generics.ListCreateAPIView):
2787 queryset = NetworkSliver.objects.select_related().all()
2788 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002789 id_serializer_class = NetworkSliverIdSerializer
2790 filter_backends = (filters.DjangoFilterBackend,)
2791 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
2792
2793 def get_serializer_class(self):
2794 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2795 if (no_hyperlinks):
2796 return self.id_serializer_class
2797 else:
2798 return self.serializer_class
2799
Scott Baker0caeaf02014-06-19 11:12:55 -07002800 def get_queryset(self):
2801 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002802
Scott Baker0caeaf02014-06-19 11:12:55 -07002803 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002804 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2805 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002806 response = {"error": "validation",
2807 "specific_error": "not serializer.is_valid()",
2808 "reasons": serializer.errors}
2809 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002810 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002811 obj.caller = request.user
2812 if obj.can_update(request.user):
2813 return super(NetworkSliverList, self).create(request, *args, **kwargs)
2814 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002815 raise Exception("failed obj.can_update")
2816
2817 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
2818 if (ret.status_code%100 != 200):
2819 raise Exception(ret.data)
2820
2821 return ret
2822
Scott Baker0caeaf02014-06-19 11:12:55 -07002823
Scott Baker89a7b7c2014-10-07 00:10:17 -07002824class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002825 queryset = NetworkSliver.objects.select_related().all()
2826 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002827 id_serializer_class = NetworkSliverIdSerializer
2828
2829 def get_serializer_class(self):
2830 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2831 if (no_hyperlinks):
2832 return self.id_serializer_class
2833 else:
2834 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002835
2836 def get_queryset(self):
2837 return NetworkSliver.select_by_user(self.request.user)
2838
Scott Baker89a7b7c2014-10-07 00:10:17 -07002839 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002840
Scott Baker89a7b7c2014-10-07 00:10:17 -07002841 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002842
2843
2844
Tony Mack06c8e472014-11-30 15:53:08 -05002845class ControllerNetworksList(generics.ListCreateAPIView):
2846 queryset = ControllerNetworks.objects.select_related().all()
2847 serializer_class = ControllerNetworksSerializer
2848 id_serializer_class = ControllerNetworksIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002849 filter_backends = (filters.DjangoFilterBackend,)
2850 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
2851
2852 def get_serializer_class(self):
2853 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2854 if (no_hyperlinks):
2855 return self.id_serializer_class
2856 else:
2857 return self.serializer_class
2858
Scott Baker0caeaf02014-06-19 11:12:55 -07002859 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05002860 return ControllerNetworks.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002861
Scott Baker0caeaf02014-06-19 11:12:55 -07002862 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002863 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2864 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002865 response = {"error": "validation",
2866 "specific_error": "not serializer.is_valid()",
2867 "reasons": serializer.errors}
2868 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002869 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002870 obj.caller = request.user
2871 if obj.can_update(request.user):
Tony Mack06c8e472014-11-30 15:53:08 -05002872 return super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002873 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002874 raise Exception("failed obj.can_update")
2875
Tony Mack06c8e472014-11-30 15:53:08 -05002876 ret = super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07002877 if (ret.status_code%100 != 200):
2878 raise Exception(ret.data)
2879
2880 return ret
2881
Scott Baker0caeaf02014-06-19 11:12:55 -07002882
Tony Mack06c8e472014-11-30 15:53:08 -05002883class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2884 queryset = ControllerNetworks.objects.select_related().all()
2885 serializer_class = ControllerNetworksSerializer
2886 id_serializer_class = ControllerNetworksIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002887
2888 def get_serializer_class(self):
2889 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2890 if (no_hyperlinks):
2891 return self.id_serializer_class
2892 else:
2893 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002894
2895 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05002896 return ControllerNetworks.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002897
Scott Baker89a7b7c2014-10-07 00:10:17 -07002898 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002899
Scott Baker89a7b7c2014-10-07 00:10:17 -07002900 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002901
2902
2903
Scott Baker89a7b7c2014-10-07 00:10:17 -07002904class FlavorList(generics.ListCreateAPIView):
2905 queryset = Flavor.objects.select_related().all()
2906 serializer_class = FlavorSerializer
2907 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002908 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002909 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker46b58542014-08-11 17:26:12 -07002910
2911 def get_serializer_class(self):
2912 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2913 if (no_hyperlinks):
2914 return self.id_serializer_class
2915 else:
2916 return self.serializer_class
2917
Scott Baker0caeaf02014-06-19 11:12:55 -07002918 def get_queryset(self):
Scott Baker89a7b7c2014-10-07 00:10:17 -07002919 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002920
2921 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002922 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2923 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002924 response = {"error": "validation",
2925 "specific_error": "not serializer.is_valid()",
2926 "reasons": serializer.errors}
2927 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002928 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002929 obj.caller = request.user
2930 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07002931 return super(FlavorList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002932 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002933 raise Exception("failed obj.can_update")
2934
2935 ret = super(FlavorList, self).create(request, *args, **kwargs)
2936 if (ret.status_code%100 != 200):
2937 raise Exception(ret.data)
2938
2939 return ret
2940
Sapan Bhatiadea39432014-06-13 03:10:36 -04002941
Scott Baker89a7b7c2014-10-07 00:10:17 -07002942class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2943 queryset = Flavor.objects.select_related().all()
2944 serializer_class = FlavorSerializer
2945 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002946
2947 def get_serializer_class(self):
2948 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2949 if (no_hyperlinks):
2950 return self.id_serializer_class
2951 else:
2952 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002953
2954 def get_queryset(self):
Scott Baker89a7b7c2014-10-07 00:10:17 -07002955 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002956
Scott Baker89a7b7c2014-10-07 00:10:17 -07002957 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002958
Scott Baker89a7b7c2014-10-07 00:10:17 -07002959 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002960
2961
2962
Scott Baker0caeaf02014-06-19 11:12:55 -07002963class ProjectList(generics.ListCreateAPIView):
2964 queryset = Project.objects.select_related().all()
2965 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002966 id_serializer_class = ProjectIdSerializer
2967 filter_backends = (filters.DjangoFilterBackend,)
2968 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
2969
2970 def get_serializer_class(self):
2971 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2972 if (no_hyperlinks):
2973 return self.id_serializer_class
2974 else:
2975 return self.serializer_class
2976
Scott Baker0caeaf02014-06-19 11:12:55 -07002977 def get_queryset(self):
2978 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002979
Scott Baker0caeaf02014-06-19 11:12:55 -07002980 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002981 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2982 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002983 response = {"error": "validation",
2984 "specific_error": "not serializer.is_valid()",
2985 "reasons": serializer.errors}
2986 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002987 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002988 obj.caller = request.user
2989 if obj.can_update(request.user):
2990 return super(ProjectList, self).create(request, *args, **kwargs)
2991 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002992 raise Exception("failed obj.can_update")
2993
2994 ret = super(ProjectList, self).create(request, *args, **kwargs)
2995 if (ret.status_code%100 != 200):
2996 raise Exception(ret.data)
2997
2998 return ret
2999
Scott Baker0caeaf02014-06-19 11:12:55 -07003000
Scott Baker89a7b7c2014-10-07 00:10:17 -07003001class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003002 queryset = Project.objects.select_related().all()
3003 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003004 id_serializer_class = ProjectIdSerializer
3005
3006 def get_serializer_class(self):
3007 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3008 if (no_hyperlinks):
3009 return self.id_serializer_class
3010 else:
3011 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003012
3013 def get_queryset(self):
3014 return Project.select_by_user(self.request.user)
3015
Scott Baker89a7b7c2014-10-07 00:10:17 -07003016 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3017
3018 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3019
3020
3021
3022class SliceList(generics.ListCreateAPIView):
3023 queryset = Slice.objects.select_related().all()
3024 serializer_class = SliceSerializer
3025 id_serializer_class = SliceIdSerializer
3026 filter_backends = (filters.DjangoFilterBackend,)
3027 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
3028
3029 def get_serializer_class(self):
3030 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3031 if (no_hyperlinks):
3032 return self.id_serializer_class
3033 else:
3034 return self.serializer_class
3035
3036 def get_queryset(self):
3037 return Slice.select_by_user(self.request.user)
3038
3039 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003040 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3041 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003042 response = {"error": "validation",
3043 "specific_error": "not serializer.is_valid()",
3044 "reasons": serializer.errors}
3045 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003046 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003047 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003048 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003049 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003050 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003051 raise Exception("failed obj.can_update")
3052
3053 ret = super(SliceList, self).create(request, *args, **kwargs)
3054 if (ret.status_code%100 != 200):
3055 raise Exception(ret.data)
3056
3057 return ret
3058
Scott Baker0caeaf02014-06-19 11:12:55 -07003059
Scott Baker89a7b7c2014-10-07 00:10:17 -07003060class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3061 queryset = Slice.objects.select_related().all()
3062 serializer_class = SliceSerializer
3063 id_serializer_class = SliceIdSerializer
3064
3065 def get_serializer_class(self):
3066 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3067 if (no_hyperlinks):
3068 return self.id_serializer_class
3069 else:
3070 return self.serializer_class
3071
3072 def get_queryset(self):
3073 return Slice.select_by_user(self.request.user)
3074
3075 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3076
3077 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3078
3079
3080
3081class NetworkList(generics.ListCreateAPIView):
3082 queryset = Network.objects.select_related().all()
3083 serializer_class = NetworkSerializer
3084 id_serializer_class = NetworkIdSerializer
3085 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker8b533192014-11-17 22:32:19 -08003086 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003087
3088 def get_serializer_class(self):
3089 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3090 if (no_hyperlinks):
3091 return self.id_serializer_class
3092 else:
3093 return self.serializer_class
3094
3095 def get_queryset(self):
3096 return Network.select_by_user(self.request.user)
3097
3098 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003099 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3100 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003101 response = {"error": "validation",
3102 "specific_error": "not serializer.is_valid()",
3103 "reasons": serializer.errors}
3104 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003105 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003106 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003107 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003108 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003109 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003110 raise Exception("failed obj.can_update")
3111
3112 ret = super(NetworkList, self).create(request, *args, **kwargs)
3113 if (ret.status_code%100 != 200):
3114 raise Exception(ret.data)
3115
3116 return ret
3117
Scott Baker89a7b7c2014-10-07 00:10:17 -07003118
3119class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3120 queryset = Network.objects.select_related().all()
3121 serializer_class = NetworkSerializer
3122 id_serializer_class = NetworkIdSerializer
3123
3124 def get_serializer_class(self):
3125 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3126 if (no_hyperlinks):
3127 return self.id_serializer_class
3128 else:
3129 return self.serializer_class
3130
3131 def get_queryset(self):
3132 return Network.select_by_user(self.request.user)
3133
3134 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3135
3136 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3137
3138
3139
3140class ServiceList(generics.ListCreateAPIView):
3141 queryset = Service.objects.select_related().all()
3142 serializer_class = ServiceSerializer
3143 id_serializer_class = ServiceIdSerializer
3144 filter_backends = (filters.DjangoFilterBackend,)
3145 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3146
3147 def get_serializer_class(self):
3148 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3149 if (no_hyperlinks):
3150 return self.id_serializer_class
3151 else:
3152 return self.serializer_class
3153
3154 def get_queryset(self):
3155 return Service.select_by_user(self.request.user)
3156
3157 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003158 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3159 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003160 response = {"error": "validation",
3161 "specific_error": "not serializer.is_valid()",
3162 "reasons": serializer.errors}
3163 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003164 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003165 obj.caller = request.user
3166 if obj.can_update(request.user):
3167 return super(ServiceList, self).create(request, *args, **kwargs)
3168 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003169 raise Exception("failed obj.can_update")
3170
3171 ret = super(ServiceList, self).create(request, *args, **kwargs)
3172 if (ret.status_code%100 != 200):
3173 raise Exception(ret.data)
3174
3175 return ret
3176
Scott Baker89a7b7c2014-10-07 00:10:17 -07003177
3178class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3179 queryset = Service.objects.select_related().all()
3180 serializer_class = ServiceSerializer
3181 id_serializer_class = ServiceIdSerializer
3182
3183 def get_serializer_class(self):
3184 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3185 if (no_hyperlinks):
3186 return self.id_serializer_class
3187 else:
3188 return self.serializer_class
3189
3190 def get_queryset(self):
3191 return Service.select_by_user(self.request.user)
3192
3193 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3194
3195 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3196
3197
3198
3199class ServiceClassList(generics.ListCreateAPIView):
3200 queryset = ServiceClass.objects.select_related().all()
3201 serializer_class = ServiceClassSerializer
3202 id_serializer_class = ServiceClassIdSerializer
3203 filter_backends = (filters.DjangoFilterBackend,)
3204 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3205
3206 def get_serializer_class(self):
3207 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3208 if (no_hyperlinks):
3209 return self.id_serializer_class
3210 else:
3211 return self.serializer_class
3212
3213 def get_queryset(self):
3214 return ServiceClass.select_by_user(self.request.user)
3215
3216 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003217 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3218 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003219 response = {"error": "validation",
3220 "specific_error": "not serializer.is_valid()",
3221 "reasons": serializer.errors}
3222 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003223 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003224 obj.caller = request.user
3225 if obj.can_update(request.user):
3226 return super(ServiceClassList, self).create(request, *args, **kwargs)
3227 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003228 raise Exception("failed obj.can_update")
3229
3230 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3231 if (ret.status_code%100 != 200):
3232 raise Exception(ret.data)
3233
3234 return ret
3235
Scott Baker89a7b7c2014-10-07 00:10:17 -07003236
3237class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3238 queryset = ServiceClass.objects.select_related().all()
3239 serializer_class = ServiceClassSerializer
3240 id_serializer_class = ServiceClassIdSerializer
3241
3242 def get_serializer_class(self):
3243 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3244 if (no_hyperlinks):
3245 return self.id_serializer_class
3246 else:
3247 return self.serializer_class
3248
3249 def get_queryset(self):
3250 return ServiceClass.select_by_user(self.request.user)
3251
3252 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3253
3254 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3255
3256
3257
Scott Bakerb744f1c2014-11-21 11:32:24 -08003258class PaymentList(generics.ListCreateAPIView):
3259 queryset = Payment.objects.select_related().all()
3260 serializer_class = PaymentSerializer
3261 id_serializer_class = PaymentIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003262 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerb744f1c2014-11-21 11:32:24 -08003263 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003264
3265 def get_serializer_class(self):
3266 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3267 if (no_hyperlinks):
3268 return self.id_serializer_class
3269 else:
3270 return self.serializer_class
3271
3272 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08003273 return Payment.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003274
3275 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003276 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3277 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003278 response = {"error": "validation",
3279 "specific_error": "not serializer.is_valid()",
3280 "reasons": serializer.errors}
3281 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003282 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003283 obj.caller = request.user
3284 if obj.can_update(request.user):
Scott Bakerb744f1c2014-11-21 11:32:24 -08003285 return super(PaymentList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003286 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003287 raise Exception("failed obj.can_update")
3288
Scott Bakerb744f1c2014-11-21 11:32:24 -08003289 ret = super(PaymentList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07003290 if (ret.status_code%100 != 200):
3291 raise Exception(ret.data)
3292
3293 return ret
3294
Scott Baker89a7b7c2014-10-07 00:10:17 -07003295
Scott Bakerb744f1c2014-11-21 11:32:24 -08003296class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3297 queryset = Payment.objects.select_related().all()
3298 serializer_class = PaymentSerializer
3299 id_serializer_class = PaymentIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003300
3301 def get_serializer_class(self):
3302 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3303 if (no_hyperlinks):
3304 return self.id_serializer_class
3305 else:
3306 return self.serializer_class
3307
3308 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08003309 return Payment.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003310
3311 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3312
3313 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3314
3315
3316
3317class ChargeList(generics.ListCreateAPIView):
3318 queryset = Charge.objects.select_related().all()
3319 serializer_class = ChargeSerializer
3320 id_serializer_class = ChargeIdSerializer
3321 filter_backends = (filters.DjangoFilterBackend,)
3322 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3323
3324 def get_serializer_class(self):
3325 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3326 if (no_hyperlinks):
3327 return self.id_serializer_class
3328 else:
3329 return self.serializer_class
3330
3331 def get_queryset(self):
3332 return Charge.select_by_user(self.request.user)
3333
3334 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003335 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3336 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003337 response = {"error": "validation",
3338 "specific_error": "not serializer.is_valid()",
3339 "reasons": serializer.errors}
3340 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003341 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003342 obj.caller = request.user
3343 if obj.can_update(request.user):
3344 return super(ChargeList, self).create(request, *args, **kwargs)
3345 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003346 raise Exception("failed obj.can_update")
3347
3348 ret = super(ChargeList, self).create(request, *args, **kwargs)
3349 if (ret.status_code%100 != 200):
3350 raise Exception(ret.data)
3351
3352 return ret
3353
Scott Baker89a7b7c2014-10-07 00:10:17 -07003354
3355class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3356 queryset = Charge.objects.select_related().all()
3357 serializer_class = ChargeSerializer
3358 id_serializer_class = ChargeIdSerializer
3359
3360 def get_serializer_class(self):
3361 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3362 if (no_hyperlinks):
3363 return self.id_serializer_class
3364 else:
3365 return self.serializer_class
3366
3367 def get_queryset(self):
3368 return Charge.select_by_user(self.request.user)
3369
3370 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3371
3372 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3373
3374
3375
3376class RoleList(generics.ListCreateAPIView):
3377 queryset = Role.objects.select_related().all()
3378 serializer_class = RoleSerializer
3379 id_serializer_class = RoleIdSerializer
3380 filter_backends = (filters.DjangoFilterBackend,)
3381 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3382
3383 def get_serializer_class(self):
3384 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3385 if (no_hyperlinks):
3386 return self.id_serializer_class
3387 else:
3388 return self.serializer_class
3389
3390 def get_queryset(self):
3391 return Role.select_by_user(self.request.user)
3392
3393 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003394 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3395 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003396 response = {"error": "validation",
3397 "specific_error": "not serializer.is_valid()",
3398 "reasons": serializer.errors}
3399 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003400 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003401 obj.caller = request.user
3402 if obj.can_update(request.user):
3403 return super(RoleList, self).create(request, *args, **kwargs)
3404 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003405 raise Exception("failed obj.can_update")
3406
3407 ret = super(RoleList, self).create(request, *args, **kwargs)
3408 if (ret.status_code%100 != 200):
3409 raise Exception(ret.data)
3410
3411 return ret
3412
Scott Baker89a7b7c2014-10-07 00:10:17 -07003413
3414class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3415 queryset = Role.objects.select_related().all()
3416 serializer_class = RoleSerializer
3417 id_serializer_class = RoleIdSerializer
3418
3419 def get_serializer_class(self):
3420 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3421 if (no_hyperlinks):
3422 return self.id_serializer_class
3423 else:
3424 return self.serializer_class
3425
3426 def get_queryset(self):
3427 return Role.select_by_user(self.request.user)
3428
3429 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3430
3431 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3432
3433
3434
3435class UsableObjectList(generics.ListCreateAPIView):
3436 queryset = UsableObject.objects.select_related().all()
3437 serializer_class = UsableObjectSerializer
3438 id_serializer_class = UsableObjectIdSerializer
3439 filter_backends = (filters.DjangoFilterBackend,)
3440 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3441
3442 def get_serializer_class(self):
3443 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3444 if (no_hyperlinks):
3445 return self.id_serializer_class
3446 else:
3447 return self.serializer_class
3448
3449 def get_queryset(self):
3450 return UsableObject.select_by_user(self.request.user)
3451
3452 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003453 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3454 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003455 response = {"error": "validation",
3456 "specific_error": "not serializer.is_valid()",
3457 "reasons": serializer.errors}
3458 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003459 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003460 obj.caller = request.user
3461 if obj.can_update(request.user):
3462 return super(UsableObjectList, self).create(request, *args, **kwargs)
3463 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003464 raise Exception("failed obj.can_update")
3465
3466 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3467 if (ret.status_code%100 != 200):
3468 raise Exception(ret.data)
3469
3470 return ret
3471
Scott Baker89a7b7c2014-10-07 00:10:17 -07003472
3473class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3474 queryset = UsableObject.objects.select_related().all()
3475 serializer_class = UsableObjectSerializer
3476 id_serializer_class = UsableObjectIdSerializer
3477
3478 def get_serializer_class(self):
3479 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3480 if (no_hyperlinks):
3481 return self.id_serializer_class
3482 else:
3483 return self.serializer_class
3484
3485 def get_queryset(self):
3486 return UsableObject.select_by_user(self.request.user)
3487
3488 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3489
3490 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3491
3492
3493
3494class SiteRoleList(generics.ListCreateAPIView):
3495 queryset = SiteRole.objects.select_related().all()
3496 serializer_class = SiteRoleSerializer
3497 id_serializer_class = SiteRoleIdSerializer
3498 filter_backends = (filters.DjangoFilterBackend,)
3499 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3500
3501 def get_serializer_class(self):
3502 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3503 if (no_hyperlinks):
3504 return self.id_serializer_class
3505 else:
3506 return self.serializer_class
3507
3508 def get_queryset(self):
3509 return SiteRole.select_by_user(self.request.user)
3510
3511 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003512 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3513 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003514 response = {"error": "validation",
3515 "specific_error": "not serializer.is_valid()",
3516 "reasons": serializer.errors}
3517 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003518 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003519 obj.caller = request.user
3520 if obj.can_update(request.user):
3521 return super(SiteRoleList, self).create(request, *args, **kwargs)
3522 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003523 raise Exception("failed obj.can_update")
3524
3525 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3526 if (ret.status_code%100 != 200):
3527 raise Exception(ret.data)
3528
3529 return ret
3530
Scott Baker89a7b7c2014-10-07 00:10:17 -07003531
3532class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3533 queryset = SiteRole.objects.select_related().all()
3534 serializer_class = SiteRoleSerializer
3535 id_serializer_class = SiteRoleIdSerializer
3536
3537 def get_serializer_class(self):
3538 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3539 if (no_hyperlinks):
3540 return self.id_serializer_class
3541 else:
3542 return self.serializer_class
3543
3544 def get_queryset(self):
3545 return SiteRole.select_by_user(self.request.user)
3546
3547 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3548
3549 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3550
3551
3552
3553class SliceCredentialList(generics.ListCreateAPIView):
3554 queryset = SliceCredential.objects.select_related().all()
3555 serializer_class = SliceCredentialSerializer
3556 id_serializer_class = SliceCredentialIdSerializer
3557 filter_backends = (filters.DjangoFilterBackend,)
3558 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3559
3560 def get_serializer_class(self):
3561 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3562 if (no_hyperlinks):
3563 return self.id_serializer_class
3564 else:
3565 return self.serializer_class
3566
3567 def get_queryset(self):
3568 return SliceCredential.select_by_user(self.request.user)
3569
3570 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003571 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3572 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003573 response = {"error": "validation",
3574 "specific_error": "not serializer.is_valid()",
3575 "reasons": serializer.errors}
3576 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003577 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003578 obj.caller = request.user
3579 if obj.can_update(request.user):
3580 return super(SliceCredentialList, self).create(request, *args, **kwargs)
3581 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003582 raise Exception("failed obj.can_update")
3583
3584 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
3585 if (ret.status_code%100 != 200):
3586 raise Exception(ret.data)
3587
3588 return ret
3589
Scott Baker89a7b7c2014-10-07 00:10:17 -07003590
3591class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3592 queryset = SliceCredential.objects.select_related().all()
3593 serializer_class = SliceCredentialSerializer
3594 id_serializer_class = SliceCredentialIdSerializer
3595
3596 def get_serializer_class(self):
3597 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3598 if (no_hyperlinks):
3599 return self.id_serializer_class
3600 else:
3601 return self.serializer_class
3602
3603 def get_queryset(self):
3604 return SliceCredential.select_by_user(self.request.user)
3605
3606 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3607
3608 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3609
3610
3611
3612class SliverList(generics.ListCreateAPIView):
3613 queryset = Sliver.objects.select_related().all()
3614 serializer_class = SliverSerializer
3615 id_serializer_class = SliverIdSerializer
3616 filter_backends = (filters.DjangoFilterBackend,)
3617 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
3618
3619 def get_serializer_class(self):
3620 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3621 if (no_hyperlinks):
3622 return self.id_serializer_class
3623 else:
3624 return self.serializer_class
3625
3626 def get_queryset(self):
3627 return Sliver.select_by_user(self.request.user)
3628
3629 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003630 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3631 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003632 response = {"error": "validation",
3633 "specific_error": "not serializer.is_valid()",
3634 "reasons": serializer.errors}
3635 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003636 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003637 obj.caller = request.user
3638 if obj.can_update(request.user):
3639 return super(SliverList, self).create(request, *args, **kwargs)
3640 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003641 raise Exception("failed obj.can_update")
3642
3643 ret = super(SliverList, self).create(request, *args, **kwargs)
3644 if (ret.status_code%100 != 200):
3645 raise Exception(ret.data)
3646
3647 return ret
3648
Scott Baker89a7b7c2014-10-07 00:10:17 -07003649
3650class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3651 queryset = Sliver.objects.select_related().all()
3652 serializer_class = SliverSerializer
3653 id_serializer_class = SliverIdSerializer
3654
3655 def get_serializer_class(self):
3656 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3657 if (no_hyperlinks):
3658 return self.id_serializer_class
3659 else:
3660 return self.serializer_class
3661
3662 def get_queryset(self):
3663 return Sliver.select_by_user(self.request.user)
3664
3665 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3666
3667 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3668
3669
3670
3671class NodeList(generics.ListCreateAPIView):
3672 queryset = Node.objects.select_related().all()
3673 serializer_class = NodeSerializer
3674 id_serializer_class = NodeIdSerializer
3675 filter_backends = (filters.DjangoFilterBackend,)
3676 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
3677
3678 def get_serializer_class(self):
3679 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3680 if (no_hyperlinks):
3681 return self.id_serializer_class
3682 else:
3683 return self.serializer_class
3684
3685 def get_queryset(self):
3686 return Node.select_by_user(self.request.user)
3687
3688 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003689 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3690 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003691 response = {"error": "validation",
3692 "specific_error": "not serializer.is_valid()",
3693 "reasons": serializer.errors}
3694 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003695 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003696 obj.caller = request.user
3697 if obj.can_update(request.user):
3698 return super(NodeList, self).create(request, *args, **kwargs)
3699 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003700 raise Exception("failed obj.can_update")
3701
3702 ret = super(NodeList, self).create(request, *args, **kwargs)
3703 if (ret.status_code%100 != 200):
3704 raise Exception(ret.data)
3705
3706 return ret
3707
Scott Baker89a7b7c2014-10-07 00:10:17 -07003708
3709class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3710 queryset = Node.objects.select_related().all()
3711 serializer_class = NodeSerializer
3712 id_serializer_class = NodeIdSerializer
3713
3714 def get_serializer_class(self):
3715 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3716 if (no_hyperlinks):
3717 return self.id_serializer_class
3718 else:
3719 return self.serializer_class
3720
3721 def get_queryset(self):
3722 return Node.select_by_user(self.request.user)
3723
3724 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3725
3726 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3727
3728
3729
3730class DashboardViewList(generics.ListCreateAPIView):
3731 queryset = DashboardView.objects.select_related().all()
3732 serializer_class = DashboardViewSerializer
3733 id_serializer_class = DashboardViewIdSerializer
3734 filter_backends = (filters.DjangoFilterBackend,)
3735 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
3736
3737 def get_serializer_class(self):
3738 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3739 if (no_hyperlinks):
3740 return self.id_serializer_class
3741 else:
3742 return self.serializer_class
3743
3744 def get_queryset(self):
3745 return DashboardView.select_by_user(self.request.user)
3746
3747 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003748 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3749 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003750 response = {"error": "validation",
3751 "specific_error": "not serializer.is_valid()",
3752 "reasons": serializer.errors}
3753 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003754 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003755 obj.caller = request.user
3756 if obj.can_update(request.user):
3757 return super(DashboardViewList, self).create(request, *args, **kwargs)
3758 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003759 raise Exception("failed obj.can_update")
3760
3761 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
3762 if (ret.status_code%100 != 200):
3763 raise Exception(ret.data)
3764
3765 return ret
3766
Scott Baker89a7b7c2014-10-07 00:10:17 -07003767
3768class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3769 queryset = DashboardView.objects.select_related().all()
3770 serializer_class = DashboardViewSerializer
3771 id_serializer_class = DashboardViewIdSerializer
3772
3773 def get_serializer_class(self):
3774 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3775 if (no_hyperlinks):
3776 return self.id_serializer_class
3777 else:
3778 return self.serializer_class
3779
3780 def get_queryset(self):
3781 return DashboardView.select_by_user(self.request.user)
3782
3783 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3784
3785 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3786
Scott Baker89a7b7c2014-10-07 00:10:17 -07003787
Scott Baker57c725c2014-11-12 01:13:53 -08003788
Tony Mack06c8e472014-11-30 15:53:08 -05003789class ControllerImagesList(generics.ListCreateAPIView):
3790 queryset = ControllerImages.objects.select_related().all()
3791 serializer_class = ControllerImagesSerializer
3792 id_serializer_class = ControllerImagesIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08003793 filter_backends = (filters.DjangoFilterBackend,)
3794 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
3795
3796 def get_serializer_class(self):
3797 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3798 if (no_hyperlinks):
3799 return self.id_serializer_class
3800 else:
3801 return self.serializer_class
3802
3803 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05003804 return ControllerImages.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08003805
3806 def create(self, request, *args, **kwargs):
3807 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3808 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003809 response = {"error": "validation",
3810 "specific_error": "not serializer.is_valid()",
3811 "reasons": serializer.errors}
3812 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08003813 obj = serializer.object
3814 obj.caller = request.user
3815 if obj.can_update(request.user):
Tony Mack06c8e472014-11-30 15:53:08 -05003816 return super(ControllerImagesList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08003817 else:
3818 raise Exception("failed obj.can_update")
3819
Tony Mack06c8e472014-11-30 15:53:08 -05003820 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08003821 if (ret.status_code%100 != 200):
3822 raise Exception(ret.data)
3823
3824 return ret
3825
3826
Tony Mack06c8e472014-11-30 15:53:08 -05003827class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3828 queryset = ControllerImages.objects.select_related().all()
3829 serializer_class = ControllerImagesSerializer
3830 id_serializer_class = ControllerImagesIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08003831
3832 def get_serializer_class(self):
3833 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3834 if (no_hyperlinks):
3835 return self.id_serializer_class
3836 else:
3837 return self.serializer_class
3838
3839 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05003840 return ControllerImages.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08003841
3842 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3843
3844 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3845
Scott Bakerb744f1c2014-11-21 11:32:24 -08003846
3847
Scott Baker89a7b7c2014-10-07 00:10:17 -07003848class ReservedResourceList(generics.ListCreateAPIView):
3849 queryset = ReservedResource.objects.select_related().all()
3850 serializer_class = ReservedResourceSerializer
3851 id_serializer_class = ReservedResourceIdSerializer
3852 filter_backends = (filters.DjangoFilterBackend,)
3853 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
3854
3855 def get_serializer_class(self):
3856 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3857 if (no_hyperlinks):
3858 return self.id_serializer_class
3859 else:
3860 return self.serializer_class
3861
3862 def get_queryset(self):
3863 return ReservedResource.select_by_user(self.request.user)
3864
3865 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003866 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3867 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003868 response = {"error": "validation",
3869 "specific_error": "not serializer.is_valid()",
3870 "reasons": serializer.errors}
3871 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003872 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003873 obj.caller = request.user
3874 if obj.can_update(request.user):
3875 return super(ReservedResourceList, self).create(request, *args, **kwargs)
3876 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003877 raise Exception("failed obj.can_update")
3878
3879 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
3880 if (ret.status_code%100 != 200):
3881 raise Exception(ret.data)
3882
3883 return ret
3884
Scott Baker89a7b7c2014-10-07 00:10:17 -07003885
3886class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3887 queryset = ReservedResource.objects.select_related().all()
3888 serializer_class = ReservedResourceSerializer
3889 id_serializer_class = ReservedResourceIdSerializer
3890
3891 def get_serializer_class(self):
3892 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3893 if (no_hyperlinks):
3894 return self.id_serializer_class
3895 else:
3896 return self.serializer_class
3897
3898 def get_queryset(self):
3899 return ReservedResource.select_by_user(self.request.user)
3900
3901 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3902
3903 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3904
3905
3906
3907class NetworkSliceList(generics.ListCreateAPIView):
3908 queryset = NetworkSlice.objects.select_related().all()
3909 serializer_class = NetworkSliceSerializer
3910 id_serializer_class = NetworkSliceIdSerializer
3911 filter_backends = (filters.DjangoFilterBackend,)
3912 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
3913
3914 def get_serializer_class(self):
3915 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3916 if (no_hyperlinks):
3917 return self.id_serializer_class
3918 else:
3919 return self.serializer_class
3920
3921 def get_queryset(self):
3922 return NetworkSlice.select_by_user(self.request.user)
3923
3924 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003925 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3926 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003927 response = {"error": "validation",
3928 "specific_error": "not serializer.is_valid()",
3929 "reasons": serializer.errors}
3930 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003931 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003932 obj.caller = request.user
3933 if obj.can_update(request.user):
3934 return super(NetworkSliceList, self).create(request, *args, **kwargs)
3935 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003936 raise Exception("failed obj.can_update")
3937
3938 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
3939 if (ret.status_code%100 != 200):
3940 raise Exception(ret.data)
3941
3942 return ret
3943
Scott Baker89a7b7c2014-10-07 00:10:17 -07003944
3945class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3946 queryset = NetworkSlice.objects.select_related().all()
3947 serializer_class = NetworkSliceSerializer
3948 id_serializer_class = NetworkSliceIdSerializer
3949
3950 def get_serializer_class(self):
3951 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3952 if (no_hyperlinks):
3953 return self.id_serializer_class
3954 else:
3955 return self.serializer_class
3956
3957 def get_queryset(self):
3958 return NetworkSlice.select_by_user(self.request.user)
3959
3960 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3961
3962 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3963
3964
3965
3966class UserDashboardViewList(generics.ListCreateAPIView):
3967 queryset = UserDashboardView.objects.select_related().all()
3968 serializer_class = UserDashboardViewSerializer
3969 id_serializer_class = UserDashboardViewIdSerializer
3970 filter_backends = (filters.DjangoFilterBackend,)
3971 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
3972
3973 def get_serializer_class(self):
3974 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3975 if (no_hyperlinks):
3976 return self.id_serializer_class
3977 else:
3978 return self.serializer_class
3979
3980 def get_queryset(self):
3981 return UserDashboardView.select_by_user(self.request.user)
3982
3983 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003984 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3985 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003986 response = {"error": "validation",
3987 "specific_error": "not serializer.is_valid()",
3988 "reasons": serializer.errors}
3989 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003990 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003991 obj.caller = request.user
3992 if obj.can_update(request.user):
3993 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
3994 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003995 raise Exception("failed obj.can_update")
3996
3997 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
3998 if (ret.status_code%100 != 200):
3999 raise Exception(ret.data)
4000
4001 return ret
4002
Scott Baker89a7b7c2014-10-07 00:10:17 -07004003
4004class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4005 queryset = UserDashboardView.objects.select_related().all()
4006 serializer_class = UserDashboardViewSerializer
4007 id_serializer_class = UserDashboardViewIdSerializer
4008
4009 def get_serializer_class(self):
4010 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4011 if (no_hyperlinks):
4012 return self.id_serializer_class
4013 else:
4014 return self.serializer_class
4015
4016 def get_queryset(self):
4017 return UserDashboardView.select_by_user(self.request.user)
4018
4019 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4020
4021 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4022
4023
4024
4025class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4026 queryset = PlanetStackPrivilege.objects.select_related().all()
4027 serializer_class = PlanetStackPrivilegeSerializer
4028 id_serializer_class = PlanetStackPrivilegeIdSerializer
4029 filter_backends = (filters.DjangoFilterBackend,)
4030 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4031
4032 def get_serializer_class(self):
4033 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4034 if (no_hyperlinks):
4035 return self.id_serializer_class
4036 else:
4037 return self.serializer_class
4038
4039 def get_queryset(self):
4040 return PlanetStackPrivilege.select_by_user(self.request.user)
4041
4042 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004043 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4044 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004045 response = {"error": "validation",
4046 "specific_error": "not serializer.is_valid()",
4047 "reasons": serializer.errors}
4048 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004049 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004050 obj.caller = request.user
4051 if obj.can_update(request.user):
4052 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4053 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004054 raise Exception("failed obj.can_update")
4055
4056 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4057 if (ret.status_code%100 != 200):
4058 raise Exception(ret.data)
4059
4060 return ret
4061
Scott Baker89a7b7c2014-10-07 00:10:17 -07004062
4063class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4064 queryset = PlanetStackPrivilege.objects.select_related().all()
4065 serializer_class = PlanetStackPrivilegeSerializer
4066 id_serializer_class = PlanetStackPrivilegeIdSerializer
4067
4068 def get_serializer_class(self):
4069 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4070 if (no_hyperlinks):
4071 return self.id_serializer_class
4072 else:
4073 return self.serializer_class
4074
4075 def get_queryset(self):
4076 return PlanetStackPrivilege.select_by_user(self.request.user)
4077
4078 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4079
4080 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4081
4082
4083
4084class UserList(generics.ListCreateAPIView):
4085 queryset = User.objects.select_related().all()
4086 serializer_class = UserSerializer
4087 id_serializer_class = UserIdSerializer
4088 filter_backends = (filters.DjangoFilterBackend,)
4089 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',)
4090
4091 def get_serializer_class(self):
4092 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4093 if (no_hyperlinks):
4094 return self.id_serializer_class
4095 else:
4096 return self.serializer_class
4097
4098 def get_queryset(self):
4099 return User.select_by_user(self.request.user)
4100
4101 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004102 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4103 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004104 response = {"error": "validation",
4105 "specific_error": "not serializer.is_valid()",
4106 "reasons": serializer.errors}
4107 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004108 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004109 obj.caller = request.user
4110 if obj.can_update(request.user):
4111 return super(UserList, self).create(request, *args, **kwargs)
4112 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004113 raise Exception("failed obj.can_update")
4114
4115 ret = super(UserList, self).create(request, *args, **kwargs)
4116 if (ret.status_code%100 != 200):
4117 raise Exception(ret.data)
4118
4119 return ret
4120
Scott Baker89a7b7c2014-10-07 00:10:17 -07004121
4122class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4123 queryset = User.objects.select_related().all()
4124 serializer_class = UserSerializer
4125 id_serializer_class = UserIdSerializer
4126
4127 def get_serializer_class(self):
4128 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4129 if (no_hyperlinks):
4130 return self.id_serializer_class
4131 else:
4132 return self.serializer_class
4133
4134 def get_queryset(self):
4135 return User.select_by_user(self.request.user)
4136
4137 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4138
4139 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4140
4141
4142
4143class DeploymentList(generics.ListCreateAPIView):
4144 queryset = Deployment.objects.select_related().all()
4145 serializer_class = DeploymentSerializer
4146 id_serializer_class = DeploymentIdSerializer
4147 filter_backends = (filters.DjangoFilterBackend,)
Tony Mack06c8e472014-11-30 15:53:08 -05004148 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','sites','sites','flavors','flavors',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004149
4150 def get_serializer_class(self):
4151 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4152 if (no_hyperlinks):
4153 return self.id_serializer_class
4154 else:
4155 return self.serializer_class
4156
4157 def get_queryset(self):
4158 return Deployment.select_by_user(self.request.user)
4159
4160 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004161 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4162 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004163 response = {"error": "validation",
4164 "specific_error": "not serializer.is_valid()",
4165 "reasons": serializer.errors}
4166 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004167 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004168 obj.caller = request.user
4169 if obj.can_update(request.user):
4170 return super(DeploymentList, self).create(request, *args, **kwargs)
4171 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004172 raise Exception("failed obj.can_update")
4173
4174 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4175 if (ret.status_code%100 != 200):
4176 raise Exception(ret.data)
4177
4178 return ret
4179
Scott Baker89a7b7c2014-10-07 00:10:17 -07004180
4181class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4182 queryset = Deployment.objects.select_related().all()
4183 serializer_class = DeploymentSerializer
4184 id_serializer_class = DeploymentIdSerializer
4185
4186 def get_serializer_class(self):
4187 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4188 if (no_hyperlinks):
4189 return self.id_serializer_class
4190 else:
4191 return self.serializer_class
4192
4193 def get_queryset(self):
4194 return Deployment.select_by_user(self.request.user)
4195
4196 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4197
4198 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4199
Tony Mack06c8e472014-11-30 15:53:08 -05004200class ControllerList(generics.ListCreateAPIView):
4201 queryset = Controller.objects.select_related().all()
4202 serializer_class = ControllerSerializer
4203 id_serializer_class = ControllerIdSerializer
4204 filter_backends = (filters.DjangoFilterBackend,)
4205 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site_deployment','admin_user','admin_password','admin_tenant','auth_url','backend_type')
Scott Baker89a7b7c2014-10-07 00:10:17 -07004206
Tony Mack06c8e472014-11-30 15:53:08 -05004207 def get_serializer_class(self):
4208 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4209 if (no_hyperlinks):
4210 return self.id_serializer_class
4211 else:
4212 return self.serializer_class
4213
4214 def get_queryset(self):
4215 return Controller.select_by_user(self.request.user)
4216
4217 def create(self, request, *args, **kwargs):
4218 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4219 if not (serializer.is_valid()):
4220 response = {"error": "validation",
4221 "specific_error": "not serializer.is_valid()",
4222 "reasons": serializer.errors}
4223 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4224 obj = serializer.object
4225 obj.caller = request.user
4226 if obj.can_update(request.user):
4227 return super(ControllerList, self).create(request, *args, **kwargs)
4228 else:
4229 raise Exception("failed obj.can_update")
4230
4231 ret = super(ControllerList, self).create(request, *args, **kwargs)
4232 if (ret.status_code%100 != 200):
4233 raise Exception(ret.data)
4234
4235 return ret
4236
4237class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4238 queryset = Controller.objects.select_related().all()
4239 serializer_class = ControllerSerializer
4240 id_serializer_class = ControllerIdSerializer
4241
4242 def get_serializer_class(self):
4243 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4244 if (no_hyperlinks):
4245 return self.id_serializer_class
4246 else:
4247 return self.serializer_class
4248
4249 def get_queryset(self):
4250 return Controller.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004251
4252class ReservationList(generics.ListCreateAPIView):
4253 queryset = Reservation.objects.select_related().all()
4254 serializer_class = ReservationSerializer
4255 id_serializer_class = ReservationIdSerializer
4256 filter_backends = (filters.DjangoFilterBackend,)
4257 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4258
4259 def get_serializer_class(self):
4260 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4261 if (no_hyperlinks):
4262 return self.id_serializer_class
4263 else:
4264 return self.serializer_class
4265
4266 def get_queryset(self):
4267 return Reservation.select_by_user(self.request.user)
4268
4269 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004270 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4271 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004272 response = {"error": "validation",
4273 "specific_error": "not serializer.is_valid()",
4274 "reasons": serializer.errors}
4275 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004276 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004277 obj.caller = request.user
4278 if obj.can_update(request.user):
4279 return super(ReservationList, self).create(request, *args, **kwargs)
4280 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004281 raise Exception("failed obj.can_update")
4282
4283 ret = super(ReservationList, self).create(request, *args, **kwargs)
4284 if (ret.status_code%100 != 200):
4285 raise Exception(ret.data)
4286
4287 return ret
4288
Scott Baker89a7b7c2014-10-07 00:10:17 -07004289
4290class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4291 queryset = Reservation.objects.select_related().all()
4292 serializer_class = ReservationSerializer
4293 id_serializer_class = ReservationIdSerializer
4294
4295 def get_serializer_class(self):
4296 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4297 if (no_hyperlinks):
4298 return self.id_serializer_class
4299 else:
4300 return self.serializer_class
4301
4302 def get_queryset(self):
4303 return Reservation.select_by_user(self.request.user)
4304
4305 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4306
4307 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4308
Scott Baker89a7b7c2014-10-07 00:10:17 -07004309
Scott Baker57c725c2014-11-12 01:13:53 -08004310
Tony Mack06c8e472014-11-30 15:53:08 -05004311class ControllerSlicesList(generics.ListCreateAPIView):
4312 queryset = ControllerSlices.objects.select_related().all()
4313 serializer_class = ControllerSlicesSerializer
4314 id_serializer_class = ControllerSlicesIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004315 filter_backends = (filters.DjangoFilterBackend,)
4316 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
4317
4318 def get_serializer_class(self):
4319 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4320 if (no_hyperlinks):
4321 return self.id_serializer_class
4322 else:
4323 return self.serializer_class
4324
4325 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05004326 return ControllerSlices.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004327
4328 def create(self, request, *args, **kwargs):
4329 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4330 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004331 response = {"error": "validation",
4332 "specific_error": "not serializer.is_valid()",
4333 "reasons": serializer.errors}
4334 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004335 obj = serializer.object
4336 obj.caller = request.user
4337 if obj.can_update(request.user):
Tony Mack06c8e472014-11-30 15:53:08 -05004338 return super(ControllerSlicesList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004339 else:
4340 raise Exception("failed obj.can_update")
4341
Tony Mack06c8e472014-11-30 15:53:08 -05004342 ret = super(ControllerSlicesList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004343 if (ret.status_code%100 != 200):
4344 raise Exception(ret.data)
4345
4346 return ret
4347
4348
Tony Mack06c8e472014-11-30 15:53:08 -05004349class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4350 queryset = ControllerSlices.objects.select_related().all()
4351 serializer_class = ControllerSlicesSerializer
4352 id_serializer_class = ControllerSlicesIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004353
4354 def get_serializer_class(self):
4355 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4356 if (no_hyperlinks):
4357 return self.id_serializer_class
4358 else:
4359 return self.serializer_class
4360
4361 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05004362 return ControllerSlices.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004363
4364 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4365
4366 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4367
Scott Bakerb744f1c2014-11-21 11:32:24 -08004368
4369
Scott Baker89a7b7c2014-10-07 00:10:17 -07004370class SitePrivilegeList(generics.ListCreateAPIView):
4371 queryset = SitePrivilege.objects.select_related().all()
4372 serializer_class = SitePrivilegeSerializer
4373 id_serializer_class = SitePrivilegeIdSerializer
4374 filter_backends = (filters.DjangoFilterBackend,)
4375 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4376
4377 def get_serializer_class(self):
4378 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4379 if (no_hyperlinks):
4380 return self.id_serializer_class
4381 else:
4382 return self.serializer_class
4383
4384 def get_queryset(self):
4385 return SitePrivilege.select_by_user(self.request.user)
4386
4387 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004388 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4389 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004390 response = {"error": "validation",
4391 "specific_error": "not serializer.is_valid()",
4392 "reasons": serializer.errors}
4393 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004394 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004395 obj.caller = request.user
4396 if obj.can_update(request.user):
4397 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4398 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004399 raise Exception("failed obj.can_update")
4400
4401 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4402 if (ret.status_code%100 != 200):
4403 raise Exception(ret.data)
4404
4405 return ret
4406
Scott Baker89a7b7c2014-10-07 00:10:17 -07004407
4408class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4409 queryset = SitePrivilege.objects.select_related().all()
4410 serializer_class = SitePrivilegeSerializer
4411 id_serializer_class = SitePrivilegeIdSerializer
4412
4413 def get_serializer_class(self):
4414 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4415 if (no_hyperlinks):
4416 return self.id_serializer_class
4417 else:
4418 return self.serializer_class
4419
4420 def get_queryset(self):
4421 return SitePrivilege.select_by_user(self.request.user)
4422
4423 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4424
4425 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4426
4427
4428
Scott Bakerb744f1c2014-11-21 11:32:24 -08004429class PlanetStackList(generics.ListCreateAPIView):
4430 queryset = PlanetStack.objects.select_related().all()
4431 serializer_class = PlanetStackSerializer
4432 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004433 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004434 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004435
4436 def get_serializer_class(self):
4437 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4438 if (no_hyperlinks):
4439 return self.id_serializer_class
4440 else:
4441 return self.serializer_class
4442
4443 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004444 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004445
4446 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004447 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4448 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004449 response = {"error": "validation",
4450 "specific_error": "not serializer.is_valid()",
4451 "reasons": serializer.errors}
4452 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004453 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004454 obj.caller = request.user
4455 if obj.can_update(request.user):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004456 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004457 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004458 raise Exception("failed obj.can_update")
4459
Scott Bakerb744f1c2014-11-21 11:32:24 -08004460 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07004461 if (ret.status_code%100 != 200):
4462 raise Exception(ret.data)
4463
4464 return ret
4465
Scott Baker89a7b7c2014-10-07 00:10:17 -07004466
Scott Bakerb744f1c2014-11-21 11:32:24 -08004467class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4468 queryset = PlanetStack.objects.select_related().all()
4469 serializer_class = PlanetStackSerializer
4470 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004471
4472 def get_serializer_class(self):
4473 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4474 if (no_hyperlinks):
4475 return self.id_serializer_class
4476 else:
4477 return self.serializer_class
4478
4479 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004480 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004481
4482 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4483
4484 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4485
Scott Baker89a7b7c2014-10-07 00:10:17 -07004486
Scott Baker57c725c2014-11-12 01:13:53 -08004487
Tony Mack06c8e472014-11-30 15:53:08 -05004488class ControllerUsersList(generics.ListCreateAPIView):
4489 queryset = ControllerUsers.objects.select_related().all()
4490 serializer_class = ControllerUsersSerializer
4491 id_serializer_class = ControllerUsersIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004492 filter_backends = (filters.DjangoFilterBackend,)
4493 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
4494
4495 def get_serializer_class(self):
4496 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4497 if (no_hyperlinks):
4498 return self.id_serializer_class
4499 else:
4500 return self.serializer_class
4501
4502 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05004503 return ControllerUsers.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004504
4505 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004506 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4507 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004508 response = {"error": "validation",
4509 "specific_error": "not serializer.is_valid()",
4510 "reasons": serializer.errors}
4511 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004512 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004513 obj.caller = request.user
4514 if obj.can_update(request.user):
Tony Mack06c8e472014-11-30 15:53:08 -05004515 return super(ControllerUsersList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004516 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004517 raise Exception("failed obj.can_update")
4518
Tony Mack06c8e472014-11-30 15:53:08 -05004519 ret = super(ControllerUsersList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07004520 if (ret.status_code%100 != 200):
4521 raise Exception(ret.data)
4522
4523 return ret
4524
Scott Baker89a7b7c2014-10-07 00:10:17 -07004525
Tony Mack06c8e472014-11-30 15:53:08 -05004526class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4527 queryset = ControllerUsers.objects.select_related().all()
4528 serializer_class = ControllerUsersSerializer
4529 id_serializer_class = ControllerUsersIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004530
4531 def get_serializer_class(self):
4532 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4533 if (no_hyperlinks):
4534 return self.id_serializer_class
4535 else:
4536 return self.serializer_class
4537
4538 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05004539 return ControllerUsers.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004540
4541 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4542
4543 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4544
4545
4546
4547class AccountList(generics.ListCreateAPIView):
4548 queryset = Account.objects.select_related().all()
4549 serializer_class = AccountSerializer
4550 id_serializer_class = AccountIdSerializer
4551 filter_backends = (filters.DjangoFilterBackend,)
4552 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4553
4554 def get_serializer_class(self):
4555 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4556 if (no_hyperlinks):
4557 return self.id_serializer_class
4558 else:
4559 return self.serializer_class
4560
4561 def get_queryset(self):
4562 return Account.select_by_user(self.request.user)
4563
4564 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004565 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4566 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004567 response = {"error": "validation",
4568 "specific_error": "not serializer.is_valid()",
4569 "reasons": serializer.errors}
4570 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004571 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004572 obj.caller = request.user
4573 if obj.can_update(request.user):
4574 return super(AccountList, self).create(request, *args, **kwargs)
4575 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004576 raise Exception("failed obj.can_update")
4577
4578 ret = super(AccountList, self).create(request, *args, **kwargs)
4579 if (ret.status_code%100 != 200):
4580 raise Exception(ret.data)
4581
4582 return ret
4583
Scott Baker89a7b7c2014-10-07 00:10:17 -07004584
4585class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4586 queryset = Account.objects.select_related().all()
4587 serializer_class = AccountSerializer
4588 id_serializer_class = AccountIdSerializer
4589
4590 def get_serializer_class(self):
4591 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4592 if (no_hyperlinks):
4593 return self.id_serializer_class
4594 else:
4595 return self.serializer_class
4596
4597 def get_queryset(self):
4598 return Account.select_by_user(self.request.user)
4599
4600 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4601
4602 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4603
4604
4605
4606class NetworkParameterTypeList(generics.ListCreateAPIView):
4607 queryset = NetworkParameterType.objects.select_related().all()
4608 serializer_class = NetworkParameterTypeSerializer
4609 id_serializer_class = NetworkParameterTypeIdSerializer
4610 filter_backends = (filters.DjangoFilterBackend,)
4611 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
4612
4613 def get_serializer_class(self):
4614 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4615 if (no_hyperlinks):
4616 return self.id_serializer_class
4617 else:
4618 return self.serializer_class
4619
4620 def get_queryset(self):
4621 return NetworkParameterType.select_by_user(self.request.user)
4622
4623 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004624 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4625 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004626 response = {"error": "validation",
4627 "specific_error": "not serializer.is_valid()",
4628 "reasons": serializer.errors}
4629 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004630 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004631 obj.caller = request.user
4632 if obj.can_update(request.user):
4633 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4634 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004635 raise Exception("failed obj.can_update")
4636
4637 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4638 if (ret.status_code%100 != 200):
4639 raise Exception(ret.data)
4640
4641 return ret
4642
Scott Baker89a7b7c2014-10-07 00:10:17 -07004643
4644class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4645 queryset = NetworkParameterType.objects.select_related().all()
4646 serializer_class = NetworkParameterTypeSerializer
4647 id_serializer_class = NetworkParameterTypeIdSerializer
4648
4649 def get_serializer_class(self):
4650 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4651 if (no_hyperlinks):
4652 return self.id_serializer_class
4653 else:
4654 return self.serializer_class
4655
4656 def get_queryset(self):
4657 return NetworkParameterType.select_by_user(self.request.user)
4658
4659 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4660
4661 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4662
4663
4664
4665class SiteCredentialList(generics.ListCreateAPIView):
4666 queryset = SiteCredential.objects.select_related().all()
4667 serializer_class = SiteCredentialSerializer
4668 id_serializer_class = SiteCredentialIdSerializer
4669 filter_backends = (filters.DjangoFilterBackend,)
4670 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
4671
4672 def get_serializer_class(self):
4673 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4674 if (no_hyperlinks):
4675 return self.id_serializer_class
4676 else:
4677 return self.serializer_class
4678
4679 def get_queryset(self):
4680 return SiteCredential.select_by_user(self.request.user)
4681
4682 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004683 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4684 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004685 response = {"error": "validation",
4686 "specific_error": "not serializer.is_valid()",
4687 "reasons": serializer.errors}
4688 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004689 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004690 obj.caller = request.user
4691 if obj.can_update(request.user):
4692 return super(SiteCredentialList, self).create(request, *args, **kwargs)
4693 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004694 raise Exception("failed obj.can_update")
4695
4696 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
4697 if (ret.status_code%100 != 200):
4698 raise Exception(ret.data)
4699
4700 return ret
4701
Scott Baker89a7b7c2014-10-07 00:10:17 -07004702
4703class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4704 queryset = SiteCredential.objects.select_related().all()
4705 serializer_class = SiteCredentialSerializer
4706 id_serializer_class = SiteCredentialIdSerializer
4707
4708 def get_serializer_class(self):
4709 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4710 if (no_hyperlinks):
4711 return self.id_serializer_class
4712 else:
4713 return self.serializer_class
4714
4715 def get_queryset(self):
4716 return SiteCredential.select_by_user(self.request.user)
4717
4718 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4719
4720 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4721
4722
4723
Tony Mack06c8e472014-11-30 15:53:08 -05004724class ControllerPrivilegeList(generics.ListCreateAPIView):
4725 queryset = ControllerPrivilege.objects.select_related().all()
4726 serializer_class = ControllerPrivilegeSerializer
4727 id_serializer_class = ControllerPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004728 filter_backends = (filters.DjangoFilterBackend,)
4729 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
4730
4731 def get_serializer_class(self):
4732 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4733 if (no_hyperlinks):
4734 return self.id_serializer_class
4735 else:
4736 return self.serializer_class
4737
4738 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05004739 return ControllerPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004740
4741 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004742 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4743 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004744 response = {"error": "validation",
4745 "specific_error": "not serializer.is_valid()",
4746 "reasons": serializer.errors}
4747 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004748 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004749 obj.caller = request.user
4750 if obj.can_update(request.user):
Tony Mack06c8e472014-11-30 15:53:08 -05004751 return super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004752 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004753 raise Exception("failed obj.can_update")
4754
Tony Mack06c8e472014-11-30 15:53:08 -05004755 ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07004756 if (ret.status_code%100 != 200):
4757 raise Exception(ret.data)
4758
4759 return ret
4760
Scott Baker89a7b7c2014-10-07 00:10:17 -07004761
Tony Mack06c8e472014-11-30 15:53:08 -05004762class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4763 queryset = ControllerPrivilege.objects.select_related().all()
4764 serializer_class = ControllerPrivilegeSerializer
4765 id_serializer_class = ControllerPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004766
4767 def get_serializer_class(self):
4768 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4769 if (no_hyperlinks):
4770 return self.id_serializer_class
4771 else:
4772 return self.serializer_class
4773
4774 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05004775 return ControllerPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004776
4777 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4778
4779 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4780
4781
4782
Tony Mack06c8e472014-11-30 15:53:08 -05004783class ControllerRoleList(generics.ListCreateAPIView):
4784 queryset = ControllerRole.objects.select_related().all()
4785 serializer_class = ControllerRoleSerializer
4786 id_serializer_class = ControllerRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004787 filter_backends = (filters.DjangoFilterBackend,)
4788 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
4789
4790 def get_serializer_class(self):
4791 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4792 if (no_hyperlinks):
4793 return self.id_serializer_class
4794 else:
4795 return self.serializer_class
4796
4797 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05004798 return ControllerRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004799
4800 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004801 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4802 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004803 response = {"error": "validation",
4804 "specific_error": "not serializer.is_valid()",
4805 "reasons": serializer.errors}
4806 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004807 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004808 obj.caller = request.user
4809 if obj.can_update(request.user):
Tony Mack06c8e472014-11-30 15:53:08 -05004810 return super(ControllerRoleList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004811 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004812 raise Exception("failed obj.can_update")
4813
Tony Mack06c8e472014-11-30 15:53:08 -05004814 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07004815 if (ret.status_code%100 != 200):
4816 raise Exception(ret.data)
4817
4818 return ret
4819
Scott Baker89a7b7c2014-10-07 00:10:17 -07004820
Tony Mack06c8e472014-11-30 15:53:08 -05004821class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4822 queryset = ControllerRole.objects.select_related().all()
4823 serializer_class = ControllerRoleSerializer
4824 id_serializer_class = ControllerRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004825
4826 def get_serializer_class(self):
4827 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4828 if (no_hyperlinks):
4829 return self.id_serializer_class
4830 else:
4831 return self.serializer_class
4832
4833 def get_queryset(self):
Tony Mack06c8e472014-11-30 15:53:08 -05004834 return ControllerRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004835
4836 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4837
4838 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4839
4840
4841
4842class UserCredentialList(generics.ListCreateAPIView):
4843 queryset = UserCredential.objects.select_related().all()
4844 serializer_class = UserCredentialSerializer
4845 id_serializer_class = UserCredentialIdSerializer
4846 filter_backends = (filters.DjangoFilterBackend,)
4847 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
4848
4849 def get_serializer_class(self):
4850 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4851 if (no_hyperlinks):
4852 return self.id_serializer_class
4853 else:
4854 return self.serializer_class
4855
4856 def get_queryset(self):
4857 return UserCredential.select_by_user(self.request.user)
4858
4859 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004860 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4861 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004862 response = {"error": "validation",
4863 "specific_error": "not serializer.is_valid()",
4864 "reasons": serializer.errors}
4865 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004866 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004867 obj.caller = request.user
4868 if obj.can_update(request.user):
4869 return super(UserCredentialList, self).create(request, *args, **kwargs)
4870 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004871 raise Exception("failed obj.can_update")
4872
4873 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
4874 if (ret.status_code%100 != 200):
4875 raise Exception(ret.data)
4876
4877 return ret
4878
Scott Baker89a7b7c2014-10-07 00:10:17 -07004879
4880class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4881 queryset = UserCredential.objects.select_related().all()
4882 serializer_class = UserCredentialSerializer
4883 id_serializer_class = UserCredentialIdSerializer
4884
4885 def get_serializer_class(self):
4886 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4887 if (no_hyperlinks):
4888 return self.id_serializer_class
4889 else:
4890 return self.serializer_class
4891
4892 def get_queryset(self):
4893 return UserCredential.select_by_user(self.request.user)
4894
4895 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4896
4897 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4898
Scott Baker89a7b7c2014-10-07 00:10:17 -07004899
Scott Baker57c725c2014-11-12 01:13:53 -08004900
Scott Bakerb744f1c2014-11-21 11:32:24 -08004901class SiteDeploymentsList(generics.ListCreateAPIView):
4902 queryset = SiteDeployments.objects.select_related().all()
4903 serializer_class = SiteDeploymentsSerializer
4904 id_serializer_class = SiteDeploymentsIdSerializer
4905 filter_backends = (filters.DjangoFilterBackend,)
Tony Mack06c8e472014-11-30 15:53:08 -05004906 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment')
Scott Bakerb744f1c2014-11-21 11:32:24 -08004907
4908 def get_serializer_class(self):
4909 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4910 if (no_hyperlinks):
4911 return self.id_serializer_class
4912 else:
4913 return self.serializer_class
4914
4915 def get_queryset(self):
4916 return SiteDeployments.select_by_user(self.request.user)
4917
4918 def create(self, request, *args, **kwargs):
4919 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4920 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004921 response = {"error": "validation",
4922 "specific_error": "not serializer.is_valid()",
4923 "reasons": serializer.errors}
4924 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004925 obj = serializer.object
4926 obj.caller = request.user
4927 if obj.can_update(request.user):
4928 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
4929 else:
4930 raise Exception("failed obj.can_update")
4931
4932 ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
4933 if (ret.status_code%100 != 200):
4934 raise Exception(ret.data)
4935
4936 return ret
4937
4938
4939class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4940 queryset = SiteDeployments.objects.select_related().all()
4941 serializer_class = SiteDeploymentsSerializer
4942 id_serializer_class = SiteDeploymentsIdSerializer
4943
4944 def get_serializer_class(self):
4945 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4946 if (no_hyperlinks):
4947 return self.id_serializer_class
4948 else:
4949 return self.serializer_class
4950
4951 def get_queryset(self):
4952 return SiteDeployments.select_by_user(self.request.user)
4953
4954 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4955
4956 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4957
Scott Baker0caeaf02014-06-19 11:12:55 -07004958class SliceTagList(generics.ListCreateAPIView):
4959 queryset = SliceTag.objects.select_related().all()
4960 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07004961 id_serializer_class = SliceTagIdSerializer
4962 filter_backends = (filters.DjangoFilterBackend,)
4963 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
4964
4965 def get_serializer_class(self):
4966 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4967 if (no_hyperlinks):
4968 return self.id_serializer_class
4969 else:
4970 return self.serializer_class
4971
Scott Baker0caeaf02014-06-19 11:12:55 -07004972 def get_queryset(self):
4973 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04004974
Scott Baker0caeaf02014-06-19 11:12:55 -07004975 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004976 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4977 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004978 response = {"error": "validation",
4979 "specific_error": "not serializer.is_valid()",
4980 "reasons": serializer.errors}
4981 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004982 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07004983 obj.caller = request.user
4984 if obj.can_update(request.user):
4985 return super(SliceTagList, self).create(request, *args, **kwargs)
4986 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004987 raise Exception("failed obj.can_update")
4988
4989 ret = super(SliceTagList, self).create(request, *args, **kwargs)
4990 if (ret.status_code%100 != 200):
4991 raise Exception(ret.data)
4992
4993 return ret
4994
Scott Baker0caeaf02014-06-19 11:12:55 -07004995
Scott Baker89a7b7c2014-10-07 00:10:17 -07004996class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07004997 queryset = SliceTag.objects.select_related().all()
4998 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07004999 id_serializer_class = SliceTagIdSerializer
5000
5001 def get_serializer_class(self):
5002 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5003 if (no_hyperlinks):
5004 return self.id_serializer_class
5005 else:
5006 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005007
5008 def get_queryset(self):
5009 return SliceTag.select_by_user(self.request.user)
5010
Scott Baker89a7b7c2014-10-07 00:10:17 -07005011 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005012
Scott Baker89a7b7c2014-10-07 00:10:17 -07005013 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005014
5015
5016
Scott Baker0caeaf02014-06-19 11:12:55 -07005017class NetworkTemplateList(generics.ListCreateAPIView):
5018 queryset = NetworkTemplate.objects.select_related().all()
5019 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005020 id_serializer_class = NetworkTemplateIdSerializer
5021 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker8b533192014-11-17 22:32:19 -08005022 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07005023
5024 def get_serializer_class(self):
5025 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5026 if (no_hyperlinks):
5027 return self.id_serializer_class
5028 else:
5029 return self.serializer_class
5030
Scott Baker0caeaf02014-06-19 11:12:55 -07005031 def get_queryset(self):
5032 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005033
Scott Baker0caeaf02014-06-19 11:12:55 -07005034 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005035 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5036 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005037 response = {"error": "validation",
5038 "specific_error": "not serializer.is_valid()",
5039 "reasons": serializer.errors}
5040 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005041 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005042 obj.caller = request.user
5043 if obj.can_update(request.user):
5044 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
5045 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005046 raise Exception("failed obj.can_update")
5047
5048 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
5049 if (ret.status_code%100 != 200):
5050 raise Exception(ret.data)
5051
5052 return ret
5053
Scott Baker0caeaf02014-06-19 11:12:55 -07005054
Scott Baker89a7b7c2014-10-07 00:10:17 -07005055class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005056 queryset = NetworkTemplate.objects.select_related().all()
5057 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005058 id_serializer_class = NetworkTemplateIdSerializer
5059
5060 def get_serializer_class(self):
5061 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5062 if (no_hyperlinks):
5063 return self.id_serializer_class
5064 else:
5065 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005066
5067 def get_queryset(self):
5068 return NetworkTemplate.select_by_user(self.request.user)
5069
Scott Baker89a7b7c2014-10-07 00:10:17 -07005070 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005071
Scott Baker89a7b7c2014-10-07 00:10:17 -07005072 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005073
5074
5075
5076class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005077 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005078 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005079 id_serializer_class = RouterIdSerializer
5080 filter_backends = (filters.DjangoFilterBackend,)
5081 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
5082
5083 def get_serializer_class(self):
5084 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5085 if (no_hyperlinks):
5086 return self.id_serializer_class
5087 else:
5088 return self.serializer_class
5089
Scott Baker0caeaf02014-06-19 11:12:55 -07005090 def get_queryset(self):
5091 return Router.select_by_user(self.request.user)
5092
5093 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005094 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5095 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005096 response = {"error": "validation",
5097 "specific_error": "not serializer.is_valid()",
5098 "reasons": serializer.errors}
5099 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005100 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005101 obj.caller = request.user
5102 if obj.can_update(request.user):
5103 return super(RouterList, self).create(request, *args, **kwargs)
5104 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005105 raise Exception("failed obj.can_update")
5106
5107 ret = super(RouterList, self).create(request, *args, **kwargs)
5108 if (ret.status_code%100 != 200):
5109 raise Exception(ret.data)
5110
5111 return ret
5112
Sapan Bhatiadea39432014-06-13 03:10:36 -04005113
Scott Baker89a7b7c2014-10-07 00:10:17 -07005114class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005115 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005116 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005117 id_serializer_class = RouterIdSerializer
5118
5119 def get_serializer_class(self):
5120 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5121 if (no_hyperlinks):
5122 return self.id_serializer_class
5123 else:
5124 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005125
5126 def get_queryset(self):
5127 return Router.select_by_user(self.request.user)
5128
Scott Baker89a7b7c2014-10-07 00:10:17 -07005129 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005130
Scott Baker89a7b7c2014-10-07 00:10:17 -07005131 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005132
5133
5134
Scott Baker0caeaf02014-06-19 11:12:55 -07005135class ServiceResourceList(generics.ListCreateAPIView):
5136 queryset = ServiceResource.objects.select_related().all()
5137 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005138 id_serializer_class = ServiceResourceIdSerializer
5139 filter_backends = (filters.DjangoFilterBackend,)
5140 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5141
5142 def get_serializer_class(self):
5143 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5144 if (no_hyperlinks):
5145 return self.id_serializer_class
5146 else:
5147 return self.serializer_class
5148
Scott Baker0caeaf02014-06-19 11:12:55 -07005149 def get_queryset(self):
5150 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005151
Scott Baker0caeaf02014-06-19 11:12:55 -07005152 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005153 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5154 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005155 response = {"error": "validation",
5156 "specific_error": "not serializer.is_valid()",
5157 "reasons": serializer.errors}
5158 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005159 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005160 obj.caller = request.user
5161 if obj.can_update(request.user):
5162 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5163 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005164 raise Exception("failed obj.can_update")
5165
5166 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5167 if (ret.status_code%100 != 200):
5168 raise Exception(ret.data)
5169
5170 return ret
5171
Scott Baker0caeaf02014-06-19 11:12:55 -07005172
Scott Baker89a7b7c2014-10-07 00:10:17 -07005173class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005174 queryset = ServiceResource.objects.select_related().all()
5175 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005176 id_serializer_class = ServiceResourceIdSerializer
5177
5178 def get_serializer_class(self):
5179 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5180 if (no_hyperlinks):
5181 return self.id_serializer_class
5182 else:
5183 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005184
5185 def get_queryset(self):
5186 return ServiceResource.select_by_user(self.request.user)
5187
Scott Baker89a7b7c2014-10-07 00:10:17 -07005188 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005189
Scott Baker89a7b7c2014-10-07 00:10:17 -07005190 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005191
Sapan Bhatiadea39432014-06-13 03:10:36 -04005192
5193