blob: 2e10d74febc8035c6c249fb8ee010859d21028b0 [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
Scott Bakerf0480fb2014-12-23 11:12:07 -080013if hasattr(serializers, "ReadOnlyField"):
14 # rest_framework 3.x
15 IdField = serializers.ReadOnlyField
16else:
17 # rest_framework 2.x
18 IdField = serializers.Field
19
Sapan Bhatiadea39432014-06-13 03:10:36 -040020"""
Scott Baker2bcbf372014-10-29 23:41:11 -070021 Schema of the generator object:
22 all: Set of all Model objects
23 all_if(regex): Set of Model objects that match regex
Scott Baker57c725c2014-11-12 01:13:53 -080024
Scott Baker2bcbf372014-10-29 23:41:11 -070025 Model object:
26 plural: English plural of object name
27 camel: CamelCase version of object name
28 refs: list of references to other Model objects
29 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040030
Scott Baker2bcbf372014-10-29 23:41:11 -070031 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040032"""
33
Scott Bakerd51d0bd2014-11-10 16:31:15 -080034def get_REST_patterns():
35 return patterns('',
36 url(r'^plstackapi/$', api_root),
37
Scott Baker515dc9e2014-12-22 09:29:05 -080038 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
39 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
40
Scott Bakerd51d0bd2014-11-10 16:31:15 -080041 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
42 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
43
Scott Baker515dc9e2014-12-22 09:29:05 -080044 url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
45 url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
46
Scott Bakerd51d0bd2014-11-10 16:31:15 -080047 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
48 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
49
50 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
51 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
52
53 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
54 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
55
56 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
57 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
58
59 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
60 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
61
62 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
63 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
64
65 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
66 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
67
68 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
69 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
70
71 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
72 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
73
Scott Bakerd51d0bd2014-11-10 16:31:15 -080074 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
75 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
76
77 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
78 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
79
80 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
81 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
82
83 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
84 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
85
86 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
87 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
88
Tony Mack3066a952015-01-05 22:48:11 -050089 url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetworks-list'),
90 url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetworks-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080091
92 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
93 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
94
95 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
96 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
97
98 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
99 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
100
101 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
102 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
103
104 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
105 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
106
107 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
108 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
109
110 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
111 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
112
113 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
114 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
115
Scott Baker515dc9e2014-12-22 09:29:05 -0800116 url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
117 url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800118
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800119 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
120 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
121
Scott Baker515dc9e2014-12-22 09:29:05 -0800122 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
123 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
124
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800125 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
126 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
127
128 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
129 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
130
Scott Baker515dc9e2014-12-22 09:29:05 -0800131 url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'),
132 url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
133
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800134 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
135 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
136
137 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
138 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
139
140 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
141 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
142
143 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
144 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
145
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800146 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
147 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
148
Scott Bakerb744f1c2014-11-21 11:32:24 -0800149 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
150 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800151
Scott Bakerf2c0c512014-12-22 17:35:34 -0800152 url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'),
153 url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'),
154
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800155 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
156 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
157
Scott Baker515dc9e2014-12-22 09:29:05 -0800158 url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
159 url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
160
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800161 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
162 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
163
164 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
165 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
166
Scott Baker515dc9e2014-12-22 09:29:05 -0800167 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
168 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800169
Tony Mack3066a952015-01-05 22:48:11 -0500170 url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controllerusers-list'),
171 url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controllerusers-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800172
173 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
174 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800175
176 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
177 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
178
Tony Mack3066a952015-01-05 22:48:11 -0500179 url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployments-list'),
180 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800181
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800182 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
183 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
184
Scott Bakerf2c0c512014-12-22 17:35:34 -0800185 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
186 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800187
188 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
189 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
190
191 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
192 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
193
Tony Mack3066a952015-01-05 22:48:11 -0500194 url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslices-list'),
195 url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslices-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800196
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800197 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400198
199@api_view(['GET'])
200def api_root(request, format=None):
201 return Response({
Scott Baker515dc9e2014-12-22 09:29:05 -0800202 'flavors': reverse('flavor-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700203 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800204 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700205 'images': reverse('image-list', request=request, format=format),
206 'networkparameters': reverse('networkparameter-list', request=request, format=format),
207 'sites': reverse('site-list', request=request, format=format),
208 'sliceroles': reverse('slicerole-list', request=request, format=format),
209 'tags': reverse('tag-list', request=request, format=format),
210 'invoices': reverse('invoice-list', request=request, format=format),
211 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
212 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800213 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700214 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700215 'projects': reverse('project-list', request=request, format=format),
216 'slices': reverse('slice-list', request=request, format=format),
217 'networks': reverse('network-list', request=request, format=format),
218 'services': reverse('service-list', request=request, format=format),
219 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800220 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700221 'charges': reverse('charge-list', request=request, format=format),
222 'roles': reverse('role-list', request=request, format=format),
223 'usableobjects': reverse('usableobject-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800224 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700225 'siteroles': reverse('siterole-list', request=request, format=format),
226 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
227 'slivers': reverse('sliver-list', request=request, format=format),
228 'nodes': reverse('node-list', request=request, format=format),
229 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800230 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700231 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800232 'payments': reverse('payment-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700233 'networkslices': reverse('networkslice-list', request=request, format=format),
234 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800235 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700236 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
237 'users': reverse('user-list', request=request, format=format),
238 'deployments': reverse('deployment-list', request=request, format=format),
239 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700240 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800241 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800242 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700243 'accounts': reverse('account-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800244 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700245 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
246 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800247 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
248 'controlleruserses': reverse('controllerusers-list', request=request, format=format),
249 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700250 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800251 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700252 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800253 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700254 'routers': reverse('router-list', request=request, format=format),
255 'serviceresources': reverse('serviceresource-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800256 'controllersliceses': reverse('controllerslices-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700257
Sapan Bhatiadea39432014-06-13 03:10:36 -0400258 })
259
260# Based on serializers.py
261
Scott Baker515dc9e2014-12-22 09:29:05 -0800262class XOSModelSerializer(serializers.ModelSerializer):
263 def save_object(self, obj, **kwargs):
264
265 """ rest_framework can't deal with ManyToMany relations that have a
266 through table. In plstackapi, most of the through tables we have
267 use defaults or blank fields, so there's no reason why we shouldn't
268 be able to save these objects.
269
270 So, let's strip out these m2m relations, and deal with them ourself.
271 """
272 obj._complex_m2m_data={};
273 if getattr(obj, '_m2m_data', None):
274 for relatedObject in obj._meta.get_all_related_many_to_many_objects():
275 if (relatedObject.field.rel.through._meta.auto_created):
276 # These are non-trough ManyToMany relations and
277 # can be updated just fine
278 continue
279 fieldName = relatedObject.get_accessor_name()
280 if fieldName in obj._m2m_data.keys():
281 obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
282 del obj._m2m_data[fieldName]
283
284 serializers.ModelSerializer.save_object(self, obj, **kwargs);
285
286 for (accessor, stuff) in obj._complex_m2m_data.items():
287 (relatedObject, data) = stuff
288 through = relatedObject.field.rel.through
289 local_fieldName = relatedObject.field.m2m_reverse_field_name()
290 remote_fieldName = relatedObject.field.m2m_field_name()
291
292 # get the current set of existing relations
293 existing = through.objects.filter(**{local_fieldName: obj});
294
295 data_ids = [item.id for item in data]
296 existing_ids = [getattr(item,remote_fieldName).id for item in existing]
297
298 #print "data_ids", data_ids
299 #print "existing_ids", existing_ids
300
301 # remove relations that are in 'existing' but not in 'data'
302 for item in list(existing):
303 if (getattr(item,remote_fieldName).id not in data_ids):
304 print "delete", getattr(item,remote_fieldName)
305 item.delete() #(purge=True)
306
307 # add relations that are in 'data' but not in 'existing'
308 for item in data:
309 if (item.id not in existing_ids):
310 #print "add", item
311 newModel = through(**{local_fieldName: obj, remote_fieldName: item})
312 newModel.save()
313
314
315
316class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800317 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800318
319
320 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
321
322
323 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
324 validators = serializers.SerializerMethodField("getValidators")
325 def getHumanReadableName(self, obj):
326 return str(obj)
327 def getValidators(self, obj):
328 try:
329 return obj.getValidators()
330 except:
331 return None
332 class Meta:
333 model = Flavor
334 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
335
336class FlavorIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800337 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800338
339
Scott Baker201f7da2014-12-23 10:56:06 -0800340 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800341
342
343 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
344 validators = serializers.SerializerMethodField("getValidators")
345 def getHumanReadableName(self, obj):
346 return str(obj)
347 def getValidators(self, obj):
348 try:
349 return obj.getValidators()
350 except:
351 return None
352 class Meta:
353 model = Flavor
354 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
355
356
Sapan Bhatiadea39432014-06-13 03:10:36 -0400357
358
Scott Baker0caeaf02014-06-19 11:12:55 -0700359class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800360 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700361
Scott Bakerb744f1c2014-11-21 11:32:24 -0800362 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800363 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800364 def getHumanReadableName(self, obj):
365 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800366 def getValidators(self, obj):
367 try:
368 return obj.getValidators()
369 except:
370 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700371 class Meta:
372 model = ServiceAttribute
Scott Baker96eb3fd2014-11-25 00:53:25 -0800373 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700374
Scott Baker515dc9e2014-12-22 09:29:05 -0800375class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800376 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700377
Scott Bakerb744f1c2014-11-21 11:32:24 -0800378 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800379 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800380 def getHumanReadableName(self, obj):
381 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800382 def getValidators(self, obj):
383 try:
384 return obj.getValidators()
385 except:
386 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800387 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700388 model = ServiceAttribute
Scott Baker96eb3fd2014-11-25 00:53:25 -0800389 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700390
391
Sapan Bhatiadea39432014-06-13 03:10:36 -0400392
393
Scott Baker515dc9e2014-12-22 09:29:05 -0800394class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800395 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800396
397 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
398 validators = serializers.SerializerMethodField("getValidators")
399 def getHumanReadableName(self, obj):
400 return str(obj)
401 def getValidators(self, obj):
402 try:
403 return obj.getValidators()
404 except:
405 return None
406 class Meta:
407 model = ControllerImages
408 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
409
410class ControllerImagesIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800411 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800412
413 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
414 validators = serializers.SerializerMethodField("getValidators")
415 def getHumanReadableName(self, obj):
416 return str(obj)
417 def getValidators(self, obj):
418 try:
419 return obj.getValidators()
420 except:
421 return None
422 class Meta:
423 model = ControllerImages
424 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
425
426
427
428
Sapan Bhatiadea39432014-06-13 03:10:36 -0400429class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800430 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700431
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800432
433 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
434
435
Scott Bakerb744f1c2014-11-21 11:32:24 -0800436 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800437 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800438 def getHumanReadableName(self, obj):
439 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800440 def getValidators(self, obj):
441 try:
442 return obj.getValidators()
443 except:
444 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700445 class Meta:
446 model = Image
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800447 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700448
Scott Baker515dc9e2014-12-22 09:29:05 -0800449class ImageIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800450 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700451
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800452
Scott Baker201f7da2014-12-23 10:56:06 -0800453 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800454
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 Baker515dc9e2014-12-22 09:29:05 -0800465 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700466 model = Image
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800467 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700468
469
Sapan Bhatiadea39432014-06-13 03:10:36 -0400470
471
Scott Baker0caeaf02014-06-19 11:12:55 -0700472class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800473 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700474
Scott Bakerb744f1c2014-11-21 11:32:24 -0800475 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800476 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800477 def getHumanReadableName(self, obj):
478 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800479 def getValidators(self, obj):
480 try:
481 return obj.getValidators()
482 except:
483 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700484 class Meta:
485 model = NetworkParameter
Scott Baker96eb3fd2014-11-25 00:53:25 -0800486 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700487
Scott Baker515dc9e2014-12-22 09:29:05 -0800488class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800489 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700490
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 Baker515dc9e2014-12-22 09:29:05 -0800500 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700501 model = NetworkParameter
Scott Baker96eb3fd2014-11-25 00:53:25 -0800502 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700503
504
Sapan Bhatiadea39432014-06-13 03:10:36 -0400505
506
507class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800508 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700509
Scott Baker515dc9e2014-12-22 09:29:05 -0800510
511 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
512
513
Scott Bakerb744f1c2014-11-21 11:32:24 -0800514 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800515 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800516 def getHumanReadableName(self, obj):
517 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800518 def getValidators(self, obj):
519 try:
520 return obj.getValidators()
521 except:
522 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700523 class Meta:
524 model = Site
Scott Baker515dc9e2014-12-22 09:29:05 -0800525 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700526
Scott Baker515dc9e2014-12-22 09:29:05 -0800527class SiteIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800528 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700529
Scott Baker515dc9e2014-12-22 09:29:05 -0800530
Scott Baker201f7da2014-12-23 10:56:06 -0800531 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800532
533
Scott Bakerb744f1c2014-11-21 11:32:24 -0800534 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800535 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800536 def getHumanReadableName(self, obj):
537 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800538 def getValidators(self, obj):
539 try:
540 return obj.getValidators()
541 except:
542 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800543 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700544 model = Site
Scott Baker515dc9e2014-12-22 09:29:05 -0800545 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700546
547
Sapan Bhatiadea39432014-06-13 03:10:36 -0400548
549
Scott Baker0caeaf02014-06-19 11:12:55 -0700550class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800551 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700552
Scott Bakerb744f1c2014-11-21 11:32:24 -0800553 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800554 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800555 def getHumanReadableName(self, obj):
556 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800557 def getValidators(self, obj):
558 try:
559 return obj.getValidators()
560 except:
561 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700562 class Meta:
563 model = SliceRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800564 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700565
Scott Baker515dc9e2014-12-22 09:29:05 -0800566class SliceRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800567 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700568
Scott Bakerb744f1c2014-11-21 11:32:24 -0800569 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800570 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800571 def getHumanReadableName(self, obj):
572 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800573 def getValidators(self, obj):
574 try:
575 return obj.getValidators()
576 except:
577 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800578 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700579 model = SliceRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800580 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700581
582
Sapan Bhatiadea39432014-06-13 03:10:36 -0400583
584
585class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800586 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700587
Scott Bakerb744f1c2014-11-21 11:32:24 -0800588 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800589 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800590 def getHumanReadableName(self, obj):
591 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800592 def getValidators(self, obj):
593 try:
594 return obj.getValidators()
595 except:
596 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700597 class Meta:
598 model = Tag
Scott Baker96eb3fd2014-11-25 00:53:25 -0800599 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700600
Scott Baker515dc9e2014-12-22 09:29:05 -0800601class TagIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800602 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700603
Scott Bakerb744f1c2014-11-21 11:32:24 -0800604 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800605 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800606 def getHumanReadableName(self, obj):
607 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800608 def getValidators(self, obj):
609 try:
610 return obj.getValidators()
611 except:
612 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800613 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700614 model = Tag
Scott Baker96eb3fd2014-11-25 00:53:25 -0800615 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700616
617
Sapan Bhatiadea39432014-06-13 03:10:36 -0400618
619
620class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800621 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700622
Scott Bakerb744f1c2014-11-21 11:32:24 -0800623 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800624 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800625 def getHumanReadableName(self, obj):
626 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800627 def getValidators(self, obj):
628 try:
629 return obj.getValidators()
630 except:
631 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700632 class Meta:
633 model = Invoice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800634 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700635
Scott Baker515dc9e2014-12-22 09:29:05 -0800636class InvoiceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800637 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700638
Scott Bakerb744f1c2014-11-21 11:32:24 -0800639 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800640 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800641 def getHumanReadableName(self, obj):
642 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800643 def getValidators(self, obj):
644 try:
645 return obj.getValidators()
646 except:
647 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800648 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700649 model = Invoice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800650 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700651
652
Sapan Bhatiadea39432014-06-13 03:10:36 -0400653
654
Scott Baker0caeaf02014-06-19 11:12:55 -0700655class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800656 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700657
Scott Bakerb744f1c2014-11-21 11:32:24 -0800658 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800659 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800660 def getHumanReadableName(self, obj):
661 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800662 def getValidators(self, obj):
663 try:
664 return obj.getValidators()
665 except:
666 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700667 class Meta:
668 model = SlicePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -0800669 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700670
Scott Baker515dc9e2014-12-22 09:29:05 -0800671class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800672 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700673
Scott Bakerb744f1c2014-11-21 11:32:24 -0800674 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800675 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800676 def getHumanReadableName(self, obj):
677 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800678 def getValidators(self, obj):
679 try:
680 return obj.getValidators()
681 except:
682 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800683 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700684 model = SlicePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -0800685 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700686
687
Scott Baker0caeaf02014-06-19 11:12:55 -0700688
689
Scott Baker89a7b7c2014-10-07 00:10:17 -0700690class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800691 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700692
Scott Bakerb744f1c2014-11-21 11:32:24 -0800693 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800694 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800695 def getHumanReadableName(self, obj):
696 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800697 def getValidators(self, obj):
698 try:
699 return obj.getValidators()
700 except:
701 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700702 class Meta:
703 model = PlanetStackRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800704 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700705
Scott Baker515dc9e2014-12-22 09:29:05 -0800706class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800707 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700708
Scott Bakerb744f1c2014-11-21 11:32:24 -0800709 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800710 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800711 def getHumanReadableName(self, obj):
712 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800713 def getValidators(self, obj):
714 try:
715 return obj.getValidators()
716 except:
717 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800718 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700719 model = PlanetStackRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800720 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700721
722
723
724
Scott Baker0caeaf02014-06-19 11:12:55 -0700725class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800726 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700727
Scott Bakerb744f1c2014-11-21 11:32:24 -0800728 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800729 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800730 def getHumanReadableName(self, obj):
731 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800732 def getValidators(self, obj):
733 try:
734 return obj.getValidators()
735 except:
736 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700737 class Meta:
738 model = NetworkSliver
Scott Baker96eb3fd2014-11-25 00:53:25 -0800739 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700740
Scott Baker515dc9e2014-12-22 09:29:05 -0800741class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800742 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700743
Scott Bakerb744f1c2014-11-21 11:32:24 -0800744 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800745 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800746 def getHumanReadableName(self, obj):
747 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800748 def getValidators(self, obj):
749 try:
750 return obj.getValidators()
751 except:
752 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800753 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700754 model = NetworkSliver
Scott Baker96eb3fd2014-11-25 00:53:25 -0800755 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700756
757
Scott Baker0caeaf02014-06-19 11:12:55 -0700758
759
Scott Baker89a7b7c2014-10-07 00:10:17 -0700760class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800761 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700762
Scott Bakerb744f1c2014-11-21 11:32:24 -0800763 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800764 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800765 def getHumanReadableName(self, obj):
766 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800767 def getValidators(self, obj):
768 try:
769 return obj.getValidators()
770 except:
771 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700772 class Meta:
773 model = Project
Scott Baker96eb3fd2014-11-25 00:53:25 -0800774 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700775
Scott Baker515dc9e2014-12-22 09:29:05 -0800776class ProjectIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800777 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700778
Scott Bakerb744f1c2014-11-21 11:32:24 -0800779 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800780 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800781 def getHumanReadableName(self, obj):
782 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800783 def getValidators(self, obj):
784 try:
785 return obj.getValidators()
786 except:
787 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800788 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700789 model = Project
Scott Baker96eb3fd2014-11-25 00:53:25 -0800790 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700791
792
793
794
Sapan Bhatiadea39432014-06-13 03:10:36 -0400795class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800796 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700797
798
799 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
800
801
802
Scott Baker2bcbf372014-10-29 23:41:11 -0700803 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
804
805
Scott Bakerb744f1c2014-11-21 11:32:24 -0800806 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800807 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800808 def getHumanReadableName(self, obj):
809 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800810 def getValidators(self, obj):
811 try:
812 return obj.getValidators()
813 except:
814 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700815 class Meta:
816 model = Slice
Scott Baker515dc9e2014-12-22 09:29:05 -0800817 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','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700818
Scott Baker515dc9e2014-12-22 09:29:05 -0800819class SliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800820 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700821
822
Scott Baker201f7da2014-12-23 10:56:06 -0800823 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700824
825
826
Scott Baker201f7da2014-12-23 10:56:06 -0800827 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700828
829
Scott Bakerb744f1c2014-11-21 11:32:24 -0800830 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800831 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800832 def getHumanReadableName(self, obj):
833 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800834 def getValidators(self, obj):
835 try:
836 return obj.getValidators()
837 except:
838 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800839 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700840 model = Slice
Scott Baker515dc9e2014-12-22 09:29:05 -0800841 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','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700842
843
Sapan Bhatiadea39432014-06-13 03:10:36 -0400844
845
846class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800847 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700848
849
Scott Baker515dc9e2014-12-22 09:29:05 -0800850 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700851
852
853
Scott Baker515dc9e2014-12-22 09:29:05 -0800854 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
855
856
857
858 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700859
860
861
862 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
863
864
865
866 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
867
868
Scott Bakerb744f1c2014-11-21 11:32:24 -0800869 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800870 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800871 def getHumanReadableName(self, obj):
872 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800873 def getValidators(self, obj):
874 try:
875 return obj.getValidators()
876 except:
877 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700878 class Meta:
879 model = Network
Scott Bakerd188c012015-01-03 12:32:45 -0800880 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700881
Scott Baker515dc9e2014-12-22 09:29:05 -0800882class NetworkIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800883 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700884
885
Scott Baker201f7da2014-12-23 10:56:06 -0800886 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700887
888
889
Scott Baker201f7da2014-12-23 10:56:06 -0800890 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700891
892
893
Scott Baker201f7da2014-12-23 10:56:06 -0800894 slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700895
896
897
Scott Baker201f7da2014-12-23 10:56:06 -0800898 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800899
900
901
Scott Baker201f7da2014-12-23 10:56:06 -0800902 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700903
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 Baker515dc9e2014-12-22 09:29:05 -0800914 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700915 model = Network
Scott Bakerd188c012015-01-03 12:32:45 -0800916 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700917
918
Sapan Bhatiadea39432014-06-13 03:10:36 -0400919
920
921class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800922 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700923
Scott Bakerb744f1c2014-11-21 11:32:24 -0800924 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800925 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800926 def getHumanReadableName(self, obj):
927 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800928 def getValidators(self, obj):
929 try:
930 return obj.getValidators()
931 except:
932 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700933 class Meta:
934 model = Service
Scott Baker96eb3fd2014-11-25 00:53:25 -0800935 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700936
Scott Baker515dc9e2014-12-22 09:29:05 -0800937class ServiceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800938 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700939
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 Baker515dc9e2014-12-22 09:29:05 -0800949 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700950 model = Service
Scott Baker96eb3fd2014-11-25 00:53:25 -0800951 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700952
953
Sapan Bhatiadea39432014-06-13 03:10:36 -0400954
955
Scott Baker0caeaf02014-06-19 11:12:55 -0700956class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800957 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700958
Scott Bakerb744f1c2014-11-21 11:32:24 -0800959 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800960 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800961 def getHumanReadableName(self, obj):
962 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800963 def getValidators(self, obj):
964 try:
965 return obj.getValidators()
966 except:
967 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700968 class Meta:
969 model = ServiceClass
Scott Baker96eb3fd2014-11-25 00:53:25 -0800970 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700971
Scott Baker515dc9e2014-12-22 09:29:05 -0800972class ServiceClassIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800973 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700974
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 Baker515dc9e2014-12-22 09:29:05 -0800984 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700985 model = ServiceClass
Scott Baker96eb3fd2014-11-25 00:53:25 -0800986 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700987
988
Sapan Bhatiadea39432014-06-13 03:10:36 -0400989
990
Tony Mack3066a952015-01-05 22:48:11 -0500991class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800992 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700993
Scott Bakerb744f1c2014-11-21 11:32:24 -0800994 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800995 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800996 def getHumanReadableName(self, obj):
997 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800998 def getValidators(self, obj):
999 try:
1000 return obj.getValidators()
1001 except:
1002 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001003 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05001004 model = ControllerNetwork
Scott Baker515dc9e2014-12-22 09:29:05 -08001005 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -07001006
Tony Mack3066a952015-01-05 22:48:11 -05001007class ControllerNetworkIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001008 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001009
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 Baker515dc9e2014-12-22 09:29:05 -08001019 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05001020 model = ControllerNetwork
Scott Baker515dc9e2014-12-22 09:29:05 -08001021 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -07001022
1023
Sapan Bhatiadea39432014-06-13 03:10:36 -04001024
1025
1026class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001027 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001028
Scott Bakerb744f1c2014-11-21 11:32:24 -08001029 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001030 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001031 def getHumanReadableName(self, obj):
1032 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001033 def getValidators(self, obj):
1034 try:
1035 return obj.getValidators()
1036 except:
1037 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001038 class Meta:
1039 model = Charge
Scott Baker96eb3fd2014-11-25 00:53:25 -08001040 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 -07001041
Scott Baker515dc9e2014-12-22 09:29:05 -08001042class ChargeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001043 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001044
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 Baker515dc9e2014-12-22 09:29:05 -08001054 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001055 model = Charge
Scott Baker96eb3fd2014-11-25 00:53:25 -08001056 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 -07001057
1058
Sapan Bhatiadea39432014-06-13 03:10:36 -04001059
1060
1061class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001062 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001063
Scott Bakerb744f1c2014-11-21 11:32:24 -08001064 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001065 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001066 def getHumanReadableName(self, obj):
1067 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001068 def getValidators(self, obj):
1069 try:
1070 return obj.getValidators()
1071 except:
1072 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001073 class Meta:
1074 model = Role
Scott Baker96eb3fd2014-11-25 00:53:25 -08001075 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001076
Scott Baker515dc9e2014-12-22 09:29:05 -08001077class RoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001078 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001079
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 Baker515dc9e2014-12-22 09:29:05 -08001089 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001090 model = Role
Scott Baker96eb3fd2014-11-25 00:53:25 -08001091 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001092
1093
Sapan Bhatiadea39432014-06-13 03:10:36 -04001094
1095
Scott Baker0caeaf02014-06-19 11:12:55 -07001096class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001097 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001098
Scott Bakerb744f1c2014-11-21 11:32:24 -08001099 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001100 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001101 def getHumanReadableName(self, obj):
1102 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001103 def getValidators(self, obj):
1104 try:
1105 return obj.getValidators()
1106 except:
1107 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001108 class Meta:
1109 model = UsableObject
Scott Baker96eb3fd2014-11-25 00:53:25 -08001110 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001111
Scott Baker515dc9e2014-12-22 09:29:05 -08001112class UsableObjectIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001113 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001114
Scott Bakerb744f1c2014-11-21 11:32:24 -08001115 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001116 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001117 def getHumanReadableName(self, obj):
1118 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001119 def getValidators(self, obj):
1120 try:
1121 return obj.getValidators()
1122 except:
1123 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001124 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001125 model = UsableObject
Scott Baker96eb3fd2014-11-25 00:53:25 -08001126 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001127
Scott Baker0caeaf02014-06-19 11:12:55 -07001128class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001129 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001130
Scott Bakerb744f1c2014-11-21 11:32:24 -08001131 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001132 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001133 def getHumanReadableName(self, obj):
1134 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001135 def getValidators(self, obj):
1136 try:
1137 return obj.getValidators()
1138 except:
1139 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001140 class Meta:
1141 model = SiteRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001142 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001143
Scott Baker515dc9e2014-12-22 09:29:05 -08001144class SiteRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001145 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001146
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 Baker515dc9e2014-12-22 09:29:05 -08001156 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001157 model = SiteRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001158 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001159
1160
Scott Baker0caeaf02014-06-19 11:12:55 -07001161
1162
Scott Baker89a7b7c2014-10-07 00:10:17 -07001163class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001164 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001165
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 = SliceCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001177 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001178
Scott Baker515dc9e2014-12-22 09:29:05 -08001179class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001180 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001181
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 Baker515dc9e2014-12-22 09:29:05 -08001191 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001192 model = SliceCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001193 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001194
1195
1196
1197
Sapan Bhatiadea39432014-06-13 03:10:36 -04001198class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001199 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001200
1201
1202 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1203
1204
Scott Bakerb744f1c2014-11-21 11:32:24 -08001205 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001206 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001207 def getHumanReadableName(self, obj):
1208 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001209 def getValidators(self, obj):
1210 try:
1211 return obj.getValidators()
1212 except:
1213 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001214 class Meta:
1215 model = Sliver
Scott Baker16fce9c2015-01-03 12:05:21 -08001216 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001217
Scott Baker515dc9e2014-12-22 09:29:05 -08001218class SliverIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001219 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001220
1221
Scott Baker201f7da2014-12-23 10:56:06 -08001222 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -07001223
1224
Scott Bakerb744f1c2014-11-21 11:32:24 -08001225 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001226 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001227 def getHumanReadableName(self, obj):
1228 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001229 def getValidators(self, obj):
1230 try:
1231 return obj.getValidators()
1232 except:
1233 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001234 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001235 model = Sliver
Scott Baker16fce9c2015-01-03 12:05:21 -08001236 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001237
1238
Sapan Bhatiadea39432014-06-13 03:10:36 -04001239
1240
1241class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001242 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001243
Scott Bakerb744f1c2014-11-21 11:32:24 -08001244 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001245 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001246 def getHumanReadableName(self, obj):
1247 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001248 def getValidators(self, obj):
1249 try:
1250 return obj.getValidators()
1251 except:
1252 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001253 class Meta:
1254 model = Node
Scott Baker515dc9e2014-12-22 09:29:05 -08001255 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001256
Scott Baker515dc9e2014-12-22 09:29:05 -08001257class NodeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001258 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001259
Scott Bakerb744f1c2014-11-21 11:32:24 -08001260 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001261 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001262 def getHumanReadableName(self, obj):
1263 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001264 def getValidators(self, obj):
1265 try:
1266 return obj.getValidators()
1267 except:
1268 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001269 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001270 model = Node
Scott Baker515dc9e2014-12-22 09:29:05 -08001271 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001272
1273
Sapan Bhatiadea39432014-06-13 03:10:36 -04001274
1275
Scott Baker0caeaf02014-06-19 11:12:55 -07001276class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001277 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001278
Scott Baker515dc9e2014-12-22 09:29:05 -08001279
1280 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1281
1282
Scott Bakerb744f1c2014-11-21 11:32:24 -08001283 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001284 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001285 def getHumanReadableName(self, obj):
1286 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001287 def getValidators(self, obj):
1288 try:
1289 return obj.getValidators()
1290 except:
1291 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001292 class Meta:
1293 model = DashboardView
Scott Baker515dc9e2014-12-22 09:29:05 -08001294 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker46b58542014-08-11 17:26:12 -07001295
Scott Baker515dc9e2014-12-22 09:29:05 -08001296class DashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001297 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001298
Scott Baker515dc9e2014-12-22 09:29:05 -08001299
Scott Baker201f7da2014-12-23 10:56:06 -08001300 controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001301
1302
Scott Bakerb744f1c2014-11-21 11:32:24 -08001303 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001304 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001305 def getHumanReadableName(self, obj):
1306 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001307 def getValidators(self, obj):
1308 try:
1309 return obj.getValidators()
1310 except:
1311 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001312 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001313 model = DashboardView
Scott Baker515dc9e2014-12-22 09:29:05 -08001314 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001315
1316
1317
1318
Scott Baker515dc9e2014-12-22 09:29:05 -08001319class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001320 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001321
1322 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 Bakerb744f1c2014-11-21 11:32:24 -08001331 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001332 model = ImageDeployments
1333 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001334
Scott Baker515dc9e2014-12-22 09:29:05 -08001335class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001336 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001337
1338 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001339 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001340 def getHumanReadableName(self, obj):
1341 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001342 def getValidators(self, obj):
1343 try:
1344 return obj.getValidators()
1345 except:
1346 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001347 class Meta:
1348 model = ImageDeployments
1349 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001350
1351
Sapan Bhatiadea39432014-06-13 03:10:36 -04001352
1353
Scott Baker0caeaf02014-06-19 11:12:55 -07001354class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001355 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001356
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:
1365 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001366 class Meta:
1367 model = ReservedResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08001368 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001369
Scott Baker515dc9e2014-12-22 09:29:05 -08001370class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001371 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001372
Scott Bakerb744f1c2014-11-21 11:32:24 -08001373 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001374 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001375 def getHumanReadableName(self, obj):
1376 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001377 def getValidators(self, obj):
1378 try:
1379 return obj.getValidators()
1380 except:
1381 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001382 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001383 model = ReservedResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08001384 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker8b533192014-11-17 22:32:19 -08001385
1386
1387
1388
Scott Baker515dc9e2014-12-22 09:29:05 -08001389class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001390 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001391
1392 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1393 validators = serializers.SerializerMethodField("getValidators")
1394 def getHumanReadableName(self, obj):
1395 return str(obj)
1396 def getValidators(self, obj):
1397 try:
1398 return obj.getValidators()
1399 except:
1400 return None
1401 class Meta:
1402 model = Payment
1403 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1404
1405class PaymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001406 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001407
1408 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1409 validators = serializers.SerializerMethodField("getValidators")
1410 def getHumanReadableName(self, obj):
1411 return str(obj)
1412 def getValidators(self, obj):
1413 try:
1414 return obj.getValidators()
1415 except:
1416 return None
1417 class Meta:
1418 model = Payment
1419 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1420
1421
1422
1423
Scott Baker0caeaf02014-06-19 11:12:55 -07001424class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001425 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001426
Scott Bakerb744f1c2014-11-21 11:32:24 -08001427 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001428 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001429 def getHumanReadableName(self, obj):
1430 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001431 def getValidators(self, obj):
1432 try:
1433 return obj.getValidators()
1434 except:
1435 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001436 class Meta:
1437 model = NetworkSlice
Scott Baker96eb3fd2014-11-25 00:53:25 -08001438 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001439
Scott Baker515dc9e2014-12-22 09:29:05 -08001440class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001441 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001442
Scott Bakerb744f1c2014-11-21 11:32:24 -08001443 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001444 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001445 def getHumanReadableName(self, obj):
1446 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001447 def getValidators(self, obj):
1448 try:
1449 return obj.getValidators()
1450 except:
1451 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001452 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001453 model = NetworkSlice
Scott Baker96eb3fd2014-11-25 00:53:25 -08001454 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001455
1456
Scott Baker0caeaf02014-06-19 11:12:55 -07001457
1458
1459class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001460 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001461
Scott Bakerb744f1c2014-11-21 11:32:24 -08001462 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001463 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001464 def getHumanReadableName(self, obj):
1465 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 = UserDashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001473 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001474
Scott Baker515dc9e2014-12-22 09:29:05 -08001475class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001476 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001477
Scott Bakerb744f1c2014-11-21 11:32:24 -08001478 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001479 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001480 def getHumanReadableName(self, obj):
1481 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001482 def getValidators(self, obj):
1483 try:
1484 return obj.getValidators()
1485 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001486 return None
1487 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001488 model = UserDashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001489 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker8b533192014-11-17 22:32:19 -08001490
1491
1492
1493
Scott Baker515dc9e2014-12-22 09:29:05 -08001494class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001495 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001496
Scott Baker515dc9e2014-12-22 09:29:05 -08001497
1498 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1499
1500
Scott Bakerb744f1c2014-11-21 11:32:24 -08001501 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001502 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001503 def getHumanReadableName(self, obj):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001504 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001505 def getValidators(self, obj):
1506 try:
1507 return obj.getValidators()
1508 except:
1509 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001510 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001511 model = Controller
1512 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
Scott Baker46b58542014-08-11 17:26:12 -07001513
Scott Baker515dc9e2014-12-22 09:29:05 -08001514class ControllerIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001515 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001516
1517
Scott Baker201f7da2014-12-23 10:56:06 -08001518 dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -07001519
1520
Scott Bakerb744f1c2014-11-21 11:32:24 -08001521 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001522 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001523 def getHumanReadableName(self, obj):
1524 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001525 def getValidators(self, obj):
1526 try:
1527 return obj.getValidators()
1528 except:
1529 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001530 class Meta:
1531 model = Controller
1532 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
1533
1534
1535
1536
1537class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001538 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001539
1540 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1541 validators = serializers.SerializerMethodField("getValidators")
1542 def getHumanReadableName(self, obj):
1543 return str(obj)
1544 def getValidators(self, obj):
1545 try:
1546 return obj.getValidators()
1547 except:
1548 return None
1549 class Meta:
1550 model = PlanetStackPrivilege
1551 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1552
1553class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001554 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001555
1556 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1557 validators = serializers.SerializerMethodField("getValidators")
1558 def getHumanReadableName(self, obj):
1559 return str(obj)
1560 def getValidators(self, obj):
1561 try:
1562 return obj.getValidators()
1563 except:
1564 return None
1565 class Meta:
1566 model = PlanetStackPrivilege
1567 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1568
1569
1570
1571
1572class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001573 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001574
1575 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1576 validators = serializers.SerializerMethodField("getValidators")
1577 def getHumanReadableName(self, obj):
1578 return str(obj)
1579 def getValidators(self, obj):
1580 try:
1581 return obj.getValidators()
1582 except:
1583 return None
1584 class Meta:
1585 model = User
1586 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',)
1587
1588class UserIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001589 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001590
1591 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1592 validators = serializers.SerializerMethodField("getValidators")
1593 def getHumanReadableName(self, obj):
1594 return str(obj)
1595 def getValidators(self, obj):
1596 try:
1597 return obj.getValidators()
1598 except:
1599 return None
1600 class Meta:
1601 model = User
1602 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',)
1603
1604
1605
1606
1607class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001608 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001609
1610
1611 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1612
1613
1614
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001615 images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1616
1617
1618
Scott Baker515dc9e2014-12-22 09:29:05 -08001619 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1620
1621
1622 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1623 validators = serializers.SerializerMethodField("getValidators")
1624 def getHumanReadableName(self, obj):
1625 return str(obj)
1626 def getValidators(self, obj):
1627 try:
1628 return obj.getValidators()
1629 except:
1630 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001631 class Meta:
1632 model = Deployment
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001633 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Scott Baker46b58542014-08-11 17:26:12 -07001634
Scott Baker515dc9e2014-12-22 09:29:05 -08001635class DeploymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001636 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001637
1638
Scott Baker201f7da2014-12-23 10:56:06 -08001639 flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001640
1641
1642
Scott Baker201f7da2014-12-23 10:56:06 -08001643 images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all())
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001644
1645
1646
Scott Baker201f7da2014-12-23 10:56:06 -08001647 sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001648
1649
Tony Mack06c8e472014-11-30 15:53:08 -05001650 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1651 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001652 def getHumanReadableName(self, obj):
1653 return str(obj)
1654 def getValidators(self, obj):
Tony Mack06c8e472014-11-30 15:53:08 -05001655 try:
1656 return obj.getValidators()
1657 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001658 return None
1659 class Meta:
1660 model = Deployment
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001661 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Tony Mack06c8e472014-11-30 15:53:08 -05001662
1663
Sapan Bhatiadea39432014-06-13 03:10:36 -04001664
1665
1666class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001667 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001668
Scott Bakerb744f1c2014-11-21 11:32:24 -08001669 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001670 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001671 def getHumanReadableName(self, obj):
1672 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001673 def getValidators(self, obj):
1674 try:
1675 return obj.getValidators()
1676 except:
1677 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001678 class Meta:
1679 model = Reservation
Scott Baker96eb3fd2014-11-25 00:53:25 -08001680 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001681
Scott Baker515dc9e2014-12-22 09:29:05 -08001682class ReservationIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001683 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001684
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 Baker515dc9e2014-12-22 09:29:05 -08001694 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001695 model = Reservation
Scott Baker96eb3fd2014-11-25 00:53:25 -08001696 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001697
1698
Scott Baker0caeaf02014-06-19 11:12:55 -07001699
1700
Scott Bakerb744f1c2014-11-21 11:32:24 -08001701class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001702 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001703
1704 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001705 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001706 def getHumanReadableName(self, obj):
1707 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001708 def getValidators(self, obj):
1709 try:
1710 return obj.getValidators()
1711 except:
1712 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001713 class Meta:
1714 model = SitePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001715 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001716
Scott Baker515dc9e2014-12-22 09:29:05 -08001717class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001718 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001719
1720 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 Baker515dc9e2014-12-22 09:29:05 -08001729 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08001730 model = SitePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001731 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001732
1733
1734
1735
1736class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001737 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001738
1739 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001740 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001741 def getHumanReadableName(self, obj):
1742 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001743 def getValidators(self, obj):
1744 try:
1745 return obj.getValidators()
1746 except:
1747 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001748 class Meta:
1749 model = PlanetStack
Scott Baker96eb3fd2014-11-25 00:53:25 -08001750 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001751
Scott Baker515dc9e2014-12-22 09:29:05 -08001752class PlanetStackIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001753 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001754
1755 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 Baker515dc9e2014-12-22 09:29:05 -08001764 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08001765 model = PlanetStack
Scott Baker96eb3fd2014-11-25 00:53:25 -08001766 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001767
1768
Sapan Bhatiadea39432014-06-13 03:10:36 -04001769
1770
Scott Bakerf2c0c512014-12-22 17:35:34 -08001771class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001772 id = IdField()
Scott Bakerf2c0c512014-12-22 17:35:34 -08001773
1774 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1775 validators = serializers.SerializerMethodField("getValidators")
1776 def getHumanReadableName(self, obj):
1777 return str(obj)
1778 def getValidators(self, obj):
1779 try:
1780 return obj.getValidators()
1781 except:
1782 return None
1783 class Meta:
1784 model = ControllerDashboardView
1785 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1786
1787class ControllerDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001788 id = IdField()
Scott Bakerf2c0c512014-12-22 17:35:34 -08001789
1790 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1791 validators = serializers.SerializerMethodField("getValidators")
1792 def getHumanReadableName(self, obj):
1793 return str(obj)
1794 def getValidators(self, obj):
1795 try:
1796 return obj.getValidators()
1797 except:
1798 return None
1799 class Meta:
1800 model = ControllerDashboardView
1801 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1802
1803
1804
1805
Sapan Bhatiadea39432014-06-13 03:10:36 -04001806class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001807 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001808
Scott Bakerb744f1c2014-11-21 11:32:24 -08001809 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001810 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001811 def getHumanReadableName(self, obj):
1812 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001813 def getValidators(self, obj):
1814 try:
1815 return obj.getValidators()
1816 except:
1817 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001818 class Meta:
1819 model = Account
Scott Baker96eb3fd2014-11-25 00:53:25 -08001820 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001821
Scott Baker515dc9e2014-12-22 09:29:05 -08001822class AccountIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001823 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001824
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 Baker515dc9e2014-12-22 09:29:05 -08001834 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001835 model = Account
Scott Baker96eb3fd2014-11-25 00:53:25 -08001836 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001837
1838
Sapan Bhatiadea39432014-06-13 03:10:36 -04001839
1840
Scott Baker515dc9e2014-12-22 09:29:05 -08001841class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001842 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001843
1844 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1845 validators = serializers.SerializerMethodField("getValidators")
1846 def getHumanReadableName(self, obj):
1847 return str(obj)
1848 def getValidators(self, obj):
1849 try:
1850 return obj.getValidators()
1851 except:
1852 return None
1853 class Meta:
1854 model = ControllerRole
1855 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1856
1857class ControllerRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001858 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001859
1860 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1861 validators = serializers.SerializerMethodField("getValidators")
1862 def getHumanReadableName(self, obj):
1863 return str(obj)
1864 def getValidators(self, obj):
1865 try:
1866 return obj.getValidators()
1867 except:
1868 return None
1869 class Meta:
1870 model = ControllerRole
1871 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1872
1873
1874
1875
Scott Baker0caeaf02014-06-19 11:12:55 -07001876class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001877 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001878
Scott Bakerb744f1c2014-11-21 11:32:24 -08001879 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001880 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001881 def getHumanReadableName(self, obj):
1882 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001883 def getValidators(self, obj):
1884 try:
1885 return obj.getValidators()
1886 except:
1887 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001888 class Meta:
1889 model = NetworkParameterType
Scott Baker96eb3fd2014-11-25 00:53:25 -08001890 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001891
Scott Baker515dc9e2014-12-22 09:29:05 -08001892class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001893 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001894
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 Baker515dc9e2014-12-22 09:29:05 -08001904 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001905 model = NetworkParameterType
Scott Baker96eb3fd2014-11-25 00:53:25 -08001906 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001907
1908
Sapan Bhatiadea39432014-06-13 03:10:36 -04001909
1910
Scott Baker89a7b7c2014-10-07 00:10:17 -07001911class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001912 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001913
Scott Bakerb744f1c2014-11-21 11:32:24 -08001914 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001915 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001916 def getHumanReadableName(self, obj):
1917 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001918 def getValidators(self, obj):
1919 try:
1920 return obj.getValidators()
1921 except:
1922 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001923 class Meta:
1924 model = SiteCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001925 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001926
Scott Baker515dc9e2014-12-22 09:29:05 -08001927class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001928 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001929
Scott Bakerb744f1c2014-11-21 11:32:24 -08001930 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 Baker515dc9e2014-12-22 09:29:05 -08001939 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001940 model = SiteCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001941 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001942
1943
Scott Baker0caeaf02014-06-19 11:12:55 -07001944
1945
Scott Baker515dc9e2014-12-22 09:29:05 -08001946class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001947 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001948
Scott Bakerb744f1c2014-11-21 11:32:24 -08001949 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001950 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001951 def getHumanReadableName(self, obj):
1952 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001953 def getValidators(self, obj):
1954 try:
1955 return obj.getValidators()
1956 except:
1957 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001958 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001959 model = DeploymentPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001960 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001961
Scott Baker515dc9e2014-12-22 09:29:05 -08001962class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001963 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001964
Scott Bakerb744f1c2014-11-21 11:32:24 -08001965 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001966 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001967 def getHumanReadableName(self, obj):
1968 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001969 def getValidators(self, obj):
1970 try:
1971 return obj.getValidators()
1972 except:
1973 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001974 class Meta:
1975 model = DeploymentPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001976 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker8b533192014-11-17 22:32:19 -08001977
1978
1979
1980
Tony Mack3066a952015-01-05 22:48:11 -05001981class ControllerUserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001982 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001983
Scott Bakerb744f1c2014-11-21 11:32:24 -08001984 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001985 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001986 def getHumanReadableName(self, obj):
1987 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001988 def getValidators(self, obj):
1989 try:
1990 return obj.getValidators()
1991 except:
1992 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001993 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05001994 model = ControllerUser
Scott Baker515dc9e2014-12-22 09:29:05 -08001995 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
1996
Tony Mack3066a952015-01-05 22:48:11 -05001997class ControllerUserIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001998 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001999
2000 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2001 validators = serializers.SerializerMethodField("getValidators")
2002 def getHumanReadableName(self, obj):
2003 return str(obj)
2004 def getValidators(self, obj):
2005 try:
2006 return obj.getValidators()
2007 except:
2008 return None
2009 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002010 model = ControllerUser
Scott Baker515dc9e2014-12-22 09:29:05 -08002011 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2012
2013
2014
2015
2016class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002017 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002018
2019 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2020 validators = serializers.SerializerMethodField("getValidators")
2021 def getHumanReadableName(self, obj):
2022 return str(obj)
2023 def getValidators(self, obj):
2024 try:
2025 return obj.getValidators()
2026 except:
2027 return None
2028 class Meta:
2029 model = DeploymentRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08002030 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002031
Scott Baker515dc9e2014-12-22 09:29:05 -08002032class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002033 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002034
Scott Bakerb744f1c2014-11-21 11:32:24 -08002035 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002036 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002037 def getHumanReadableName(self, obj):
2038 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002039 def getValidators(self, obj):
2040 try:
2041 return obj.getValidators()
2042 except:
2043 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002044 class Meta:
2045 model = DeploymentRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08002046 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002047
2048
Sapan Bhatiadea39432014-06-13 03:10:36 -04002049
2050
Scott Baker89a7b7c2014-10-07 00:10:17 -07002051class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002052 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002053
Scott Bakerb744f1c2014-11-21 11:32:24 -08002054 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002055 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002056 def getHumanReadableName(self, obj):
2057 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002058 def getValidators(self, obj):
2059 try:
2060 return obj.getValidators()
2061 except:
2062 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002063 class Meta:
2064 model = UserCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08002065 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002066
Scott Baker515dc9e2014-12-22 09:29:05 -08002067class UserCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002068 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002069
Scott Bakerb744f1c2014-11-21 11:32:24 -08002070 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002071 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002072 def getHumanReadableName(self, obj):
2073 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002074 def getValidators(self, obj):
2075 try:
2076 return obj.getValidators()
2077 except:
2078 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002079 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002080 model = UserCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08002081 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08002082
2083
2084
2085
Tony Mack3066a952015-01-05 22:48:11 -05002086class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002087 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08002088
2089 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002090 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002091 def getHumanReadableName(self, obj):
2092 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002093 def getValidators(self, obj):
2094 try:
2095 return obj.getValidators()
2096 except:
2097 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08002098 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002099 model = SiteDeployment
Scott Baker515dc9e2014-12-22 09:29:05 -08002100 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08002101
Tony Mack3066a952015-01-05 22:48:11 -05002102class SiteDeploymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002103 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08002104
2105 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002106 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002107 def getHumanReadableName(self, obj):
2108 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002109 def getValidators(self, obj):
2110 try:
2111 return obj.getValidators()
2112 except:
2113 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002114 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002115 model = SiteDeployment
Scott Baker515dc9e2014-12-22 09:29:05 -08002116 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
2117
2118
Scott Baker89a7b7c2014-10-07 00:10:17 -07002119
2120
Scott Baker0caeaf02014-06-19 11:12:55 -07002121class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002122 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002123
Scott Bakerb744f1c2014-11-21 11:32:24 -08002124 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002125 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002126 def getHumanReadableName(self, obj):
2127 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002128 def getValidators(self, obj):
2129 try:
2130 return obj.getValidators()
2131 except:
2132 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002133 class Meta:
2134 model = SliceTag
Scott Baker96eb3fd2014-11-25 00:53:25 -08002135 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002136
Scott Baker515dc9e2014-12-22 09:29:05 -08002137class SliceTagIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002138 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002139
Scott Bakerb744f1c2014-11-21 11:32:24 -08002140 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002141 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002142 def getHumanReadableName(self, obj):
2143 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002144 def getValidators(self, obj):
2145 try:
2146 return obj.getValidators()
2147 except:
2148 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002149 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002150 model = SliceTag
Scott Baker96eb3fd2014-11-25 00:53:25 -08002151 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002152
2153
Scott Baker0caeaf02014-06-19 11:12:55 -07002154
2155
Scott Bakerf2c0c512014-12-22 17:35:34 -08002156class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002157 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002158
Scott Bakerb744f1c2014-11-21 11:32:24 -08002159 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002160 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002161 def getHumanReadableName(self, obj):
2162 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002163 def getValidators(self, obj):
2164 try:
2165 return obj.getValidators()
2166 except:
2167 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002168 class Meta:
Scott Bakerf2c0c512014-12-22 17:35:34 -08002169 model = NetworkTemplate
Scott Baker16fce9c2015-01-03 12:05:21 -08002170 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07002171
Scott Bakerf2c0c512014-12-22 17:35:34 -08002172class NetworkTemplateIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002173 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002174
Scott Bakerb744f1c2014-11-21 11:32:24 -08002175 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002176 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002177 def getHumanReadableName(self, obj):
2178 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002179 def getValidators(self, obj):
2180 try:
2181 return obj.getValidators()
2182 except:
2183 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002184 class Meta:
Scott Bakerf2c0c512014-12-22 17:35:34 -08002185 model = NetworkTemplate
Scott Baker16fce9c2015-01-03 12:05:21 -08002186 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07002187
2188
Sapan Bhatiadea39432014-06-13 03:10:36 -04002189
2190
2191class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002192 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002193
Scott Baker515dc9e2014-12-22 09:29:05 -08002194
2195 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2196
2197
2198
2199 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2200
2201
Scott Bakerb744f1c2014-11-21 11:32:24 -08002202 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002203 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002204 def getHumanReadableName(self, obj):
2205 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002206 def getValidators(self, obj):
2207 try:
2208 return obj.getValidators()
2209 except:
2210 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002211 class Meta:
2212 model = Router
Scott Baker515dc9e2014-12-22 09:29:05 -08002213 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002214
Scott Baker515dc9e2014-12-22 09:29:05 -08002215class RouterIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002216 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002217
Scott Baker515dc9e2014-12-22 09:29:05 -08002218
Scott Baker201f7da2014-12-23 10:56:06 -08002219 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08002220
2221
2222
Scott Baker201f7da2014-12-23 10:56:06 -08002223 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08002224
2225
Scott Bakerb744f1c2014-11-21 11:32:24 -08002226 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002227 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002228 def getHumanReadableName(self, obj):
2229 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002230 def getValidators(self, obj):
2231 try:
2232 return obj.getValidators()
2233 except:
2234 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002235 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002236 model = Router
Scott Baker515dc9e2014-12-22 09:29:05 -08002237 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002238
2239
Sapan Bhatiadea39432014-06-13 03:10:36 -04002240
2241
Scott Baker0caeaf02014-06-19 11:12:55 -07002242class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002243 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002244
Scott Bakerb744f1c2014-11-21 11:32:24 -08002245 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002246 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002247 def getHumanReadableName(self, obj):
2248 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002249 def getValidators(self, obj):
2250 try:
2251 return obj.getValidators()
2252 except:
2253 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002254 class Meta:
2255 model = ServiceResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08002256 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 -07002257
Scott Baker515dc9e2014-12-22 09:29:05 -08002258class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002259 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002260
Scott Bakerb744f1c2014-11-21 11:32:24 -08002261 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002262 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002263 def getHumanReadableName(self, obj):
2264 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002265 def getValidators(self, obj):
2266 try:
2267 return obj.getValidators()
2268 except:
2269 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002270 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002271 model = ServiceResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08002272 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 -07002273
2274
Sapan Bhatiadea39432014-06-13 03:10:36 -04002275
2276
Tony Mack3066a952015-01-05 22:48:11 -05002277class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002278 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002279
2280 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2281 validators = serializers.SerializerMethodField("getValidators")
2282 def getHumanReadableName(self, obj):
2283 return str(obj)
2284 def getValidators(self, obj):
2285 try:
2286 return obj.getValidators()
2287 except:
2288 return None
2289 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002290 model = ControllerSlice
Scott Baker515dc9e2014-12-22 09:29:05 -08002291 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2292
Tony Mack3066a952015-01-05 22:48:11 -05002293class ControllerSliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002294 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002295
2296 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2297 validators = serializers.SerializerMethodField("getValidators")
2298 def getHumanReadableName(self, obj):
2299 return str(obj)
2300 def getValidators(self, obj):
2301 try:
2302 return obj.getValidators()
2303 except:
2304 return None
2305 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002306 model = ControllerSlice
Scott Baker515dc9e2014-12-22 09:29:05 -08002307 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2308
2309
2310
2311
Sapan Bhatiadea39432014-06-13 03:10:36 -04002312serializerLookUp = {
2313
Scott Baker515dc9e2014-12-22 09:29:05 -08002314 Flavor: FlavorSerializer,
2315
Scott Baker0caeaf02014-06-19 11:12:55 -07002316 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002317
Scott Baker515dc9e2014-12-22 09:29:05 -08002318 ControllerImages: ControllerImagesSerializer,
2319
Sapan Bhatiadea39432014-06-13 03:10:36 -04002320 Image: ImageSerializer,
2321
Scott Baker0caeaf02014-06-19 11:12:55 -07002322 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002323
2324 Site: SiteSerializer,
2325
Scott Baker0caeaf02014-06-19 11:12:55 -07002326 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002327
2328 Tag: TagSerializer,
2329
2330 Invoice: InvoiceSerializer,
2331
Scott Baker0caeaf02014-06-19 11:12:55 -07002332 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002333
Scott Baker89a7b7c2014-10-07 00:10:17 -07002334 PlanetStackRole: PlanetStackRoleSerializer,
2335
Scott Baker0caeaf02014-06-19 11:12:55 -07002336 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002337
Scott Baker89a7b7c2014-10-07 00:10:17 -07002338 Project: ProjectSerializer,
2339
Sapan Bhatiadea39432014-06-13 03:10:36 -04002340 Slice: SliceSerializer,
2341
2342 Network: NetworkSerializer,
2343
2344 Service: ServiceSerializer,
2345
Scott Baker0caeaf02014-06-19 11:12:55 -07002346 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002347
Tony Mack3066a952015-01-05 22:48:11 -05002348 ControllerNetwork: ControllerNetworkSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002349
2350 Charge: ChargeSerializer,
2351
2352 Role: RoleSerializer,
2353
Scott Baker0caeaf02014-06-19 11:12:55 -07002354 UsableObject: UsableObjectSerializer,
2355
2356 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002357
Scott Baker89a7b7c2014-10-07 00:10:17 -07002358 SliceCredential: SliceCredentialSerializer,
2359
Sapan Bhatiadea39432014-06-13 03:10:36 -04002360 Sliver: SliverSerializer,
2361
2362 Node: NodeSerializer,
2363
Scott Baker0caeaf02014-06-19 11:12:55 -07002364 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002365
Scott Baker515dc9e2014-12-22 09:29:05 -08002366 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002367
Scott Bakerb744f1c2014-11-21 11:32:24 -08002368 ReservedResource: ReservedResourceSerializer,
Scott Baker8b533192014-11-17 22:32:19 -08002369
Scott Baker515dc9e2014-12-22 09:29:05 -08002370 Payment: PaymentSerializer,
2371
Scott Baker0caeaf02014-06-19 11:12:55 -07002372 NetworkSlice: NetworkSliceSerializer,
2373
2374 UserDashboardView: UserDashboardViewSerializer,
2375
Scott Baker515dc9e2014-12-22 09:29:05 -08002376 Controller: ControllerSerializer,
2377
Scott Baker0caeaf02014-06-19 11:12:55 -07002378 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002379
2380 User: UserSerializer,
2381
2382 Deployment: DeploymentSerializer,
2383
2384 Reservation: ReservationSerializer,
2385
Scott Baker0caeaf02014-06-19 11:12:55 -07002386 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002387
Scott Bakerb744f1c2014-11-21 11:32:24 -08002388 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002389
Scott Bakerf2c0c512014-12-22 17:35:34 -08002390 ControllerDashboardView: ControllerDashboardViewSerializer,
2391
Sapan Bhatiadea39432014-06-13 03:10:36 -04002392 Account: AccountSerializer,
2393
Scott Baker515dc9e2014-12-22 09:29:05 -08002394 ControllerRole: ControllerRoleSerializer,
2395
Scott Baker0caeaf02014-06-19 11:12:55 -07002396 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002397
Scott Baker89a7b7c2014-10-07 00:10:17 -07002398 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002399
Scott Baker515dc9e2014-12-22 09:29:05 -08002400 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002401
Tony Mack3066a952015-01-05 22:48:11 -05002402 ControllerUser: ControllerUserSerializer,
Scott Baker515dc9e2014-12-22 09:29:05 -08002403
2404 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002405
Scott Baker89a7b7c2014-10-07 00:10:17 -07002406 UserCredential: UserCredentialSerializer,
2407
Tony Mack3066a952015-01-05 22:48:11 -05002408 SiteDeployment: SiteDeploymentSerializer,
Scott Bakerb744f1c2014-11-21 11:32:24 -08002409
Scott Baker0caeaf02014-06-19 11:12:55 -07002410 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002411
Scott Bakerf2c0c512014-12-22 17:35:34 -08002412 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002413
2414 Router: RouterSerializer,
2415
Scott Baker0caeaf02014-06-19 11:12:55 -07002416 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002417
Tony Mack3066a952015-01-05 22:48:11 -05002418 ControllerSlice: ControllerSliceSerializer,
Scott Baker515dc9e2014-12-22 09:29:05 -08002419
Sapan Bhatiadea39432014-06-13 03:10:36 -04002420 None: None,
2421 }
2422
Scott Baker89a7b7c2014-10-07 00:10:17 -07002423class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2424
2425 # To handle fine-grained field permissions, we have to check can_update
2426 # the object has been updated but before it has been saved.
2427
2428 def update(self, request, *args, **kwargs):
2429 partial = kwargs.pop('partial', False)
2430 self.object = self.get_object_or_none()
2431
2432 serializer = self.get_serializer(self.object, data=request.DATA,
2433 files=request.FILES, partial=partial)
2434
2435 if not serializer.is_valid():
Scott Baker96eb3fd2014-11-25 00:53:25 -08002436 response = {"error": "validation",
2437 "specific_error": "not serializer.is_valid()",
2438 "reasons": serializer.errors}
2439 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002440
2441 try:
2442 self.pre_save(serializer.object)
2443 except ValidationError as err:
2444 # full_clean on model instance may be called in pre_save,
2445 # so we have to handle eventual errors.
Scott Baker96eb3fd2014-11-25 00:53:25 -08002446 response = {"error": "validation",
2447 "specific_error": "ValidationError in pre_save",
2448 "reasons": err.message_dict}
2449 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002450
2451 if serializer.object is not None:
2452 if not serializer.object.can_update(request.user):
2453 return Response(status=status.HTTP_400_BAD_REQUEST)
2454
2455 if self.object is None:
2456 self.object = serializer.save(force_insert=True)
2457 self.post_save(self.object, created=True)
2458 return Response(serializer.data, status=status.HTTP_201_CREATED)
2459
2460 self.object = serializer.save(force_update=True)
2461 self.post_save(self.object, created=False)
2462 return Response(serializer.data, status=status.HTTP_200_OK)
2463
2464 def destroy(self, request, *args, **kwargs):
2465 obj = self.get_object()
2466 if obj.can_update(request.user):
Scott Baker2bcbf372014-10-29 23:41:11 -07002467 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002468 else:
2469 return Response(status=status.HTTP_400_BAD_REQUEST)
2470
2471
Sapan Bhatiadea39432014-06-13 03:10:36 -04002472# Based on core/views/*.py
2473
2474
Scott Baker515dc9e2014-12-22 09:29:05 -08002475class FlavorList(generics.ListCreateAPIView):
2476 queryset = Flavor.objects.select_related().all()
2477 serializer_class = FlavorSerializer
2478 id_serializer_class = FlavorIdSerializer
2479 filter_backends = (filters.DjangoFilterBackend,)
2480 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
2481
2482 def get_serializer_class(self):
2483 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2484 if (no_hyperlinks):
2485 return self.id_serializer_class
2486 else:
2487 return self.serializer_class
2488
2489 def get_queryset(self):
2490 return Flavor.select_by_user(self.request.user)
2491
2492 def create(self, request, *args, **kwargs):
2493 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2494 if not (serializer.is_valid()):
2495 response = {"error": "validation",
2496 "specific_error": "not serializer.is_valid()",
2497 "reasons": serializer.errors}
2498 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2499 obj = serializer.object
2500 obj.caller = request.user
2501 if obj.can_update(request.user):
2502 return super(FlavorList, self).create(request, *args, **kwargs)
2503 else:
2504 raise Exception("failed obj.can_update")
2505
2506 ret = super(FlavorList, self).create(request, *args, **kwargs)
2507 if (ret.status_code%100 != 200):
2508 raise Exception(ret.data)
2509
2510 return ret
2511
2512
2513class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2514 queryset = Flavor.objects.select_related().all()
2515 serializer_class = FlavorSerializer
2516 id_serializer_class = FlavorIdSerializer
2517
2518 def get_serializer_class(self):
2519 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2520 if (no_hyperlinks):
2521 return self.id_serializer_class
2522 else:
2523 return self.serializer_class
2524
2525 def get_queryset(self):
2526 return Flavor.select_by_user(self.request.user)
2527
2528 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2529
2530 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2531
2532
2533
Scott Baker0caeaf02014-06-19 11:12:55 -07002534class ServiceAttributeList(generics.ListCreateAPIView):
2535 queryset = ServiceAttribute.objects.select_related().all()
2536 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002537 id_serializer_class = ServiceAttributeIdSerializer
2538 filter_backends = (filters.DjangoFilterBackend,)
2539 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2540
2541 def get_serializer_class(self):
2542 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2543 if (no_hyperlinks):
2544 return self.id_serializer_class
2545 else:
2546 return self.serializer_class
2547
Scott Baker0caeaf02014-06-19 11:12:55 -07002548 def get_queryset(self):
2549 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002550
Scott Baker0caeaf02014-06-19 11:12:55 -07002551 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002552 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2553 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002554 response = {"error": "validation",
2555 "specific_error": "not serializer.is_valid()",
2556 "reasons": serializer.errors}
2557 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002558 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002559 obj.caller = request.user
2560 if obj.can_update(request.user):
2561 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2562 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002563 raise Exception("failed obj.can_update")
2564
2565 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2566 if (ret.status_code%100 != 200):
2567 raise Exception(ret.data)
2568
2569 return ret
2570
Scott Baker0caeaf02014-06-19 11:12:55 -07002571
Scott Baker89a7b7c2014-10-07 00:10:17 -07002572class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002573 queryset = ServiceAttribute.objects.select_related().all()
2574 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002575 id_serializer_class = ServiceAttributeIdSerializer
2576
2577 def get_serializer_class(self):
2578 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2579 if (no_hyperlinks):
2580 return self.id_serializer_class
2581 else:
2582 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002583
2584 def get_queryset(self):
2585 return ServiceAttribute.select_by_user(self.request.user)
2586
Scott Baker89a7b7c2014-10-07 00:10:17 -07002587 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002588
Scott Baker89a7b7c2014-10-07 00:10:17 -07002589 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002590
2591
2592
Scott Baker515dc9e2014-12-22 09:29:05 -08002593class ControllerImagesList(generics.ListCreateAPIView):
2594 queryset = ControllerImages.objects.select_related().all()
2595 serializer_class = ControllerImagesSerializer
2596 id_serializer_class = ControllerImagesIdSerializer
2597 filter_backends = (filters.DjangoFilterBackend,)
2598 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
2599
2600 def get_serializer_class(self):
2601 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2602 if (no_hyperlinks):
2603 return self.id_serializer_class
2604 else:
2605 return self.serializer_class
2606
2607 def get_queryset(self):
2608 return ControllerImages.select_by_user(self.request.user)
2609
2610 def create(self, request, *args, **kwargs):
2611 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2612 if not (serializer.is_valid()):
2613 response = {"error": "validation",
2614 "specific_error": "not serializer.is_valid()",
2615 "reasons": serializer.errors}
2616 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2617 obj = serializer.object
2618 obj.caller = request.user
2619 if obj.can_update(request.user):
2620 return super(ControllerImagesList, self).create(request, *args, **kwargs)
2621 else:
2622 raise Exception("failed obj.can_update")
2623
2624 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2625 if (ret.status_code%100 != 200):
2626 raise Exception(ret.data)
2627
2628 return ret
2629
2630
2631class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2632 queryset = ControllerImages.objects.select_related().all()
2633 serializer_class = ControllerImagesSerializer
2634 id_serializer_class = ControllerImagesIdSerializer
2635
2636 def get_serializer_class(self):
2637 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2638 if (no_hyperlinks):
2639 return self.id_serializer_class
2640 else:
2641 return self.serializer_class
2642
2643 def get_queryset(self):
2644 return ControllerImages.select_by_user(self.request.user)
2645
2646 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2647
2648 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2649
2650
2651
Sapan Bhatiadea39432014-06-13 03:10:36 -04002652class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002653 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002654 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002655 id_serializer_class = ImageIdSerializer
2656 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08002657 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002658
2659 def get_serializer_class(self):
2660 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2661 if (no_hyperlinks):
2662 return self.id_serializer_class
2663 else:
2664 return self.serializer_class
2665
Scott Baker0caeaf02014-06-19 11:12:55 -07002666 def get_queryset(self):
2667 return Image.select_by_user(self.request.user)
2668
2669 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002670 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2671 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002672 response = {"error": "validation",
2673 "specific_error": "not serializer.is_valid()",
2674 "reasons": serializer.errors}
2675 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002676 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002677 obj.caller = request.user
2678 if obj.can_update(request.user):
2679 return super(ImageList, self).create(request, *args, **kwargs)
2680 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002681 raise Exception("failed obj.can_update")
2682
2683 ret = super(ImageList, self).create(request, *args, **kwargs)
2684 if (ret.status_code%100 != 200):
2685 raise Exception(ret.data)
2686
2687 return ret
2688
Sapan Bhatiadea39432014-06-13 03:10:36 -04002689
Scott Baker89a7b7c2014-10-07 00:10:17 -07002690class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002691 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002692 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002693 id_serializer_class = ImageIdSerializer
2694
2695 def get_serializer_class(self):
2696 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2697 if (no_hyperlinks):
2698 return self.id_serializer_class
2699 else:
2700 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002701
2702 def get_queryset(self):
2703 return Image.select_by_user(self.request.user)
2704
Scott Baker89a7b7c2014-10-07 00:10:17 -07002705 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002706
Scott Baker89a7b7c2014-10-07 00:10:17 -07002707 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002708
2709
2710
Scott Baker0caeaf02014-06-19 11:12:55 -07002711class NetworkParameterList(generics.ListCreateAPIView):
2712 queryset = NetworkParameter.objects.select_related().all()
2713 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002714 id_serializer_class = NetworkParameterIdSerializer
2715 filter_backends = (filters.DjangoFilterBackend,)
2716 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2717
2718 def get_serializer_class(self):
2719 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2720 if (no_hyperlinks):
2721 return self.id_serializer_class
2722 else:
2723 return self.serializer_class
2724
Scott Baker0caeaf02014-06-19 11:12:55 -07002725 def get_queryset(self):
2726 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002727
Scott Baker0caeaf02014-06-19 11:12:55 -07002728 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002729 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2730 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002731 response = {"error": "validation",
2732 "specific_error": "not serializer.is_valid()",
2733 "reasons": serializer.errors}
2734 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002735 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002736 obj.caller = request.user
2737 if obj.can_update(request.user):
2738 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2739 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002740 raise Exception("failed obj.can_update")
2741
2742 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2743 if (ret.status_code%100 != 200):
2744 raise Exception(ret.data)
2745
2746 return ret
2747
Scott Baker0caeaf02014-06-19 11:12:55 -07002748
Scott Baker89a7b7c2014-10-07 00:10:17 -07002749class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002750 queryset = NetworkParameter.objects.select_related().all()
2751 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002752 id_serializer_class = NetworkParameterIdSerializer
2753
2754 def get_serializer_class(self):
2755 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2756 if (no_hyperlinks):
2757 return self.id_serializer_class
2758 else:
2759 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002760
2761 def get_queryset(self):
2762 return NetworkParameter.select_by_user(self.request.user)
2763
Scott Baker89a7b7c2014-10-07 00:10:17 -07002764 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002765
Scott Baker89a7b7c2014-10-07 00:10:17 -07002766 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002767
2768
2769
2770class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002771 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002772 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002773 id_serializer_class = SiteIdSerializer
2774 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08002775 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002776
2777 def get_serializer_class(self):
2778 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2779 if (no_hyperlinks):
2780 return self.id_serializer_class
2781 else:
2782 return self.serializer_class
2783
Scott Baker0caeaf02014-06-19 11:12:55 -07002784 def get_queryset(self):
2785 return Site.select_by_user(self.request.user)
2786
2787 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002788 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2789 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002790 response = {"error": "validation",
2791 "specific_error": "not serializer.is_valid()",
2792 "reasons": serializer.errors}
2793 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002794 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002795 obj.caller = request.user
2796 if obj.can_update(request.user):
2797 return super(SiteList, self).create(request, *args, **kwargs)
2798 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002799 raise Exception("failed obj.can_update")
2800
2801 ret = super(SiteList, self).create(request, *args, **kwargs)
2802 if (ret.status_code%100 != 200):
2803 raise Exception(ret.data)
2804
2805 return ret
2806
Sapan Bhatiadea39432014-06-13 03:10:36 -04002807
Scott Baker89a7b7c2014-10-07 00:10:17 -07002808class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002809 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002810 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002811 id_serializer_class = SiteIdSerializer
2812
2813 def get_serializer_class(self):
2814 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2815 if (no_hyperlinks):
2816 return self.id_serializer_class
2817 else:
2818 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002819
2820 def get_queryset(self):
2821 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002822
Scott Baker89a7b7c2014-10-07 00:10:17 -07002823 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002824
Scott Baker89a7b7c2014-10-07 00:10:17 -07002825 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002826
2827
2828
2829class SliceRoleList(generics.ListCreateAPIView):
2830 queryset = SliceRole.objects.select_related().all()
2831 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002832 id_serializer_class = SliceRoleIdSerializer
2833 filter_backends = (filters.DjangoFilterBackend,)
2834 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2835
2836 def get_serializer_class(self):
2837 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2838 if (no_hyperlinks):
2839 return self.id_serializer_class
2840 else:
2841 return self.serializer_class
2842
Scott Baker0caeaf02014-06-19 11:12:55 -07002843 def get_queryset(self):
2844 return SliceRole.select_by_user(self.request.user)
2845
2846 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002847 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2848 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002849 response = {"error": "validation",
2850 "specific_error": "not serializer.is_valid()",
2851 "reasons": serializer.errors}
2852 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002853 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002854 obj.caller = request.user
2855 if obj.can_update(request.user):
2856 return super(SliceRoleList, self).create(request, *args, **kwargs)
2857 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002858 raise Exception("failed obj.can_update")
2859
2860 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2861 if (ret.status_code%100 != 200):
2862 raise Exception(ret.data)
2863
2864 return ret
2865
Scott Baker0caeaf02014-06-19 11:12:55 -07002866
Scott Baker89a7b7c2014-10-07 00:10:17 -07002867class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002868 queryset = SliceRole.objects.select_related().all()
2869 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002870 id_serializer_class = SliceRoleIdSerializer
2871
2872 def get_serializer_class(self):
2873 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2874 if (no_hyperlinks):
2875 return self.id_serializer_class
2876 else:
2877 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002878
2879 def get_queryset(self):
2880 return SliceRole.select_by_user(self.request.user)
2881
Scott Baker89a7b7c2014-10-07 00:10:17 -07002882 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002883
Scott Baker89a7b7c2014-10-07 00:10:17 -07002884 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002885
2886
2887
2888class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002889 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002890 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002891 id_serializer_class = TagIdSerializer
2892 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002893 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002894
2895 def get_serializer_class(self):
2896 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2897 if (no_hyperlinks):
2898 return self.id_serializer_class
2899 else:
2900 return self.serializer_class
2901
Scott Baker0caeaf02014-06-19 11:12:55 -07002902 def get_queryset(self):
2903 return Tag.select_by_user(self.request.user)
2904
2905 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002906 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2907 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002908 response = {"error": "validation",
2909 "specific_error": "not serializer.is_valid()",
2910 "reasons": serializer.errors}
2911 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002912 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002913 obj.caller = request.user
2914 if obj.can_update(request.user):
2915 return super(TagList, self).create(request, *args, **kwargs)
2916 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002917 raise Exception("failed obj.can_update")
2918
2919 ret = super(TagList, self).create(request, *args, **kwargs)
2920 if (ret.status_code%100 != 200):
2921 raise Exception(ret.data)
2922
2923 return ret
2924
Sapan Bhatiadea39432014-06-13 03:10:36 -04002925
Scott Baker89a7b7c2014-10-07 00:10:17 -07002926class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002927 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002928 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002929 id_serializer_class = TagIdSerializer
2930
2931 def get_serializer_class(self):
2932 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2933 if (no_hyperlinks):
2934 return self.id_serializer_class
2935 else:
2936 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002937
2938 def get_queryset(self):
2939 return Tag.select_by_user(self.request.user)
2940
Scott Baker89a7b7c2014-10-07 00:10:17 -07002941 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002942
Scott Baker89a7b7c2014-10-07 00:10:17 -07002943 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002944
2945
2946
2947class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002948 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002949 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002950 id_serializer_class = InvoiceIdSerializer
2951 filter_backends = (filters.DjangoFilterBackend,)
2952 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
2953
2954 def get_serializer_class(self):
2955 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2956 if (no_hyperlinks):
2957 return self.id_serializer_class
2958 else:
2959 return self.serializer_class
2960
Scott Baker0caeaf02014-06-19 11:12:55 -07002961 def get_queryset(self):
2962 return Invoice.select_by_user(self.request.user)
2963
2964 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002965 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2966 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002967 response = {"error": "validation",
2968 "specific_error": "not serializer.is_valid()",
2969 "reasons": serializer.errors}
2970 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002971 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002972 obj.caller = request.user
2973 if obj.can_update(request.user):
2974 return super(InvoiceList, self).create(request, *args, **kwargs)
2975 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002976 raise Exception("failed obj.can_update")
2977
2978 ret = super(InvoiceList, self).create(request, *args, **kwargs)
2979 if (ret.status_code%100 != 200):
2980 raise Exception(ret.data)
2981
2982 return ret
2983
Sapan Bhatiadea39432014-06-13 03:10:36 -04002984
Scott Baker89a7b7c2014-10-07 00:10:17 -07002985class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002986 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002987 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002988 id_serializer_class = InvoiceIdSerializer
2989
2990 def get_serializer_class(self):
2991 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2992 if (no_hyperlinks):
2993 return self.id_serializer_class
2994 else:
2995 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002996
2997 def get_queryset(self):
2998 return Invoice.select_by_user(self.request.user)
2999
Scott Baker89a7b7c2014-10-07 00:10:17 -07003000 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003001
Scott Baker89a7b7c2014-10-07 00:10:17 -07003002 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003003
3004
3005
Scott Baker0caeaf02014-06-19 11:12:55 -07003006class SlicePrivilegeList(generics.ListCreateAPIView):
3007 queryset = SlicePrivilege.objects.select_related().all()
3008 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003009 id_serializer_class = SlicePrivilegeIdSerializer
3010 filter_backends = (filters.DjangoFilterBackend,)
3011 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
3012
3013 def get_serializer_class(self):
3014 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3015 if (no_hyperlinks):
3016 return self.id_serializer_class
3017 else:
3018 return self.serializer_class
3019
Scott Baker0caeaf02014-06-19 11:12:55 -07003020 def get_queryset(self):
3021 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003022
Scott Baker0caeaf02014-06-19 11:12:55 -07003023 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003024 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3025 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003026 response = {"error": "validation",
3027 "specific_error": "not serializer.is_valid()",
3028 "reasons": serializer.errors}
3029 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003030 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003031 obj.caller = request.user
3032 if obj.can_update(request.user):
3033 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3034 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003035 raise Exception("failed obj.can_update")
3036
3037 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3038 if (ret.status_code%100 != 200):
3039 raise Exception(ret.data)
3040
3041 return ret
3042
Scott Baker0caeaf02014-06-19 11:12:55 -07003043
Scott Baker89a7b7c2014-10-07 00:10:17 -07003044class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003045 queryset = SlicePrivilege.objects.select_related().all()
3046 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003047 id_serializer_class = SlicePrivilegeIdSerializer
3048
3049 def get_serializer_class(self):
3050 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3051 if (no_hyperlinks):
3052 return self.id_serializer_class
3053 else:
3054 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003055
3056 def get_queryset(self):
3057 return SlicePrivilege.select_by_user(self.request.user)
3058
Scott Baker89a7b7c2014-10-07 00:10:17 -07003059 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3060
3061 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3062
3063
3064
3065class PlanetStackRoleList(generics.ListCreateAPIView):
3066 queryset = PlanetStackRole.objects.select_related().all()
3067 serializer_class = PlanetStackRoleSerializer
3068 id_serializer_class = PlanetStackRoleIdSerializer
3069 filter_backends = (filters.DjangoFilterBackend,)
3070 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3071
3072 def get_serializer_class(self):
3073 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3074 if (no_hyperlinks):
3075 return self.id_serializer_class
3076 else:
3077 return self.serializer_class
3078
3079 def get_queryset(self):
3080 return PlanetStackRole.select_by_user(self.request.user)
3081
3082 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003083 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3084 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003085 response = {"error": "validation",
3086 "specific_error": "not serializer.is_valid()",
3087 "reasons": serializer.errors}
3088 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003089 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003090 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003091 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003092 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003093 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003094 raise Exception("failed obj.can_update")
3095
3096 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3097 if (ret.status_code%100 != 200):
3098 raise Exception(ret.data)
3099
3100 return ret
3101
Scott Baker0caeaf02014-06-19 11:12:55 -07003102
Scott Baker89a7b7c2014-10-07 00:10:17 -07003103class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3104 queryset = PlanetStackRole.objects.select_related().all()
3105 serializer_class = PlanetStackRoleSerializer
3106 id_serializer_class = PlanetStackRoleIdSerializer
3107
3108 def get_serializer_class(self):
3109 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3110 if (no_hyperlinks):
3111 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003112 else:
Scott Baker89a7b7c2014-10-07 00:10:17 -07003113 return self.serializer_class
3114
3115 def get_queryset(self):
3116 return PlanetStackRole.select_by_user(self.request.user)
3117
3118 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3119
3120 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003121
3122
3123
Scott Baker0caeaf02014-06-19 11:12:55 -07003124class NetworkSliverList(generics.ListCreateAPIView):
3125 queryset = NetworkSliver.objects.select_related().all()
3126 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003127 id_serializer_class = NetworkSliverIdSerializer
3128 filter_backends = (filters.DjangoFilterBackend,)
3129 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
3130
3131 def get_serializer_class(self):
3132 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3133 if (no_hyperlinks):
3134 return self.id_serializer_class
3135 else:
3136 return self.serializer_class
3137
Scott Baker0caeaf02014-06-19 11:12:55 -07003138 def get_queryset(self):
3139 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003140
Scott Baker0caeaf02014-06-19 11:12:55 -07003141 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003142 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3143 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003144 response = {"error": "validation",
3145 "specific_error": "not serializer.is_valid()",
3146 "reasons": serializer.errors}
3147 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003148 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003149 obj.caller = request.user
3150 if obj.can_update(request.user):
3151 return super(NetworkSliverList, self).create(request, *args, **kwargs)
3152 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003153 raise Exception("failed obj.can_update")
3154
3155 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3156 if (ret.status_code%100 != 200):
3157 raise Exception(ret.data)
3158
3159 return ret
3160
Scott Baker0caeaf02014-06-19 11:12:55 -07003161
Scott Baker89a7b7c2014-10-07 00:10:17 -07003162class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003163 queryset = NetworkSliver.objects.select_related().all()
3164 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003165 id_serializer_class = NetworkSliverIdSerializer
3166
3167 def get_serializer_class(self):
3168 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3169 if (no_hyperlinks):
3170 return self.id_serializer_class
3171 else:
3172 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003173
3174 def get_queryset(self):
3175 return NetworkSliver.select_by_user(self.request.user)
3176
Scott Baker89a7b7c2014-10-07 00:10:17 -07003177 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003178
Scott Baker89a7b7c2014-10-07 00:10:17 -07003179 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003180
3181
3182
Scott Baker0caeaf02014-06-19 11:12:55 -07003183class ProjectList(generics.ListCreateAPIView):
3184 queryset = Project.objects.select_related().all()
3185 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003186 id_serializer_class = ProjectIdSerializer
3187 filter_backends = (filters.DjangoFilterBackend,)
3188 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3189
3190 def get_serializer_class(self):
3191 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3192 if (no_hyperlinks):
3193 return self.id_serializer_class
3194 else:
3195 return self.serializer_class
3196
Scott Baker0caeaf02014-06-19 11:12:55 -07003197 def get_queryset(self):
3198 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003199
Scott Baker0caeaf02014-06-19 11:12:55 -07003200 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003201 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3202 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003203 response = {"error": "validation",
3204 "specific_error": "not serializer.is_valid()",
3205 "reasons": serializer.errors}
3206 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003207 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003208 obj.caller = request.user
3209 if obj.can_update(request.user):
3210 return super(ProjectList, self).create(request, *args, **kwargs)
3211 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003212 raise Exception("failed obj.can_update")
3213
3214 ret = super(ProjectList, self).create(request, *args, **kwargs)
3215 if (ret.status_code%100 != 200):
3216 raise Exception(ret.data)
3217
3218 return ret
3219
Scott Baker0caeaf02014-06-19 11:12:55 -07003220
Scott Baker89a7b7c2014-10-07 00:10:17 -07003221class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003222 queryset = Project.objects.select_related().all()
3223 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003224 id_serializer_class = ProjectIdSerializer
3225
3226 def get_serializer_class(self):
3227 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3228 if (no_hyperlinks):
3229 return self.id_serializer_class
3230 else:
3231 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003232
3233 def get_queryset(self):
3234 return Project.select_by_user(self.request.user)
3235
Scott Baker89a7b7c2014-10-07 00:10:17 -07003236 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3237
3238 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3239
3240
3241
3242class SliceList(generics.ListCreateAPIView):
3243 queryset = Slice.objects.select_related().all()
3244 serializer_class = SliceSerializer
3245 id_serializer_class = SliceIdSerializer
3246 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003247 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','networks',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003248
3249 def get_serializer_class(self):
3250 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3251 if (no_hyperlinks):
3252 return self.id_serializer_class
3253 else:
3254 return self.serializer_class
3255
3256 def get_queryset(self):
3257 return Slice.select_by_user(self.request.user)
3258
3259 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003260 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3261 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003262 response = {"error": "validation",
3263 "specific_error": "not serializer.is_valid()",
3264 "reasons": serializer.errors}
3265 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003266 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003267 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003268 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003269 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003270 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003271 raise Exception("failed obj.can_update")
3272
3273 ret = super(SliceList, self).create(request, *args, **kwargs)
3274 if (ret.status_code%100 != 200):
3275 raise Exception(ret.data)
3276
3277 return ret
3278
Scott Baker0caeaf02014-06-19 11:12:55 -07003279
Scott Baker89a7b7c2014-10-07 00:10:17 -07003280class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3281 queryset = Slice.objects.select_related().all()
3282 serializer_class = SliceSerializer
3283 id_serializer_class = SliceIdSerializer
3284
3285 def get_serializer_class(self):
3286 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3287 if (no_hyperlinks):
3288 return self.id_serializer_class
3289 else:
3290 return self.serializer_class
3291
3292 def get_queryset(self):
3293 return Slice.select_by_user(self.request.user)
3294
3295 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3296
3297 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3298
3299
3300
3301class NetworkList(generics.ListCreateAPIView):
3302 queryset = Network.objects.select_related().all()
3303 serializer_class = NetworkSerializer
3304 id_serializer_class = NetworkIdSerializer
3305 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerd188c012015-01-03 12:32:45 -08003306 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003307
3308 def get_serializer_class(self):
3309 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3310 if (no_hyperlinks):
3311 return self.id_serializer_class
3312 else:
3313 return self.serializer_class
3314
3315 def get_queryset(self):
3316 return Network.select_by_user(self.request.user)
3317
3318 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003319 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3320 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003321 response = {"error": "validation",
3322 "specific_error": "not serializer.is_valid()",
3323 "reasons": serializer.errors}
3324 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003325 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003326 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003327 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003328 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003329 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003330 raise Exception("failed obj.can_update")
3331
3332 ret = super(NetworkList, self).create(request, *args, **kwargs)
3333 if (ret.status_code%100 != 200):
3334 raise Exception(ret.data)
3335
3336 return ret
3337
Scott Baker89a7b7c2014-10-07 00:10:17 -07003338
3339class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3340 queryset = Network.objects.select_related().all()
3341 serializer_class = NetworkSerializer
3342 id_serializer_class = NetworkIdSerializer
3343
3344 def get_serializer_class(self):
3345 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3346 if (no_hyperlinks):
3347 return self.id_serializer_class
3348 else:
3349 return self.serializer_class
3350
3351 def get_queryset(self):
3352 return Network.select_by_user(self.request.user)
3353
3354 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3355
3356 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3357
3358
3359
3360class ServiceList(generics.ListCreateAPIView):
3361 queryset = Service.objects.select_related().all()
3362 serializer_class = ServiceSerializer
3363 id_serializer_class = ServiceIdSerializer
3364 filter_backends = (filters.DjangoFilterBackend,)
3365 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3366
3367 def get_serializer_class(self):
3368 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3369 if (no_hyperlinks):
3370 return self.id_serializer_class
3371 else:
3372 return self.serializer_class
3373
3374 def get_queryset(self):
3375 return Service.select_by_user(self.request.user)
3376
3377 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003378 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3379 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003380 response = {"error": "validation",
3381 "specific_error": "not serializer.is_valid()",
3382 "reasons": serializer.errors}
3383 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003384 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003385 obj.caller = request.user
3386 if obj.can_update(request.user):
3387 return super(ServiceList, self).create(request, *args, **kwargs)
3388 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003389 raise Exception("failed obj.can_update")
3390
3391 ret = super(ServiceList, self).create(request, *args, **kwargs)
3392 if (ret.status_code%100 != 200):
3393 raise Exception(ret.data)
3394
3395 return ret
3396
Scott Baker89a7b7c2014-10-07 00:10:17 -07003397
3398class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3399 queryset = Service.objects.select_related().all()
3400 serializer_class = ServiceSerializer
3401 id_serializer_class = ServiceIdSerializer
3402
3403 def get_serializer_class(self):
3404 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3405 if (no_hyperlinks):
3406 return self.id_serializer_class
3407 else:
3408 return self.serializer_class
3409
3410 def get_queryset(self):
3411 return Service.select_by_user(self.request.user)
3412
3413 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3414
3415 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3416
3417
3418
3419class ServiceClassList(generics.ListCreateAPIView):
3420 queryset = ServiceClass.objects.select_related().all()
3421 serializer_class = ServiceClassSerializer
3422 id_serializer_class = ServiceClassIdSerializer
3423 filter_backends = (filters.DjangoFilterBackend,)
3424 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3425
3426 def get_serializer_class(self):
3427 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3428 if (no_hyperlinks):
3429 return self.id_serializer_class
3430 else:
3431 return self.serializer_class
3432
3433 def get_queryset(self):
3434 return ServiceClass.select_by_user(self.request.user)
3435
3436 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003437 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3438 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003439 response = {"error": "validation",
3440 "specific_error": "not serializer.is_valid()",
3441 "reasons": serializer.errors}
3442 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003443 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003444 obj.caller = request.user
3445 if obj.can_update(request.user):
3446 return super(ServiceClassList, self).create(request, *args, **kwargs)
3447 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003448 raise Exception("failed obj.can_update")
3449
3450 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3451 if (ret.status_code%100 != 200):
3452 raise Exception(ret.data)
3453
3454 return ret
3455
Scott Baker89a7b7c2014-10-07 00:10:17 -07003456
3457class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3458 queryset = ServiceClass.objects.select_related().all()
3459 serializer_class = ServiceClassSerializer
3460 id_serializer_class = ServiceClassIdSerializer
3461
3462 def get_serializer_class(self):
3463 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3464 if (no_hyperlinks):
3465 return self.id_serializer_class
3466 else:
3467 return self.serializer_class
3468
3469 def get_queryset(self):
3470 return ServiceClass.select_by_user(self.request.user)
3471
3472 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3473
3474 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3475
3476
3477
Tony Mack3066a952015-01-05 22:48:11 -05003478class ControllerNetworkList(generics.ListCreateAPIView):
3479 queryset = ControllerNetwork.objects.select_related().all()
3480 serializer_class = ControllerNetworkSerializer
3481 id_serializer_class = ControllerNetworkIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003482 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003483 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003484
3485 def get_serializer_class(self):
3486 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3487 if (no_hyperlinks):
3488 return self.id_serializer_class
3489 else:
3490 return self.serializer_class
3491
3492 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05003493 return ControllerNetwork.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003494
3495 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003496 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3497 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003498 response = {"error": "validation",
3499 "specific_error": "not serializer.is_valid()",
3500 "reasons": serializer.errors}
3501 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003502 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003503 obj.caller = request.user
3504 if obj.can_update(request.user):
Tony Mack3066a952015-01-05 22:48:11 -05003505 return super(ControllerNetworkList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003506 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003507 raise Exception("failed obj.can_update")
3508
Tony Mack3066a952015-01-05 22:48:11 -05003509 ret = super(ControllerNetworkList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07003510 if (ret.status_code%100 != 200):
3511 raise Exception(ret.data)
3512
3513 return ret
3514
Scott Baker89a7b7c2014-10-07 00:10:17 -07003515
Tony Mack3066a952015-01-05 22:48:11 -05003516class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3517 queryset = ControllerNetwork.objects.select_related().all()
3518 serializer_class = ControllerNetworkSerializer
3519 id_serializer_class = ControllerNetworkIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003520
3521 def get_serializer_class(self):
3522 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3523 if (no_hyperlinks):
3524 return self.id_serializer_class
3525 else:
3526 return self.serializer_class
3527
3528 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05003529 return ControllerNetwork.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003530
3531 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3532
3533 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3534
3535
3536
3537class ChargeList(generics.ListCreateAPIView):
3538 queryset = Charge.objects.select_related().all()
3539 serializer_class = ChargeSerializer
3540 id_serializer_class = ChargeIdSerializer
3541 filter_backends = (filters.DjangoFilterBackend,)
3542 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3543
3544 def get_serializer_class(self):
3545 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3546 if (no_hyperlinks):
3547 return self.id_serializer_class
3548 else:
3549 return self.serializer_class
3550
3551 def get_queryset(self):
3552 return Charge.select_by_user(self.request.user)
3553
3554 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003555 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3556 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003557 response = {"error": "validation",
3558 "specific_error": "not serializer.is_valid()",
3559 "reasons": serializer.errors}
3560 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003561 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003562 obj.caller = request.user
3563 if obj.can_update(request.user):
3564 return super(ChargeList, self).create(request, *args, **kwargs)
3565 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003566 raise Exception("failed obj.can_update")
3567
3568 ret = super(ChargeList, self).create(request, *args, **kwargs)
3569 if (ret.status_code%100 != 200):
3570 raise Exception(ret.data)
3571
3572 return ret
3573
Scott Baker89a7b7c2014-10-07 00:10:17 -07003574
3575class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3576 queryset = Charge.objects.select_related().all()
3577 serializer_class = ChargeSerializer
3578 id_serializer_class = ChargeIdSerializer
3579
3580 def get_serializer_class(self):
3581 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3582 if (no_hyperlinks):
3583 return self.id_serializer_class
3584 else:
3585 return self.serializer_class
3586
3587 def get_queryset(self):
3588 return Charge.select_by_user(self.request.user)
3589
3590 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3591
3592 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3593
3594
3595
3596class RoleList(generics.ListCreateAPIView):
3597 queryset = Role.objects.select_related().all()
3598 serializer_class = RoleSerializer
3599 id_serializer_class = RoleIdSerializer
3600 filter_backends = (filters.DjangoFilterBackend,)
3601 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3602
3603 def get_serializer_class(self):
3604 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3605 if (no_hyperlinks):
3606 return self.id_serializer_class
3607 else:
3608 return self.serializer_class
3609
3610 def get_queryset(self):
3611 return Role.select_by_user(self.request.user)
3612
3613 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003614 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3615 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003616 response = {"error": "validation",
3617 "specific_error": "not serializer.is_valid()",
3618 "reasons": serializer.errors}
3619 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003620 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003621 obj.caller = request.user
3622 if obj.can_update(request.user):
3623 return super(RoleList, self).create(request, *args, **kwargs)
3624 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003625 raise Exception("failed obj.can_update")
3626
3627 ret = super(RoleList, self).create(request, *args, **kwargs)
3628 if (ret.status_code%100 != 200):
3629 raise Exception(ret.data)
3630
3631 return ret
3632
Scott Baker89a7b7c2014-10-07 00:10:17 -07003633
3634class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3635 queryset = Role.objects.select_related().all()
3636 serializer_class = RoleSerializer
3637 id_serializer_class = RoleIdSerializer
3638
3639 def get_serializer_class(self):
3640 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3641 if (no_hyperlinks):
3642 return self.id_serializer_class
3643 else:
3644 return self.serializer_class
3645
3646 def get_queryset(self):
3647 return Role.select_by_user(self.request.user)
3648
3649 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3650
3651 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3652
3653
3654
3655class UsableObjectList(generics.ListCreateAPIView):
3656 queryset = UsableObject.objects.select_related().all()
3657 serializer_class = UsableObjectSerializer
3658 id_serializer_class = UsableObjectIdSerializer
3659 filter_backends = (filters.DjangoFilterBackend,)
3660 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3661
3662 def get_serializer_class(self):
3663 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3664 if (no_hyperlinks):
3665 return self.id_serializer_class
3666 else:
3667 return self.serializer_class
3668
3669 def get_queryset(self):
3670 return UsableObject.select_by_user(self.request.user)
3671
3672 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003673 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3674 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003675 response = {"error": "validation",
3676 "specific_error": "not serializer.is_valid()",
3677 "reasons": serializer.errors}
3678 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003679 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003680 obj.caller = request.user
3681 if obj.can_update(request.user):
3682 return super(UsableObjectList, self).create(request, *args, **kwargs)
3683 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003684 raise Exception("failed obj.can_update")
3685
3686 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3687 if (ret.status_code%100 != 200):
3688 raise Exception(ret.data)
3689
3690 return ret
3691
Scott Baker89a7b7c2014-10-07 00:10:17 -07003692
3693class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3694 queryset = UsableObject.objects.select_related().all()
3695 serializer_class = UsableObjectSerializer
3696 id_serializer_class = UsableObjectIdSerializer
3697
3698 def get_serializer_class(self):
3699 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3700 if (no_hyperlinks):
3701 return self.id_serializer_class
3702 else:
3703 return self.serializer_class
3704
3705 def get_queryset(self):
3706 return UsableObject.select_by_user(self.request.user)
3707
3708 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3709
3710 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3711
3712
Scott Baker89a7b7c2014-10-07 00:10:17 -07003713class SiteRoleList(generics.ListCreateAPIView):
3714 queryset = SiteRole.objects.select_related().all()
3715 serializer_class = SiteRoleSerializer
3716 id_serializer_class = SiteRoleIdSerializer
3717 filter_backends = (filters.DjangoFilterBackend,)
3718 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3719
3720 def get_serializer_class(self):
3721 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3722 if (no_hyperlinks):
3723 return self.id_serializer_class
3724 else:
3725 return self.serializer_class
3726
3727 def get_queryset(self):
3728 return SiteRole.select_by_user(self.request.user)
3729
3730 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003731 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3732 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003733 response = {"error": "validation",
3734 "specific_error": "not serializer.is_valid()",
3735 "reasons": serializer.errors}
3736 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003737 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003738 obj.caller = request.user
3739 if obj.can_update(request.user):
3740 return super(SiteRoleList, self).create(request, *args, **kwargs)
3741 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003742 raise Exception("failed obj.can_update")
3743
3744 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3745 if (ret.status_code%100 != 200):
3746 raise Exception(ret.data)
3747
3748 return ret
3749
Scott Baker89a7b7c2014-10-07 00:10:17 -07003750
3751class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3752 queryset = SiteRole.objects.select_related().all()
3753 serializer_class = SiteRoleSerializer
3754 id_serializer_class = SiteRoleIdSerializer
3755
3756 def get_serializer_class(self):
3757 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3758 if (no_hyperlinks):
3759 return self.id_serializer_class
3760 else:
3761 return self.serializer_class
3762
3763 def get_queryset(self):
3764 return SiteRole.select_by_user(self.request.user)
3765
3766 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3767
3768 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3769
3770
3771
3772class SliceCredentialList(generics.ListCreateAPIView):
3773 queryset = SliceCredential.objects.select_related().all()
3774 serializer_class = SliceCredentialSerializer
3775 id_serializer_class = SliceCredentialIdSerializer
3776 filter_backends = (filters.DjangoFilterBackend,)
3777 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3778
3779 def get_serializer_class(self):
3780 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3781 if (no_hyperlinks):
3782 return self.id_serializer_class
3783 else:
3784 return self.serializer_class
3785
3786 def get_queryset(self):
3787 return SliceCredential.select_by_user(self.request.user)
3788
3789 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003790 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3791 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003792 response = {"error": "validation",
3793 "specific_error": "not serializer.is_valid()",
3794 "reasons": serializer.errors}
3795 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003796 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003797 obj.caller = request.user
3798 if obj.can_update(request.user):
3799 return super(SliceCredentialList, self).create(request, *args, **kwargs)
3800 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003801 raise Exception("failed obj.can_update")
3802
3803 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
3804 if (ret.status_code%100 != 200):
3805 raise Exception(ret.data)
3806
3807 return ret
3808
Scott Baker89a7b7c2014-10-07 00:10:17 -07003809
3810class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3811 queryset = SliceCredential.objects.select_related().all()
3812 serializer_class = SliceCredentialSerializer
3813 id_serializer_class = SliceCredentialIdSerializer
3814
3815 def get_serializer_class(self):
3816 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3817 if (no_hyperlinks):
3818 return self.id_serializer_class
3819 else:
3820 return self.serializer_class
3821
3822 def get_queryset(self):
3823 return SliceCredential.select_by_user(self.request.user)
3824
3825 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3826
3827 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3828
3829
3830
3831class SliverList(generics.ListCreateAPIView):
3832 queryset = Sliver.objects.select_related().all()
3833 serializer_class = SliverSerializer
3834 id_serializer_class = SliverIdSerializer
3835 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker16fce9c2015-01-03 12:05:21 -08003836 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003837
3838 def get_serializer_class(self):
3839 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3840 if (no_hyperlinks):
3841 return self.id_serializer_class
3842 else:
3843 return self.serializer_class
3844
3845 def get_queryset(self):
3846 return Sliver.select_by_user(self.request.user)
3847
3848 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003849 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3850 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003851 response = {"error": "validation",
3852 "specific_error": "not serializer.is_valid()",
3853 "reasons": serializer.errors}
3854 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003855 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003856 obj.caller = request.user
3857 if obj.can_update(request.user):
3858 return super(SliverList, self).create(request, *args, **kwargs)
3859 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003860 raise Exception("failed obj.can_update")
3861
3862 ret = super(SliverList, self).create(request, *args, **kwargs)
3863 if (ret.status_code%100 != 200):
3864 raise Exception(ret.data)
3865
3866 return ret
3867
Scott Baker89a7b7c2014-10-07 00:10:17 -07003868
3869class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3870 queryset = Sliver.objects.select_related().all()
3871 serializer_class = SliverSerializer
3872 id_serializer_class = SliverIdSerializer
3873
3874 def get_serializer_class(self):
3875 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3876 if (no_hyperlinks):
3877 return self.id_serializer_class
3878 else:
3879 return self.serializer_class
3880
3881 def get_queryset(self):
3882 return Sliver.select_by_user(self.request.user)
3883
3884 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3885
3886 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3887
3888
3889
3890class NodeList(generics.ListCreateAPIView):
3891 queryset = Node.objects.select_related().all()
3892 serializer_class = NodeSerializer
3893 id_serializer_class = NodeIdSerializer
3894 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003895 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003896
3897 def get_serializer_class(self):
3898 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3899 if (no_hyperlinks):
3900 return self.id_serializer_class
3901 else:
3902 return self.serializer_class
3903
3904 def get_queryset(self):
3905 return Node.select_by_user(self.request.user)
3906
3907 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003908 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3909 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003910 response = {"error": "validation",
3911 "specific_error": "not serializer.is_valid()",
3912 "reasons": serializer.errors}
3913 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003914 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003915 obj.caller = request.user
3916 if obj.can_update(request.user):
3917 return super(NodeList, self).create(request, *args, **kwargs)
3918 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003919 raise Exception("failed obj.can_update")
3920
3921 ret = super(NodeList, self).create(request, *args, **kwargs)
3922 if (ret.status_code%100 != 200):
3923 raise Exception(ret.data)
3924
3925 return ret
3926
Scott Baker89a7b7c2014-10-07 00:10:17 -07003927
3928class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3929 queryset = Node.objects.select_related().all()
3930 serializer_class = NodeSerializer
3931 id_serializer_class = NodeIdSerializer
3932
3933 def get_serializer_class(self):
3934 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3935 if (no_hyperlinks):
3936 return self.id_serializer_class
3937 else:
3938 return self.serializer_class
3939
3940 def get_queryset(self):
3941 return Node.select_by_user(self.request.user)
3942
3943 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3944
3945 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3946
3947
3948
3949class DashboardViewList(generics.ListCreateAPIView):
3950 queryset = DashboardView.objects.select_related().all()
3951 serializer_class = DashboardViewSerializer
3952 id_serializer_class = DashboardViewIdSerializer
3953 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003954 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003955
3956 def get_serializer_class(self):
3957 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3958 if (no_hyperlinks):
3959 return self.id_serializer_class
3960 else:
3961 return self.serializer_class
3962
3963 def get_queryset(self):
3964 return DashboardView.select_by_user(self.request.user)
3965
3966 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003967 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3968 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003969 response = {"error": "validation",
3970 "specific_error": "not serializer.is_valid()",
3971 "reasons": serializer.errors}
3972 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003973 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003974 obj.caller = request.user
3975 if obj.can_update(request.user):
3976 return super(DashboardViewList, self).create(request, *args, **kwargs)
3977 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003978 raise Exception("failed obj.can_update")
3979
3980 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
3981 if (ret.status_code%100 != 200):
3982 raise Exception(ret.data)
3983
3984 return ret
3985
Scott Baker89a7b7c2014-10-07 00:10:17 -07003986
3987class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3988 queryset = DashboardView.objects.select_related().all()
3989 serializer_class = DashboardViewSerializer
3990 id_serializer_class = DashboardViewIdSerializer
3991
3992 def get_serializer_class(self):
3993 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3994 if (no_hyperlinks):
3995 return self.id_serializer_class
3996 else:
3997 return self.serializer_class
3998
3999 def get_queryset(self):
4000 return DashboardView.select_by_user(self.request.user)
4001
4002 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4003
4004 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4005
Scott Baker89a7b7c2014-10-07 00:10:17 -07004006
Scott Baker57c725c2014-11-12 01:13:53 -08004007
Scott Baker515dc9e2014-12-22 09:29:05 -08004008class ImageDeploymentsList(generics.ListCreateAPIView):
4009 queryset = ImageDeployments.objects.select_related().all()
4010 serializer_class = ImageDeploymentsSerializer
4011 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004012 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08004013 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004014
4015 def get_serializer_class(self):
4016 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4017 if (no_hyperlinks):
4018 return self.id_serializer_class
4019 else:
4020 return self.serializer_class
4021
4022 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08004023 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004024
4025 def create(self, request, *args, **kwargs):
4026 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4027 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004028 response = {"error": "validation",
4029 "specific_error": "not serializer.is_valid()",
4030 "reasons": serializer.errors}
4031 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004032 obj = serializer.object
4033 obj.caller = request.user
4034 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08004035 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004036 else:
4037 raise Exception("failed obj.can_update")
4038
Scott Baker515dc9e2014-12-22 09:29:05 -08004039 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004040 if (ret.status_code%100 != 200):
4041 raise Exception(ret.data)
4042
4043 return ret
4044
4045
Scott Baker515dc9e2014-12-22 09:29:05 -08004046class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4047 queryset = ImageDeployments.objects.select_related().all()
4048 serializer_class = ImageDeploymentsSerializer
4049 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004050
4051 def get_serializer_class(self):
4052 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4053 if (no_hyperlinks):
4054 return self.id_serializer_class
4055 else:
4056 return self.serializer_class
4057
4058 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08004059 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004060
4061 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4062
4063 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4064
Scott Bakerb744f1c2014-11-21 11:32:24 -08004065
4066
Scott Baker89a7b7c2014-10-07 00:10:17 -07004067class ReservedResourceList(generics.ListCreateAPIView):
4068 queryset = ReservedResource.objects.select_related().all()
4069 serializer_class = ReservedResourceSerializer
4070 id_serializer_class = ReservedResourceIdSerializer
4071 filter_backends = (filters.DjangoFilterBackend,)
4072 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
4073
4074 def get_serializer_class(self):
4075 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4076 if (no_hyperlinks):
4077 return self.id_serializer_class
4078 else:
4079 return self.serializer_class
4080
4081 def get_queryset(self):
4082 return ReservedResource.select_by_user(self.request.user)
4083
4084 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004085 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4086 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004087 response = {"error": "validation",
4088 "specific_error": "not serializer.is_valid()",
4089 "reasons": serializer.errors}
4090 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004091 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004092 obj.caller = request.user
4093 if obj.can_update(request.user):
4094 return super(ReservedResourceList, self).create(request, *args, **kwargs)
4095 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004096 raise Exception("failed obj.can_update")
4097
4098 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4099 if (ret.status_code%100 != 200):
4100 raise Exception(ret.data)
4101
4102 return ret
4103
Scott Baker89a7b7c2014-10-07 00:10:17 -07004104
4105class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4106 queryset = ReservedResource.objects.select_related().all()
4107 serializer_class = ReservedResourceSerializer
4108 id_serializer_class = ReservedResourceIdSerializer
4109
4110 def get_serializer_class(self):
4111 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4112 if (no_hyperlinks):
4113 return self.id_serializer_class
4114 else:
4115 return self.serializer_class
4116
4117 def get_queryset(self):
4118 return ReservedResource.select_by_user(self.request.user)
4119
4120 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4121
4122 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4123
4124
4125
Scott Baker515dc9e2014-12-22 09:29:05 -08004126class PaymentList(generics.ListCreateAPIView):
4127 queryset = Payment.objects.select_related().all()
4128 serializer_class = PaymentSerializer
4129 id_serializer_class = PaymentIdSerializer
4130 filter_backends = (filters.DjangoFilterBackend,)
4131 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
4132
4133 def get_serializer_class(self):
4134 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4135 if (no_hyperlinks):
4136 return self.id_serializer_class
4137 else:
4138 return self.serializer_class
4139
4140 def get_queryset(self):
4141 return Payment.select_by_user(self.request.user)
4142
4143 def create(self, request, *args, **kwargs):
4144 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4145 if not (serializer.is_valid()):
4146 response = {"error": "validation",
4147 "specific_error": "not serializer.is_valid()",
4148 "reasons": serializer.errors}
4149 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4150 obj = serializer.object
4151 obj.caller = request.user
4152 if obj.can_update(request.user):
4153 return super(PaymentList, self).create(request, *args, **kwargs)
4154 else:
4155 raise Exception("failed obj.can_update")
4156
4157 ret = super(PaymentList, self).create(request, *args, **kwargs)
4158 if (ret.status_code%100 != 200):
4159 raise Exception(ret.data)
4160
4161 return ret
4162
4163
4164class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4165 queryset = Payment.objects.select_related().all()
4166 serializer_class = PaymentSerializer
4167 id_serializer_class = PaymentIdSerializer
4168
4169 def get_serializer_class(self):
4170 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4171 if (no_hyperlinks):
4172 return self.id_serializer_class
4173 else:
4174 return self.serializer_class
4175
4176 def get_queryset(self):
4177 return Payment.select_by_user(self.request.user)
4178
4179 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4180
4181 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4182
4183
4184
Scott Baker89a7b7c2014-10-07 00:10:17 -07004185class NetworkSliceList(generics.ListCreateAPIView):
4186 queryset = NetworkSlice.objects.select_related().all()
4187 serializer_class = NetworkSliceSerializer
4188 id_serializer_class = NetworkSliceIdSerializer
4189 filter_backends = (filters.DjangoFilterBackend,)
4190 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
4191
4192 def get_serializer_class(self):
4193 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4194 if (no_hyperlinks):
4195 return self.id_serializer_class
4196 else:
4197 return self.serializer_class
4198
4199 def get_queryset(self):
4200 return NetworkSlice.select_by_user(self.request.user)
4201
4202 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004203 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4204 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004205 response = {"error": "validation",
4206 "specific_error": "not serializer.is_valid()",
4207 "reasons": serializer.errors}
4208 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004209 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004210 obj.caller = request.user
4211 if obj.can_update(request.user):
4212 return super(NetworkSliceList, self).create(request, *args, **kwargs)
4213 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004214 raise Exception("failed obj.can_update")
4215
4216 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4217 if (ret.status_code%100 != 200):
4218 raise Exception(ret.data)
4219
4220 return ret
4221
Scott Baker89a7b7c2014-10-07 00:10:17 -07004222
4223class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4224 queryset = NetworkSlice.objects.select_related().all()
4225 serializer_class = NetworkSliceSerializer
4226 id_serializer_class = NetworkSliceIdSerializer
4227
4228 def get_serializer_class(self):
4229 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4230 if (no_hyperlinks):
4231 return self.id_serializer_class
4232 else:
4233 return self.serializer_class
4234
4235 def get_queryset(self):
4236 return NetworkSlice.select_by_user(self.request.user)
4237
4238 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4239
4240 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4241
4242
4243
4244class UserDashboardViewList(generics.ListCreateAPIView):
4245 queryset = UserDashboardView.objects.select_related().all()
4246 serializer_class = UserDashboardViewSerializer
4247 id_serializer_class = UserDashboardViewIdSerializer
4248 filter_backends = (filters.DjangoFilterBackend,)
4249 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4250
4251 def get_serializer_class(self):
4252 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4253 if (no_hyperlinks):
4254 return self.id_serializer_class
4255 else:
4256 return self.serializer_class
4257
4258 def get_queryset(self):
4259 return UserDashboardView.select_by_user(self.request.user)
4260
4261 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004262 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4263 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004264 response = {"error": "validation",
4265 "specific_error": "not serializer.is_valid()",
4266 "reasons": serializer.errors}
4267 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004268 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004269 obj.caller = request.user
4270 if obj.can_update(request.user):
4271 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4272 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004273 raise Exception("failed obj.can_update")
4274
4275 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4276 if (ret.status_code%100 != 200):
4277 raise Exception(ret.data)
4278
4279 return ret
4280
Scott Baker89a7b7c2014-10-07 00:10:17 -07004281
4282class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4283 queryset = UserDashboardView.objects.select_related().all()
4284 serializer_class = UserDashboardViewSerializer
4285 id_serializer_class = UserDashboardViewIdSerializer
4286
4287 def get_serializer_class(self):
4288 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4289 if (no_hyperlinks):
4290 return self.id_serializer_class
4291 else:
4292 return self.serializer_class
4293
4294 def get_queryset(self):
4295 return UserDashboardView.select_by_user(self.request.user)
4296
4297 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4298
4299 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4300
4301
4302
Scott Baker515dc9e2014-12-22 09:29:05 -08004303class ControllerList(generics.ListCreateAPIView):
4304 queryset = Controller.objects.select_related().all()
4305 serializer_class = ControllerSerializer
4306 id_serializer_class = ControllerIdSerializer
4307 filter_backends = (filters.DjangoFilterBackend,)
4308 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
4309
4310 def get_serializer_class(self):
4311 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4312 if (no_hyperlinks):
4313 return self.id_serializer_class
4314 else:
4315 return self.serializer_class
4316
4317 def get_queryset(self):
4318 return Controller.select_by_user(self.request.user)
4319
4320 def create(self, request, *args, **kwargs):
4321 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4322 if not (serializer.is_valid()):
4323 response = {"error": "validation",
4324 "specific_error": "not serializer.is_valid()",
4325 "reasons": serializer.errors}
4326 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4327 obj = serializer.object
4328 obj.caller = request.user
4329 if obj.can_update(request.user):
4330 return super(ControllerList, self).create(request, *args, **kwargs)
4331 else:
4332 raise Exception("failed obj.can_update")
4333
4334 ret = super(ControllerList, self).create(request, *args, **kwargs)
4335 if (ret.status_code%100 != 200):
4336 raise Exception(ret.data)
4337
4338 return ret
4339
4340
4341class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4342 queryset = Controller.objects.select_related().all()
4343 serializer_class = ControllerSerializer
4344 id_serializer_class = ControllerIdSerializer
4345
4346 def get_serializer_class(self):
4347 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4348 if (no_hyperlinks):
4349 return self.id_serializer_class
4350 else:
4351 return self.serializer_class
4352
4353 def get_queryset(self):
4354 return Controller.select_by_user(self.request.user)
4355
4356 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4357
4358 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4359
4360
4361
Scott Baker89a7b7c2014-10-07 00:10:17 -07004362class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4363 queryset = PlanetStackPrivilege.objects.select_related().all()
4364 serializer_class = PlanetStackPrivilegeSerializer
4365 id_serializer_class = PlanetStackPrivilegeIdSerializer
4366 filter_backends = (filters.DjangoFilterBackend,)
4367 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4368
4369 def get_serializer_class(self):
4370 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4371 if (no_hyperlinks):
4372 return self.id_serializer_class
4373 else:
4374 return self.serializer_class
4375
4376 def get_queryset(self):
4377 return PlanetStackPrivilege.select_by_user(self.request.user)
4378
4379 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004380 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4381 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004382 response = {"error": "validation",
4383 "specific_error": "not serializer.is_valid()",
4384 "reasons": serializer.errors}
4385 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004386 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004387 obj.caller = request.user
4388 if obj.can_update(request.user):
4389 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4390 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004391 raise Exception("failed obj.can_update")
4392
4393 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4394 if (ret.status_code%100 != 200):
4395 raise Exception(ret.data)
4396
4397 return ret
4398
Scott Baker89a7b7c2014-10-07 00:10:17 -07004399
4400class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4401 queryset = PlanetStackPrivilege.objects.select_related().all()
4402 serializer_class = PlanetStackPrivilegeSerializer
4403 id_serializer_class = PlanetStackPrivilegeIdSerializer
4404
4405 def get_serializer_class(self):
4406 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4407 if (no_hyperlinks):
4408 return self.id_serializer_class
4409 else:
4410 return self.serializer_class
4411
4412 def get_queryset(self):
4413 return PlanetStackPrivilege.select_by_user(self.request.user)
4414
4415 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4416
4417 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4418
4419
4420
4421class UserList(generics.ListCreateAPIView):
4422 queryset = User.objects.select_related().all()
4423 serializer_class = UserSerializer
4424 id_serializer_class = UserIdSerializer
4425 filter_backends = (filters.DjangoFilterBackend,)
4426 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',)
4427
4428 def get_serializer_class(self):
4429 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4430 if (no_hyperlinks):
4431 return self.id_serializer_class
4432 else:
4433 return self.serializer_class
4434
4435 def get_queryset(self):
4436 return User.select_by_user(self.request.user)
4437
4438 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004439 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4440 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004441 response = {"error": "validation",
4442 "specific_error": "not serializer.is_valid()",
4443 "reasons": serializer.errors}
4444 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004445 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004446 obj.caller = request.user
4447 if obj.can_update(request.user):
4448 return super(UserList, self).create(request, *args, **kwargs)
4449 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004450 raise Exception("failed obj.can_update")
4451
4452 ret = super(UserList, self).create(request, *args, **kwargs)
4453 if (ret.status_code%100 != 200):
4454 raise Exception(ret.data)
4455
4456 return ret
4457
Scott Baker89a7b7c2014-10-07 00:10:17 -07004458
4459class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4460 queryset = User.objects.select_related().all()
4461 serializer_class = UserSerializer
4462 id_serializer_class = UserIdSerializer
4463
4464 def get_serializer_class(self):
4465 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4466 if (no_hyperlinks):
4467 return self.id_serializer_class
4468 else:
4469 return self.serializer_class
4470
4471 def get_queryset(self):
4472 return User.select_by_user(self.request.user)
4473
4474 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4475
4476 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4477
4478
4479
4480class DeploymentList(generics.ListCreateAPIView):
4481 queryset = Deployment.objects.select_related().all()
4482 serializer_class = DeploymentSerializer
4483 id_serializer_class = DeploymentIdSerializer
4484 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08004485 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004486
4487 def get_serializer_class(self):
4488 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4489 if (no_hyperlinks):
4490 return self.id_serializer_class
4491 else:
4492 return self.serializer_class
4493
4494 def get_queryset(self):
4495 return Deployment.select_by_user(self.request.user)
4496
4497 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004498 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4499 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004500 response = {"error": "validation",
4501 "specific_error": "not serializer.is_valid()",
4502 "reasons": serializer.errors}
4503 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004504 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004505 obj.caller = request.user
4506 if obj.can_update(request.user):
4507 return super(DeploymentList, self).create(request, *args, **kwargs)
4508 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004509 raise Exception("failed obj.can_update")
4510
4511 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4512 if (ret.status_code%100 != 200):
4513 raise Exception(ret.data)
4514
4515 return ret
4516
Scott Baker89a7b7c2014-10-07 00:10:17 -07004517
4518class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4519 queryset = Deployment.objects.select_related().all()
4520 serializer_class = DeploymentSerializer
4521 id_serializer_class = DeploymentIdSerializer
4522
4523 def get_serializer_class(self):
4524 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4525 if (no_hyperlinks):
4526 return self.id_serializer_class
4527 else:
4528 return self.serializer_class
4529
4530 def get_queryset(self):
4531 return Deployment.select_by_user(self.request.user)
4532
4533 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4534
4535 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4536
4537
4538
4539class ReservationList(generics.ListCreateAPIView):
4540 queryset = Reservation.objects.select_related().all()
4541 serializer_class = ReservationSerializer
4542 id_serializer_class = ReservationIdSerializer
4543 filter_backends = (filters.DjangoFilterBackend,)
4544 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4545
4546 def get_serializer_class(self):
4547 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4548 if (no_hyperlinks):
4549 return self.id_serializer_class
4550 else:
4551 return self.serializer_class
4552
4553 def get_queryset(self):
4554 return Reservation.select_by_user(self.request.user)
4555
4556 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004557 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4558 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004559 response = {"error": "validation",
4560 "specific_error": "not serializer.is_valid()",
4561 "reasons": serializer.errors}
4562 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004563 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004564 obj.caller = request.user
4565 if obj.can_update(request.user):
4566 return super(ReservationList, self).create(request, *args, **kwargs)
4567 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004568 raise Exception("failed obj.can_update")
4569
4570 ret = super(ReservationList, self).create(request, *args, **kwargs)
4571 if (ret.status_code%100 != 200):
4572 raise Exception(ret.data)
4573
4574 return ret
4575
Scott Baker89a7b7c2014-10-07 00:10:17 -07004576
4577class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4578 queryset = Reservation.objects.select_related().all()
4579 serializer_class = ReservationSerializer
4580 id_serializer_class = ReservationIdSerializer
4581
4582 def get_serializer_class(self):
4583 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4584 if (no_hyperlinks):
4585 return self.id_serializer_class
4586 else:
4587 return self.serializer_class
4588
4589 def get_queryset(self):
4590 return Reservation.select_by_user(self.request.user)
4591
4592 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4593
4594 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4595
Scott Baker89a7b7c2014-10-07 00:10:17 -07004596
Scott Baker57c725c2014-11-12 01:13:53 -08004597
Scott Baker89a7b7c2014-10-07 00:10:17 -07004598class SitePrivilegeList(generics.ListCreateAPIView):
4599 queryset = SitePrivilege.objects.select_related().all()
4600 serializer_class = SitePrivilegeSerializer
4601 id_serializer_class = SitePrivilegeIdSerializer
4602 filter_backends = (filters.DjangoFilterBackend,)
4603 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4604
4605 def get_serializer_class(self):
4606 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4607 if (no_hyperlinks):
4608 return self.id_serializer_class
4609 else:
4610 return self.serializer_class
4611
4612 def get_queryset(self):
4613 return SitePrivilege.select_by_user(self.request.user)
4614
4615 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004616 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4617 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004618 response = {"error": "validation",
4619 "specific_error": "not serializer.is_valid()",
4620 "reasons": serializer.errors}
4621 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004622 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004623 obj.caller = request.user
4624 if obj.can_update(request.user):
4625 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4626 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004627 raise Exception("failed obj.can_update")
4628
4629 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4630 if (ret.status_code%100 != 200):
4631 raise Exception(ret.data)
4632
4633 return ret
4634
Scott Baker89a7b7c2014-10-07 00:10:17 -07004635
4636class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4637 queryset = SitePrivilege.objects.select_related().all()
4638 serializer_class = SitePrivilegeSerializer
4639 id_serializer_class = SitePrivilegeIdSerializer
4640
4641 def get_serializer_class(self):
4642 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4643 if (no_hyperlinks):
4644 return self.id_serializer_class
4645 else:
4646 return self.serializer_class
4647
4648 def get_queryset(self):
4649 return SitePrivilege.select_by_user(self.request.user)
4650
4651 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4652
4653 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4654
4655
4656
Scott Bakerb744f1c2014-11-21 11:32:24 -08004657class PlanetStackList(generics.ListCreateAPIView):
4658 queryset = PlanetStack.objects.select_related().all()
4659 serializer_class = PlanetStackSerializer
4660 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004661 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004662 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004663
4664 def get_serializer_class(self):
4665 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4666 if (no_hyperlinks):
4667 return self.id_serializer_class
4668 else:
4669 return self.serializer_class
4670
4671 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004672 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004673
4674 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004675 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4676 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004677 response = {"error": "validation",
4678 "specific_error": "not serializer.is_valid()",
4679 "reasons": serializer.errors}
4680 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004681 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004682 obj.caller = request.user
4683 if obj.can_update(request.user):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004684 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004685 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004686 raise Exception("failed obj.can_update")
4687
Scott Bakerb744f1c2014-11-21 11:32:24 -08004688 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07004689 if (ret.status_code%100 != 200):
4690 raise Exception(ret.data)
4691
4692 return ret
4693
Scott Baker89a7b7c2014-10-07 00:10:17 -07004694
Scott Bakerb744f1c2014-11-21 11:32:24 -08004695class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4696 queryset = PlanetStack.objects.select_related().all()
4697 serializer_class = PlanetStackSerializer
4698 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004699
4700 def get_serializer_class(self):
4701 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4702 if (no_hyperlinks):
4703 return self.id_serializer_class
4704 else:
4705 return self.serializer_class
4706
4707 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004708 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004709
4710 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4711
4712 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4713
Scott Baker89a7b7c2014-10-07 00:10:17 -07004714
Scott Baker57c725c2014-11-12 01:13:53 -08004715
Scott Bakerf2c0c512014-12-22 17:35:34 -08004716class ControllerDashboardViewList(generics.ListCreateAPIView):
4717 queryset = ControllerDashboardView.objects.select_related().all()
4718 serializer_class = ControllerDashboardViewSerializer
4719 id_serializer_class = ControllerDashboardViewIdSerializer
4720 filter_backends = (filters.DjangoFilterBackend,)
4721 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
4722
4723 def get_serializer_class(self):
4724 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4725 if (no_hyperlinks):
4726 return self.id_serializer_class
4727 else:
4728 return self.serializer_class
4729
4730 def get_queryset(self):
4731 return ControllerDashboardView.select_by_user(self.request.user)
4732
4733 def create(self, request, *args, **kwargs):
4734 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4735 if not (serializer.is_valid()):
4736 response = {"error": "validation",
4737 "specific_error": "not serializer.is_valid()",
4738 "reasons": serializer.errors}
4739 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4740 obj = serializer.object
4741 obj.caller = request.user
4742 if obj.can_update(request.user):
4743 return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
4744 else:
4745 raise Exception("failed obj.can_update")
4746
4747 ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
4748 if (ret.status_code%100 != 200):
4749 raise Exception(ret.data)
4750
4751 return ret
4752
4753
4754class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4755 queryset = ControllerDashboardView.objects.select_related().all()
4756 serializer_class = ControllerDashboardViewSerializer
4757 id_serializer_class = ControllerDashboardViewIdSerializer
4758
4759 def get_serializer_class(self):
4760 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4761 if (no_hyperlinks):
4762 return self.id_serializer_class
4763 else:
4764 return self.serializer_class
4765
4766 def get_queryset(self):
4767 return ControllerDashboardView.select_by_user(self.request.user)
4768
4769 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4770
4771 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4772
4773
4774
Scott Baker89a7b7c2014-10-07 00:10:17 -07004775class AccountList(generics.ListCreateAPIView):
4776 queryset = Account.objects.select_related().all()
4777 serializer_class = AccountSerializer
4778 id_serializer_class = AccountIdSerializer
4779 filter_backends = (filters.DjangoFilterBackend,)
4780 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4781
4782 def get_serializer_class(self):
4783 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4784 if (no_hyperlinks):
4785 return self.id_serializer_class
4786 else:
4787 return self.serializer_class
4788
4789 def get_queryset(self):
4790 return Account.select_by_user(self.request.user)
4791
4792 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004793 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4794 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004795 response = {"error": "validation",
4796 "specific_error": "not serializer.is_valid()",
4797 "reasons": serializer.errors}
4798 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004799 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004800 obj.caller = request.user
4801 if obj.can_update(request.user):
4802 return super(AccountList, self).create(request, *args, **kwargs)
4803 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004804 raise Exception("failed obj.can_update")
4805
4806 ret = super(AccountList, self).create(request, *args, **kwargs)
4807 if (ret.status_code%100 != 200):
4808 raise Exception(ret.data)
4809
4810 return ret
4811
Scott Baker89a7b7c2014-10-07 00:10:17 -07004812
4813class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4814 queryset = Account.objects.select_related().all()
4815 serializer_class = AccountSerializer
4816 id_serializer_class = AccountIdSerializer
4817
4818 def get_serializer_class(self):
4819 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4820 if (no_hyperlinks):
4821 return self.id_serializer_class
4822 else:
4823 return self.serializer_class
4824
4825 def get_queryset(self):
4826 return Account.select_by_user(self.request.user)
4827
4828 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4829
4830 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4831
4832
4833
Scott Baker515dc9e2014-12-22 09:29:05 -08004834class ControllerRoleList(generics.ListCreateAPIView):
4835 queryset = ControllerRole.objects.select_related().all()
4836 serializer_class = ControllerRoleSerializer
4837 id_serializer_class = ControllerRoleIdSerializer
4838 filter_backends = (filters.DjangoFilterBackend,)
4839 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
4840
4841 def get_serializer_class(self):
4842 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4843 if (no_hyperlinks):
4844 return self.id_serializer_class
4845 else:
4846 return self.serializer_class
4847
4848 def get_queryset(self):
4849 return ControllerRole.select_by_user(self.request.user)
4850
4851 def create(self, request, *args, **kwargs):
4852 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4853 if not (serializer.is_valid()):
4854 response = {"error": "validation",
4855 "specific_error": "not serializer.is_valid()",
4856 "reasons": serializer.errors}
4857 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4858 obj = serializer.object
4859 obj.caller = request.user
4860 if obj.can_update(request.user):
4861 return super(ControllerRoleList, self).create(request, *args, **kwargs)
4862 else:
4863 raise Exception("failed obj.can_update")
4864
4865 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
4866 if (ret.status_code%100 != 200):
4867 raise Exception(ret.data)
4868
4869 return ret
4870
4871
4872class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4873 queryset = ControllerRole.objects.select_related().all()
4874 serializer_class = ControllerRoleSerializer
4875 id_serializer_class = ControllerRoleIdSerializer
4876
4877 def get_serializer_class(self):
4878 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4879 if (no_hyperlinks):
4880 return self.id_serializer_class
4881 else:
4882 return self.serializer_class
4883
4884 def get_queryset(self):
4885 return ControllerRole.select_by_user(self.request.user)
4886
4887 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4888
4889 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4890
4891
4892
Scott Baker89a7b7c2014-10-07 00:10:17 -07004893class NetworkParameterTypeList(generics.ListCreateAPIView):
4894 queryset = NetworkParameterType.objects.select_related().all()
4895 serializer_class = NetworkParameterTypeSerializer
4896 id_serializer_class = NetworkParameterTypeIdSerializer
4897 filter_backends = (filters.DjangoFilterBackend,)
4898 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
4899
4900 def get_serializer_class(self):
4901 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4902 if (no_hyperlinks):
4903 return self.id_serializer_class
4904 else:
4905 return self.serializer_class
4906
4907 def get_queryset(self):
4908 return NetworkParameterType.select_by_user(self.request.user)
4909
4910 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004911 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4912 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004913 response = {"error": "validation",
4914 "specific_error": "not serializer.is_valid()",
4915 "reasons": serializer.errors}
4916 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004917 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004918 obj.caller = request.user
4919 if obj.can_update(request.user):
4920 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4921 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004922 raise Exception("failed obj.can_update")
4923
4924 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4925 if (ret.status_code%100 != 200):
4926 raise Exception(ret.data)
4927
4928 return ret
4929
Scott Baker89a7b7c2014-10-07 00:10:17 -07004930
4931class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4932 queryset = NetworkParameterType.objects.select_related().all()
4933 serializer_class = NetworkParameterTypeSerializer
4934 id_serializer_class = NetworkParameterTypeIdSerializer
4935
4936 def get_serializer_class(self):
4937 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4938 if (no_hyperlinks):
4939 return self.id_serializer_class
4940 else:
4941 return self.serializer_class
4942
4943 def get_queryset(self):
4944 return NetworkParameterType.select_by_user(self.request.user)
4945
4946 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4947
4948 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4949
4950
4951
4952class SiteCredentialList(generics.ListCreateAPIView):
4953 queryset = SiteCredential.objects.select_related().all()
4954 serializer_class = SiteCredentialSerializer
4955 id_serializer_class = SiteCredentialIdSerializer
4956 filter_backends = (filters.DjangoFilterBackend,)
4957 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
4958
4959 def get_serializer_class(self):
4960 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4961 if (no_hyperlinks):
4962 return self.id_serializer_class
4963 else:
4964 return self.serializer_class
4965
4966 def get_queryset(self):
4967 return SiteCredential.select_by_user(self.request.user)
4968
4969 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004970 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4971 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004972 response = {"error": "validation",
4973 "specific_error": "not serializer.is_valid()",
4974 "reasons": serializer.errors}
4975 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004976 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004977 obj.caller = request.user
4978 if obj.can_update(request.user):
4979 return super(SiteCredentialList, self).create(request, *args, **kwargs)
4980 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004981 raise Exception("failed obj.can_update")
4982
4983 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
4984 if (ret.status_code%100 != 200):
4985 raise Exception(ret.data)
4986
4987 return ret
4988
Scott Baker89a7b7c2014-10-07 00:10:17 -07004989
4990class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4991 queryset = SiteCredential.objects.select_related().all()
4992 serializer_class = SiteCredentialSerializer
4993 id_serializer_class = SiteCredentialIdSerializer
4994
4995 def get_serializer_class(self):
4996 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4997 if (no_hyperlinks):
4998 return self.id_serializer_class
4999 else:
5000 return self.serializer_class
5001
5002 def get_queryset(self):
5003 return SiteCredential.select_by_user(self.request.user)
5004
5005 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5006
5007 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5008
5009
5010
Scott Baker515dc9e2014-12-22 09:29:05 -08005011class DeploymentPrivilegeList(generics.ListCreateAPIView):
5012 queryset = DeploymentPrivilege.objects.select_related().all()
5013 serializer_class = DeploymentPrivilegeSerializer
5014 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005015 filter_backends = (filters.DjangoFilterBackend,)
5016 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
5017
5018 def get_serializer_class(self):
5019 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5020 if (no_hyperlinks):
5021 return self.id_serializer_class
5022 else:
5023 return self.serializer_class
5024
5025 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005026 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005027
5028 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005029 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5030 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005031 response = {"error": "validation",
5032 "specific_error": "not serializer.is_valid()",
5033 "reasons": serializer.errors}
5034 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005035 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005036 obj.caller = request.user
5037 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005038 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005039 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005040 raise Exception("failed obj.can_update")
5041
Scott Baker515dc9e2014-12-22 09:29:05 -08005042 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005043 if (ret.status_code%100 != 200):
5044 raise Exception(ret.data)
5045
5046 return ret
5047
Scott Baker89a7b7c2014-10-07 00:10:17 -07005048
Scott Baker515dc9e2014-12-22 09:29:05 -08005049class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5050 queryset = DeploymentPrivilege.objects.select_related().all()
5051 serializer_class = DeploymentPrivilegeSerializer
5052 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005053
5054 def get_serializer_class(self):
5055 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5056 if (no_hyperlinks):
5057 return self.id_serializer_class
5058 else:
5059 return self.serializer_class
5060
5061 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005062 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005063
5064 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5065
5066 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5067
5068
5069
Tony Mack3066a952015-01-05 22:48:11 -05005070class ControllerUserList(generics.ListCreateAPIView):
5071 queryset = ControllerUser.objects.select_related().all()
5072 serializer_class = ControllerUserSerializer
5073 id_serializer_class = ControllerUserIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005074 filter_backends = (filters.DjangoFilterBackend,)
5075 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
5076
5077 def get_serializer_class(self):
5078 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5079 if (no_hyperlinks):
5080 return self.id_serializer_class
5081 else:
5082 return self.serializer_class
5083
5084 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005085 return ControllerUser.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005086
5087 def create(self, request, *args, **kwargs):
5088 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5089 if not (serializer.is_valid()):
5090 response = {"error": "validation",
5091 "specific_error": "not serializer.is_valid()",
5092 "reasons": serializer.errors}
5093 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5094 obj = serializer.object
5095 obj.caller = request.user
5096 if obj.can_update(request.user):
Tony Mack3066a952015-01-05 22:48:11 -05005097 return super(ControllerUserList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005098 else:
5099 raise Exception("failed obj.can_update")
5100
Tony Mack3066a952015-01-05 22:48:11 -05005101 ret = super(ControllerUserList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005102 if (ret.status_code%100 != 200):
5103 raise Exception(ret.data)
5104
5105 return ret
5106
5107
Tony Mack3066a952015-01-05 22:48:11 -05005108class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5109 queryset = ControllerUser.objects.select_related().all()
5110 serializer_class = ControllerUserSerializer
5111 id_serializer_class = ControllerUserIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005112
5113 def get_serializer_class(self):
5114 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5115 if (no_hyperlinks):
5116 return self.id_serializer_class
5117 else:
5118 return self.serializer_class
5119
5120 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005121 return ControllerUser.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005122
5123 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5124
5125 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5126
5127
5128
5129class DeploymentRoleList(generics.ListCreateAPIView):
5130 queryset = DeploymentRole.objects.select_related().all()
5131 serializer_class = DeploymentRoleSerializer
5132 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005133 filter_backends = (filters.DjangoFilterBackend,)
5134 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5135
5136 def get_serializer_class(self):
5137 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5138 if (no_hyperlinks):
5139 return self.id_serializer_class
5140 else:
5141 return self.serializer_class
5142
5143 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005144 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005145
5146 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005147 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5148 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005149 response = {"error": "validation",
5150 "specific_error": "not serializer.is_valid()",
5151 "reasons": serializer.errors}
5152 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005153 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005154 obj.caller = request.user
5155 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005156 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005157 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005158 raise Exception("failed obj.can_update")
5159
Scott Baker515dc9e2014-12-22 09:29:05 -08005160 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005161 if (ret.status_code%100 != 200):
5162 raise Exception(ret.data)
5163
5164 return ret
5165
Scott Baker89a7b7c2014-10-07 00:10:17 -07005166
Scott Baker515dc9e2014-12-22 09:29:05 -08005167class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5168 queryset = DeploymentRole.objects.select_related().all()
5169 serializer_class = DeploymentRoleSerializer
5170 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005171
5172 def get_serializer_class(self):
5173 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5174 if (no_hyperlinks):
5175 return self.id_serializer_class
5176 else:
5177 return self.serializer_class
5178
5179 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005180 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005181
5182 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5183
5184 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5185
5186
5187
5188class UserCredentialList(generics.ListCreateAPIView):
5189 queryset = UserCredential.objects.select_related().all()
5190 serializer_class = UserCredentialSerializer
5191 id_serializer_class = UserCredentialIdSerializer
5192 filter_backends = (filters.DjangoFilterBackend,)
5193 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
5194
5195 def get_serializer_class(self):
5196 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5197 if (no_hyperlinks):
5198 return self.id_serializer_class
5199 else:
5200 return self.serializer_class
5201
5202 def get_queryset(self):
5203 return UserCredential.select_by_user(self.request.user)
5204
5205 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005206 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5207 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005208 response = {"error": "validation",
5209 "specific_error": "not serializer.is_valid()",
5210 "reasons": serializer.errors}
5211 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005212 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005213 obj.caller = request.user
5214 if obj.can_update(request.user):
5215 return super(UserCredentialList, self).create(request, *args, **kwargs)
5216 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005217 raise Exception("failed obj.can_update")
5218
5219 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
5220 if (ret.status_code%100 != 200):
5221 raise Exception(ret.data)
5222
5223 return ret
5224
Scott Baker89a7b7c2014-10-07 00:10:17 -07005225
5226class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5227 queryset = UserCredential.objects.select_related().all()
5228 serializer_class = UserCredentialSerializer
5229 id_serializer_class = UserCredentialIdSerializer
5230
5231 def get_serializer_class(self):
5232 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5233 if (no_hyperlinks):
5234 return self.id_serializer_class
5235 else:
5236 return self.serializer_class
5237
5238 def get_queryset(self):
5239 return UserCredential.select_by_user(self.request.user)
5240
5241 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5242
5243 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5244
Scott Baker89a7b7c2014-10-07 00:10:17 -07005245
Scott Baker57c725c2014-11-12 01:13:53 -08005246
Tony Mack3066a952015-01-05 22:48:11 -05005247class SiteDeploymentList(generics.ListCreateAPIView):
5248 queryset = SiteDeployment.objects.select_related().all()
5249 serializer_class = SiteDeploymentSerializer
5250 id_serializer_class = SiteDeploymentIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08005251 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08005252 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005253
5254 def get_serializer_class(self):
5255 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5256 if (no_hyperlinks):
5257 return self.id_serializer_class
5258 else:
5259 return self.serializer_class
5260
5261 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005262 return SiteDeployment.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005263
5264 def create(self, request, *args, **kwargs):
5265 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5266 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005267 response = {"error": "validation",
5268 "specific_error": "not serializer.is_valid()",
5269 "reasons": serializer.errors}
5270 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005271 obj = serializer.object
5272 obj.caller = request.user
5273 if obj.can_update(request.user):
Tony Mack3066a952015-01-05 22:48:11 -05005274 return super(SiteDeploymentList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005275 else:
5276 raise Exception("failed obj.can_update")
5277
Tony Mack3066a952015-01-05 22:48:11 -05005278 ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005279 if (ret.status_code%100 != 200):
5280 raise Exception(ret.data)
5281
5282 return ret
5283
5284
Tony Mack3066a952015-01-05 22:48:11 -05005285class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5286 queryset = SiteDeployment.objects.select_related().all()
5287 serializer_class = SiteDeploymentSerializer
5288 id_serializer_class = SiteDeploymentIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08005289
5290 def get_serializer_class(self):
5291 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5292 if (no_hyperlinks):
5293 return self.id_serializer_class
5294 else:
5295 return self.serializer_class
5296
5297 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005298 return SiteDeployment.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005299
5300 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5301
5302 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5303
Scott Baker515dc9e2014-12-22 09:29:05 -08005304
5305
Scott Baker0caeaf02014-06-19 11:12:55 -07005306class SliceTagList(generics.ListCreateAPIView):
5307 queryset = SliceTag.objects.select_related().all()
5308 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005309 id_serializer_class = SliceTagIdSerializer
5310 filter_backends = (filters.DjangoFilterBackend,)
5311 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5312
5313 def get_serializer_class(self):
5314 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5315 if (no_hyperlinks):
5316 return self.id_serializer_class
5317 else:
5318 return self.serializer_class
5319
Scott Baker0caeaf02014-06-19 11:12:55 -07005320 def get_queryset(self):
5321 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005322
Scott Baker0caeaf02014-06-19 11:12:55 -07005323 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005324 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5325 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005326 response = {"error": "validation",
5327 "specific_error": "not serializer.is_valid()",
5328 "reasons": serializer.errors}
5329 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005330 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005331 obj.caller = request.user
5332 if obj.can_update(request.user):
5333 return super(SliceTagList, self).create(request, *args, **kwargs)
5334 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005335 raise Exception("failed obj.can_update")
5336
5337 ret = super(SliceTagList, self).create(request, *args, **kwargs)
5338 if (ret.status_code%100 != 200):
5339 raise Exception(ret.data)
5340
5341 return ret
5342
Scott Baker0caeaf02014-06-19 11:12:55 -07005343
Scott Baker89a7b7c2014-10-07 00:10:17 -07005344class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005345 queryset = SliceTag.objects.select_related().all()
5346 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005347 id_serializer_class = SliceTagIdSerializer
5348
5349 def get_serializer_class(self):
5350 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5351 if (no_hyperlinks):
5352 return self.id_serializer_class
5353 else:
5354 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005355
5356 def get_queryset(self):
5357 return SliceTag.select_by_user(self.request.user)
5358
Scott Baker89a7b7c2014-10-07 00:10:17 -07005359 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005360
Scott Baker89a7b7c2014-10-07 00:10:17 -07005361 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005362
5363
5364
Scott Bakerf2c0c512014-12-22 17:35:34 -08005365class NetworkTemplateList(generics.ListCreateAPIView):
5366 queryset = NetworkTemplate.objects.select_related().all()
5367 serializer_class = NetworkTemplateSerializer
5368 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005369 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker16fce9c2015-01-03 12:05:21 -08005370 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07005371
5372 def get_serializer_class(self):
5373 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5374 if (no_hyperlinks):
5375 return self.id_serializer_class
5376 else:
5377 return self.serializer_class
5378
Scott Baker0caeaf02014-06-19 11:12:55 -07005379 def get_queryset(self):
Scott Bakerf2c0c512014-12-22 17:35:34 -08005380 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005381
Scott Baker0caeaf02014-06-19 11:12:55 -07005382 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005383 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5384 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005385 response = {"error": "validation",
5386 "specific_error": "not serializer.is_valid()",
5387 "reasons": serializer.errors}
5388 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005389 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005390 obj.caller = request.user
5391 if obj.can_update(request.user):
Scott Bakerf2c0c512014-12-22 17:35:34 -08005392 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07005393 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005394 raise Exception("failed obj.can_update")
5395
Scott Bakerf2c0c512014-12-22 17:35:34 -08005396 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005397 if (ret.status_code%100 != 200):
5398 raise Exception(ret.data)
5399
5400 return ret
5401
Scott Baker0caeaf02014-06-19 11:12:55 -07005402
Scott Bakerf2c0c512014-12-22 17:35:34 -08005403class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5404 queryset = NetworkTemplate.objects.select_related().all()
5405 serializer_class = NetworkTemplateSerializer
5406 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005407
5408 def get_serializer_class(self):
5409 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5410 if (no_hyperlinks):
5411 return self.id_serializer_class
5412 else:
5413 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005414
5415 def get_queryset(self):
Scott Bakerf2c0c512014-12-22 17:35:34 -08005416 return NetworkTemplate.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07005417
Scott Baker89a7b7c2014-10-07 00:10:17 -07005418 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005419
Scott Baker89a7b7c2014-10-07 00:10:17 -07005420 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005421
5422
5423
5424class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005425 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005426 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005427 id_serializer_class = RouterIdSerializer
5428 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08005429 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07005430
5431 def get_serializer_class(self):
5432 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5433 if (no_hyperlinks):
5434 return self.id_serializer_class
5435 else:
5436 return self.serializer_class
5437
Scott Baker0caeaf02014-06-19 11:12:55 -07005438 def get_queryset(self):
5439 return Router.select_by_user(self.request.user)
5440
5441 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005442 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5443 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005444 response = {"error": "validation",
5445 "specific_error": "not serializer.is_valid()",
5446 "reasons": serializer.errors}
5447 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005448 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005449 obj.caller = request.user
5450 if obj.can_update(request.user):
5451 return super(RouterList, self).create(request, *args, **kwargs)
5452 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005453 raise Exception("failed obj.can_update")
5454
5455 ret = super(RouterList, self).create(request, *args, **kwargs)
5456 if (ret.status_code%100 != 200):
5457 raise Exception(ret.data)
5458
5459 return ret
5460
Sapan Bhatiadea39432014-06-13 03:10:36 -04005461
Scott Baker89a7b7c2014-10-07 00:10:17 -07005462class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005463 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005464 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005465 id_serializer_class = RouterIdSerializer
5466
5467 def get_serializer_class(self):
5468 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5469 if (no_hyperlinks):
5470 return self.id_serializer_class
5471 else:
5472 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005473
5474 def get_queryset(self):
5475 return Router.select_by_user(self.request.user)
5476
Scott Baker89a7b7c2014-10-07 00:10:17 -07005477 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005478
Scott Baker89a7b7c2014-10-07 00:10:17 -07005479 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005480
5481
5482
Scott Baker0caeaf02014-06-19 11:12:55 -07005483class ServiceResourceList(generics.ListCreateAPIView):
5484 queryset = ServiceResource.objects.select_related().all()
5485 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005486 id_serializer_class = ServiceResourceIdSerializer
5487 filter_backends = (filters.DjangoFilterBackend,)
5488 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5489
5490 def get_serializer_class(self):
5491 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5492 if (no_hyperlinks):
5493 return self.id_serializer_class
5494 else:
5495 return self.serializer_class
5496
Scott Baker0caeaf02014-06-19 11:12:55 -07005497 def get_queryset(self):
5498 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005499
Scott Baker0caeaf02014-06-19 11:12:55 -07005500 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005501 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5502 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005503 response = {"error": "validation",
5504 "specific_error": "not serializer.is_valid()",
5505 "reasons": serializer.errors}
5506 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005507 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005508 obj.caller = request.user
5509 if obj.can_update(request.user):
5510 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5511 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005512 raise Exception("failed obj.can_update")
5513
5514 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5515 if (ret.status_code%100 != 200):
5516 raise Exception(ret.data)
5517
5518 return ret
5519
Scott Baker0caeaf02014-06-19 11:12:55 -07005520
Scott Baker89a7b7c2014-10-07 00:10:17 -07005521class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005522 queryset = ServiceResource.objects.select_related().all()
5523 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005524 id_serializer_class = ServiceResourceIdSerializer
5525
5526 def get_serializer_class(self):
5527 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5528 if (no_hyperlinks):
5529 return self.id_serializer_class
5530 else:
5531 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005532
5533 def get_queryset(self):
5534 return ServiceResource.select_by_user(self.request.user)
5535
Scott Baker89a7b7c2014-10-07 00:10:17 -07005536 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005537
Scott Baker89a7b7c2014-10-07 00:10:17 -07005538 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005539
Sapan Bhatiadea39432014-06-13 03:10:36 -04005540
5541
Tony Mack3066a952015-01-05 22:48:11 -05005542class ControllerSliceList(generics.ListCreateAPIView):
5543 queryset = ControllerSlice.objects.select_related().all()
5544 serializer_class = ControllerSliceSerializer
5545 id_serializer_class = ControllerSliceIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005546 filter_backends = (filters.DjangoFilterBackend,)
5547 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
5548
5549 def get_serializer_class(self):
5550 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5551 if (no_hyperlinks):
5552 return self.id_serializer_class
5553 else:
5554 return self.serializer_class
5555
5556 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005557 return ControllerSlice.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005558
5559 def create(self, request, *args, **kwargs):
5560 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5561 if not (serializer.is_valid()):
5562 response = {"error": "validation",
5563 "specific_error": "not serializer.is_valid()",
5564 "reasons": serializer.errors}
5565 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5566 obj = serializer.object
5567 obj.caller = request.user
5568 if obj.can_update(request.user):
Tony Mack3066a952015-01-05 22:48:11 -05005569 return super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005570 else:
5571 raise Exception("failed obj.can_update")
5572
Tony Mack3066a952015-01-05 22:48:11 -05005573 ret = super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005574 if (ret.status_code%100 != 200):
5575 raise Exception(ret.data)
5576
5577 return ret
5578
5579
Tony Mack3066a952015-01-05 22:48:11 -05005580class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5581 queryset = ControllerSlice.objects.select_related().all()
5582 serializer_class = ControllerSliceSerializer
5583 id_serializer_class = ControllerSliceIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005584
5585 def get_serializer_class(self):
5586 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5587 if (no_hyperlinks):
5588 return self.id_serializer_class
5589 else:
5590 return self.serializer_class
5591
5592 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005593 return ControllerSlice.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005594
5595 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5596
5597 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5598
5599
5600