blob: c7b189bb1a5ea5c279ae89a631fee76cce633708 [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
Scott Baker515dc9e2014-12-22 09:29:05 -080071 url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'),
72 url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'),
73
Scott Bakerd51d0bd2014-11-10 16:31:15 -080074 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
75 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
76
Scott Bakerd51d0bd2014-11-10 16:31:15 -080077 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
78 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
79
80 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
81 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
82
83 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
84 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
85
86 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
87 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
88
89 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
90 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
91
Tony Mack3066a952015-01-05 22:48:11 -050092 url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetworks-list'),
93 url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetworks-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080094
95 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
96 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
97
98 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
99 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
100
101 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
102 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
103
104 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
105 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
106
107 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
108 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
109
110 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
111 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
112
113 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
114 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
115
116 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
117 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
118
Scott Baker515dc9e2014-12-22 09:29:05 -0800119 url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
120 url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800121
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800122 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
123 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
124
Scott Baker515dc9e2014-12-22 09:29:05 -0800125 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
126 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
127
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800128 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
129 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
130
131 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
132 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
133
Scott Baker515dc9e2014-12-22 09:29:05 -0800134 url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'),
135 url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
136
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800137 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
138 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
139
140 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
141 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
142
143 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
144 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
145
146 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
147 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
148
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800149 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
150 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
151
Scott Bakerb744f1c2014-11-21 11:32:24 -0800152 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
153 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800154
Scott Bakerf2c0c512014-12-22 17:35:34 -0800155 url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'),
156 url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'),
157
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800158 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
159 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
160
Scott Baker515dc9e2014-12-22 09:29:05 -0800161 url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
162 url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
163
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800164 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
165 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
166
167 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
168 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
169
Scott Baker515dc9e2014-12-22 09:29:05 -0800170 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
171 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800172
Tony Mack3066a952015-01-05 22:48:11 -0500173 url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controllerusers-list'),
174 url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controllerusers-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800175
176 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
177 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800178
179 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
180 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
181
Tony Mack3066a952015-01-05 22:48:11 -0500182 url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployments-list'),
183 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800184
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800185 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
186 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
187
Scott Bakerf2c0c512014-12-22 17:35:34 -0800188 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
189 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800190
191 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
192 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
193
194 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
195 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
196
Tony Mack3066a952015-01-05 22:48:11 -0500197 url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslices-list'),
198 url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslices-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800199
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800200 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400201
202@api_view(['GET'])
203def api_root(request, format=None):
204 return Response({
Scott Baker515dc9e2014-12-22 09:29:05 -0800205 'flavors': reverse('flavor-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700206 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800207 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700208 'images': reverse('image-list', request=request, format=format),
209 'networkparameters': reverse('networkparameter-list', request=request, format=format),
210 'sites': reverse('site-list', request=request, format=format),
211 'sliceroles': reverse('slicerole-list', request=request, format=format),
212 'tags': reverse('tag-list', request=request, format=format),
213 'invoices': reverse('invoice-list', request=request, format=format),
214 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
215 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800216 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700217 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700218 'projects': reverse('project-list', request=request, format=format),
219 'slices': reverse('slice-list', request=request, format=format),
220 'networks': reverse('network-list', request=request, format=format),
221 'services': reverse('service-list', request=request, format=format),
222 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800223 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700224 'charges': reverse('charge-list', request=request, format=format),
225 'roles': reverse('role-list', request=request, format=format),
226 'usableobjects': reverse('usableobject-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800227 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700228 'siteroles': reverse('siterole-list', request=request, format=format),
229 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
230 'slivers': reverse('sliver-list', request=request, format=format),
231 'nodes': reverse('node-list', request=request, format=format),
232 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800233 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700234 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800235 'payments': reverse('payment-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700236 'networkslices': reverse('networkslice-list', request=request, format=format),
237 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800238 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700239 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
240 'users': reverse('user-list', request=request, format=format),
241 'deployments': reverse('deployment-list', request=request, format=format),
242 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700243 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800244 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800245 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700246 'accounts': reverse('account-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800247 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700248 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
249 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800250 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
251 'controlleruserses': reverse('controllerusers-list', request=request, format=format),
252 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700253 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800254 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700255 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800256 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700257 'routers': reverse('router-list', request=request, format=format),
258 'serviceresources': reverse('serviceresource-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800259 'controllersliceses': reverse('controllerslices-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700260
Sapan Bhatiadea39432014-06-13 03:10:36 -0400261 })
262
263# Based on serializers.py
264
Scott Baker515dc9e2014-12-22 09:29:05 -0800265class XOSModelSerializer(serializers.ModelSerializer):
266 def save_object(self, obj, **kwargs):
267
268 """ rest_framework can't deal with ManyToMany relations that have a
269 through table. In plstackapi, most of the through tables we have
270 use defaults or blank fields, so there's no reason why we shouldn't
271 be able to save these objects.
272
273 So, let's strip out these m2m relations, and deal with them ourself.
274 """
275 obj._complex_m2m_data={};
276 if getattr(obj, '_m2m_data', None):
277 for relatedObject in obj._meta.get_all_related_many_to_many_objects():
278 if (relatedObject.field.rel.through._meta.auto_created):
279 # These are non-trough ManyToMany relations and
280 # can be updated just fine
281 continue
282 fieldName = relatedObject.get_accessor_name()
283 if fieldName in obj._m2m_data.keys():
284 obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
285 del obj._m2m_data[fieldName]
286
287 serializers.ModelSerializer.save_object(self, obj, **kwargs);
288
289 for (accessor, stuff) in obj._complex_m2m_data.items():
290 (relatedObject, data) = stuff
291 through = relatedObject.field.rel.through
292 local_fieldName = relatedObject.field.m2m_reverse_field_name()
293 remote_fieldName = relatedObject.field.m2m_field_name()
294
295 # get the current set of existing relations
296 existing = through.objects.filter(**{local_fieldName: obj});
297
298 data_ids = [item.id for item in data]
299 existing_ids = [getattr(item,remote_fieldName).id for item in existing]
300
301 #print "data_ids", data_ids
302 #print "existing_ids", existing_ids
303
304 # remove relations that are in 'existing' but not in 'data'
305 for item in list(existing):
306 if (getattr(item,remote_fieldName).id not in data_ids):
307 print "delete", getattr(item,remote_fieldName)
308 item.delete() #(purge=True)
309
310 # add relations that are in 'data' but not in 'existing'
311 for item in data:
312 if (item.id not in existing_ids):
313 #print "add", item
314 newModel = through(**{local_fieldName: obj, remote_fieldName: item})
315 newModel.save()
316
317
318
319class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800320 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800321
322
323 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
324
325
326 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
327 validators = serializers.SerializerMethodField("getValidators")
328 def getHumanReadableName(self, obj):
329 return str(obj)
330 def getValidators(self, obj):
331 try:
332 return obj.getValidators()
333 except:
334 return None
335 class Meta:
336 model = Flavor
337 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
338
339class FlavorIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800340 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800341
342
Scott Baker201f7da2014-12-23 10:56:06 -0800343 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800344
345
346 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
347 validators = serializers.SerializerMethodField("getValidators")
348 def getHumanReadableName(self, obj):
349 return str(obj)
350 def getValidators(self, obj):
351 try:
352 return obj.getValidators()
353 except:
354 return None
355 class Meta:
356 model = Flavor
357 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
358
359
Sapan Bhatiadea39432014-06-13 03:10:36 -0400360
361
Scott Baker0caeaf02014-06-19 11:12:55 -0700362class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800363 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700364
Scott Bakerb744f1c2014-11-21 11:32:24 -0800365 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800366 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800367 def getHumanReadableName(self, obj):
368 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800369 def getValidators(self, obj):
370 try:
371 return obj.getValidators()
372 except:
373 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700374 class Meta:
375 model = ServiceAttribute
Scott Baker96eb3fd2014-11-25 00:53:25 -0800376 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700377
Scott Baker515dc9e2014-12-22 09:29:05 -0800378class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800379 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700380
Scott Bakerb744f1c2014-11-21 11:32:24 -0800381 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800382 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800383 def getHumanReadableName(self, obj):
384 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800385 def getValidators(self, obj):
386 try:
387 return obj.getValidators()
388 except:
389 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800390 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700391 model = ServiceAttribute
Scott Baker96eb3fd2014-11-25 00:53:25 -0800392 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700393
394
Sapan Bhatiadea39432014-06-13 03:10:36 -0400395
396
Scott Baker515dc9e2014-12-22 09:29:05 -0800397class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800398 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800399
400 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
401 validators = serializers.SerializerMethodField("getValidators")
402 def getHumanReadableName(self, obj):
403 return str(obj)
404 def getValidators(self, obj):
405 try:
406 return obj.getValidators()
407 except:
408 return None
409 class Meta:
410 model = ControllerImages
411 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
412
413class ControllerImagesIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800414 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800415
416 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
417 validators = serializers.SerializerMethodField("getValidators")
418 def getHumanReadableName(self, obj):
419 return str(obj)
420 def getValidators(self, obj):
421 try:
422 return obj.getValidators()
423 except:
424 return None
425 class Meta:
426 model = ControllerImages
427 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
428
429
430
431
Sapan Bhatiadea39432014-06-13 03:10:36 -0400432class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800433 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700434
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800435
436 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
437
438
Scott Bakerb744f1c2014-11-21 11:32:24 -0800439 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800440 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800441 def getHumanReadableName(self, obj):
442 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800443 def getValidators(self, obj):
444 try:
445 return obj.getValidators()
446 except:
447 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700448 class Meta:
449 model = Image
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800450 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700451
Scott Baker515dc9e2014-12-22 09:29:05 -0800452class ImageIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800453 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700454
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800455
Scott Baker201f7da2014-12-23 10:56:06 -0800456 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800457
458
Scott Bakerb744f1c2014-11-21 11:32:24 -0800459 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800460 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800461 def getHumanReadableName(self, obj):
462 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800463 def getValidators(self, obj):
464 try:
465 return obj.getValidators()
466 except:
467 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800468 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700469 model = Image
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800470 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700471
472
Sapan Bhatiadea39432014-06-13 03:10:36 -0400473
474
Scott Baker0caeaf02014-06-19 11:12:55 -0700475class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800476 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700477
Scott Bakerb744f1c2014-11-21 11:32:24 -0800478 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800479 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800480 def getHumanReadableName(self, obj):
481 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800482 def getValidators(self, obj):
483 try:
484 return obj.getValidators()
485 except:
486 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700487 class Meta:
488 model = NetworkParameter
Scott Baker96eb3fd2014-11-25 00:53:25 -0800489 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700490
Scott Baker515dc9e2014-12-22 09:29:05 -0800491class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800492 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700493
Scott Bakerb744f1c2014-11-21 11:32:24 -0800494 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800495 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800496 def getHumanReadableName(self, obj):
497 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800498 def getValidators(self, obj):
499 try:
500 return obj.getValidators()
501 except:
502 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800503 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700504 model = NetworkParameter
Scott Baker96eb3fd2014-11-25 00:53:25 -0800505 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700506
507
Sapan Bhatiadea39432014-06-13 03:10:36 -0400508
509
510class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800511 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700512
Scott Baker515dc9e2014-12-22 09:29:05 -0800513
514 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
515
516
Scott Bakerb744f1c2014-11-21 11:32:24 -0800517 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800518 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800519 def getHumanReadableName(self, obj):
520 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800521 def getValidators(self, obj):
522 try:
523 return obj.getValidators()
524 except:
525 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700526 class Meta:
527 model = Site
Scott Baker515dc9e2014-12-22 09:29:05 -0800528 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 -0700529
Scott Baker515dc9e2014-12-22 09:29:05 -0800530class SiteIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800531 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700532
Scott Baker515dc9e2014-12-22 09:29:05 -0800533
Scott Baker201f7da2014-12-23 10:56:06 -0800534 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800535
536
Scott Bakerb744f1c2014-11-21 11:32:24 -0800537 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800538 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800539 def getHumanReadableName(self, obj):
540 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800541 def getValidators(self, obj):
542 try:
543 return obj.getValidators()
544 except:
545 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800546 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700547 model = Site
Scott Baker515dc9e2014-12-22 09:29:05 -0800548 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 -0700549
550
Sapan Bhatiadea39432014-06-13 03:10:36 -0400551
552
Scott Baker0caeaf02014-06-19 11:12:55 -0700553class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800554 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700555
Scott Bakerb744f1c2014-11-21 11:32:24 -0800556 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800557 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800558 def getHumanReadableName(self, obj):
559 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800560 def getValidators(self, obj):
561 try:
562 return obj.getValidators()
563 except:
564 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700565 class Meta:
566 model = SliceRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800567 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700568
Scott Baker515dc9e2014-12-22 09:29:05 -0800569class SliceRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800570 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700571
Scott Bakerb744f1c2014-11-21 11:32:24 -0800572 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800573 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800574 def getHumanReadableName(self, obj):
575 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800576 def getValidators(self, obj):
577 try:
578 return obj.getValidators()
579 except:
580 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800581 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700582 model = SliceRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800583 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700584
585
Sapan Bhatiadea39432014-06-13 03:10:36 -0400586
587
588class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800589 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700590
Scott Bakerb744f1c2014-11-21 11:32:24 -0800591 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800592 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800593 def getHumanReadableName(self, obj):
594 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800595 def getValidators(self, obj):
596 try:
597 return obj.getValidators()
598 except:
599 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700600 class Meta:
601 model = Tag
Scott Baker96eb3fd2014-11-25 00:53:25 -0800602 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700603
Scott Baker515dc9e2014-12-22 09:29:05 -0800604class TagIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800605 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700606
Scott Bakerb744f1c2014-11-21 11:32:24 -0800607 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800608 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800609 def getHumanReadableName(self, obj):
610 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800611 def getValidators(self, obj):
612 try:
613 return obj.getValidators()
614 except:
615 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800616 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700617 model = Tag
Scott Baker96eb3fd2014-11-25 00:53:25 -0800618 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700619
620
Sapan Bhatiadea39432014-06-13 03:10:36 -0400621
622
623class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800624 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700625
Scott Bakerb744f1c2014-11-21 11:32:24 -0800626 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800627 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800628 def getHumanReadableName(self, obj):
629 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800630 def getValidators(self, obj):
631 try:
632 return obj.getValidators()
633 except:
634 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700635 class Meta:
636 model = Invoice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800637 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700638
Scott Baker515dc9e2014-12-22 09:29:05 -0800639class InvoiceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800640 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700641
Scott Bakerb744f1c2014-11-21 11:32:24 -0800642 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800643 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800644 def getHumanReadableName(self, obj):
645 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800646 def getValidators(self, obj):
647 try:
648 return obj.getValidators()
649 except:
650 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800651 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700652 model = Invoice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800653 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700654
655
Sapan Bhatiadea39432014-06-13 03:10:36 -0400656
657
Scott Baker0caeaf02014-06-19 11:12:55 -0700658class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800659 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700660
Scott Bakerb744f1c2014-11-21 11:32:24 -0800661 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800662 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800663 def getHumanReadableName(self, obj):
664 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800665 def getValidators(self, obj):
666 try:
667 return obj.getValidators()
668 except:
669 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700670 class Meta:
671 model = SlicePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -0800672 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700673
Scott Baker515dc9e2014-12-22 09:29:05 -0800674class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800675 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700676
Scott Bakerb744f1c2014-11-21 11:32:24 -0800677 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800678 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800679 def getHumanReadableName(self, obj):
680 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800681 def getValidators(self, obj):
682 try:
683 return obj.getValidators()
684 except:
685 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800686 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700687 model = SlicePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -0800688 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700689
690
Scott Baker0caeaf02014-06-19 11:12:55 -0700691
692
Scott Baker89a7b7c2014-10-07 00:10:17 -0700693class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800694 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700695
Scott Bakerb744f1c2014-11-21 11:32:24 -0800696 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800697 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800698 def getHumanReadableName(self, obj):
699 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800700 def getValidators(self, obj):
701 try:
702 return obj.getValidators()
703 except:
704 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700705 class Meta:
706 model = PlanetStackRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800707 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700708
Scott Baker515dc9e2014-12-22 09:29:05 -0800709class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800710 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700711
Scott Bakerb744f1c2014-11-21 11:32:24 -0800712 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800713 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800714 def getHumanReadableName(self, obj):
715 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800716 def getValidators(self, obj):
717 try:
718 return obj.getValidators()
719 except:
720 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800721 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700722 model = PlanetStackRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800723 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700724
725
726
727
Scott Baker515dc9e2014-12-22 09:29:05 -0800728class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800729 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800730
731 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
732 validators = serializers.SerializerMethodField("getValidators")
733 def getHumanReadableName(self, obj):
734 return str(obj)
735 def getValidators(self, obj):
736 try:
737 return obj.getValidators()
738 except:
739 return None
740 class Meta:
741 model = ControllerPrivilege
742 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',)
743
744class ControllerPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800745 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800746
747 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
748 validators = serializers.SerializerMethodField("getValidators")
749 def getHumanReadableName(self, obj):
750 return str(obj)
751 def getValidators(self, obj):
752 try:
753 return obj.getValidators()
754 except:
755 return None
756 class Meta:
757 model = ControllerPrivilege
758 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',)
759
760
761
762
Scott Baker0caeaf02014-06-19 11:12:55 -0700763class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800764 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700765
Scott Bakerb744f1c2014-11-21 11:32:24 -0800766 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800767 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800768 def getHumanReadableName(self, obj):
769 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800770 def getValidators(self, obj):
771 try:
772 return obj.getValidators()
773 except:
774 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700775 class Meta:
776 model = NetworkSliver
Scott Baker96eb3fd2014-11-25 00:53:25 -0800777 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700778
Scott Baker515dc9e2014-12-22 09:29:05 -0800779class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800780 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700781
Scott Bakerb744f1c2014-11-21 11:32:24 -0800782 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800783 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800784 def getHumanReadableName(self, obj):
785 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800786 def getValidators(self, obj):
787 try:
788 return obj.getValidators()
789 except:
790 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800791 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700792 model = NetworkSliver
Scott Baker96eb3fd2014-11-25 00:53:25 -0800793 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700794
795
Scott Baker0caeaf02014-06-19 11:12:55 -0700796
797
Scott Baker89a7b7c2014-10-07 00:10:17 -0700798class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800799 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700800
Scott Bakerb744f1c2014-11-21 11:32:24 -0800801 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800802 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800803 def getHumanReadableName(self, obj):
804 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800805 def getValidators(self, obj):
806 try:
807 return obj.getValidators()
808 except:
809 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700810 class Meta:
811 model = Project
Scott Baker96eb3fd2014-11-25 00:53:25 -0800812 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700813
Scott Baker515dc9e2014-12-22 09:29:05 -0800814class ProjectIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800815 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700816
Scott Bakerb744f1c2014-11-21 11:32:24 -0800817 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800818 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800819 def getHumanReadableName(self, obj):
820 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800821 def getValidators(self, obj):
822 try:
823 return obj.getValidators()
824 except:
825 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800826 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700827 model = Project
Scott Baker96eb3fd2014-11-25 00:53:25 -0800828 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700829
830
831
832
Sapan Bhatiadea39432014-06-13 03:10:36 -0400833class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800834 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700835
836
837 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
838
839
840
Scott Baker2bcbf372014-10-29 23:41:11 -0700841 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
842
843
Scott Bakerb744f1c2014-11-21 11:32:24 -0800844 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800845 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800846 def getHumanReadableName(self, obj):
847 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800848 def getValidators(self, obj):
849 try:
850 return obj.getValidators()
851 except:
852 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700853 class Meta:
854 model = Slice
Scott Baker515dc9e2014-12-22 09:29:05 -0800855 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 -0700856
Scott Baker515dc9e2014-12-22 09:29:05 -0800857class SliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800858 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700859
860
Scott Baker201f7da2014-12-23 10:56:06 -0800861 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700862
863
864
Scott Baker201f7da2014-12-23 10:56:06 -0800865 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700866
867
Scott Bakerb744f1c2014-11-21 11:32:24 -0800868 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800869 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800870 def getHumanReadableName(self, obj):
871 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800872 def getValidators(self, obj):
873 try:
874 return obj.getValidators()
875 except:
876 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800877 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700878 model = Slice
Scott Baker515dc9e2014-12-22 09:29:05 -0800879 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 -0700880
881
Sapan Bhatiadea39432014-06-13 03:10:36 -0400882
883
884class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800885 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700886
887
Scott Baker515dc9e2014-12-22 09:29:05 -0800888 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700889
890
891
Scott Baker515dc9e2014-12-22 09:29:05 -0800892 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
893
894
895
896 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700897
898
899
900 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
901
902
903
904 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
905
906
Scott Bakerb744f1c2014-11-21 11:32:24 -0800907 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800908 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800909 def getHumanReadableName(self, obj):
910 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800911 def getValidators(self, obj):
912 try:
913 return obj.getValidators()
914 except:
915 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700916 class Meta:
917 model = Network
Scott Bakerd188c012015-01-03 12:32:45 -0800918 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 -0700919
Scott Baker515dc9e2014-12-22 09:29:05 -0800920class NetworkIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800921 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700922
923
Scott Baker201f7da2014-12-23 10:56:06 -0800924 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700925
926
927
Scott Baker201f7da2014-12-23 10:56:06 -0800928 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700929
930
931
Scott Baker201f7da2014-12-23 10:56:06 -0800932 slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700933
934
935
Scott Baker201f7da2014-12-23 10:56:06 -0800936 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800937
938
939
Scott Baker201f7da2014-12-23 10:56:06 -0800940 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700941
942
Scott Bakerb744f1c2014-11-21 11:32:24 -0800943 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800944 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800945 def getHumanReadableName(self, obj):
946 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800947 def getValidators(self, obj):
948 try:
949 return obj.getValidators()
950 except:
951 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800952 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700953 model = Network
Scott Bakerd188c012015-01-03 12:32:45 -0800954 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 -0700955
956
Sapan Bhatiadea39432014-06-13 03:10:36 -0400957
958
959class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800960 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700961
Scott Bakerb744f1c2014-11-21 11:32:24 -0800962 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800963 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800964 def getHumanReadableName(self, obj):
965 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800966 def getValidators(self, obj):
967 try:
968 return obj.getValidators()
969 except:
970 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700971 class Meta:
972 model = Service
Scott Baker96eb3fd2014-11-25 00:53:25 -0800973 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700974
Scott Baker515dc9e2014-12-22 09:29:05 -0800975class ServiceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800976 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700977
Scott Bakerb744f1c2014-11-21 11:32:24 -0800978 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800979 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800980 def getHumanReadableName(self, obj):
981 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800982 def getValidators(self, obj):
983 try:
984 return obj.getValidators()
985 except:
986 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800987 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700988 model = Service
Scott Baker96eb3fd2014-11-25 00:53:25 -0800989 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700990
991
Sapan Bhatiadea39432014-06-13 03:10:36 -0400992
993
Scott Baker0caeaf02014-06-19 11:12:55 -0700994class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800995 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700996
Scott Bakerb744f1c2014-11-21 11:32:24 -0800997 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800998 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800999 def getHumanReadableName(self, obj):
1000 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001001 def getValidators(self, obj):
1002 try:
1003 return obj.getValidators()
1004 except:
1005 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001006 class Meta:
1007 model = ServiceClass
Scott Baker96eb3fd2014-11-25 00:53:25 -08001008 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001009
Scott Baker515dc9e2014-12-22 09:29:05 -08001010class ServiceClassIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001011 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001012
Scott Bakerb744f1c2014-11-21 11:32:24 -08001013 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001014 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001015 def getHumanReadableName(self, obj):
1016 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001017 def getValidators(self, obj):
1018 try:
1019 return obj.getValidators()
1020 except:
1021 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001022 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001023 model = ServiceClass
Scott Baker96eb3fd2014-11-25 00:53:25 -08001024 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001025
1026
Sapan Bhatiadea39432014-06-13 03:10:36 -04001027
1028
Tony Mack3066a952015-01-05 22:48:11 -05001029class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001030 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001031
Scott Bakerb744f1c2014-11-21 11:32:24 -08001032 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001033 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001034 def getHumanReadableName(self, obj):
1035 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001036 def getValidators(self, obj):
1037 try:
1038 return obj.getValidators()
1039 except:
1040 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001041 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05001042 model = ControllerNetwork
Scott Baker515dc9e2014-12-22 09:29:05 -08001043 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 -07001044
Tony Mack3066a952015-01-05 22:48:11 -05001045class ControllerNetworkIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001046 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001047
Scott Bakerb744f1c2014-11-21 11:32:24 -08001048 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001049 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001050 def getHumanReadableName(self, obj):
1051 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001052 def getValidators(self, obj):
1053 try:
1054 return obj.getValidators()
1055 except:
1056 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001057 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05001058 model = ControllerNetwork
Scott Baker515dc9e2014-12-22 09:29:05 -08001059 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 -07001060
1061
Sapan Bhatiadea39432014-06-13 03:10:36 -04001062
1063
1064class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001065 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001066
Scott Bakerb744f1c2014-11-21 11:32:24 -08001067 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001068 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001069 def getHumanReadableName(self, obj):
1070 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001071 def getValidators(self, obj):
1072 try:
1073 return obj.getValidators()
1074 except:
1075 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001076 class Meta:
1077 model = Charge
Scott Baker96eb3fd2014-11-25 00:53:25 -08001078 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 -07001079
Scott Baker515dc9e2014-12-22 09:29:05 -08001080class ChargeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001081 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001082
Scott Bakerb744f1c2014-11-21 11:32:24 -08001083 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001084 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001085 def getHumanReadableName(self, obj):
1086 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001087 def getValidators(self, obj):
1088 try:
1089 return obj.getValidators()
1090 except:
1091 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001092 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001093 model = Charge
Scott Baker96eb3fd2014-11-25 00:53:25 -08001094 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 -07001095
1096
Sapan Bhatiadea39432014-06-13 03:10:36 -04001097
1098
1099class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001100 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001101
Scott Bakerb744f1c2014-11-21 11:32:24 -08001102 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001103 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001104 def getHumanReadableName(self, obj):
1105 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001106 def getValidators(self, obj):
1107 try:
1108 return obj.getValidators()
1109 except:
1110 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001111 class Meta:
1112 model = Role
Scott Baker96eb3fd2014-11-25 00:53:25 -08001113 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001114
Scott Baker515dc9e2014-12-22 09:29:05 -08001115class RoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001116 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001117
Scott Bakerb744f1c2014-11-21 11:32:24 -08001118 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001119 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001120 def getHumanReadableName(self, obj):
1121 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001122 def getValidators(self, obj):
1123 try:
1124 return obj.getValidators()
1125 except:
1126 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001127 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001128 model = Role
Scott Baker96eb3fd2014-11-25 00:53:25 -08001129 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001130
1131
Sapan Bhatiadea39432014-06-13 03:10:36 -04001132
1133
Scott Baker0caeaf02014-06-19 11:12:55 -07001134class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001135 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001136
Scott Bakerb744f1c2014-11-21 11:32:24 -08001137 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001138 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001139 def getHumanReadableName(self, obj):
1140 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001141 def getValidators(self, obj):
1142 try:
1143 return obj.getValidators()
1144 except:
1145 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001146 class Meta:
1147 model = UsableObject
Scott Baker96eb3fd2014-11-25 00:53:25 -08001148 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001149
Scott Baker515dc9e2014-12-22 09:29:05 -08001150class UsableObjectIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001151 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001152
Scott Bakerb744f1c2014-11-21 11:32:24 -08001153 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001154 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001155 def getHumanReadableName(self, obj):
1156 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001157 def getValidators(self, obj):
1158 try:
1159 return obj.getValidators()
1160 except:
1161 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001162 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001163 model = UsableObject
Scott Baker96eb3fd2014-11-25 00:53:25 -08001164 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001165
Scott Baker0caeaf02014-06-19 11:12:55 -07001166class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001167 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001168
Scott Bakerb744f1c2014-11-21 11:32:24 -08001169 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001170 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001171 def getHumanReadableName(self, obj):
1172 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001173 def getValidators(self, obj):
1174 try:
1175 return obj.getValidators()
1176 except:
1177 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001178 class Meta:
1179 model = SiteRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001180 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001181
Scott Baker515dc9e2014-12-22 09:29:05 -08001182class SiteRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001183 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001184
Scott Bakerb744f1c2014-11-21 11:32:24 -08001185 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001186 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001187 def getHumanReadableName(self, obj):
1188 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001189 def getValidators(self, obj):
1190 try:
1191 return obj.getValidators()
1192 except:
1193 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001194 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001195 model = SiteRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001196 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001197
1198
Scott Baker0caeaf02014-06-19 11:12:55 -07001199
1200
Scott Baker89a7b7c2014-10-07 00:10:17 -07001201class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001202 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001203
Scott Bakerb744f1c2014-11-21 11:32:24 -08001204 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001205 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001206 def getHumanReadableName(self, obj):
1207 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001208 def getValidators(self, obj):
1209 try:
1210 return obj.getValidators()
1211 except:
1212 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001213 class Meta:
1214 model = SliceCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001215 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001216
Scott Baker515dc9e2014-12-22 09:29:05 -08001217class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001218 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001219
Scott Bakerb744f1c2014-11-21 11:32:24 -08001220 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001221 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001222 def getHumanReadableName(self, obj):
1223 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001224 def getValidators(self, obj):
1225 try:
1226 return obj.getValidators()
1227 except:
1228 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001229 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001230 model = SliceCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001231 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001232
1233
1234
1235
Sapan Bhatiadea39432014-06-13 03:10:36 -04001236class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001237 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001238
1239
1240 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1241
1242
Scott Bakerb744f1c2014-11-21 11:32:24 -08001243 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001244 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001245 def getHumanReadableName(self, obj):
1246 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001247 def getValidators(self, obj):
1248 try:
1249 return obj.getValidators()
1250 except:
1251 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001252 class Meta:
1253 model = Sliver
Scott Baker16fce9c2015-01-03 12:05:21 -08001254 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 -07001255
Scott Baker515dc9e2014-12-22 09:29:05 -08001256class SliverIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001257 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001258
1259
Scott Baker201f7da2014-12-23 10:56:06 -08001260 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -07001261
1262
Scott Bakerb744f1c2014-11-21 11:32:24 -08001263 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001264 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001265 def getHumanReadableName(self, obj):
1266 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001267 def getValidators(self, obj):
1268 try:
1269 return obj.getValidators()
1270 except:
1271 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001272 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001273 model = Sliver
Scott Baker16fce9c2015-01-03 12:05:21 -08001274 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 -07001275
1276
Sapan Bhatiadea39432014-06-13 03:10:36 -04001277
1278
1279class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001280 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001281
Scott Bakerb744f1c2014-11-21 11:32:24 -08001282 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001283 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001284 def getHumanReadableName(self, obj):
1285 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001286 def getValidators(self, obj):
1287 try:
1288 return obj.getValidators()
1289 except:
1290 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001291 class Meta:
1292 model = Node
Scott Baker515dc9e2014-12-22 09:29:05 -08001293 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001294
Scott Baker515dc9e2014-12-22 09:29:05 -08001295class NodeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001296 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001297
Scott Bakerb744f1c2014-11-21 11:32:24 -08001298 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001299 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001300 def getHumanReadableName(self, obj):
1301 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001302 def getValidators(self, obj):
1303 try:
1304 return obj.getValidators()
1305 except:
1306 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001307 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001308 model = Node
Scott Baker515dc9e2014-12-22 09:29:05 -08001309 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001310
1311
Sapan Bhatiadea39432014-06-13 03:10:36 -04001312
1313
Scott Baker0caeaf02014-06-19 11:12:55 -07001314class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001315 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001316
Scott Baker515dc9e2014-12-22 09:29:05 -08001317
1318 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1319
1320
Scott Bakerb744f1c2014-11-21 11:32:24 -08001321 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001322 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001323 def getHumanReadableName(self, obj):
1324 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001325 def getValidators(self, obj):
1326 try:
1327 return obj.getValidators()
1328 except:
1329 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001330 class Meta:
1331 model = DashboardView
Scott Baker515dc9e2014-12-22 09:29:05 -08001332 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker46b58542014-08-11 17:26:12 -07001333
Scott Baker515dc9e2014-12-22 09:29:05 -08001334class DashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001335 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001336
Scott Baker515dc9e2014-12-22 09:29:05 -08001337
Scott Baker201f7da2014-12-23 10:56:06 -08001338 controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001339
1340
Scott Bakerb744f1c2014-11-21 11:32:24 -08001341 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001342 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001343 def getHumanReadableName(self, obj):
1344 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001345 def getValidators(self, obj):
1346 try:
1347 return obj.getValidators()
1348 except:
1349 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001350 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001351 model = DashboardView
Scott Baker515dc9e2014-12-22 09:29:05 -08001352 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001353
1354
1355
1356
Scott Baker515dc9e2014-12-22 09:29:05 -08001357class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001358 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001359
1360 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001361 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001362 def getHumanReadableName(self, obj):
1363 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001364 def getValidators(self, obj):
1365 try:
1366 return obj.getValidators()
1367 except:
1368 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001369 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001370 model = ImageDeployments
1371 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001372
Scott Baker515dc9e2014-12-22 09:29:05 -08001373class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001374 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001375
1376 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001377 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001378 def getHumanReadableName(self, obj):
1379 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001380 def getValidators(self, obj):
1381 try:
1382 return obj.getValidators()
1383 except:
1384 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001385 class Meta:
1386 model = ImageDeployments
1387 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001388
1389
Sapan Bhatiadea39432014-06-13 03:10:36 -04001390
1391
Scott Baker0caeaf02014-06-19 11:12:55 -07001392class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001393 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001394
Scott Bakerb744f1c2014-11-21 11:32:24 -08001395 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001396 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001397 def getHumanReadableName(self, obj):
1398 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001399 def getValidators(self, obj):
1400 try:
1401 return obj.getValidators()
1402 except:
1403 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001404 class Meta:
1405 model = ReservedResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08001406 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001407
Scott Baker515dc9e2014-12-22 09:29:05 -08001408class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001409 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001410
Scott Bakerb744f1c2014-11-21 11:32:24 -08001411 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001412 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001413 def getHumanReadableName(self, obj):
1414 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001415 def getValidators(self, obj):
1416 try:
1417 return obj.getValidators()
1418 except:
1419 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001420 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001421 model = ReservedResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08001422 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker8b533192014-11-17 22:32:19 -08001423
1424
1425
1426
Scott Baker515dc9e2014-12-22 09:29:05 -08001427class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001428 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001429
1430 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1431 validators = serializers.SerializerMethodField("getValidators")
1432 def getHumanReadableName(self, obj):
1433 return str(obj)
1434 def getValidators(self, obj):
1435 try:
1436 return obj.getValidators()
1437 except:
1438 return None
1439 class Meta:
1440 model = Payment
1441 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1442
1443class PaymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001444 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001445
1446 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1447 validators = serializers.SerializerMethodField("getValidators")
1448 def getHumanReadableName(self, obj):
1449 return str(obj)
1450 def getValidators(self, obj):
1451 try:
1452 return obj.getValidators()
1453 except:
1454 return None
1455 class Meta:
1456 model = Payment
1457 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1458
1459
1460
1461
Scott Baker0caeaf02014-06-19 11:12:55 -07001462class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001463 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001464
Scott Bakerb744f1c2014-11-21 11:32:24 -08001465 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001466 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001467 def getHumanReadableName(self, obj):
1468 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001469 def getValidators(self, obj):
1470 try:
1471 return obj.getValidators()
1472 except:
1473 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001474 class Meta:
1475 model = NetworkSlice
Scott Baker96eb3fd2014-11-25 00:53:25 -08001476 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001477
Scott Baker515dc9e2014-12-22 09:29:05 -08001478class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001479 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001480
Scott Bakerb744f1c2014-11-21 11:32:24 -08001481 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001482 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001483 def getHumanReadableName(self, obj):
1484 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001485 def getValidators(self, obj):
1486 try:
1487 return obj.getValidators()
1488 except:
1489 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001490 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001491 model = NetworkSlice
Scott Baker96eb3fd2014-11-25 00:53:25 -08001492 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001493
1494
Scott Baker0caeaf02014-06-19 11:12:55 -07001495
1496
1497class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001498 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001499
Scott Bakerb744f1c2014-11-21 11:32:24 -08001500 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001501 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001502 def getHumanReadableName(self, obj):
1503 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001504 def getValidators(self, obj):
1505 try:
1506 return obj.getValidators()
1507 except:
1508 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001509 class Meta:
1510 model = UserDashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001511 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001512
Scott Baker515dc9e2014-12-22 09:29:05 -08001513class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001514 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001515
Scott Bakerb744f1c2014-11-21 11:32:24 -08001516 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001517 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001518 def getHumanReadableName(self, obj):
1519 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001520 def getValidators(self, obj):
1521 try:
1522 return obj.getValidators()
1523 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001524 return None
1525 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001526 model = UserDashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001527 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker8b533192014-11-17 22:32:19 -08001528
1529
1530
1531
Scott Baker515dc9e2014-12-22 09:29:05 -08001532class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001533 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001534
Scott Baker515dc9e2014-12-22 09:29:05 -08001535
1536 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1537
1538
Scott Bakerb744f1c2014-11-21 11:32:24 -08001539 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001540 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001541 def getHumanReadableName(self, obj):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001542 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001543 def getValidators(self, obj):
1544 try:
1545 return obj.getValidators()
1546 except:
1547 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001548 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001549 model = Controller
1550 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 -07001551
Scott Baker515dc9e2014-12-22 09:29:05 -08001552class ControllerIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001553 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001554
1555
Scott Baker201f7da2014-12-23 10:56:06 -08001556 dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -07001557
1558
Scott Bakerb744f1c2014-11-21 11:32:24 -08001559 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001560 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001561 def getHumanReadableName(self, obj):
1562 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001563 def getValidators(self, obj):
1564 try:
1565 return obj.getValidators()
1566 except:
1567 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001568 class Meta:
1569 model = Controller
1570 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
1571
1572
1573
1574
1575class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001576 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001577
1578 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1579 validators = serializers.SerializerMethodField("getValidators")
1580 def getHumanReadableName(self, obj):
1581 return str(obj)
1582 def getValidators(self, obj):
1583 try:
1584 return obj.getValidators()
1585 except:
1586 return None
1587 class Meta:
1588 model = PlanetStackPrivilege
1589 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1590
1591class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001592 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001593
1594 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1595 validators = serializers.SerializerMethodField("getValidators")
1596 def getHumanReadableName(self, obj):
1597 return str(obj)
1598 def getValidators(self, obj):
1599 try:
1600 return obj.getValidators()
1601 except:
1602 return None
1603 class Meta:
1604 model = PlanetStackPrivilege
1605 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1606
1607
1608
1609
1610class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001611 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001612
1613 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1614 validators = serializers.SerializerMethodField("getValidators")
1615 def getHumanReadableName(self, obj):
1616 return str(obj)
1617 def getValidators(self, obj):
1618 try:
1619 return obj.getValidators()
1620 except:
1621 return None
1622 class Meta:
1623 model = User
1624 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',)
1625
1626class UserIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001627 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001628
1629 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1630 validators = serializers.SerializerMethodField("getValidators")
1631 def getHumanReadableName(self, obj):
1632 return str(obj)
1633 def getValidators(self, obj):
1634 try:
1635 return obj.getValidators()
1636 except:
1637 return None
1638 class Meta:
1639 model = User
1640 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',)
1641
1642
1643
1644
1645class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001646 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001647
1648
1649 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1650
1651
1652
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001653 images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1654
1655
1656
Scott Baker515dc9e2014-12-22 09:29:05 -08001657 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1658
1659
1660 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1661 validators = serializers.SerializerMethodField("getValidators")
1662 def getHumanReadableName(self, obj):
1663 return str(obj)
1664 def getValidators(self, obj):
1665 try:
1666 return obj.getValidators()
1667 except:
1668 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001669 class Meta:
1670 model = Deployment
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001671 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Scott Baker46b58542014-08-11 17:26:12 -07001672
Scott Baker515dc9e2014-12-22 09:29:05 -08001673class DeploymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001674 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001675
1676
Scott Baker201f7da2014-12-23 10:56:06 -08001677 flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001678
1679
1680
Scott Baker201f7da2014-12-23 10:56:06 -08001681 images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all())
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001682
1683
1684
Scott Baker201f7da2014-12-23 10:56:06 -08001685 sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001686
1687
Tony Mack06c8e472014-11-30 15:53:08 -05001688 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1689 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001690 def getHumanReadableName(self, obj):
1691 return str(obj)
1692 def getValidators(self, obj):
Tony Mack06c8e472014-11-30 15:53:08 -05001693 try:
1694 return obj.getValidators()
1695 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001696 return None
1697 class Meta:
1698 model = Deployment
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001699 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Tony Mack06c8e472014-11-30 15:53:08 -05001700
1701
Sapan Bhatiadea39432014-06-13 03:10:36 -04001702
1703
1704class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001705 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001706
Scott Bakerb744f1c2014-11-21 11:32:24 -08001707 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001708 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001709 def getHumanReadableName(self, obj):
1710 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001711 def getValidators(self, obj):
1712 try:
1713 return obj.getValidators()
1714 except:
1715 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001716 class Meta:
1717 model = Reservation
Scott Baker96eb3fd2014-11-25 00:53:25 -08001718 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001719
Scott Baker515dc9e2014-12-22 09:29:05 -08001720class ReservationIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001721 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001722
Scott Bakerb744f1c2014-11-21 11:32:24 -08001723 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001724 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001725 def getHumanReadableName(self, obj):
1726 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001727 def getValidators(self, obj):
1728 try:
1729 return obj.getValidators()
1730 except:
1731 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001732 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001733 model = Reservation
Scott Baker96eb3fd2014-11-25 00:53:25 -08001734 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001735
1736
Scott Baker0caeaf02014-06-19 11:12:55 -07001737
1738
Scott Bakerb744f1c2014-11-21 11:32:24 -08001739class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001740 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001741
1742 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001743 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001744 def getHumanReadableName(self, obj):
1745 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001746 def getValidators(self, obj):
1747 try:
1748 return obj.getValidators()
1749 except:
1750 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001751 class Meta:
1752 model = SitePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001753 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001754
Scott Baker515dc9e2014-12-22 09:29:05 -08001755class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001756 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001757
1758 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001759 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001760 def getHumanReadableName(self, obj):
1761 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001762 def getValidators(self, obj):
1763 try:
1764 return obj.getValidators()
1765 except:
1766 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001767 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08001768 model = SitePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001769 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001770
1771
1772
1773
1774class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001775 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001776
1777 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001778 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001779 def getHumanReadableName(self, obj):
1780 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001781 def getValidators(self, obj):
1782 try:
1783 return obj.getValidators()
1784 except:
1785 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001786 class Meta:
1787 model = PlanetStack
Scott Baker96eb3fd2014-11-25 00:53:25 -08001788 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001789
Scott Baker515dc9e2014-12-22 09:29:05 -08001790class PlanetStackIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001791 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001792
1793 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001794 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001795 def getHumanReadableName(self, obj):
1796 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001797 def getValidators(self, obj):
1798 try:
1799 return obj.getValidators()
1800 except:
1801 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001802 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08001803 model = PlanetStack
Scott Baker96eb3fd2014-11-25 00:53:25 -08001804 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001805
1806
Sapan Bhatiadea39432014-06-13 03:10:36 -04001807
1808
Scott Bakerf2c0c512014-12-22 17:35:34 -08001809class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001810 id = IdField()
Scott Bakerf2c0c512014-12-22 17:35:34 -08001811
1812 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1813 validators = serializers.SerializerMethodField("getValidators")
1814 def getHumanReadableName(self, obj):
1815 return str(obj)
1816 def getValidators(self, obj):
1817 try:
1818 return obj.getValidators()
1819 except:
1820 return None
1821 class Meta:
1822 model = ControllerDashboardView
1823 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1824
1825class ControllerDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001826 id = IdField()
Scott Bakerf2c0c512014-12-22 17:35:34 -08001827
1828 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1829 validators = serializers.SerializerMethodField("getValidators")
1830 def getHumanReadableName(self, obj):
1831 return str(obj)
1832 def getValidators(self, obj):
1833 try:
1834 return obj.getValidators()
1835 except:
1836 return None
1837 class Meta:
1838 model = ControllerDashboardView
1839 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1840
1841
1842
1843
Sapan Bhatiadea39432014-06-13 03:10:36 -04001844class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001845 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001846
Scott Bakerb744f1c2014-11-21 11:32:24 -08001847 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001848 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001849 def getHumanReadableName(self, obj):
1850 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001851 def getValidators(self, obj):
1852 try:
1853 return obj.getValidators()
1854 except:
1855 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001856 class Meta:
1857 model = Account
Scott Baker96eb3fd2014-11-25 00:53:25 -08001858 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001859
Scott Baker515dc9e2014-12-22 09:29:05 -08001860class AccountIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001861 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001862
Scott Bakerb744f1c2014-11-21 11:32:24 -08001863 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001864 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001865 def getHumanReadableName(self, obj):
1866 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001867 def getValidators(self, obj):
1868 try:
1869 return obj.getValidators()
1870 except:
1871 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001872 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001873 model = Account
Scott Baker96eb3fd2014-11-25 00:53:25 -08001874 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001875
1876
Sapan Bhatiadea39432014-06-13 03:10:36 -04001877
1878
Scott Baker515dc9e2014-12-22 09:29:05 -08001879class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001880 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001881
1882 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1883 validators = serializers.SerializerMethodField("getValidators")
1884 def getHumanReadableName(self, obj):
1885 return str(obj)
1886 def getValidators(self, obj):
1887 try:
1888 return obj.getValidators()
1889 except:
1890 return None
1891 class Meta:
1892 model = ControllerRole
1893 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1894
1895class ControllerRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001896 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001897
1898 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1899 validators = serializers.SerializerMethodField("getValidators")
1900 def getHumanReadableName(self, obj):
1901 return str(obj)
1902 def getValidators(self, obj):
1903 try:
1904 return obj.getValidators()
1905 except:
1906 return None
1907 class Meta:
1908 model = ControllerRole
1909 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1910
1911
1912
1913
Scott Baker0caeaf02014-06-19 11:12:55 -07001914class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001915 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001916
Scott Bakerb744f1c2014-11-21 11:32:24 -08001917 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001918 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001919 def getHumanReadableName(self, obj):
1920 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001921 def getValidators(self, obj):
1922 try:
1923 return obj.getValidators()
1924 except:
1925 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001926 class Meta:
1927 model = NetworkParameterType
Scott Baker96eb3fd2014-11-25 00:53:25 -08001928 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001929
Scott Baker515dc9e2014-12-22 09:29:05 -08001930class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001931 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001932
Scott Bakerb744f1c2014-11-21 11:32:24 -08001933 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001934 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001935 def getHumanReadableName(self, obj):
1936 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001937 def getValidators(self, obj):
1938 try:
1939 return obj.getValidators()
1940 except:
1941 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001942 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001943 model = NetworkParameterType
Scott Baker96eb3fd2014-11-25 00:53:25 -08001944 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001945
1946
Sapan Bhatiadea39432014-06-13 03:10:36 -04001947
1948
Scott Baker89a7b7c2014-10-07 00:10:17 -07001949class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001950 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001951
Scott Bakerb744f1c2014-11-21 11:32:24 -08001952 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001953 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001954 def getHumanReadableName(self, obj):
1955 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001956 def getValidators(self, obj):
1957 try:
1958 return obj.getValidators()
1959 except:
1960 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001961 class Meta:
1962 model = SiteCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001963 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001964
Scott Baker515dc9e2014-12-22 09:29:05 -08001965class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001966 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001967
Scott Bakerb744f1c2014-11-21 11:32:24 -08001968 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001969 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001970 def getHumanReadableName(self, obj):
1971 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001972 def getValidators(self, obj):
1973 try:
1974 return obj.getValidators()
1975 except:
1976 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001977 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001978 model = SiteCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001979 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001980
1981
Scott Baker0caeaf02014-06-19 11:12:55 -07001982
1983
Scott Baker515dc9e2014-12-22 09:29:05 -08001984class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001985 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001986
Scott Bakerb744f1c2014-11-21 11:32:24 -08001987 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001988 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001989 def getHumanReadableName(self, obj):
1990 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001991 def getValidators(self, obj):
1992 try:
1993 return obj.getValidators()
1994 except:
1995 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001996 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001997 model = DeploymentPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001998 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001999
Scott Baker515dc9e2014-12-22 09:29:05 -08002000class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002001 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002002
Scott Bakerb744f1c2014-11-21 11:32:24 -08002003 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002004 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002005 def getHumanReadableName(self, obj):
2006 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002007 def getValidators(self, obj):
2008 try:
2009 return obj.getValidators()
2010 except:
2011 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002012 class Meta:
2013 model = DeploymentPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08002014 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker8b533192014-11-17 22:32:19 -08002015
2016
2017
2018
Tony Mack3066a952015-01-05 22:48:11 -05002019class ControllerUserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002020 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002021
Scott Bakerb744f1c2014-11-21 11:32:24 -08002022 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002023 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002024 def getHumanReadableName(self, obj):
2025 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002026 def getValidators(self, obj):
2027 try:
2028 return obj.getValidators()
2029 except:
2030 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002031 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002032 model = ControllerUser
Scott Baker515dc9e2014-12-22 09:29:05 -08002033 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2034
Tony Mack3066a952015-01-05 22:48:11 -05002035class ControllerUserIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002036 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002037
2038 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2039 validators = serializers.SerializerMethodField("getValidators")
2040 def getHumanReadableName(self, obj):
2041 return str(obj)
2042 def getValidators(self, obj):
2043 try:
2044 return obj.getValidators()
2045 except:
2046 return None
2047 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002048 model = ControllerUser
Scott Baker515dc9e2014-12-22 09:29:05 -08002049 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2050
2051
2052
2053
2054class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002055 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002056
2057 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2058 validators = serializers.SerializerMethodField("getValidators")
2059 def getHumanReadableName(self, obj):
2060 return str(obj)
2061 def getValidators(self, obj):
2062 try:
2063 return obj.getValidators()
2064 except:
2065 return None
2066 class Meta:
2067 model = DeploymentRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08002068 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002069
Scott Baker515dc9e2014-12-22 09:29:05 -08002070class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002071 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002072
Scott Bakerb744f1c2014-11-21 11:32:24 -08002073 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002074 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002075 def getHumanReadableName(self, obj):
2076 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002077 def getValidators(self, obj):
2078 try:
2079 return obj.getValidators()
2080 except:
2081 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002082 class Meta:
2083 model = DeploymentRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08002084 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002085
2086
Sapan Bhatiadea39432014-06-13 03:10:36 -04002087
2088
Scott Baker89a7b7c2014-10-07 00:10:17 -07002089class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002090 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002091
Scott Bakerb744f1c2014-11-21 11:32:24 -08002092 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002093 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002094 def getHumanReadableName(self, obj):
2095 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002096 def getValidators(self, obj):
2097 try:
2098 return obj.getValidators()
2099 except:
2100 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002101 class Meta:
2102 model = UserCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08002103 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002104
Scott Baker515dc9e2014-12-22 09:29:05 -08002105class UserCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002106 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002107
Scott Bakerb744f1c2014-11-21 11:32:24 -08002108 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002109 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002110 def getHumanReadableName(self, obj):
2111 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002112 def getValidators(self, obj):
2113 try:
2114 return obj.getValidators()
2115 except:
2116 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002117 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002118 model = UserCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08002119 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08002120
2121
2122
2123
Tony Mack3066a952015-01-05 22:48:11 -05002124class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002125 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08002126
2127 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002128 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002129 def getHumanReadableName(self, obj):
2130 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002131 def getValidators(self, obj):
2132 try:
2133 return obj.getValidators()
2134 except:
2135 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08002136 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002137 model = SiteDeployment
Scott Baker515dc9e2014-12-22 09:29:05 -08002138 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08002139
Tony Mack3066a952015-01-05 22:48:11 -05002140class SiteDeploymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002141 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08002142
2143 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002144 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002145 def getHumanReadableName(self, obj):
2146 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002147 def getValidators(self, obj):
2148 try:
2149 return obj.getValidators()
2150 except:
2151 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002152 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002153 model = SiteDeployment
Scott Baker515dc9e2014-12-22 09:29:05 -08002154 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
2155
2156
Scott Baker89a7b7c2014-10-07 00:10:17 -07002157
2158
Scott Baker0caeaf02014-06-19 11:12:55 -07002159class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002160 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002161
Scott Bakerb744f1c2014-11-21 11:32:24 -08002162 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002163 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002164 def getHumanReadableName(self, obj):
2165 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002166 def getValidators(self, obj):
2167 try:
2168 return obj.getValidators()
2169 except:
2170 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002171 class Meta:
2172 model = SliceTag
Scott Baker96eb3fd2014-11-25 00:53:25 -08002173 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002174
Scott Baker515dc9e2014-12-22 09:29:05 -08002175class SliceTagIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002176 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002177
Scott Bakerb744f1c2014-11-21 11:32:24 -08002178 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002179 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002180 def getHumanReadableName(self, obj):
2181 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002182 def getValidators(self, obj):
2183 try:
2184 return obj.getValidators()
2185 except:
2186 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002187 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002188 model = SliceTag
Scott Baker96eb3fd2014-11-25 00:53:25 -08002189 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002190
2191
Scott Baker0caeaf02014-06-19 11:12:55 -07002192
2193
Scott Bakerf2c0c512014-12-22 17:35:34 -08002194class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002195 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002196
Scott Bakerb744f1c2014-11-21 11:32:24 -08002197 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002198 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002199 def getHumanReadableName(self, obj):
2200 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002201 def getValidators(self, obj):
2202 try:
2203 return obj.getValidators()
2204 except:
2205 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002206 class Meta:
Scott Bakerf2c0c512014-12-22 17:35:34 -08002207 model = NetworkTemplate
Scott Baker16fce9c2015-01-03 12:05:21 -08002208 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 -07002209
Scott Bakerf2c0c512014-12-22 17:35:34 -08002210class NetworkTemplateIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002211 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002212
Scott Bakerb744f1c2014-11-21 11:32:24 -08002213 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002214 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002215 def getHumanReadableName(self, obj):
2216 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002217 def getValidators(self, obj):
2218 try:
2219 return obj.getValidators()
2220 except:
2221 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002222 class Meta:
Scott Bakerf2c0c512014-12-22 17:35:34 -08002223 model = NetworkTemplate
Scott Baker16fce9c2015-01-03 12:05:21 -08002224 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 -07002225
2226
Sapan Bhatiadea39432014-06-13 03:10:36 -04002227
2228
2229class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002230 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002231
Scott Baker515dc9e2014-12-22 09:29:05 -08002232
2233 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2234
2235
2236
2237 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2238
2239
Scott Bakerb744f1c2014-11-21 11:32:24 -08002240 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002241 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002242 def getHumanReadableName(self, obj):
2243 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002244 def getValidators(self, obj):
2245 try:
2246 return obj.getValidators()
2247 except:
2248 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002249 class Meta:
2250 model = Router
Scott Baker515dc9e2014-12-22 09:29:05 -08002251 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002252
Scott Baker515dc9e2014-12-22 09:29:05 -08002253class RouterIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002254 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002255
Scott Baker515dc9e2014-12-22 09:29:05 -08002256
Scott Baker201f7da2014-12-23 10:56:06 -08002257 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08002258
2259
2260
Scott Baker201f7da2014-12-23 10:56:06 -08002261 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08002262
2263
Scott Bakerb744f1c2014-11-21 11:32:24 -08002264 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002265 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002266 def getHumanReadableName(self, obj):
2267 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002268 def getValidators(self, obj):
2269 try:
2270 return obj.getValidators()
2271 except:
2272 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002273 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002274 model = Router
Scott Baker515dc9e2014-12-22 09:29:05 -08002275 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002276
2277
Sapan Bhatiadea39432014-06-13 03:10:36 -04002278
2279
Scott Baker0caeaf02014-06-19 11:12:55 -07002280class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002281 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002282
Scott Bakerb744f1c2014-11-21 11:32:24 -08002283 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002284 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002285 def getHumanReadableName(self, obj):
2286 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002287 def getValidators(self, obj):
2288 try:
2289 return obj.getValidators()
2290 except:
2291 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002292 class Meta:
2293 model = ServiceResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08002294 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 -07002295
Scott Baker515dc9e2014-12-22 09:29:05 -08002296class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002297 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002298
Scott Bakerb744f1c2014-11-21 11:32:24 -08002299 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002300 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002301 def getHumanReadableName(self, obj):
2302 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002303 def getValidators(self, obj):
2304 try:
2305 return obj.getValidators()
2306 except:
2307 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002308 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002309 model = ServiceResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08002310 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 -07002311
2312
Sapan Bhatiadea39432014-06-13 03:10:36 -04002313
2314
Tony Mack3066a952015-01-05 22:48:11 -05002315class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002316 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002317
2318 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2319 validators = serializers.SerializerMethodField("getValidators")
2320 def getHumanReadableName(self, obj):
2321 return str(obj)
2322 def getValidators(self, obj):
2323 try:
2324 return obj.getValidators()
2325 except:
2326 return None
2327 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002328 model = ControllerSlice
Scott Baker515dc9e2014-12-22 09:29:05 -08002329 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2330
Tony Mack3066a952015-01-05 22:48:11 -05002331class ControllerSliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002332 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002333
2334 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2335 validators = serializers.SerializerMethodField("getValidators")
2336 def getHumanReadableName(self, obj):
2337 return str(obj)
2338 def getValidators(self, obj):
2339 try:
2340 return obj.getValidators()
2341 except:
2342 return None
2343 class Meta:
Tony Mack3066a952015-01-05 22:48:11 -05002344 model = ControllerSlice
Scott Baker515dc9e2014-12-22 09:29:05 -08002345 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2346
2347
2348
2349
Sapan Bhatiadea39432014-06-13 03:10:36 -04002350serializerLookUp = {
2351
Scott Baker515dc9e2014-12-22 09:29:05 -08002352 Flavor: FlavorSerializer,
2353
Scott Baker0caeaf02014-06-19 11:12:55 -07002354 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002355
Scott Baker515dc9e2014-12-22 09:29:05 -08002356 ControllerImages: ControllerImagesSerializer,
2357
Sapan Bhatiadea39432014-06-13 03:10:36 -04002358 Image: ImageSerializer,
2359
Scott Baker0caeaf02014-06-19 11:12:55 -07002360 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002361
2362 Site: SiteSerializer,
2363
Scott Baker0caeaf02014-06-19 11:12:55 -07002364 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002365
2366 Tag: TagSerializer,
2367
2368 Invoice: InvoiceSerializer,
2369
Scott Baker0caeaf02014-06-19 11:12:55 -07002370 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002371
Scott Baker89a7b7c2014-10-07 00:10:17 -07002372 PlanetStackRole: PlanetStackRoleSerializer,
2373
Scott Baker515dc9e2014-12-22 09:29:05 -08002374 ControllerPrivilege: ControllerPrivilegeSerializer,
2375
Scott Baker0caeaf02014-06-19 11:12:55 -07002376 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002377
Scott Baker89a7b7c2014-10-07 00:10:17 -07002378 Project: ProjectSerializer,
2379
Sapan Bhatiadea39432014-06-13 03:10:36 -04002380 Slice: SliceSerializer,
2381
2382 Network: NetworkSerializer,
2383
2384 Service: ServiceSerializer,
2385
Scott Baker0caeaf02014-06-19 11:12:55 -07002386 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002387
Tony Mack3066a952015-01-05 22:48:11 -05002388 ControllerNetwork: ControllerNetworkSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002389
2390 Charge: ChargeSerializer,
2391
2392 Role: RoleSerializer,
2393
Scott Baker0caeaf02014-06-19 11:12:55 -07002394 UsableObject: UsableObjectSerializer,
2395
2396 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002397
Scott Baker89a7b7c2014-10-07 00:10:17 -07002398 SliceCredential: SliceCredentialSerializer,
2399
Sapan Bhatiadea39432014-06-13 03:10:36 -04002400 Sliver: SliverSerializer,
2401
2402 Node: NodeSerializer,
2403
Scott Baker0caeaf02014-06-19 11:12:55 -07002404 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002405
Scott Baker515dc9e2014-12-22 09:29:05 -08002406 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002407
Scott Bakerb744f1c2014-11-21 11:32:24 -08002408 ReservedResource: ReservedResourceSerializer,
Scott Baker8b533192014-11-17 22:32:19 -08002409
Scott Baker515dc9e2014-12-22 09:29:05 -08002410 Payment: PaymentSerializer,
2411
Scott Baker0caeaf02014-06-19 11:12:55 -07002412 NetworkSlice: NetworkSliceSerializer,
2413
2414 UserDashboardView: UserDashboardViewSerializer,
2415
Scott Baker515dc9e2014-12-22 09:29:05 -08002416 Controller: ControllerSerializer,
2417
Scott Baker0caeaf02014-06-19 11:12:55 -07002418 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002419
2420 User: UserSerializer,
2421
2422 Deployment: DeploymentSerializer,
2423
2424 Reservation: ReservationSerializer,
2425
Scott Baker0caeaf02014-06-19 11:12:55 -07002426 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002427
Scott Bakerb744f1c2014-11-21 11:32:24 -08002428 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002429
Scott Bakerf2c0c512014-12-22 17:35:34 -08002430 ControllerDashboardView: ControllerDashboardViewSerializer,
2431
Sapan Bhatiadea39432014-06-13 03:10:36 -04002432 Account: AccountSerializer,
2433
Scott Baker515dc9e2014-12-22 09:29:05 -08002434 ControllerRole: ControllerRoleSerializer,
2435
Scott Baker0caeaf02014-06-19 11:12:55 -07002436 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002437
Scott Baker89a7b7c2014-10-07 00:10:17 -07002438 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002439
Scott Baker515dc9e2014-12-22 09:29:05 -08002440 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002441
Tony Mack3066a952015-01-05 22:48:11 -05002442 ControllerUser: ControllerUserSerializer,
Scott Baker515dc9e2014-12-22 09:29:05 -08002443
2444 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002445
Scott Baker89a7b7c2014-10-07 00:10:17 -07002446 UserCredential: UserCredentialSerializer,
2447
Tony Mack3066a952015-01-05 22:48:11 -05002448 SiteDeployment: SiteDeploymentSerializer,
Scott Bakerb744f1c2014-11-21 11:32:24 -08002449
Scott Baker0caeaf02014-06-19 11:12:55 -07002450 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002451
Scott Bakerf2c0c512014-12-22 17:35:34 -08002452 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002453
2454 Router: RouterSerializer,
2455
Scott Baker0caeaf02014-06-19 11:12:55 -07002456 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002457
Tony Mack3066a952015-01-05 22:48:11 -05002458 ControllerSlice: ControllerSliceSerializer,
Scott Baker515dc9e2014-12-22 09:29:05 -08002459
Sapan Bhatiadea39432014-06-13 03:10:36 -04002460 None: None,
2461 }
2462
Scott Baker89a7b7c2014-10-07 00:10:17 -07002463class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2464
2465 # To handle fine-grained field permissions, we have to check can_update
2466 # the object has been updated but before it has been saved.
2467
2468 def update(self, request, *args, **kwargs):
2469 partial = kwargs.pop('partial', False)
2470 self.object = self.get_object_or_none()
2471
2472 serializer = self.get_serializer(self.object, data=request.DATA,
2473 files=request.FILES, partial=partial)
2474
2475 if not serializer.is_valid():
Scott Baker96eb3fd2014-11-25 00:53:25 -08002476 response = {"error": "validation",
2477 "specific_error": "not serializer.is_valid()",
2478 "reasons": serializer.errors}
2479 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002480
2481 try:
2482 self.pre_save(serializer.object)
2483 except ValidationError as err:
2484 # full_clean on model instance may be called in pre_save,
2485 # so we have to handle eventual errors.
Scott Baker96eb3fd2014-11-25 00:53:25 -08002486 response = {"error": "validation",
2487 "specific_error": "ValidationError in pre_save",
2488 "reasons": err.message_dict}
2489 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002490
2491 if serializer.object is not None:
2492 if not serializer.object.can_update(request.user):
2493 return Response(status=status.HTTP_400_BAD_REQUEST)
2494
2495 if self.object is None:
2496 self.object = serializer.save(force_insert=True)
2497 self.post_save(self.object, created=True)
2498 return Response(serializer.data, status=status.HTTP_201_CREATED)
2499
2500 self.object = serializer.save(force_update=True)
2501 self.post_save(self.object, created=False)
2502 return Response(serializer.data, status=status.HTTP_200_OK)
2503
2504 def destroy(self, request, *args, **kwargs):
2505 obj = self.get_object()
2506 if obj.can_update(request.user):
Scott Baker2bcbf372014-10-29 23:41:11 -07002507 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002508 else:
2509 return Response(status=status.HTTP_400_BAD_REQUEST)
2510
2511
Sapan Bhatiadea39432014-06-13 03:10:36 -04002512# Based on core/views/*.py
2513
2514
Scott Baker515dc9e2014-12-22 09:29:05 -08002515class FlavorList(generics.ListCreateAPIView):
2516 queryset = Flavor.objects.select_related().all()
2517 serializer_class = FlavorSerializer
2518 id_serializer_class = FlavorIdSerializer
2519 filter_backends = (filters.DjangoFilterBackend,)
2520 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
2521
2522 def get_serializer_class(self):
2523 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2524 if (no_hyperlinks):
2525 return self.id_serializer_class
2526 else:
2527 return self.serializer_class
2528
2529 def get_queryset(self):
2530 return Flavor.select_by_user(self.request.user)
2531
2532 def create(self, request, *args, **kwargs):
2533 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2534 if not (serializer.is_valid()):
2535 response = {"error": "validation",
2536 "specific_error": "not serializer.is_valid()",
2537 "reasons": serializer.errors}
2538 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2539 obj = serializer.object
2540 obj.caller = request.user
2541 if obj.can_update(request.user):
2542 return super(FlavorList, self).create(request, *args, **kwargs)
2543 else:
2544 raise Exception("failed obj.can_update")
2545
2546 ret = super(FlavorList, self).create(request, *args, **kwargs)
2547 if (ret.status_code%100 != 200):
2548 raise Exception(ret.data)
2549
2550 return ret
2551
2552
2553class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2554 queryset = Flavor.objects.select_related().all()
2555 serializer_class = FlavorSerializer
2556 id_serializer_class = FlavorIdSerializer
2557
2558 def get_serializer_class(self):
2559 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2560 if (no_hyperlinks):
2561 return self.id_serializer_class
2562 else:
2563 return self.serializer_class
2564
2565 def get_queryset(self):
2566 return Flavor.select_by_user(self.request.user)
2567
2568 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2569
2570 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2571
2572
2573
Scott Baker0caeaf02014-06-19 11:12:55 -07002574class ServiceAttributeList(generics.ListCreateAPIView):
2575 queryset = ServiceAttribute.objects.select_related().all()
2576 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002577 id_serializer_class = ServiceAttributeIdSerializer
2578 filter_backends = (filters.DjangoFilterBackend,)
2579 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2580
2581 def get_serializer_class(self):
2582 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2583 if (no_hyperlinks):
2584 return self.id_serializer_class
2585 else:
2586 return self.serializer_class
2587
Scott Baker0caeaf02014-06-19 11:12:55 -07002588 def get_queryset(self):
2589 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002590
Scott Baker0caeaf02014-06-19 11:12:55 -07002591 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002592 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2593 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002594 response = {"error": "validation",
2595 "specific_error": "not serializer.is_valid()",
2596 "reasons": serializer.errors}
2597 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002598 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002599 obj.caller = request.user
2600 if obj.can_update(request.user):
2601 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2602 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002603 raise Exception("failed obj.can_update")
2604
2605 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2606 if (ret.status_code%100 != 200):
2607 raise Exception(ret.data)
2608
2609 return ret
2610
Scott Baker0caeaf02014-06-19 11:12:55 -07002611
Scott Baker89a7b7c2014-10-07 00:10:17 -07002612class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002613 queryset = ServiceAttribute.objects.select_related().all()
2614 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002615 id_serializer_class = ServiceAttributeIdSerializer
2616
2617 def get_serializer_class(self):
2618 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2619 if (no_hyperlinks):
2620 return self.id_serializer_class
2621 else:
2622 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002623
2624 def get_queryset(self):
2625 return ServiceAttribute.select_by_user(self.request.user)
2626
Scott Baker89a7b7c2014-10-07 00:10:17 -07002627 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002628
Scott Baker89a7b7c2014-10-07 00:10:17 -07002629 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002630
2631
2632
Scott Baker515dc9e2014-12-22 09:29:05 -08002633class ControllerImagesList(generics.ListCreateAPIView):
2634 queryset = ControllerImages.objects.select_related().all()
2635 serializer_class = ControllerImagesSerializer
2636 id_serializer_class = ControllerImagesIdSerializer
2637 filter_backends = (filters.DjangoFilterBackend,)
2638 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
2639
2640 def get_serializer_class(self):
2641 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2642 if (no_hyperlinks):
2643 return self.id_serializer_class
2644 else:
2645 return self.serializer_class
2646
2647 def get_queryset(self):
2648 return ControllerImages.select_by_user(self.request.user)
2649
2650 def create(self, request, *args, **kwargs):
2651 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2652 if not (serializer.is_valid()):
2653 response = {"error": "validation",
2654 "specific_error": "not serializer.is_valid()",
2655 "reasons": serializer.errors}
2656 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2657 obj = serializer.object
2658 obj.caller = request.user
2659 if obj.can_update(request.user):
2660 return super(ControllerImagesList, self).create(request, *args, **kwargs)
2661 else:
2662 raise Exception("failed obj.can_update")
2663
2664 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2665 if (ret.status_code%100 != 200):
2666 raise Exception(ret.data)
2667
2668 return ret
2669
2670
2671class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2672 queryset = ControllerImages.objects.select_related().all()
2673 serializer_class = ControllerImagesSerializer
2674 id_serializer_class = ControllerImagesIdSerializer
2675
2676 def get_serializer_class(self):
2677 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2678 if (no_hyperlinks):
2679 return self.id_serializer_class
2680 else:
2681 return self.serializer_class
2682
2683 def get_queryset(self):
2684 return ControllerImages.select_by_user(self.request.user)
2685
2686 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2687
2688 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2689
2690
2691
Sapan Bhatiadea39432014-06-13 03:10:36 -04002692class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002693 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002694 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002695 id_serializer_class = ImageIdSerializer
2696 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08002697 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002698
2699 def get_serializer_class(self):
2700 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2701 if (no_hyperlinks):
2702 return self.id_serializer_class
2703 else:
2704 return self.serializer_class
2705
Scott Baker0caeaf02014-06-19 11:12:55 -07002706 def get_queryset(self):
2707 return Image.select_by_user(self.request.user)
2708
2709 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002710 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2711 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002712 response = {"error": "validation",
2713 "specific_error": "not serializer.is_valid()",
2714 "reasons": serializer.errors}
2715 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002716 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002717 obj.caller = request.user
2718 if obj.can_update(request.user):
2719 return super(ImageList, self).create(request, *args, **kwargs)
2720 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002721 raise Exception("failed obj.can_update")
2722
2723 ret = super(ImageList, self).create(request, *args, **kwargs)
2724 if (ret.status_code%100 != 200):
2725 raise Exception(ret.data)
2726
2727 return ret
2728
Sapan Bhatiadea39432014-06-13 03:10:36 -04002729
Scott Baker89a7b7c2014-10-07 00:10:17 -07002730class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002731 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002732 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002733 id_serializer_class = ImageIdSerializer
2734
2735 def get_serializer_class(self):
2736 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2737 if (no_hyperlinks):
2738 return self.id_serializer_class
2739 else:
2740 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002741
2742 def get_queryset(self):
2743 return Image.select_by_user(self.request.user)
2744
Scott Baker89a7b7c2014-10-07 00:10:17 -07002745 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002746
Scott Baker89a7b7c2014-10-07 00:10:17 -07002747 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002748
2749
2750
Scott Baker0caeaf02014-06-19 11:12:55 -07002751class NetworkParameterList(generics.ListCreateAPIView):
2752 queryset = NetworkParameter.objects.select_related().all()
2753 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002754 id_serializer_class = NetworkParameterIdSerializer
2755 filter_backends = (filters.DjangoFilterBackend,)
2756 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2757
2758 def get_serializer_class(self):
2759 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2760 if (no_hyperlinks):
2761 return self.id_serializer_class
2762 else:
2763 return self.serializer_class
2764
Scott Baker0caeaf02014-06-19 11:12:55 -07002765 def get_queryset(self):
2766 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002767
Scott Baker0caeaf02014-06-19 11:12:55 -07002768 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002769 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2770 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002771 response = {"error": "validation",
2772 "specific_error": "not serializer.is_valid()",
2773 "reasons": serializer.errors}
2774 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002775 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002776 obj.caller = request.user
2777 if obj.can_update(request.user):
2778 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2779 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002780 raise Exception("failed obj.can_update")
2781
2782 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2783 if (ret.status_code%100 != 200):
2784 raise Exception(ret.data)
2785
2786 return ret
2787
Scott Baker0caeaf02014-06-19 11:12:55 -07002788
Scott Baker89a7b7c2014-10-07 00:10:17 -07002789class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002790 queryset = NetworkParameter.objects.select_related().all()
2791 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002792 id_serializer_class = NetworkParameterIdSerializer
2793
2794 def get_serializer_class(self):
2795 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2796 if (no_hyperlinks):
2797 return self.id_serializer_class
2798 else:
2799 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002800
2801 def get_queryset(self):
2802 return NetworkParameter.select_by_user(self.request.user)
2803
Scott Baker89a7b7c2014-10-07 00:10:17 -07002804 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002805
Scott Baker89a7b7c2014-10-07 00:10:17 -07002806 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002807
2808
2809
2810class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002811 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002812 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002813 id_serializer_class = SiteIdSerializer
2814 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08002815 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 -07002816
2817 def get_serializer_class(self):
2818 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2819 if (no_hyperlinks):
2820 return self.id_serializer_class
2821 else:
2822 return self.serializer_class
2823
Scott Baker0caeaf02014-06-19 11:12:55 -07002824 def get_queryset(self):
2825 return Site.select_by_user(self.request.user)
2826
2827 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002828 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2829 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002830 response = {"error": "validation",
2831 "specific_error": "not serializer.is_valid()",
2832 "reasons": serializer.errors}
2833 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002834 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002835 obj.caller = request.user
2836 if obj.can_update(request.user):
2837 return super(SiteList, self).create(request, *args, **kwargs)
2838 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002839 raise Exception("failed obj.can_update")
2840
2841 ret = super(SiteList, self).create(request, *args, **kwargs)
2842 if (ret.status_code%100 != 200):
2843 raise Exception(ret.data)
2844
2845 return ret
2846
Sapan Bhatiadea39432014-06-13 03:10:36 -04002847
Scott Baker89a7b7c2014-10-07 00:10:17 -07002848class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002849 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002850 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002851 id_serializer_class = SiteIdSerializer
2852
2853 def get_serializer_class(self):
2854 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2855 if (no_hyperlinks):
2856 return self.id_serializer_class
2857 else:
2858 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002859
2860 def get_queryset(self):
2861 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002862
Scott Baker89a7b7c2014-10-07 00:10:17 -07002863 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002864
Scott Baker89a7b7c2014-10-07 00:10:17 -07002865 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002866
2867
2868
2869class SliceRoleList(generics.ListCreateAPIView):
2870 queryset = SliceRole.objects.select_related().all()
2871 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002872 id_serializer_class = SliceRoleIdSerializer
2873 filter_backends = (filters.DjangoFilterBackend,)
2874 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2875
2876 def get_serializer_class(self):
2877 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2878 if (no_hyperlinks):
2879 return self.id_serializer_class
2880 else:
2881 return self.serializer_class
2882
Scott Baker0caeaf02014-06-19 11:12:55 -07002883 def get_queryset(self):
2884 return SliceRole.select_by_user(self.request.user)
2885
2886 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002887 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2888 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002889 response = {"error": "validation",
2890 "specific_error": "not serializer.is_valid()",
2891 "reasons": serializer.errors}
2892 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002893 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002894 obj.caller = request.user
2895 if obj.can_update(request.user):
2896 return super(SliceRoleList, self).create(request, *args, **kwargs)
2897 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002898 raise Exception("failed obj.can_update")
2899
2900 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2901 if (ret.status_code%100 != 200):
2902 raise Exception(ret.data)
2903
2904 return ret
2905
Scott Baker0caeaf02014-06-19 11:12:55 -07002906
Scott Baker89a7b7c2014-10-07 00:10:17 -07002907class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002908 queryset = SliceRole.objects.select_related().all()
2909 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002910 id_serializer_class = SliceRoleIdSerializer
2911
2912 def get_serializer_class(self):
2913 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2914 if (no_hyperlinks):
2915 return self.id_serializer_class
2916 else:
2917 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002918
2919 def get_queryset(self):
2920 return SliceRole.select_by_user(self.request.user)
2921
Scott Baker89a7b7c2014-10-07 00:10:17 -07002922 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002923
Scott Baker89a7b7c2014-10-07 00:10:17 -07002924 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002925
2926
2927
2928class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002929 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002930 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002931 id_serializer_class = TagIdSerializer
2932 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002933 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002934
2935 def get_serializer_class(self):
2936 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2937 if (no_hyperlinks):
2938 return self.id_serializer_class
2939 else:
2940 return self.serializer_class
2941
Scott Baker0caeaf02014-06-19 11:12:55 -07002942 def get_queryset(self):
2943 return Tag.select_by_user(self.request.user)
2944
2945 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002946 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2947 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002948 response = {"error": "validation",
2949 "specific_error": "not serializer.is_valid()",
2950 "reasons": serializer.errors}
2951 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002952 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002953 obj.caller = request.user
2954 if obj.can_update(request.user):
2955 return super(TagList, self).create(request, *args, **kwargs)
2956 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002957 raise Exception("failed obj.can_update")
2958
2959 ret = super(TagList, self).create(request, *args, **kwargs)
2960 if (ret.status_code%100 != 200):
2961 raise Exception(ret.data)
2962
2963 return ret
2964
Sapan Bhatiadea39432014-06-13 03:10:36 -04002965
Scott Baker89a7b7c2014-10-07 00:10:17 -07002966class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002967 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002968 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002969 id_serializer_class = TagIdSerializer
2970
2971 def get_serializer_class(self):
2972 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2973 if (no_hyperlinks):
2974 return self.id_serializer_class
2975 else:
2976 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002977
2978 def get_queryset(self):
2979 return Tag.select_by_user(self.request.user)
2980
Scott Baker89a7b7c2014-10-07 00:10:17 -07002981 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002982
Scott Baker89a7b7c2014-10-07 00:10:17 -07002983 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002984
2985
2986
2987class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002988 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002989 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002990 id_serializer_class = InvoiceIdSerializer
2991 filter_backends = (filters.DjangoFilterBackend,)
2992 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
2993
2994 def get_serializer_class(self):
2995 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2996 if (no_hyperlinks):
2997 return self.id_serializer_class
2998 else:
2999 return self.serializer_class
3000
Scott Baker0caeaf02014-06-19 11:12:55 -07003001 def get_queryset(self):
3002 return Invoice.select_by_user(self.request.user)
3003
3004 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003005 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3006 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003007 response = {"error": "validation",
3008 "specific_error": "not serializer.is_valid()",
3009 "reasons": serializer.errors}
3010 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003011 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003012 obj.caller = request.user
3013 if obj.can_update(request.user):
3014 return super(InvoiceList, self).create(request, *args, **kwargs)
3015 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003016 raise Exception("failed obj.can_update")
3017
3018 ret = super(InvoiceList, self).create(request, *args, **kwargs)
3019 if (ret.status_code%100 != 200):
3020 raise Exception(ret.data)
3021
3022 return ret
3023
Sapan Bhatiadea39432014-06-13 03:10:36 -04003024
Scott Baker89a7b7c2014-10-07 00:10:17 -07003025class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003026 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003027 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003028 id_serializer_class = InvoiceIdSerializer
3029
3030 def get_serializer_class(self):
3031 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3032 if (no_hyperlinks):
3033 return self.id_serializer_class
3034 else:
3035 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003036
3037 def get_queryset(self):
3038 return Invoice.select_by_user(self.request.user)
3039
Scott Baker89a7b7c2014-10-07 00:10:17 -07003040 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003041
Scott Baker89a7b7c2014-10-07 00:10:17 -07003042 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003043
3044
3045
Scott Baker0caeaf02014-06-19 11:12:55 -07003046class SlicePrivilegeList(generics.ListCreateAPIView):
3047 queryset = SlicePrivilege.objects.select_related().all()
3048 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003049 id_serializer_class = SlicePrivilegeIdSerializer
3050 filter_backends = (filters.DjangoFilterBackend,)
3051 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
3052
3053 def get_serializer_class(self):
3054 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3055 if (no_hyperlinks):
3056 return self.id_serializer_class
3057 else:
3058 return self.serializer_class
3059
Scott Baker0caeaf02014-06-19 11:12:55 -07003060 def get_queryset(self):
3061 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003062
Scott Baker0caeaf02014-06-19 11:12:55 -07003063 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003064 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3065 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003066 response = {"error": "validation",
3067 "specific_error": "not serializer.is_valid()",
3068 "reasons": serializer.errors}
3069 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003070 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003071 obj.caller = request.user
3072 if obj.can_update(request.user):
3073 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3074 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003075 raise Exception("failed obj.can_update")
3076
3077 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3078 if (ret.status_code%100 != 200):
3079 raise Exception(ret.data)
3080
3081 return ret
3082
Scott Baker0caeaf02014-06-19 11:12:55 -07003083
Scott Baker89a7b7c2014-10-07 00:10:17 -07003084class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003085 queryset = SlicePrivilege.objects.select_related().all()
3086 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003087 id_serializer_class = SlicePrivilegeIdSerializer
3088
3089 def get_serializer_class(self):
3090 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3091 if (no_hyperlinks):
3092 return self.id_serializer_class
3093 else:
3094 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003095
3096 def get_queryset(self):
3097 return SlicePrivilege.select_by_user(self.request.user)
3098
Scott Baker89a7b7c2014-10-07 00:10:17 -07003099 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3100
3101 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3102
3103
3104
3105class PlanetStackRoleList(generics.ListCreateAPIView):
3106 queryset = PlanetStackRole.objects.select_related().all()
3107 serializer_class = PlanetStackRoleSerializer
3108 id_serializer_class = PlanetStackRoleIdSerializer
3109 filter_backends = (filters.DjangoFilterBackend,)
3110 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3111
3112 def get_serializer_class(self):
3113 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3114 if (no_hyperlinks):
3115 return self.id_serializer_class
3116 else:
3117 return self.serializer_class
3118
3119 def get_queryset(self):
3120 return PlanetStackRole.select_by_user(self.request.user)
3121
3122 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003123 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3124 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003125 response = {"error": "validation",
3126 "specific_error": "not serializer.is_valid()",
3127 "reasons": serializer.errors}
3128 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003129 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003130 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003131 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003132 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003133 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003134 raise Exception("failed obj.can_update")
3135
3136 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3137 if (ret.status_code%100 != 200):
3138 raise Exception(ret.data)
3139
3140 return ret
3141
Scott Baker0caeaf02014-06-19 11:12:55 -07003142
Scott Baker89a7b7c2014-10-07 00:10:17 -07003143class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3144 queryset = PlanetStackRole.objects.select_related().all()
3145 serializer_class = PlanetStackRoleSerializer
3146 id_serializer_class = PlanetStackRoleIdSerializer
3147
3148 def get_serializer_class(self):
3149 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3150 if (no_hyperlinks):
3151 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003152 else:
Scott Baker89a7b7c2014-10-07 00:10:17 -07003153 return self.serializer_class
3154
3155 def get_queryset(self):
3156 return PlanetStackRole.select_by_user(self.request.user)
3157
3158 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3159
3160 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003161
3162
3163
Scott Baker515dc9e2014-12-22 09:29:05 -08003164class ControllerPrivilegeList(generics.ListCreateAPIView):
3165 queryset = ControllerPrivilege.objects.select_related().all()
3166 serializer_class = ControllerPrivilegeSerializer
3167 id_serializer_class = ControllerPrivilegeIdSerializer
3168 filter_backends = (filters.DjangoFilterBackend,)
3169 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','role',)
3170
3171 def get_serializer_class(self):
3172 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3173 if (no_hyperlinks):
3174 return self.id_serializer_class
3175 else:
3176 return self.serializer_class
3177
3178 def get_queryset(self):
3179 return ControllerPrivilege.select_by_user(self.request.user)
3180
3181 def create(self, request, *args, **kwargs):
3182 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3183 if not (serializer.is_valid()):
3184 response = {"error": "validation",
3185 "specific_error": "not serializer.is_valid()",
3186 "reasons": serializer.errors}
3187 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3188 obj = serializer.object
3189 obj.caller = request.user
3190 if obj.can_update(request.user):
3191 return super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
3192 else:
3193 raise Exception("failed obj.can_update")
3194
3195 ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
3196 if (ret.status_code%100 != 200):
3197 raise Exception(ret.data)
3198
3199 return ret
3200
3201
3202class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3203 queryset = ControllerPrivilege.objects.select_related().all()
3204 serializer_class = ControllerPrivilegeSerializer
3205 id_serializer_class = ControllerPrivilegeIdSerializer
3206
3207 def get_serializer_class(self):
3208 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3209 if (no_hyperlinks):
3210 return self.id_serializer_class
3211 else:
3212 return self.serializer_class
3213
3214 def get_queryset(self):
3215 return ControllerPrivilege.select_by_user(self.request.user)
3216
3217 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3218
3219 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3220
3221
3222
Scott Baker0caeaf02014-06-19 11:12:55 -07003223class NetworkSliverList(generics.ListCreateAPIView):
3224 queryset = NetworkSliver.objects.select_related().all()
3225 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003226 id_serializer_class = NetworkSliverIdSerializer
3227 filter_backends = (filters.DjangoFilterBackend,)
3228 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
3229
3230 def get_serializer_class(self):
3231 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3232 if (no_hyperlinks):
3233 return self.id_serializer_class
3234 else:
3235 return self.serializer_class
3236
Scott Baker0caeaf02014-06-19 11:12:55 -07003237 def get_queryset(self):
3238 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003239
Scott Baker0caeaf02014-06-19 11:12:55 -07003240 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003241 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3242 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003243 response = {"error": "validation",
3244 "specific_error": "not serializer.is_valid()",
3245 "reasons": serializer.errors}
3246 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003247 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003248 obj.caller = request.user
3249 if obj.can_update(request.user):
3250 return super(NetworkSliverList, self).create(request, *args, **kwargs)
3251 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003252 raise Exception("failed obj.can_update")
3253
3254 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3255 if (ret.status_code%100 != 200):
3256 raise Exception(ret.data)
3257
3258 return ret
3259
Scott Baker0caeaf02014-06-19 11:12:55 -07003260
Scott Baker89a7b7c2014-10-07 00:10:17 -07003261class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003262 queryset = NetworkSliver.objects.select_related().all()
3263 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003264 id_serializer_class = NetworkSliverIdSerializer
3265
3266 def get_serializer_class(self):
3267 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3268 if (no_hyperlinks):
3269 return self.id_serializer_class
3270 else:
3271 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003272
3273 def get_queryset(self):
3274 return NetworkSliver.select_by_user(self.request.user)
3275
Scott Baker89a7b7c2014-10-07 00:10:17 -07003276 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003277
Scott Baker89a7b7c2014-10-07 00:10:17 -07003278 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003279
3280
3281
Scott Baker0caeaf02014-06-19 11:12:55 -07003282class ProjectList(generics.ListCreateAPIView):
3283 queryset = Project.objects.select_related().all()
3284 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003285 id_serializer_class = ProjectIdSerializer
3286 filter_backends = (filters.DjangoFilterBackend,)
3287 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3288
3289 def get_serializer_class(self):
3290 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3291 if (no_hyperlinks):
3292 return self.id_serializer_class
3293 else:
3294 return self.serializer_class
3295
Scott Baker0caeaf02014-06-19 11:12:55 -07003296 def get_queryset(self):
3297 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003298
Scott Baker0caeaf02014-06-19 11:12:55 -07003299 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003300 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3301 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003302 response = {"error": "validation",
3303 "specific_error": "not serializer.is_valid()",
3304 "reasons": serializer.errors}
3305 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003306 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003307 obj.caller = request.user
3308 if obj.can_update(request.user):
3309 return super(ProjectList, self).create(request, *args, **kwargs)
3310 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003311 raise Exception("failed obj.can_update")
3312
3313 ret = super(ProjectList, self).create(request, *args, **kwargs)
3314 if (ret.status_code%100 != 200):
3315 raise Exception(ret.data)
3316
3317 return ret
3318
Scott Baker0caeaf02014-06-19 11:12:55 -07003319
Scott Baker89a7b7c2014-10-07 00:10:17 -07003320class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003321 queryset = Project.objects.select_related().all()
3322 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003323 id_serializer_class = ProjectIdSerializer
3324
3325 def get_serializer_class(self):
3326 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3327 if (no_hyperlinks):
3328 return self.id_serializer_class
3329 else:
3330 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003331
3332 def get_queryset(self):
3333 return Project.select_by_user(self.request.user)
3334
Scott Baker89a7b7c2014-10-07 00:10:17 -07003335 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3336
3337 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3338
3339
3340
3341class SliceList(generics.ListCreateAPIView):
3342 queryset = Slice.objects.select_related().all()
3343 serializer_class = SliceSerializer
3344 id_serializer_class = SliceIdSerializer
3345 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003346 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 -07003347
3348 def get_serializer_class(self):
3349 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3350 if (no_hyperlinks):
3351 return self.id_serializer_class
3352 else:
3353 return self.serializer_class
3354
3355 def get_queryset(self):
3356 return Slice.select_by_user(self.request.user)
3357
3358 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003359 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3360 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003361 response = {"error": "validation",
3362 "specific_error": "not serializer.is_valid()",
3363 "reasons": serializer.errors}
3364 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003365 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003366 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003367 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003368 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003369 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003370 raise Exception("failed obj.can_update")
3371
3372 ret = super(SliceList, self).create(request, *args, **kwargs)
3373 if (ret.status_code%100 != 200):
3374 raise Exception(ret.data)
3375
3376 return ret
3377
Scott Baker0caeaf02014-06-19 11:12:55 -07003378
Scott Baker89a7b7c2014-10-07 00:10:17 -07003379class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3380 queryset = Slice.objects.select_related().all()
3381 serializer_class = SliceSerializer
3382 id_serializer_class = SliceIdSerializer
3383
3384 def get_serializer_class(self):
3385 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3386 if (no_hyperlinks):
3387 return self.id_serializer_class
3388 else:
3389 return self.serializer_class
3390
3391 def get_queryset(self):
3392 return Slice.select_by_user(self.request.user)
3393
3394 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3395
3396 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3397
3398
3399
3400class NetworkList(generics.ListCreateAPIView):
3401 queryset = Network.objects.select_related().all()
3402 serializer_class = NetworkSerializer
3403 id_serializer_class = NetworkIdSerializer
3404 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerd188c012015-01-03 12:32:45 -08003405 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 -07003406
3407 def get_serializer_class(self):
3408 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3409 if (no_hyperlinks):
3410 return self.id_serializer_class
3411 else:
3412 return self.serializer_class
3413
3414 def get_queryset(self):
3415 return Network.select_by_user(self.request.user)
3416
3417 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003418 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3419 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003420 response = {"error": "validation",
3421 "specific_error": "not serializer.is_valid()",
3422 "reasons": serializer.errors}
3423 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003424 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003425 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003426 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003427 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003428 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003429 raise Exception("failed obj.can_update")
3430
3431 ret = super(NetworkList, self).create(request, *args, **kwargs)
3432 if (ret.status_code%100 != 200):
3433 raise Exception(ret.data)
3434
3435 return ret
3436
Scott Baker89a7b7c2014-10-07 00:10:17 -07003437
3438class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3439 queryset = Network.objects.select_related().all()
3440 serializer_class = NetworkSerializer
3441 id_serializer_class = NetworkIdSerializer
3442
3443 def get_serializer_class(self):
3444 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3445 if (no_hyperlinks):
3446 return self.id_serializer_class
3447 else:
3448 return self.serializer_class
3449
3450 def get_queryset(self):
3451 return Network.select_by_user(self.request.user)
3452
3453 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3454
3455 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3456
3457
3458
3459class ServiceList(generics.ListCreateAPIView):
3460 queryset = Service.objects.select_related().all()
3461 serializer_class = ServiceSerializer
3462 id_serializer_class = ServiceIdSerializer
3463 filter_backends = (filters.DjangoFilterBackend,)
3464 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3465
3466 def get_serializer_class(self):
3467 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3468 if (no_hyperlinks):
3469 return self.id_serializer_class
3470 else:
3471 return self.serializer_class
3472
3473 def get_queryset(self):
3474 return Service.select_by_user(self.request.user)
3475
3476 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003477 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3478 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003479 response = {"error": "validation",
3480 "specific_error": "not serializer.is_valid()",
3481 "reasons": serializer.errors}
3482 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003483 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003484 obj.caller = request.user
3485 if obj.can_update(request.user):
3486 return super(ServiceList, self).create(request, *args, **kwargs)
3487 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003488 raise Exception("failed obj.can_update")
3489
3490 ret = super(ServiceList, self).create(request, *args, **kwargs)
3491 if (ret.status_code%100 != 200):
3492 raise Exception(ret.data)
3493
3494 return ret
3495
Scott Baker89a7b7c2014-10-07 00:10:17 -07003496
3497class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3498 queryset = Service.objects.select_related().all()
3499 serializer_class = ServiceSerializer
3500 id_serializer_class = ServiceIdSerializer
3501
3502 def get_serializer_class(self):
3503 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3504 if (no_hyperlinks):
3505 return self.id_serializer_class
3506 else:
3507 return self.serializer_class
3508
3509 def get_queryset(self):
3510 return Service.select_by_user(self.request.user)
3511
3512 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3513
3514 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3515
3516
3517
3518class ServiceClassList(generics.ListCreateAPIView):
3519 queryset = ServiceClass.objects.select_related().all()
3520 serializer_class = ServiceClassSerializer
3521 id_serializer_class = ServiceClassIdSerializer
3522 filter_backends = (filters.DjangoFilterBackend,)
3523 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3524
3525 def get_serializer_class(self):
3526 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3527 if (no_hyperlinks):
3528 return self.id_serializer_class
3529 else:
3530 return self.serializer_class
3531
3532 def get_queryset(self):
3533 return ServiceClass.select_by_user(self.request.user)
3534
3535 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003536 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3537 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003538 response = {"error": "validation",
3539 "specific_error": "not serializer.is_valid()",
3540 "reasons": serializer.errors}
3541 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003542 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003543 obj.caller = request.user
3544 if obj.can_update(request.user):
3545 return super(ServiceClassList, self).create(request, *args, **kwargs)
3546 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003547 raise Exception("failed obj.can_update")
3548
3549 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3550 if (ret.status_code%100 != 200):
3551 raise Exception(ret.data)
3552
3553 return ret
3554
Scott Baker89a7b7c2014-10-07 00:10:17 -07003555
3556class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3557 queryset = ServiceClass.objects.select_related().all()
3558 serializer_class = ServiceClassSerializer
3559 id_serializer_class = ServiceClassIdSerializer
3560
3561 def get_serializer_class(self):
3562 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3563 if (no_hyperlinks):
3564 return self.id_serializer_class
3565 else:
3566 return self.serializer_class
3567
3568 def get_queryset(self):
3569 return ServiceClass.select_by_user(self.request.user)
3570
3571 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3572
3573 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3574
3575
3576
Tony Mack3066a952015-01-05 22:48:11 -05003577class ControllerNetworkList(generics.ListCreateAPIView):
3578 queryset = ControllerNetwork.objects.select_related().all()
3579 serializer_class = ControllerNetworkSerializer
3580 id_serializer_class = ControllerNetworkIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003581 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003582 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 -07003583
3584 def get_serializer_class(self):
3585 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3586 if (no_hyperlinks):
3587 return self.id_serializer_class
3588 else:
3589 return self.serializer_class
3590
3591 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05003592 return ControllerNetwork.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003593
3594 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003595 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3596 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003597 response = {"error": "validation",
3598 "specific_error": "not serializer.is_valid()",
3599 "reasons": serializer.errors}
3600 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003601 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003602 obj.caller = request.user
3603 if obj.can_update(request.user):
Tony Mack3066a952015-01-05 22:48:11 -05003604 return super(ControllerNetworkList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003605 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003606 raise Exception("failed obj.can_update")
3607
Tony Mack3066a952015-01-05 22:48:11 -05003608 ret = super(ControllerNetworkList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07003609 if (ret.status_code%100 != 200):
3610 raise Exception(ret.data)
3611
3612 return ret
3613
Scott Baker89a7b7c2014-10-07 00:10:17 -07003614
Tony Mack3066a952015-01-05 22:48:11 -05003615class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3616 queryset = ControllerNetwork.objects.select_related().all()
3617 serializer_class = ControllerNetworkSerializer
3618 id_serializer_class = ControllerNetworkIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003619
3620 def get_serializer_class(self):
3621 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3622 if (no_hyperlinks):
3623 return self.id_serializer_class
3624 else:
3625 return self.serializer_class
3626
3627 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05003628 return ControllerNetwork.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003629
3630 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3631
3632 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3633
3634
3635
3636class ChargeList(generics.ListCreateAPIView):
3637 queryset = Charge.objects.select_related().all()
3638 serializer_class = ChargeSerializer
3639 id_serializer_class = ChargeIdSerializer
3640 filter_backends = (filters.DjangoFilterBackend,)
3641 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3642
3643 def get_serializer_class(self):
3644 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3645 if (no_hyperlinks):
3646 return self.id_serializer_class
3647 else:
3648 return self.serializer_class
3649
3650 def get_queryset(self):
3651 return Charge.select_by_user(self.request.user)
3652
3653 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003654 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3655 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003656 response = {"error": "validation",
3657 "specific_error": "not serializer.is_valid()",
3658 "reasons": serializer.errors}
3659 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003660 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003661 obj.caller = request.user
3662 if obj.can_update(request.user):
3663 return super(ChargeList, self).create(request, *args, **kwargs)
3664 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003665 raise Exception("failed obj.can_update")
3666
3667 ret = super(ChargeList, self).create(request, *args, **kwargs)
3668 if (ret.status_code%100 != 200):
3669 raise Exception(ret.data)
3670
3671 return ret
3672
Scott Baker89a7b7c2014-10-07 00:10:17 -07003673
3674class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3675 queryset = Charge.objects.select_related().all()
3676 serializer_class = ChargeSerializer
3677 id_serializer_class = ChargeIdSerializer
3678
3679 def get_serializer_class(self):
3680 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3681 if (no_hyperlinks):
3682 return self.id_serializer_class
3683 else:
3684 return self.serializer_class
3685
3686 def get_queryset(self):
3687 return Charge.select_by_user(self.request.user)
3688
3689 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3690
3691 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3692
3693
3694
3695class RoleList(generics.ListCreateAPIView):
3696 queryset = Role.objects.select_related().all()
3697 serializer_class = RoleSerializer
3698 id_serializer_class = RoleIdSerializer
3699 filter_backends = (filters.DjangoFilterBackend,)
3700 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3701
3702 def get_serializer_class(self):
3703 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3704 if (no_hyperlinks):
3705 return self.id_serializer_class
3706 else:
3707 return self.serializer_class
3708
3709 def get_queryset(self):
3710 return Role.select_by_user(self.request.user)
3711
3712 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003713 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3714 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003715 response = {"error": "validation",
3716 "specific_error": "not serializer.is_valid()",
3717 "reasons": serializer.errors}
3718 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003719 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003720 obj.caller = request.user
3721 if obj.can_update(request.user):
3722 return super(RoleList, self).create(request, *args, **kwargs)
3723 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003724 raise Exception("failed obj.can_update")
3725
3726 ret = super(RoleList, self).create(request, *args, **kwargs)
3727 if (ret.status_code%100 != 200):
3728 raise Exception(ret.data)
3729
3730 return ret
3731
Scott Baker89a7b7c2014-10-07 00:10:17 -07003732
3733class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3734 queryset = Role.objects.select_related().all()
3735 serializer_class = RoleSerializer
3736 id_serializer_class = RoleIdSerializer
3737
3738 def get_serializer_class(self):
3739 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3740 if (no_hyperlinks):
3741 return self.id_serializer_class
3742 else:
3743 return self.serializer_class
3744
3745 def get_queryset(self):
3746 return Role.select_by_user(self.request.user)
3747
3748 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3749
3750 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3751
3752
3753
3754class UsableObjectList(generics.ListCreateAPIView):
3755 queryset = UsableObject.objects.select_related().all()
3756 serializer_class = UsableObjectSerializer
3757 id_serializer_class = UsableObjectIdSerializer
3758 filter_backends = (filters.DjangoFilterBackend,)
3759 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3760
3761 def get_serializer_class(self):
3762 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3763 if (no_hyperlinks):
3764 return self.id_serializer_class
3765 else:
3766 return self.serializer_class
3767
3768 def get_queryset(self):
3769 return UsableObject.select_by_user(self.request.user)
3770
3771 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003772 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3773 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003774 response = {"error": "validation",
3775 "specific_error": "not serializer.is_valid()",
3776 "reasons": serializer.errors}
3777 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003778 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003779 obj.caller = request.user
3780 if obj.can_update(request.user):
3781 return super(UsableObjectList, self).create(request, *args, **kwargs)
3782 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003783 raise Exception("failed obj.can_update")
3784
3785 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3786 if (ret.status_code%100 != 200):
3787 raise Exception(ret.data)
3788
3789 return ret
3790
Scott Baker89a7b7c2014-10-07 00:10:17 -07003791
3792class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3793 queryset = UsableObject.objects.select_related().all()
3794 serializer_class = UsableObjectSerializer
3795 id_serializer_class = UsableObjectIdSerializer
3796
3797 def get_serializer_class(self):
3798 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3799 if (no_hyperlinks):
3800 return self.id_serializer_class
3801 else:
3802 return self.serializer_class
3803
3804 def get_queryset(self):
3805 return UsableObject.select_by_user(self.request.user)
3806
3807 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3808
3809 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3810
3811
Scott Baker89a7b7c2014-10-07 00:10:17 -07003812class SiteRoleList(generics.ListCreateAPIView):
3813 queryset = SiteRole.objects.select_related().all()
3814 serializer_class = SiteRoleSerializer
3815 id_serializer_class = SiteRoleIdSerializer
3816 filter_backends = (filters.DjangoFilterBackend,)
3817 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3818
3819 def get_serializer_class(self):
3820 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3821 if (no_hyperlinks):
3822 return self.id_serializer_class
3823 else:
3824 return self.serializer_class
3825
3826 def get_queryset(self):
3827 return SiteRole.select_by_user(self.request.user)
3828
3829 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003830 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3831 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003832 response = {"error": "validation",
3833 "specific_error": "not serializer.is_valid()",
3834 "reasons": serializer.errors}
3835 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003836 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003837 obj.caller = request.user
3838 if obj.can_update(request.user):
3839 return super(SiteRoleList, self).create(request, *args, **kwargs)
3840 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003841 raise Exception("failed obj.can_update")
3842
3843 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3844 if (ret.status_code%100 != 200):
3845 raise Exception(ret.data)
3846
3847 return ret
3848
Scott Baker89a7b7c2014-10-07 00:10:17 -07003849
3850class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3851 queryset = SiteRole.objects.select_related().all()
3852 serializer_class = SiteRoleSerializer
3853 id_serializer_class = SiteRoleIdSerializer
3854
3855 def get_serializer_class(self):
3856 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3857 if (no_hyperlinks):
3858 return self.id_serializer_class
3859 else:
3860 return self.serializer_class
3861
3862 def get_queryset(self):
3863 return SiteRole.select_by_user(self.request.user)
3864
3865 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3866
3867 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3868
3869
3870
3871class SliceCredentialList(generics.ListCreateAPIView):
3872 queryset = SliceCredential.objects.select_related().all()
3873 serializer_class = SliceCredentialSerializer
3874 id_serializer_class = SliceCredentialIdSerializer
3875 filter_backends = (filters.DjangoFilterBackend,)
3876 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3877
3878 def get_serializer_class(self):
3879 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3880 if (no_hyperlinks):
3881 return self.id_serializer_class
3882 else:
3883 return self.serializer_class
3884
3885 def get_queryset(self):
3886 return SliceCredential.select_by_user(self.request.user)
3887
3888 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003889 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3890 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003891 response = {"error": "validation",
3892 "specific_error": "not serializer.is_valid()",
3893 "reasons": serializer.errors}
3894 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003895 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003896 obj.caller = request.user
3897 if obj.can_update(request.user):
3898 return super(SliceCredentialList, self).create(request, *args, **kwargs)
3899 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003900 raise Exception("failed obj.can_update")
3901
3902 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
3903 if (ret.status_code%100 != 200):
3904 raise Exception(ret.data)
3905
3906 return ret
3907
Scott Baker89a7b7c2014-10-07 00:10:17 -07003908
3909class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3910 queryset = SliceCredential.objects.select_related().all()
3911 serializer_class = SliceCredentialSerializer
3912 id_serializer_class = SliceCredentialIdSerializer
3913
3914 def get_serializer_class(self):
3915 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3916 if (no_hyperlinks):
3917 return self.id_serializer_class
3918 else:
3919 return self.serializer_class
3920
3921 def get_queryset(self):
3922 return SliceCredential.select_by_user(self.request.user)
3923
3924 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3925
3926 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3927
3928
3929
3930class SliverList(generics.ListCreateAPIView):
3931 queryset = Sliver.objects.select_related().all()
3932 serializer_class = SliverSerializer
3933 id_serializer_class = SliverIdSerializer
3934 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker16fce9c2015-01-03 12:05:21 -08003935 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 -07003936
3937 def get_serializer_class(self):
3938 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3939 if (no_hyperlinks):
3940 return self.id_serializer_class
3941 else:
3942 return self.serializer_class
3943
3944 def get_queryset(self):
3945 return Sliver.select_by_user(self.request.user)
3946
3947 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003948 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3949 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003950 response = {"error": "validation",
3951 "specific_error": "not serializer.is_valid()",
3952 "reasons": serializer.errors}
3953 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003954 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003955 obj.caller = request.user
3956 if obj.can_update(request.user):
3957 return super(SliverList, self).create(request, *args, **kwargs)
3958 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003959 raise Exception("failed obj.can_update")
3960
3961 ret = super(SliverList, self).create(request, *args, **kwargs)
3962 if (ret.status_code%100 != 200):
3963 raise Exception(ret.data)
3964
3965 return ret
3966
Scott Baker89a7b7c2014-10-07 00:10:17 -07003967
3968class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3969 queryset = Sliver.objects.select_related().all()
3970 serializer_class = SliverSerializer
3971 id_serializer_class = SliverIdSerializer
3972
3973 def get_serializer_class(self):
3974 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3975 if (no_hyperlinks):
3976 return self.id_serializer_class
3977 else:
3978 return self.serializer_class
3979
3980 def get_queryset(self):
3981 return Sliver.select_by_user(self.request.user)
3982
3983 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3984
3985 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3986
3987
3988
3989class NodeList(generics.ListCreateAPIView):
3990 queryset = Node.objects.select_related().all()
3991 serializer_class = NodeSerializer
3992 id_serializer_class = NodeIdSerializer
3993 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003994 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003995
3996 def get_serializer_class(self):
3997 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3998 if (no_hyperlinks):
3999 return self.id_serializer_class
4000 else:
4001 return self.serializer_class
4002
4003 def get_queryset(self):
4004 return Node.select_by_user(self.request.user)
4005
4006 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004007 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4008 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004009 response = {"error": "validation",
4010 "specific_error": "not serializer.is_valid()",
4011 "reasons": serializer.errors}
4012 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004013 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004014 obj.caller = request.user
4015 if obj.can_update(request.user):
4016 return super(NodeList, self).create(request, *args, **kwargs)
4017 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004018 raise Exception("failed obj.can_update")
4019
4020 ret = super(NodeList, self).create(request, *args, **kwargs)
4021 if (ret.status_code%100 != 200):
4022 raise Exception(ret.data)
4023
4024 return ret
4025
Scott Baker89a7b7c2014-10-07 00:10:17 -07004026
4027class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4028 queryset = Node.objects.select_related().all()
4029 serializer_class = NodeSerializer
4030 id_serializer_class = NodeIdSerializer
4031
4032 def get_serializer_class(self):
4033 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4034 if (no_hyperlinks):
4035 return self.id_serializer_class
4036 else:
4037 return self.serializer_class
4038
4039 def get_queryset(self):
4040 return Node.select_by_user(self.request.user)
4041
4042 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4043
4044 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4045
4046
4047
4048class DashboardViewList(generics.ListCreateAPIView):
4049 queryset = DashboardView.objects.select_related().all()
4050 serializer_class = DashboardViewSerializer
4051 id_serializer_class = DashboardViewIdSerializer
4052 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08004053 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004054
4055 def get_serializer_class(self):
4056 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4057 if (no_hyperlinks):
4058 return self.id_serializer_class
4059 else:
4060 return self.serializer_class
4061
4062 def get_queryset(self):
4063 return DashboardView.select_by_user(self.request.user)
4064
4065 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004066 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4067 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004068 response = {"error": "validation",
4069 "specific_error": "not serializer.is_valid()",
4070 "reasons": serializer.errors}
4071 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004072 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004073 obj.caller = request.user
4074 if obj.can_update(request.user):
4075 return super(DashboardViewList, self).create(request, *args, **kwargs)
4076 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004077 raise Exception("failed obj.can_update")
4078
4079 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
4080 if (ret.status_code%100 != 200):
4081 raise Exception(ret.data)
4082
4083 return ret
4084
Scott Baker89a7b7c2014-10-07 00:10:17 -07004085
4086class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4087 queryset = DashboardView.objects.select_related().all()
4088 serializer_class = DashboardViewSerializer
4089 id_serializer_class = DashboardViewIdSerializer
4090
4091 def get_serializer_class(self):
4092 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4093 if (no_hyperlinks):
4094 return self.id_serializer_class
4095 else:
4096 return self.serializer_class
4097
4098 def get_queryset(self):
4099 return DashboardView.select_by_user(self.request.user)
4100
4101 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4102
4103 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4104
Scott Baker89a7b7c2014-10-07 00:10:17 -07004105
Scott Baker57c725c2014-11-12 01:13:53 -08004106
Scott Baker515dc9e2014-12-22 09:29:05 -08004107class ImageDeploymentsList(generics.ListCreateAPIView):
4108 queryset = ImageDeployments.objects.select_related().all()
4109 serializer_class = ImageDeploymentsSerializer
4110 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004111 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08004112 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004113
4114 def get_serializer_class(self):
4115 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4116 if (no_hyperlinks):
4117 return self.id_serializer_class
4118 else:
4119 return self.serializer_class
4120
4121 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08004122 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004123
4124 def create(self, request, *args, **kwargs):
4125 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4126 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004127 response = {"error": "validation",
4128 "specific_error": "not serializer.is_valid()",
4129 "reasons": serializer.errors}
4130 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004131 obj = serializer.object
4132 obj.caller = request.user
4133 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08004134 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004135 else:
4136 raise Exception("failed obj.can_update")
4137
Scott Baker515dc9e2014-12-22 09:29:05 -08004138 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004139 if (ret.status_code%100 != 200):
4140 raise Exception(ret.data)
4141
4142 return ret
4143
4144
Scott Baker515dc9e2014-12-22 09:29:05 -08004145class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4146 queryset = ImageDeployments.objects.select_related().all()
4147 serializer_class = ImageDeploymentsSerializer
4148 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004149
4150 def get_serializer_class(self):
4151 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4152 if (no_hyperlinks):
4153 return self.id_serializer_class
4154 else:
4155 return self.serializer_class
4156
4157 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08004158 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004159
4160 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4161
4162 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4163
Scott Bakerb744f1c2014-11-21 11:32:24 -08004164
4165
Scott Baker89a7b7c2014-10-07 00:10:17 -07004166class ReservedResourceList(generics.ListCreateAPIView):
4167 queryset = ReservedResource.objects.select_related().all()
4168 serializer_class = ReservedResourceSerializer
4169 id_serializer_class = ReservedResourceIdSerializer
4170 filter_backends = (filters.DjangoFilterBackend,)
4171 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
4172
4173 def get_serializer_class(self):
4174 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4175 if (no_hyperlinks):
4176 return self.id_serializer_class
4177 else:
4178 return self.serializer_class
4179
4180 def get_queryset(self):
4181 return ReservedResource.select_by_user(self.request.user)
4182
4183 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004184 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4185 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004186 response = {"error": "validation",
4187 "specific_error": "not serializer.is_valid()",
4188 "reasons": serializer.errors}
4189 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004190 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004191 obj.caller = request.user
4192 if obj.can_update(request.user):
4193 return super(ReservedResourceList, self).create(request, *args, **kwargs)
4194 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004195 raise Exception("failed obj.can_update")
4196
4197 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4198 if (ret.status_code%100 != 200):
4199 raise Exception(ret.data)
4200
4201 return ret
4202
Scott Baker89a7b7c2014-10-07 00:10:17 -07004203
4204class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4205 queryset = ReservedResource.objects.select_related().all()
4206 serializer_class = ReservedResourceSerializer
4207 id_serializer_class = ReservedResourceIdSerializer
4208
4209 def get_serializer_class(self):
4210 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4211 if (no_hyperlinks):
4212 return self.id_serializer_class
4213 else:
4214 return self.serializer_class
4215
4216 def get_queryset(self):
4217 return ReservedResource.select_by_user(self.request.user)
4218
4219 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4220
4221 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4222
4223
4224
Scott Baker515dc9e2014-12-22 09:29:05 -08004225class PaymentList(generics.ListCreateAPIView):
4226 queryset = Payment.objects.select_related().all()
4227 serializer_class = PaymentSerializer
4228 id_serializer_class = PaymentIdSerializer
4229 filter_backends = (filters.DjangoFilterBackend,)
4230 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
4231
4232 def get_serializer_class(self):
4233 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4234 if (no_hyperlinks):
4235 return self.id_serializer_class
4236 else:
4237 return self.serializer_class
4238
4239 def get_queryset(self):
4240 return Payment.select_by_user(self.request.user)
4241
4242 def create(self, request, *args, **kwargs):
4243 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4244 if not (serializer.is_valid()):
4245 response = {"error": "validation",
4246 "specific_error": "not serializer.is_valid()",
4247 "reasons": serializer.errors}
4248 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4249 obj = serializer.object
4250 obj.caller = request.user
4251 if obj.can_update(request.user):
4252 return super(PaymentList, self).create(request, *args, **kwargs)
4253 else:
4254 raise Exception("failed obj.can_update")
4255
4256 ret = super(PaymentList, self).create(request, *args, **kwargs)
4257 if (ret.status_code%100 != 200):
4258 raise Exception(ret.data)
4259
4260 return ret
4261
4262
4263class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4264 queryset = Payment.objects.select_related().all()
4265 serializer_class = PaymentSerializer
4266 id_serializer_class = PaymentIdSerializer
4267
4268 def get_serializer_class(self):
4269 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4270 if (no_hyperlinks):
4271 return self.id_serializer_class
4272 else:
4273 return self.serializer_class
4274
4275 def get_queryset(self):
4276 return Payment.select_by_user(self.request.user)
4277
4278 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4279
4280 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4281
4282
4283
Scott Baker89a7b7c2014-10-07 00:10:17 -07004284class NetworkSliceList(generics.ListCreateAPIView):
4285 queryset = NetworkSlice.objects.select_related().all()
4286 serializer_class = NetworkSliceSerializer
4287 id_serializer_class = NetworkSliceIdSerializer
4288 filter_backends = (filters.DjangoFilterBackend,)
4289 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
4290
4291 def get_serializer_class(self):
4292 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4293 if (no_hyperlinks):
4294 return self.id_serializer_class
4295 else:
4296 return self.serializer_class
4297
4298 def get_queryset(self):
4299 return NetworkSlice.select_by_user(self.request.user)
4300
4301 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004302 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4303 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004304 response = {"error": "validation",
4305 "specific_error": "not serializer.is_valid()",
4306 "reasons": serializer.errors}
4307 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004308 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004309 obj.caller = request.user
4310 if obj.can_update(request.user):
4311 return super(NetworkSliceList, self).create(request, *args, **kwargs)
4312 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004313 raise Exception("failed obj.can_update")
4314
4315 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4316 if (ret.status_code%100 != 200):
4317 raise Exception(ret.data)
4318
4319 return ret
4320
Scott Baker89a7b7c2014-10-07 00:10:17 -07004321
4322class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4323 queryset = NetworkSlice.objects.select_related().all()
4324 serializer_class = NetworkSliceSerializer
4325 id_serializer_class = NetworkSliceIdSerializer
4326
4327 def get_serializer_class(self):
4328 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4329 if (no_hyperlinks):
4330 return self.id_serializer_class
4331 else:
4332 return self.serializer_class
4333
4334 def get_queryset(self):
4335 return NetworkSlice.select_by_user(self.request.user)
4336
4337 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4338
4339 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4340
4341
4342
4343class UserDashboardViewList(generics.ListCreateAPIView):
4344 queryset = UserDashboardView.objects.select_related().all()
4345 serializer_class = UserDashboardViewSerializer
4346 id_serializer_class = UserDashboardViewIdSerializer
4347 filter_backends = (filters.DjangoFilterBackend,)
4348 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4349
4350 def get_serializer_class(self):
4351 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4352 if (no_hyperlinks):
4353 return self.id_serializer_class
4354 else:
4355 return self.serializer_class
4356
4357 def get_queryset(self):
4358 return UserDashboardView.select_by_user(self.request.user)
4359
4360 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004361 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4362 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004363 response = {"error": "validation",
4364 "specific_error": "not serializer.is_valid()",
4365 "reasons": serializer.errors}
4366 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004367 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004368 obj.caller = request.user
4369 if obj.can_update(request.user):
4370 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4371 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004372 raise Exception("failed obj.can_update")
4373
4374 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4375 if (ret.status_code%100 != 200):
4376 raise Exception(ret.data)
4377
4378 return ret
4379
Scott Baker89a7b7c2014-10-07 00:10:17 -07004380
4381class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4382 queryset = UserDashboardView.objects.select_related().all()
4383 serializer_class = UserDashboardViewSerializer
4384 id_serializer_class = UserDashboardViewIdSerializer
4385
4386 def get_serializer_class(self):
4387 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4388 if (no_hyperlinks):
4389 return self.id_serializer_class
4390 else:
4391 return self.serializer_class
4392
4393 def get_queryset(self):
4394 return UserDashboardView.select_by_user(self.request.user)
4395
4396 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4397
4398 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4399
4400
4401
Scott Baker515dc9e2014-12-22 09:29:05 -08004402class ControllerList(generics.ListCreateAPIView):
4403 queryset = Controller.objects.select_related().all()
4404 serializer_class = ControllerSerializer
4405 id_serializer_class = ControllerIdSerializer
4406 filter_backends = (filters.DjangoFilterBackend,)
4407 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
4408
4409 def get_serializer_class(self):
4410 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4411 if (no_hyperlinks):
4412 return self.id_serializer_class
4413 else:
4414 return self.serializer_class
4415
4416 def get_queryset(self):
4417 return Controller.select_by_user(self.request.user)
4418
4419 def create(self, request, *args, **kwargs):
4420 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4421 if not (serializer.is_valid()):
4422 response = {"error": "validation",
4423 "specific_error": "not serializer.is_valid()",
4424 "reasons": serializer.errors}
4425 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4426 obj = serializer.object
4427 obj.caller = request.user
4428 if obj.can_update(request.user):
4429 return super(ControllerList, self).create(request, *args, **kwargs)
4430 else:
4431 raise Exception("failed obj.can_update")
4432
4433 ret = super(ControllerList, self).create(request, *args, **kwargs)
4434 if (ret.status_code%100 != 200):
4435 raise Exception(ret.data)
4436
4437 return ret
4438
4439
4440class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4441 queryset = Controller.objects.select_related().all()
4442 serializer_class = ControllerSerializer
4443 id_serializer_class = ControllerIdSerializer
4444
4445 def get_serializer_class(self):
4446 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4447 if (no_hyperlinks):
4448 return self.id_serializer_class
4449 else:
4450 return self.serializer_class
4451
4452 def get_queryset(self):
4453 return Controller.select_by_user(self.request.user)
4454
4455 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4456
4457 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4458
4459
4460
Scott Baker89a7b7c2014-10-07 00:10:17 -07004461class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4462 queryset = PlanetStackPrivilege.objects.select_related().all()
4463 serializer_class = PlanetStackPrivilegeSerializer
4464 id_serializer_class = PlanetStackPrivilegeIdSerializer
4465 filter_backends = (filters.DjangoFilterBackend,)
4466 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4467
4468 def get_serializer_class(self):
4469 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4470 if (no_hyperlinks):
4471 return self.id_serializer_class
4472 else:
4473 return self.serializer_class
4474
4475 def get_queryset(self):
4476 return PlanetStackPrivilege.select_by_user(self.request.user)
4477
4478 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004479 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4480 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004481 response = {"error": "validation",
4482 "specific_error": "not serializer.is_valid()",
4483 "reasons": serializer.errors}
4484 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004485 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004486 obj.caller = request.user
4487 if obj.can_update(request.user):
4488 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4489 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004490 raise Exception("failed obj.can_update")
4491
4492 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4493 if (ret.status_code%100 != 200):
4494 raise Exception(ret.data)
4495
4496 return ret
4497
Scott Baker89a7b7c2014-10-07 00:10:17 -07004498
4499class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4500 queryset = PlanetStackPrivilege.objects.select_related().all()
4501 serializer_class = PlanetStackPrivilegeSerializer
4502 id_serializer_class = PlanetStackPrivilegeIdSerializer
4503
4504 def get_serializer_class(self):
4505 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4506 if (no_hyperlinks):
4507 return self.id_serializer_class
4508 else:
4509 return self.serializer_class
4510
4511 def get_queryset(self):
4512 return PlanetStackPrivilege.select_by_user(self.request.user)
4513
4514 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4515
4516 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4517
4518
4519
4520class UserList(generics.ListCreateAPIView):
4521 queryset = User.objects.select_related().all()
4522 serializer_class = UserSerializer
4523 id_serializer_class = UserIdSerializer
4524 filter_backends = (filters.DjangoFilterBackend,)
4525 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',)
4526
4527 def get_serializer_class(self):
4528 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4529 if (no_hyperlinks):
4530 return self.id_serializer_class
4531 else:
4532 return self.serializer_class
4533
4534 def get_queryset(self):
4535 return User.select_by_user(self.request.user)
4536
4537 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004538 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4539 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004540 response = {"error": "validation",
4541 "specific_error": "not serializer.is_valid()",
4542 "reasons": serializer.errors}
4543 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004544 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004545 obj.caller = request.user
4546 if obj.can_update(request.user):
4547 return super(UserList, self).create(request, *args, **kwargs)
4548 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004549 raise Exception("failed obj.can_update")
4550
4551 ret = super(UserList, self).create(request, *args, **kwargs)
4552 if (ret.status_code%100 != 200):
4553 raise Exception(ret.data)
4554
4555 return ret
4556
Scott Baker89a7b7c2014-10-07 00:10:17 -07004557
4558class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4559 queryset = User.objects.select_related().all()
4560 serializer_class = UserSerializer
4561 id_serializer_class = UserIdSerializer
4562
4563 def get_serializer_class(self):
4564 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4565 if (no_hyperlinks):
4566 return self.id_serializer_class
4567 else:
4568 return self.serializer_class
4569
4570 def get_queryset(self):
4571 return User.select_by_user(self.request.user)
4572
4573 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4574
4575 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4576
4577
4578
4579class DeploymentList(generics.ListCreateAPIView):
4580 queryset = Deployment.objects.select_related().all()
4581 serializer_class = DeploymentSerializer
4582 id_serializer_class = DeploymentIdSerializer
4583 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08004584 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004585
4586 def get_serializer_class(self):
4587 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4588 if (no_hyperlinks):
4589 return self.id_serializer_class
4590 else:
4591 return self.serializer_class
4592
4593 def get_queryset(self):
4594 return Deployment.select_by_user(self.request.user)
4595
4596 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004597 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4598 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004599 response = {"error": "validation",
4600 "specific_error": "not serializer.is_valid()",
4601 "reasons": serializer.errors}
4602 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004603 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004604 obj.caller = request.user
4605 if obj.can_update(request.user):
4606 return super(DeploymentList, self).create(request, *args, **kwargs)
4607 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004608 raise Exception("failed obj.can_update")
4609
4610 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4611 if (ret.status_code%100 != 200):
4612 raise Exception(ret.data)
4613
4614 return ret
4615
Scott Baker89a7b7c2014-10-07 00:10:17 -07004616
4617class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4618 queryset = Deployment.objects.select_related().all()
4619 serializer_class = DeploymentSerializer
4620 id_serializer_class = DeploymentIdSerializer
4621
4622 def get_serializer_class(self):
4623 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4624 if (no_hyperlinks):
4625 return self.id_serializer_class
4626 else:
4627 return self.serializer_class
4628
4629 def get_queryset(self):
4630 return Deployment.select_by_user(self.request.user)
4631
4632 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4633
4634 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4635
4636
4637
4638class ReservationList(generics.ListCreateAPIView):
4639 queryset = Reservation.objects.select_related().all()
4640 serializer_class = ReservationSerializer
4641 id_serializer_class = ReservationIdSerializer
4642 filter_backends = (filters.DjangoFilterBackend,)
4643 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4644
4645 def get_serializer_class(self):
4646 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4647 if (no_hyperlinks):
4648 return self.id_serializer_class
4649 else:
4650 return self.serializer_class
4651
4652 def get_queryset(self):
4653 return Reservation.select_by_user(self.request.user)
4654
4655 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004656 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4657 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004658 response = {"error": "validation",
4659 "specific_error": "not serializer.is_valid()",
4660 "reasons": serializer.errors}
4661 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004662 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004663 obj.caller = request.user
4664 if obj.can_update(request.user):
4665 return super(ReservationList, self).create(request, *args, **kwargs)
4666 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004667 raise Exception("failed obj.can_update")
4668
4669 ret = super(ReservationList, self).create(request, *args, **kwargs)
4670 if (ret.status_code%100 != 200):
4671 raise Exception(ret.data)
4672
4673 return ret
4674
Scott Baker89a7b7c2014-10-07 00:10:17 -07004675
4676class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4677 queryset = Reservation.objects.select_related().all()
4678 serializer_class = ReservationSerializer
4679 id_serializer_class = ReservationIdSerializer
4680
4681 def get_serializer_class(self):
4682 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4683 if (no_hyperlinks):
4684 return self.id_serializer_class
4685 else:
4686 return self.serializer_class
4687
4688 def get_queryset(self):
4689 return Reservation.select_by_user(self.request.user)
4690
4691 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4692
4693 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4694
Scott Baker89a7b7c2014-10-07 00:10:17 -07004695
Scott Baker57c725c2014-11-12 01:13:53 -08004696
Scott Baker89a7b7c2014-10-07 00:10:17 -07004697class SitePrivilegeList(generics.ListCreateAPIView):
4698 queryset = SitePrivilege.objects.select_related().all()
4699 serializer_class = SitePrivilegeSerializer
4700 id_serializer_class = SitePrivilegeIdSerializer
4701 filter_backends = (filters.DjangoFilterBackend,)
4702 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4703
4704 def get_serializer_class(self):
4705 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4706 if (no_hyperlinks):
4707 return self.id_serializer_class
4708 else:
4709 return self.serializer_class
4710
4711 def get_queryset(self):
4712 return SitePrivilege.select_by_user(self.request.user)
4713
4714 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004715 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4716 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004717 response = {"error": "validation",
4718 "specific_error": "not serializer.is_valid()",
4719 "reasons": serializer.errors}
4720 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004721 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004722 obj.caller = request.user
4723 if obj.can_update(request.user):
4724 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4725 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004726 raise Exception("failed obj.can_update")
4727
4728 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4729 if (ret.status_code%100 != 200):
4730 raise Exception(ret.data)
4731
4732 return ret
4733
Scott Baker89a7b7c2014-10-07 00:10:17 -07004734
4735class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4736 queryset = SitePrivilege.objects.select_related().all()
4737 serializer_class = SitePrivilegeSerializer
4738 id_serializer_class = SitePrivilegeIdSerializer
4739
4740 def get_serializer_class(self):
4741 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4742 if (no_hyperlinks):
4743 return self.id_serializer_class
4744 else:
4745 return self.serializer_class
4746
4747 def get_queryset(self):
4748 return SitePrivilege.select_by_user(self.request.user)
4749
4750 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4751
4752 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4753
4754
4755
Scott Bakerb744f1c2014-11-21 11:32:24 -08004756class PlanetStackList(generics.ListCreateAPIView):
4757 queryset = PlanetStack.objects.select_related().all()
4758 serializer_class = PlanetStackSerializer
4759 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004760 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004761 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004762
4763 def get_serializer_class(self):
4764 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4765 if (no_hyperlinks):
4766 return self.id_serializer_class
4767 else:
4768 return self.serializer_class
4769
4770 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004771 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004772
4773 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004774 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4775 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004776 response = {"error": "validation",
4777 "specific_error": "not serializer.is_valid()",
4778 "reasons": serializer.errors}
4779 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004780 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004781 obj.caller = request.user
4782 if obj.can_update(request.user):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004783 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004784 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004785 raise Exception("failed obj.can_update")
4786
Scott Bakerb744f1c2014-11-21 11:32:24 -08004787 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07004788 if (ret.status_code%100 != 200):
4789 raise Exception(ret.data)
4790
4791 return ret
4792
Scott Baker89a7b7c2014-10-07 00:10:17 -07004793
Scott Bakerb744f1c2014-11-21 11:32:24 -08004794class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4795 queryset = PlanetStack.objects.select_related().all()
4796 serializer_class = PlanetStackSerializer
4797 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004798
4799 def get_serializer_class(self):
4800 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4801 if (no_hyperlinks):
4802 return self.id_serializer_class
4803 else:
4804 return self.serializer_class
4805
4806 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004807 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004808
4809 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4810
4811 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4812
Scott Baker89a7b7c2014-10-07 00:10:17 -07004813
Scott Baker57c725c2014-11-12 01:13:53 -08004814
Scott Bakerf2c0c512014-12-22 17:35:34 -08004815class ControllerDashboardViewList(generics.ListCreateAPIView):
4816 queryset = ControllerDashboardView.objects.select_related().all()
4817 serializer_class = ControllerDashboardViewSerializer
4818 id_serializer_class = ControllerDashboardViewIdSerializer
4819 filter_backends = (filters.DjangoFilterBackend,)
4820 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
4821
4822 def get_serializer_class(self):
4823 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4824 if (no_hyperlinks):
4825 return self.id_serializer_class
4826 else:
4827 return self.serializer_class
4828
4829 def get_queryset(self):
4830 return ControllerDashboardView.select_by_user(self.request.user)
4831
4832 def create(self, request, *args, **kwargs):
4833 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4834 if not (serializer.is_valid()):
4835 response = {"error": "validation",
4836 "specific_error": "not serializer.is_valid()",
4837 "reasons": serializer.errors}
4838 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4839 obj = serializer.object
4840 obj.caller = request.user
4841 if obj.can_update(request.user):
4842 return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
4843 else:
4844 raise Exception("failed obj.can_update")
4845
4846 ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
4847 if (ret.status_code%100 != 200):
4848 raise Exception(ret.data)
4849
4850 return ret
4851
4852
4853class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4854 queryset = ControllerDashboardView.objects.select_related().all()
4855 serializer_class = ControllerDashboardViewSerializer
4856 id_serializer_class = ControllerDashboardViewIdSerializer
4857
4858 def get_serializer_class(self):
4859 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4860 if (no_hyperlinks):
4861 return self.id_serializer_class
4862 else:
4863 return self.serializer_class
4864
4865 def get_queryset(self):
4866 return ControllerDashboardView.select_by_user(self.request.user)
4867
4868 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4869
4870 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4871
4872
4873
Scott Baker89a7b7c2014-10-07 00:10:17 -07004874class AccountList(generics.ListCreateAPIView):
4875 queryset = Account.objects.select_related().all()
4876 serializer_class = AccountSerializer
4877 id_serializer_class = AccountIdSerializer
4878 filter_backends = (filters.DjangoFilterBackend,)
4879 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4880
4881 def get_serializer_class(self):
4882 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4883 if (no_hyperlinks):
4884 return self.id_serializer_class
4885 else:
4886 return self.serializer_class
4887
4888 def get_queryset(self):
4889 return Account.select_by_user(self.request.user)
4890
4891 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004892 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4893 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004894 response = {"error": "validation",
4895 "specific_error": "not serializer.is_valid()",
4896 "reasons": serializer.errors}
4897 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004898 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004899 obj.caller = request.user
4900 if obj.can_update(request.user):
4901 return super(AccountList, self).create(request, *args, **kwargs)
4902 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004903 raise Exception("failed obj.can_update")
4904
4905 ret = super(AccountList, self).create(request, *args, **kwargs)
4906 if (ret.status_code%100 != 200):
4907 raise Exception(ret.data)
4908
4909 return ret
4910
Scott Baker89a7b7c2014-10-07 00:10:17 -07004911
4912class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4913 queryset = Account.objects.select_related().all()
4914 serializer_class = AccountSerializer
4915 id_serializer_class = AccountIdSerializer
4916
4917 def get_serializer_class(self):
4918 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4919 if (no_hyperlinks):
4920 return self.id_serializer_class
4921 else:
4922 return self.serializer_class
4923
4924 def get_queryset(self):
4925 return Account.select_by_user(self.request.user)
4926
4927 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4928
4929 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4930
4931
4932
Scott Baker515dc9e2014-12-22 09:29:05 -08004933class ControllerRoleList(generics.ListCreateAPIView):
4934 queryset = ControllerRole.objects.select_related().all()
4935 serializer_class = ControllerRoleSerializer
4936 id_serializer_class = ControllerRoleIdSerializer
4937 filter_backends = (filters.DjangoFilterBackend,)
4938 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
4939
4940 def get_serializer_class(self):
4941 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4942 if (no_hyperlinks):
4943 return self.id_serializer_class
4944 else:
4945 return self.serializer_class
4946
4947 def get_queryset(self):
4948 return ControllerRole.select_by_user(self.request.user)
4949
4950 def create(self, request, *args, **kwargs):
4951 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4952 if not (serializer.is_valid()):
4953 response = {"error": "validation",
4954 "specific_error": "not serializer.is_valid()",
4955 "reasons": serializer.errors}
4956 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4957 obj = serializer.object
4958 obj.caller = request.user
4959 if obj.can_update(request.user):
4960 return super(ControllerRoleList, self).create(request, *args, **kwargs)
4961 else:
4962 raise Exception("failed obj.can_update")
4963
4964 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
4965 if (ret.status_code%100 != 200):
4966 raise Exception(ret.data)
4967
4968 return ret
4969
4970
4971class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4972 queryset = ControllerRole.objects.select_related().all()
4973 serializer_class = ControllerRoleSerializer
4974 id_serializer_class = ControllerRoleIdSerializer
4975
4976 def get_serializer_class(self):
4977 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4978 if (no_hyperlinks):
4979 return self.id_serializer_class
4980 else:
4981 return self.serializer_class
4982
4983 def get_queryset(self):
4984 return ControllerRole.select_by_user(self.request.user)
4985
4986 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4987
4988 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4989
4990
4991
Scott Baker89a7b7c2014-10-07 00:10:17 -07004992class NetworkParameterTypeList(generics.ListCreateAPIView):
4993 queryset = NetworkParameterType.objects.select_related().all()
4994 serializer_class = NetworkParameterTypeSerializer
4995 id_serializer_class = NetworkParameterTypeIdSerializer
4996 filter_backends = (filters.DjangoFilterBackend,)
4997 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
4998
4999 def get_serializer_class(self):
5000 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5001 if (no_hyperlinks):
5002 return self.id_serializer_class
5003 else:
5004 return self.serializer_class
5005
5006 def get_queryset(self):
5007 return NetworkParameterType.select_by_user(self.request.user)
5008
5009 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005010 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5011 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005012 response = {"error": "validation",
5013 "specific_error": "not serializer.is_valid()",
5014 "reasons": serializer.errors}
5015 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005016 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005017 obj.caller = request.user
5018 if obj.can_update(request.user):
5019 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5020 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005021 raise Exception("failed obj.can_update")
5022
5023 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5024 if (ret.status_code%100 != 200):
5025 raise Exception(ret.data)
5026
5027 return ret
5028
Scott Baker89a7b7c2014-10-07 00:10:17 -07005029
5030class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5031 queryset = NetworkParameterType.objects.select_related().all()
5032 serializer_class = NetworkParameterTypeSerializer
5033 id_serializer_class = NetworkParameterTypeIdSerializer
5034
5035 def get_serializer_class(self):
5036 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5037 if (no_hyperlinks):
5038 return self.id_serializer_class
5039 else:
5040 return self.serializer_class
5041
5042 def get_queryset(self):
5043 return NetworkParameterType.select_by_user(self.request.user)
5044
5045 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5046
5047 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5048
5049
5050
5051class SiteCredentialList(generics.ListCreateAPIView):
5052 queryset = SiteCredential.objects.select_related().all()
5053 serializer_class = SiteCredentialSerializer
5054 id_serializer_class = SiteCredentialIdSerializer
5055 filter_backends = (filters.DjangoFilterBackend,)
5056 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
5057
5058 def get_serializer_class(self):
5059 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5060 if (no_hyperlinks):
5061 return self.id_serializer_class
5062 else:
5063 return self.serializer_class
5064
5065 def get_queryset(self):
5066 return SiteCredential.select_by_user(self.request.user)
5067
5068 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005069 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5070 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005071 response = {"error": "validation",
5072 "specific_error": "not serializer.is_valid()",
5073 "reasons": serializer.errors}
5074 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005075 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005076 obj.caller = request.user
5077 if obj.can_update(request.user):
5078 return super(SiteCredentialList, self).create(request, *args, **kwargs)
5079 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005080 raise Exception("failed obj.can_update")
5081
5082 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
5083 if (ret.status_code%100 != 200):
5084 raise Exception(ret.data)
5085
5086 return ret
5087
Scott Baker89a7b7c2014-10-07 00:10:17 -07005088
5089class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5090 queryset = SiteCredential.objects.select_related().all()
5091 serializer_class = SiteCredentialSerializer
5092 id_serializer_class = SiteCredentialIdSerializer
5093
5094 def get_serializer_class(self):
5095 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5096 if (no_hyperlinks):
5097 return self.id_serializer_class
5098 else:
5099 return self.serializer_class
5100
5101 def get_queryset(self):
5102 return SiteCredential.select_by_user(self.request.user)
5103
5104 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5105
5106 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5107
5108
5109
Scott Baker515dc9e2014-12-22 09:29:05 -08005110class DeploymentPrivilegeList(generics.ListCreateAPIView):
5111 queryset = DeploymentPrivilege.objects.select_related().all()
5112 serializer_class = DeploymentPrivilegeSerializer
5113 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005114 filter_backends = (filters.DjangoFilterBackend,)
5115 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
5116
5117 def get_serializer_class(self):
5118 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5119 if (no_hyperlinks):
5120 return self.id_serializer_class
5121 else:
5122 return self.serializer_class
5123
5124 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005125 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005126
5127 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005128 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5129 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005130 response = {"error": "validation",
5131 "specific_error": "not serializer.is_valid()",
5132 "reasons": serializer.errors}
5133 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005134 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005135 obj.caller = request.user
5136 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005137 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005138 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005139 raise Exception("failed obj.can_update")
5140
Scott Baker515dc9e2014-12-22 09:29:05 -08005141 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005142 if (ret.status_code%100 != 200):
5143 raise Exception(ret.data)
5144
5145 return ret
5146
Scott Baker89a7b7c2014-10-07 00:10:17 -07005147
Scott Baker515dc9e2014-12-22 09:29:05 -08005148class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5149 queryset = DeploymentPrivilege.objects.select_related().all()
5150 serializer_class = DeploymentPrivilegeSerializer
5151 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005152
5153 def get_serializer_class(self):
5154 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5155 if (no_hyperlinks):
5156 return self.id_serializer_class
5157 else:
5158 return self.serializer_class
5159
5160 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005161 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005162
5163 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5164
5165 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5166
5167
5168
Tony Mack3066a952015-01-05 22:48:11 -05005169class ControllerUserList(generics.ListCreateAPIView):
5170 queryset = ControllerUser.objects.select_related().all()
5171 serializer_class = ControllerUserSerializer
5172 id_serializer_class = ControllerUserIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005173 filter_backends = (filters.DjangoFilterBackend,)
5174 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
5175
5176 def get_serializer_class(self):
5177 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5178 if (no_hyperlinks):
5179 return self.id_serializer_class
5180 else:
5181 return self.serializer_class
5182
5183 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005184 return ControllerUser.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005185
5186 def create(self, request, *args, **kwargs):
5187 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5188 if not (serializer.is_valid()):
5189 response = {"error": "validation",
5190 "specific_error": "not serializer.is_valid()",
5191 "reasons": serializer.errors}
5192 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5193 obj = serializer.object
5194 obj.caller = request.user
5195 if obj.can_update(request.user):
Tony Mack3066a952015-01-05 22:48:11 -05005196 return super(ControllerUserList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005197 else:
5198 raise Exception("failed obj.can_update")
5199
Tony Mack3066a952015-01-05 22:48:11 -05005200 ret = super(ControllerUserList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005201 if (ret.status_code%100 != 200):
5202 raise Exception(ret.data)
5203
5204 return ret
5205
5206
Tony Mack3066a952015-01-05 22:48:11 -05005207class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5208 queryset = ControllerUser.objects.select_related().all()
5209 serializer_class = ControllerUserSerializer
5210 id_serializer_class = ControllerUserIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005211
5212 def get_serializer_class(self):
5213 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5214 if (no_hyperlinks):
5215 return self.id_serializer_class
5216 else:
5217 return self.serializer_class
5218
5219 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005220 return ControllerUser.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005221
5222 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5223
5224 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5225
5226
5227
5228class DeploymentRoleList(generics.ListCreateAPIView):
5229 queryset = DeploymentRole.objects.select_related().all()
5230 serializer_class = DeploymentRoleSerializer
5231 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005232 filter_backends = (filters.DjangoFilterBackend,)
5233 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5234
5235 def get_serializer_class(self):
5236 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5237 if (no_hyperlinks):
5238 return self.id_serializer_class
5239 else:
5240 return self.serializer_class
5241
5242 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005243 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005244
5245 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005246 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5247 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005248 response = {"error": "validation",
5249 "specific_error": "not serializer.is_valid()",
5250 "reasons": serializer.errors}
5251 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005252 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005253 obj.caller = request.user
5254 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005255 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005256 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005257 raise Exception("failed obj.can_update")
5258
Scott Baker515dc9e2014-12-22 09:29:05 -08005259 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005260 if (ret.status_code%100 != 200):
5261 raise Exception(ret.data)
5262
5263 return ret
5264
Scott Baker89a7b7c2014-10-07 00:10:17 -07005265
Scott Baker515dc9e2014-12-22 09:29:05 -08005266class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5267 queryset = DeploymentRole.objects.select_related().all()
5268 serializer_class = DeploymentRoleSerializer
5269 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005270
5271 def get_serializer_class(self):
5272 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5273 if (no_hyperlinks):
5274 return self.id_serializer_class
5275 else:
5276 return self.serializer_class
5277
5278 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005279 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005280
5281 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5282
5283 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5284
5285
5286
5287class UserCredentialList(generics.ListCreateAPIView):
5288 queryset = UserCredential.objects.select_related().all()
5289 serializer_class = UserCredentialSerializer
5290 id_serializer_class = UserCredentialIdSerializer
5291 filter_backends = (filters.DjangoFilterBackend,)
5292 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
5293
5294 def get_serializer_class(self):
5295 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5296 if (no_hyperlinks):
5297 return self.id_serializer_class
5298 else:
5299 return self.serializer_class
5300
5301 def get_queryset(self):
5302 return UserCredential.select_by_user(self.request.user)
5303
5304 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005305 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5306 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005307 response = {"error": "validation",
5308 "specific_error": "not serializer.is_valid()",
5309 "reasons": serializer.errors}
5310 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005311 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005312 obj.caller = request.user
5313 if obj.can_update(request.user):
5314 return super(UserCredentialList, self).create(request, *args, **kwargs)
5315 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005316 raise Exception("failed obj.can_update")
5317
5318 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
5319 if (ret.status_code%100 != 200):
5320 raise Exception(ret.data)
5321
5322 return ret
5323
Scott Baker89a7b7c2014-10-07 00:10:17 -07005324
5325class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5326 queryset = UserCredential.objects.select_related().all()
5327 serializer_class = UserCredentialSerializer
5328 id_serializer_class = UserCredentialIdSerializer
5329
5330 def get_serializer_class(self):
5331 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5332 if (no_hyperlinks):
5333 return self.id_serializer_class
5334 else:
5335 return self.serializer_class
5336
5337 def get_queryset(self):
5338 return UserCredential.select_by_user(self.request.user)
5339
5340 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5341
5342 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5343
Scott Baker89a7b7c2014-10-07 00:10:17 -07005344
Scott Baker57c725c2014-11-12 01:13:53 -08005345
Tony Mack3066a952015-01-05 22:48:11 -05005346class SiteDeploymentList(generics.ListCreateAPIView):
5347 queryset = SiteDeployment.objects.select_related().all()
5348 serializer_class = SiteDeploymentSerializer
5349 id_serializer_class = SiteDeploymentIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08005350 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08005351 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005352
5353 def get_serializer_class(self):
5354 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5355 if (no_hyperlinks):
5356 return self.id_serializer_class
5357 else:
5358 return self.serializer_class
5359
5360 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005361 return SiteDeployment.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005362
5363 def create(self, request, *args, **kwargs):
5364 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5365 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005366 response = {"error": "validation",
5367 "specific_error": "not serializer.is_valid()",
5368 "reasons": serializer.errors}
5369 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005370 obj = serializer.object
5371 obj.caller = request.user
5372 if obj.can_update(request.user):
Tony Mack3066a952015-01-05 22:48:11 -05005373 return super(SiteDeploymentList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005374 else:
5375 raise Exception("failed obj.can_update")
5376
Tony Mack3066a952015-01-05 22:48:11 -05005377 ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005378 if (ret.status_code%100 != 200):
5379 raise Exception(ret.data)
5380
5381 return ret
5382
5383
Tony Mack3066a952015-01-05 22:48:11 -05005384class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5385 queryset = SiteDeployment.objects.select_related().all()
5386 serializer_class = SiteDeploymentSerializer
5387 id_serializer_class = SiteDeploymentIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08005388
5389 def get_serializer_class(self):
5390 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5391 if (no_hyperlinks):
5392 return self.id_serializer_class
5393 else:
5394 return self.serializer_class
5395
5396 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005397 return SiteDeployment.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005398
5399 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5400
5401 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5402
Scott Baker515dc9e2014-12-22 09:29:05 -08005403
5404
Scott Baker0caeaf02014-06-19 11:12:55 -07005405class SliceTagList(generics.ListCreateAPIView):
5406 queryset = SliceTag.objects.select_related().all()
5407 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005408 id_serializer_class = SliceTagIdSerializer
5409 filter_backends = (filters.DjangoFilterBackend,)
5410 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5411
5412 def get_serializer_class(self):
5413 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5414 if (no_hyperlinks):
5415 return self.id_serializer_class
5416 else:
5417 return self.serializer_class
5418
Scott Baker0caeaf02014-06-19 11:12:55 -07005419 def get_queryset(self):
5420 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005421
Scott Baker0caeaf02014-06-19 11:12:55 -07005422 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005423 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5424 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005425 response = {"error": "validation",
5426 "specific_error": "not serializer.is_valid()",
5427 "reasons": serializer.errors}
5428 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005429 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005430 obj.caller = request.user
5431 if obj.can_update(request.user):
5432 return super(SliceTagList, self).create(request, *args, **kwargs)
5433 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005434 raise Exception("failed obj.can_update")
5435
5436 ret = super(SliceTagList, self).create(request, *args, **kwargs)
5437 if (ret.status_code%100 != 200):
5438 raise Exception(ret.data)
5439
5440 return ret
5441
Scott Baker0caeaf02014-06-19 11:12:55 -07005442
Scott Baker89a7b7c2014-10-07 00:10:17 -07005443class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005444 queryset = SliceTag.objects.select_related().all()
5445 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005446 id_serializer_class = SliceTagIdSerializer
5447
5448 def get_serializer_class(self):
5449 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5450 if (no_hyperlinks):
5451 return self.id_serializer_class
5452 else:
5453 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005454
5455 def get_queryset(self):
5456 return SliceTag.select_by_user(self.request.user)
5457
Scott Baker89a7b7c2014-10-07 00:10:17 -07005458 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005459
Scott Baker89a7b7c2014-10-07 00:10:17 -07005460 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005461
5462
5463
Scott Bakerf2c0c512014-12-22 17:35:34 -08005464class NetworkTemplateList(generics.ListCreateAPIView):
5465 queryset = NetworkTemplate.objects.select_related().all()
5466 serializer_class = NetworkTemplateSerializer
5467 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005468 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker16fce9c2015-01-03 12:05:21 -08005469 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 -07005470
5471 def get_serializer_class(self):
5472 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5473 if (no_hyperlinks):
5474 return self.id_serializer_class
5475 else:
5476 return self.serializer_class
5477
Scott Baker0caeaf02014-06-19 11:12:55 -07005478 def get_queryset(self):
Scott Bakerf2c0c512014-12-22 17:35:34 -08005479 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005480
Scott Baker0caeaf02014-06-19 11:12:55 -07005481 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005482 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5483 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005484 response = {"error": "validation",
5485 "specific_error": "not serializer.is_valid()",
5486 "reasons": serializer.errors}
5487 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005488 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005489 obj.caller = request.user
5490 if obj.can_update(request.user):
Scott Bakerf2c0c512014-12-22 17:35:34 -08005491 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07005492 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005493 raise Exception("failed obj.can_update")
5494
Scott Bakerf2c0c512014-12-22 17:35:34 -08005495 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005496 if (ret.status_code%100 != 200):
5497 raise Exception(ret.data)
5498
5499 return ret
5500
Scott Baker0caeaf02014-06-19 11:12:55 -07005501
Scott Bakerf2c0c512014-12-22 17:35:34 -08005502class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5503 queryset = NetworkTemplate.objects.select_related().all()
5504 serializer_class = NetworkTemplateSerializer
5505 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005506
5507 def get_serializer_class(self):
5508 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5509 if (no_hyperlinks):
5510 return self.id_serializer_class
5511 else:
5512 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005513
5514 def get_queryset(self):
Scott Bakerf2c0c512014-12-22 17:35:34 -08005515 return NetworkTemplate.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07005516
Scott Baker89a7b7c2014-10-07 00:10:17 -07005517 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005518
Scott Baker89a7b7c2014-10-07 00:10:17 -07005519 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005520
5521
5522
5523class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005524 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005525 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005526 id_serializer_class = RouterIdSerializer
5527 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08005528 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07005529
5530 def get_serializer_class(self):
5531 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5532 if (no_hyperlinks):
5533 return self.id_serializer_class
5534 else:
5535 return self.serializer_class
5536
Scott Baker0caeaf02014-06-19 11:12:55 -07005537 def get_queryset(self):
5538 return Router.select_by_user(self.request.user)
5539
5540 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005541 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5542 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005543 response = {"error": "validation",
5544 "specific_error": "not serializer.is_valid()",
5545 "reasons": serializer.errors}
5546 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005547 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005548 obj.caller = request.user
5549 if obj.can_update(request.user):
5550 return super(RouterList, self).create(request, *args, **kwargs)
5551 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005552 raise Exception("failed obj.can_update")
5553
5554 ret = super(RouterList, self).create(request, *args, **kwargs)
5555 if (ret.status_code%100 != 200):
5556 raise Exception(ret.data)
5557
5558 return ret
5559
Sapan Bhatiadea39432014-06-13 03:10:36 -04005560
Scott Baker89a7b7c2014-10-07 00:10:17 -07005561class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005562 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005563 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005564 id_serializer_class = RouterIdSerializer
5565
5566 def get_serializer_class(self):
5567 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5568 if (no_hyperlinks):
5569 return self.id_serializer_class
5570 else:
5571 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005572
5573 def get_queryset(self):
5574 return Router.select_by_user(self.request.user)
5575
Scott Baker89a7b7c2014-10-07 00:10:17 -07005576 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005577
Scott Baker89a7b7c2014-10-07 00:10:17 -07005578 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005579
5580
5581
Scott Baker0caeaf02014-06-19 11:12:55 -07005582class ServiceResourceList(generics.ListCreateAPIView):
5583 queryset = ServiceResource.objects.select_related().all()
5584 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005585 id_serializer_class = ServiceResourceIdSerializer
5586 filter_backends = (filters.DjangoFilterBackend,)
5587 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5588
5589 def get_serializer_class(self):
5590 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5591 if (no_hyperlinks):
5592 return self.id_serializer_class
5593 else:
5594 return self.serializer_class
5595
Scott Baker0caeaf02014-06-19 11:12:55 -07005596 def get_queryset(self):
5597 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005598
Scott Baker0caeaf02014-06-19 11:12:55 -07005599 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005600 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5601 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005602 response = {"error": "validation",
5603 "specific_error": "not serializer.is_valid()",
5604 "reasons": serializer.errors}
5605 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005606 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005607 obj.caller = request.user
5608 if obj.can_update(request.user):
5609 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5610 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005611 raise Exception("failed obj.can_update")
5612
5613 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5614 if (ret.status_code%100 != 200):
5615 raise Exception(ret.data)
5616
5617 return ret
5618
Scott Baker0caeaf02014-06-19 11:12:55 -07005619
Scott Baker89a7b7c2014-10-07 00:10:17 -07005620class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005621 queryset = ServiceResource.objects.select_related().all()
5622 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005623 id_serializer_class = ServiceResourceIdSerializer
5624
5625 def get_serializer_class(self):
5626 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5627 if (no_hyperlinks):
5628 return self.id_serializer_class
5629 else:
5630 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005631
5632 def get_queryset(self):
5633 return ServiceResource.select_by_user(self.request.user)
5634
Scott Baker89a7b7c2014-10-07 00:10:17 -07005635 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005636
Scott Baker89a7b7c2014-10-07 00:10:17 -07005637 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005638
Sapan Bhatiadea39432014-06-13 03:10:36 -04005639
5640
Tony Mack3066a952015-01-05 22:48:11 -05005641class ControllerSliceList(generics.ListCreateAPIView):
5642 queryset = ControllerSlice.objects.select_related().all()
5643 serializer_class = ControllerSliceSerializer
5644 id_serializer_class = ControllerSliceIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005645 filter_backends = (filters.DjangoFilterBackend,)
5646 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
5647
5648 def get_serializer_class(self):
5649 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5650 if (no_hyperlinks):
5651 return self.id_serializer_class
5652 else:
5653 return self.serializer_class
5654
5655 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005656 return ControllerSlice.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005657
5658 def create(self, request, *args, **kwargs):
5659 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5660 if not (serializer.is_valid()):
5661 response = {"error": "validation",
5662 "specific_error": "not serializer.is_valid()",
5663 "reasons": serializer.errors}
5664 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5665 obj = serializer.object
5666 obj.caller = request.user
5667 if obj.can_update(request.user):
Tony Mack3066a952015-01-05 22:48:11 -05005668 return super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005669 else:
5670 raise Exception("failed obj.can_update")
5671
Tony Mack3066a952015-01-05 22:48:11 -05005672 ret = super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005673 if (ret.status_code%100 != 200):
5674 raise Exception(ret.data)
5675
5676 return ret
5677
5678
Tony Mack3066a952015-01-05 22:48:11 -05005679class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5680 queryset = ControllerSlice.objects.select_related().all()
5681 serializer_class = ControllerSliceSerializer
5682 id_serializer_class = ControllerSliceIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005683
5684 def get_serializer_class(self):
5685 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5686 if (no_hyperlinks):
5687 return self.id_serializer_class
5688 else:
5689 return self.serializer_class
5690
5691 def get_queryset(self):
Tony Mack3066a952015-01-05 22:48:11 -05005692 return ControllerSlice.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005693
5694 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5695
5696 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5697
5698
5699