blob: 3e6f7b00d4e8fa473b31ca96e7086f20b110f506 [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Baker89a7b7c2014-10-07 00:10:17 -07006from rest_framework import status
Scott Baker57c725c2014-11-12 01:13:53 -08007from rest_framework.generics import GenericAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04008from core.models import *
9from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -070010from rest_framework import filters
Scott Bakerd51d0bd2014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Sapan Bhatiadea39432014-06-13 03:10:36 -040012
13"""
Scott Baker2bcbf372014-10-29 23:41:11 -070014 Schema of the generator object:
15 all: Set of all Model objects
16 all_if(regex): Set of Model objects that match regex
Scott Baker57c725c2014-11-12 01:13:53 -080017
Scott Baker2bcbf372014-10-29 23:41:11 -070018 Model object:
19 plural: English plural of object name
20 camel: CamelCase version of object name
21 refs: list of references to other Model objects
22 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040023
Scott Baker2bcbf372014-10-29 23:41:11 -070024 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040025"""
26
Scott Bakerd51d0bd2014-11-10 16:31:15 -080027def get_REST_patterns():
28 return patterns('',
29 url(r'^plstackapi/$', api_root),
30
Scott Baker515dc9e2014-12-22 09:29:05 -080031 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
32 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
33
Scott Bakerd51d0bd2014-11-10 16:31:15 -080034 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
35 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
36
Scott Baker515dc9e2014-12-22 09:29:05 -080037 url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
38 url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
39
Scott Bakerd51d0bd2014-11-10 16:31:15 -080040 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
41 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
42
43 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
44 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
45
46 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
47 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
48
49 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
50 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
51
52 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
53 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
54
55 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
56 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
57
58 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
59 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
60
61 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
62 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
63
Scott Baker515dc9e2014-12-22 09:29:05 -080064 url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'),
65 url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'),
66
Scott Bakerd51d0bd2014-11-10 16:31:15 -080067 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
68 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
69
Scott Bakerd51d0bd2014-11-10 16:31:15 -080070 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
71 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
72
73 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
74 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
75
76 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
77 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
78
79 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
80 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
81
82 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
83 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
84
Scott Baker515dc9e2014-12-22 09:29:05 -080085 url(r'plstackapi/controllernetworks/$', ControllerNetworksList.as_view(), name='controllernetworks-list'),
86 url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworksDetail.as_view(), name ='controllernetworks-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080087
88 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
89 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
90
91 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
92 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
93
94 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
95 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
96
Scott Baker515dc9e2014-12-22 09:29:05 -080097 url(r'plstackapi/controllersitedeploymentses/$', ControllerSiteDeploymentsList.as_view(), name='controllersitedeployments-list'),
98 url(r'plstackapi/controllersitedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDeploymentsDetail.as_view(), name ='controllersitedeployments-detail'),
99
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800100 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
101 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
102
103 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
104 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
105
106 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
107 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
108
109 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
110 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
111
112 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
113 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
114
Scott Baker515dc9e2014-12-22 09:29:05 -0800115 url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
116 url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800117
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800118 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
119 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
120
Scott Baker515dc9e2014-12-22 09:29:05 -0800121 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
122 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
123
124 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
125 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
126
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800127 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
128 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
129
130 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
131 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
132
Scott Baker515dc9e2014-12-22 09:29:05 -0800133 url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'),
134 url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
135
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800136 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
137 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
138
139 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
140 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
141
142 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
143 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
144
145 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
146 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
147
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800148 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
149 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
150
Scott Bakerb744f1c2014-11-21 11:32:24 -0800151 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
152 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800153
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800154 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
155 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
156
Scott Baker515dc9e2014-12-22 09:29:05 -0800157 url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
158 url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
159
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800160 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
161 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
162
163 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
164 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
165
Scott Baker515dc9e2014-12-22 09:29:05 -0800166 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
167 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800168
Scott Baker515dc9e2014-12-22 09:29:05 -0800169 url(r'plstackapi/controllerusers/$', ControllerUsersList.as_view(), name='controllerusers-list'),
170 url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUsersDetail.as_view(), name ='controllerusers-detail'),
171
172 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
173 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800174
175 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
176 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
177
Scott Bakerb744f1c2014-11-21 11:32:24 -0800178 url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'),
179 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800180
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800181 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
182 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
183
Scott Baker515dc9e2014-12-22 09:29:05 -0800184 url(r'plstackapi/controllerdashboards/$', ControllerDashboardList.as_view(), name='controllerdashboard-list'),
185 url(r'plstackapi/controllerdashboards/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardDetail.as_view(), name ='controllerdashboard-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800186
187 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
188 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
189
190 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
191 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
192
Scott Baker515dc9e2014-12-22 09:29:05 -0800193 url(r'plstackapi/controllerslices/$', ControllerSlicesList.as_view(), name='controllerslices-list'),
194 url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicesDetail.as_view(), name ='controllerslices-detail'),
195
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800196 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400197
198@api_view(['GET'])
199def api_root(request, format=None):
200 return Response({
Scott Baker515dc9e2014-12-22 09:29:05 -0800201 'flavors': reverse('flavor-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700202 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800203 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700204 'images': reverse('image-list', request=request, format=format),
205 'networkparameters': reverse('networkparameter-list', request=request, format=format),
206 'sites': reverse('site-list', request=request, format=format),
207 'sliceroles': reverse('slicerole-list', request=request, format=format),
208 'tags': reverse('tag-list', request=request, format=format),
209 'invoices': reverse('invoice-list', request=request, format=format),
210 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
211 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800212 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700213 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700214 'projects': reverse('project-list', request=request, format=format),
215 'slices': reverse('slice-list', request=request, format=format),
216 'networks': reverse('network-list', request=request, format=format),
217 'services': reverse('service-list', request=request, format=format),
218 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800219 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700220 'charges': reverse('charge-list', request=request, format=format),
221 'roles': reverse('role-list', request=request, format=format),
222 'usableobjects': reverse('usableobject-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800223 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700224 'siteroles': reverse('siterole-list', request=request, format=format),
225 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
226 'slivers': reverse('sliver-list', request=request, format=format),
227 'nodes': reverse('node-list', request=request, format=format),
228 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800229 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700230 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800231 'payments': reverse('payment-list', request=request, format=format),
232 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700233 'networkslices': reverse('networkslice-list', request=request, format=format),
234 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800235 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700236 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
237 'users': reverse('user-list', request=request, format=format),
238 'deployments': reverse('deployment-list', request=request, format=format),
239 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700240 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800241 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700242 'accounts': reverse('account-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800243 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700244 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
245 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800246 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
247 'controlleruserses': reverse('controllerusers-list', request=request, format=format),
248 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700249 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800250 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700251 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800252 'controllerdashboards': reverse('controllerdashboard-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700253 'routers': reverse('router-list', request=request, format=format),
254 'serviceresources': reverse('serviceresource-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800255 'controllersliceses': reverse('controllerslices-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700256
Sapan Bhatiadea39432014-06-13 03:10:36 -0400257 })
258
259# Based on serializers.py
260
Scott Baker515dc9e2014-12-22 09:29:05 -0800261class XOSModelSerializer(serializers.ModelSerializer):
262 def save_object(self, obj, **kwargs):
263
264 """ rest_framework can't deal with ManyToMany relations that have a
265 through table. In plstackapi, most of the through tables we have
266 use defaults or blank fields, so there's no reason why we shouldn't
267 be able to save these objects.
268
269 So, let's strip out these m2m relations, and deal with them ourself.
270 """
271 obj._complex_m2m_data={};
272 if getattr(obj, '_m2m_data', None):
273 for relatedObject in obj._meta.get_all_related_many_to_many_objects():
274 if (relatedObject.field.rel.through._meta.auto_created):
275 # These are non-trough ManyToMany relations and
276 # can be updated just fine
277 continue
278 fieldName = relatedObject.get_accessor_name()
279 if fieldName in obj._m2m_data.keys():
280 obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
281 del obj._m2m_data[fieldName]
282
283 serializers.ModelSerializer.save_object(self, obj, **kwargs);
284
285 for (accessor, stuff) in obj._complex_m2m_data.items():
286 (relatedObject, data) = stuff
287 through = relatedObject.field.rel.through
288 local_fieldName = relatedObject.field.m2m_reverse_field_name()
289 remote_fieldName = relatedObject.field.m2m_field_name()
290
291 # get the current set of existing relations
292 existing = through.objects.filter(**{local_fieldName: obj});
293
294 data_ids = [item.id for item in data]
295 existing_ids = [getattr(item,remote_fieldName).id for item in existing]
296
297 #print "data_ids", data_ids
298 #print "existing_ids", existing_ids
299
300 # remove relations that are in 'existing' but not in 'data'
301 for item in list(existing):
302 if (getattr(item,remote_fieldName).id not in data_ids):
303 print "delete", getattr(item,remote_fieldName)
304 item.delete() #(purge=True)
305
306 # add relations that are in 'data' but not in 'existing'
307 for item in data:
308 if (item.id not in existing_ids):
309 #print "add", item
310 newModel = through(**{local_fieldName: obj, remote_fieldName: item})
311 newModel.save()
312
313
314
315class FlavorSerializer(serializers.HyperlinkedModelSerializer):
316 id = serializers.Field()
317
318
319 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
320
321
322 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
323 validators = serializers.SerializerMethodField("getValidators")
324 def getHumanReadableName(self, obj):
325 return str(obj)
326 def getValidators(self, obj):
327 try:
328 return obj.getValidators()
329 except:
330 return None
331 class Meta:
332 model = Flavor
333 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
334
335class FlavorIdSerializer(XOSModelSerializer):
336 id = serializers.Field()
337
338
339 deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail')
340
341
342 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
343 validators = serializers.SerializerMethodField("getValidators")
344 def getHumanReadableName(self, obj):
345 return str(obj)
346 def getValidators(self, obj):
347 try:
348 return obj.getValidators()
349 except:
350 return None
351 class Meta:
352 model = Flavor
353 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
354
355
Sapan Bhatiadea39432014-06-13 03:10:36 -0400356
357
Scott Baker0caeaf02014-06-19 11:12:55 -0700358class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700359 id = serializers.Field()
360
Scott Bakerb744f1c2014-11-21 11:32:24 -0800361 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800362 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800363 def getHumanReadableName(self, obj):
364 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800365 def getValidators(self, obj):
366 try:
367 return obj.getValidators()
368 except:
369 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700370 class Meta:
371 model = ServiceAttribute
Scott Baker96eb3fd2014-11-25 00:53:25 -0800372 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700373
Scott Baker515dc9e2014-12-22 09:29:05 -0800374class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700375 id = serializers.Field()
376
Scott Bakerb744f1c2014-11-21 11:32:24 -0800377 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800378 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800379 def getHumanReadableName(self, obj):
380 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800381 def getValidators(self, obj):
382 try:
383 return obj.getValidators()
384 except:
385 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800386 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700387 model = ServiceAttribute
Scott Baker96eb3fd2014-11-25 00:53:25 -0800388 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700389
390
Sapan Bhatiadea39432014-06-13 03:10:36 -0400391
392
Scott Baker515dc9e2014-12-22 09:29:05 -0800393class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
394 id = serializers.Field()
395
396 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
397 validators = serializers.SerializerMethodField("getValidators")
398 def getHumanReadableName(self, obj):
399 return str(obj)
400 def getValidators(self, obj):
401 try:
402 return obj.getValidators()
403 except:
404 return None
405 class Meta:
406 model = ControllerImages
407 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
408
409class ControllerImagesIdSerializer(XOSModelSerializer):
410 id = serializers.Field()
411
412 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
413 validators = serializers.SerializerMethodField("getValidators")
414 def getHumanReadableName(self, obj):
415 return str(obj)
416 def getValidators(self, obj):
417 try:
418 return obj.getValidators()
419 except:
420 return None
421 class Meta:
422 model = ControllerImages
423 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
424
425
426
427
Sapan Bhatiadea39432014-06-13 03:10:36 -0400428class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700429 id = serializers.Field()
430
Scott Bakerb744f1c2014-11-21 11:32:24 -0800431 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800432 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800433 def getHumanReadableName(self, obj):
434 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800435 def getValidators(self, obj):
436 try:
437 return obj.getValidators()
438 except:
439 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700440 class Meta:
441 model = Image
Scott Baker96eb3fd2014-11-25 00:53:25 -0800442 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700443
Scott Baker515dc9e2014-12-22 09:29:05 -0800444class ImageIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700445 id = serializers.Field()
446
Scott Bakerb744f1c2014-11-21 11:32:24 -0800447 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800448 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800449 def getHumanReadableName(self, obj):
450 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800451 def getValidators(self, obj):
452 try:
453 return obj.getValidators()
454 except:
455 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800456 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700457 model = Image
Scott Baker96eb3fd2014-11-25 00:53:25 -0800458 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700459
460
Sapan Bhatiadea39432014-06-13 03:10:36 -0400461
462
Scott Baker0caeaf02014-06-19 11:12:55 -0700463class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700464 id = serializers.Field()
465
Scott Bakerb744f1c2014-11-21 11:32:24 -0800466 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800467 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800468 def getHumanReadableName(self, obj):
469 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800470 def getValidators(self, obj):
471 try:
472 return obj.getValidators()
473 except:
474 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700475 class Meta:
476 model = NetworkParameter
Scott Baker96eb3fd2014-11-25 00:53:25 -0800477 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700478
Scott Baker515dc9e2014-12-22 09:29:05 -0800479class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700480 id = serializers.Field()
481
Scott Bakerb744f1c2014-11-21 11:32:24 -0800482 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800483 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800484 def getHumanReadableName(self, obj):
485 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800486 def getValidators(self, obj):
487 try:
488 return obj.getValidators()
489 except:
490 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800491 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700492 model = NetworkParameter
Scott Baker96eb3fd2014-11-25 00:53:25 -0800493 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700494
495
Sapan Bhatiadea39432014-06-13 03:10:36 -0400496
497
498class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700499 id = serializers.Field()
500
Scott Baker515dc9e2014-12-22 09:29:05 -0800501
502 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
503
504
Scott Bakerb744f1c2014-11-21 11:32:24 -0800505 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800506 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800507 def getHumanReadableName(self, obj):
508 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800509 def getValidators(self, obj):
510 try:
511 return obj.getValidators()
512 except:
513 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700514 class Meta:
515 model = Site
Scott Baker515dc9e2014-12-22 09:29:05 -0800516 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 -0700517
Scott Baker515dc9e2014-12-22 09:29:05 -0800518class SiteIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700519 id = serializers.Field()
520
Scott Baker515dc9e2014-12-22 09:29:05 -0800521
522 deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail')
523
524
Scott Bakerb744f1c2014-11-21 11:32:24 -0800525 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800526 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800527 def getHumanReadableName(self, obj):
528 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800529 def getValidators(self, obj):
530 try:
531 return obj.getValidators()
532 except:
533 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800534 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700535 model = Site
Scott Baker515dc9e2014-12-22 09:29:05 -0800536 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 -0700537
538
Sapan Bhatiadea39432014-06-13 03:10:36 -0400539
540
Scott Baker0caeaf02014-06-19 11:12:55 -0700541class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700542 id = serializers.Field()
543
Scott Bakerb744f1c2014-11-21 11:32:24 -0800544 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800545 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800546 def getHumanReadableName(self, obj):
547 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800548 def getValidators(self, obj):
549 try:
550 return obj.getValidators()
551 except:
552 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700553 class Meta:
554 model = SliceRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800555 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700556
Scott Baker515dc9e2014-12-22 09:29:05 -0800557class SliceRoleIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700558 id = serializers.Field()
559
Scott Bakerb744f1c2014-11-21 11:32:24 -0800560 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800561 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800562 def getHumanReadableName(self, obj):
563 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800564 def getValidators(self, obj):
565 try:
566 return obj.getValidators()
567 except:
568 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800569 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700570 model = SliceRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800571 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700572
573
Sapan Bhatiadea39432014-06-13 03:10:36 -0400574
575
576class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700577 id = serializers.Field()
578
Scott Bakerb744f1c2014-11-21 11:32:24 -0800579 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800580 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800581 def getHumanReadableName(self, obj):
582 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800583 def getValidators(self, obj):
584 try:
585 return obj.getValidators()
586 except:
587 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700588 class Meta:
589 model = Tag
Scott Baker96eb3fd2014-11-25 00:53:25 -0800590 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700591
Scott Baker515dc9e2014-12-22 09:29:05 -0800592class TagIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700593 id = serializers.Field()
594
Scott Bakerb744f1c2014-11-21 11:32:24 -0800595 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800596 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800597 def getHumanReadableName(self, obj):
598 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800599 def getValidators(self, obj):
600 try:
601 return obj.getValidators()
602 except:
603 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800604 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700605 model = Tag
Scott Baker96eb3fd2014-11-25 00:53:25 -0800606 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700607
608
Sapan Bhatiadea39432014-06-13 03:10:36 -0400609
610
611class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700612 id = serializers.Field()
613
Scott Bakerb744f1c2014-11-21 11:32:24 -0800614 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800615 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800616 def getHumanReadableName(self, obj):
617 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800618 def getValidators(self, obj):
619 try:
620 return obj.getValidators()
621 except:
622 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700623 class Meta:
624 model = Invoice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800625 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700626
Scott Baker515dc9e2014-12-22 09:29:05 -0800627class InvoiceIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700628 id = serializers.Field()
629
Scott Bakerb744f1c2014-11-21 11:32:24 -0800630 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800631 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800632 def getHumanReadableName(self, obj):
633 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800634 def getValidators(self, obj):
635 try:
636 return obj.getValidators()
637 except:
638 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800639 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700640 model = Invoice
Scott Baker96eb3fd2014-11-25 00:53:25 -0800641 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700642
643
Sapan Bhatiadea39432014-06-13 03:10:36 -0400644
645
Scott Baker0caeaf02014-06-19 11:12:55 -0700646class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700647 id = serializers.Field()
648
Scott Bakerb744f1c2014-11-21 11:32:24 -0800649 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800650 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800651 def getHumanReadableName(self, obj):
652 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800653 def getValidators(self, obj):
654 try:
655 return obj.getValidators()
656 except:
657 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700658 class Meta:
659 model = SlicePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -0800660 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700661
Scott Baker515dc9e2014-12-22 09:29:05 -0800662class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700663 id = serializers.Field()
664
Scott Bakerb744f1c2014-11-21 11:32:24 -0800665 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800666 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800667 def getHumanReadableName(self, obj):
668 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800669 def getValidators(self, obj):
670 try:
671 return obj.getValidators()
672 except:
673 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800674 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700675 model = SlicePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -0800676 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700677
678
Scott Baker0caeaf02014-06-19 11:12:55 -0700679
680
Scott Baker89a7b7c2014-10-07 00:10:17 -0700681class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700682 id = serializers.Field()
683
Scott Bakerb744f1c2014-11-21 11:32:24 -0800684 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800685 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800686 def getHumanReadableName(self, obj):
687 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800688 def getValidators(self, obj):
689 try:
690 return obj.getValidators()
691 except:
692 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700693 class Meta:
694 model = PlanetStackRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800695 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700696
Scott Baker515dc9e2014-12-22 09:29:05 -0800697class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700698 id = serializers.Field()
699
Scott Bakerb744f1c2014-11-21 11:32:24 -0800700 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800701 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800702 def getHumanReadableName(self, obj):
703 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800704 def getValidators(self, obj):
705 try:
706 return obj.getValidators()
707 except:
708 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800709 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700710 model = PlanetStackRole
Scott Baker96eb3fd2014-11-25 00:53:25 -0800711 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700712
713
714
715
Scott Baker515dc9e2014-12-22 09:29:05 -0800716class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
717 id = serializers.Field()
718
719 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
720 validators = serializers.SerializerMethodField("getValidators")
721 def getHumanReadableName(self, obj):
722 return str(obj)
723 def getValidators(self, obj):
724 try:
725 return obj.getValidators()
726 except:
727 return None
728 class Meta:
729 model = ControllerPrivilege
730 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',)
731
732class ControllerPrivilegeIdSerializer(XOSModelSerializer):
733 id = serializers.Field()
734
735 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
736 validators = serializers.SerializerMethodField("getValidators")
737 def getHumanReadableName(self, obj):
738 return str(obj)
739 def getValidators(self, obj):
740 try:
741 return obj.getValidators()
742 except:
743 return None
744 class Meta:
745 model = ControllerPrivilege
746 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',)
747
748
749
750
Scott Baker0caeaf02014-06-19 11:12:55 -0700751class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700752 id = serializers.Field()
753
Scott Bakerb744f1c2014-11-21 11:32:24 -0800754 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800755 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800756 def getHumanReadableName(self, obj):
757 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800758 def getValidators(self, obj):
759 try:
760 return obj.getValidators()
761 except:
762 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700763 class Meta:
764 model = NetworkSliver
Scott Baker96eb3fd2014-11-25 00:53:25 -0800765 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700766
Scott Baker515dc9e2014-12-22 09:29:05 -0800767class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700768 id = serializers.Field()
769
Scott Bakerb744f1c2014-11-21 11:32:24 -0800770 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800771 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800772 def getHumanReadableName(self, obj):
773 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800774 def getValidators(self, obj):
775 try:
776 return obj.getValidators()
777 except:
778 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800779 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700780 model = NetworkSliver
Scott Baker96eb3fd2014-11-25 00:53:25 -0800781 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700782
783
Scott Baker0caeaf02014-06-19 11:12:55 -0700784
785
Scott Baker89a7b7c2014-10-07 00:10:17 -0700786class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700787 id = serializers.Field()
788
Scott Bakerb744f1c2014-11-21 11:32:24 -0800789 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800790 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800791 def getHumanReadableName(self, obj):
792 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800793 def getValidators(self, obj):
794 try:
795 return obj.getValidators()
796 except:
797 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700798 class Meta:
799 model = Project
Scott Baker96eb3fd2014-11-25 00:53:25 -0800800 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700801
Scott Baker515dc9e2014-12-22 09:29:05 -0800802class ProjectIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700803 id = serializers.Field()
804
Scott Bakerb744f1c2014-11-21 11:32:24 -0800805 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800806 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800807 def getHumanReadableName(self, obj):
808 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800809 def getValidators(self, obj):
810 try:
811 return obj.getValidators()
812 except:
813 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800814 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700815 model = Project
Scott Baker96eb3fd2014-11-25 00:53:25 -0800816 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700817
818
819
820
Sapan Bhatiadea39432014-06-13 03:10:36 -0400821class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700822 id = serializers.Field()
823
824
825 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
826
827
828
Scott Baker2bcbf372014-10-29 23:41:11 -0700829 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
830
831
Scott Bakerb744f1c2014-11-21 11:32:24 -0800832 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800833 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800834 def getHumanReadableName(self, obj):
835 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800836 def getValidators(self, obj):
837 try:
838 return obj.getValidators()
839 except:
840 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700841 class Meta:
842 model = Slice
Scott Baker515dc9e2014-12-22 09:29:05 -0800843 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 -0700844
Scott Baker515dc9e2014-12-22 09:29:05 -0800845class SliceIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700846 id = serializers.Field()
847
848
Scott Baker515dc9e2014-12-22 09:29:05 -0800849 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700850
851
852
Scott Baker515dc9e2014-12-22 09:29:05 -0800853 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700854
855
Scott Bakerb744f1c2014-11-21 11:32:24 -0800856 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800857 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800858 def getHumanReadableName(self, obj):
859 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800860 def getValidators(self, obj):
861 try:
862 return obj.getValidators()
863 except:
864 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800865 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700866 model = Slice
Scott Baker515dc9e2014-12-22 09:29:05 -0800867 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 -0700868
869
Sapan Bhatiadea39432014-06-13 03:10:36 -0400870
871
872class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700873 id = serializers.Field()
874
875
Scott Baker515dc9e2014-12-22 09:29:05 -0800876 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700877
878
879
Scott Baker515dc9e2014-12-22 09:29:05 -0800880 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
881
882
883
884 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700885
886
887
888 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
889
890
891
892 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
893
894
Scott Bakerb744f1c2014-11-21 11:32:24 -0800895 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800896 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800897 def getHumanReadableName(self, obj):
898 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800899 def getValidators(self, obj):
900 try:
901 return obj.getValidators()
902 except:
903 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700904 class Meta:
905 model = Network
Scott Baker515dc9e2014-12-22 09:29:05 -0800906 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700907
Scott Baker515dc9e2014-12-22 09:29:05 -0800908class NetworkIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700909 id = serializers.Field()
910
911
Scott Baker515dc9e2014-12-22 09:29:05 -0800912 slices = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='slice-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700913
914
915
Scott Baker515dc9e2014-12-22 09:29:05 -0800916 slices = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='slice-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700917
918
919
Scott Baker515dc9e2014-12-22 09:29:05 -0800920 slivers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='sliver-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700921
922
923
Scott Baker515dc9e2014-12-22 09:29:05 -0800924 routers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='router-detail')
925
926
927
928 routers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='router-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700929
930
Scott Bakerb744f1c2014-11-21 11:32:24 -0800931 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800932 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800933 def getHumanReadableName(self, obj):
934 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800935 def getValidators(self, obj):
936 try:
937 return obj.getValidators()
938 except:
939 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800940 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700941 model = Network
Scott Baker515dc9e2014-12-22 09:29:05 -0800942 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700943
944
Sapan Bhatiadea39432014-06-13 03:10:36 -0400945
946
947class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700948 id = serializers.Field()
949
Scott Bakerb744f1c2014-11-21 11:32:24 -0800950 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800951 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800952 def getHumanReadableName(self, obj):
953 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800954 def getValidators(self, obj):
955 try:
956 return obj.getValidators()
957 except:
958 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700959 class Meta:
960 model = Service
Scott Baker96eb3fd2014-11-25 00:53:25 -0800961 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700962
Scott Baker515dc9e2014-12-22 09:29:05 -0800963class ServiceIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700964 id = serializers.Field()
965
Scott Bakerb744f1c2014-11-21 11:32:24 -0800966 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800967 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800968 def getHumanReadableName(self, obj):
969 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800970 def getValidators(self, obj):
971 try:
972 return obj.getValidators()
973 except:
974 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800975 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700976 model = Service
Scott Baker96eb3fd2014-11-25 00:53:25 -0800977 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700978
979
Sapan Bhatiadea39432014-06-13 03:10:36 -0400980
981
Scott Baker0caeaf02014-06-19 11:12:55 -0700982class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700983 id = serializers.Field()
984
Scott Bakerb744f1c2014-11-21 11:32:24 -0800985 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800986 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800987 def getHumanReadableName(self, obj):
988 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800989 def getValidators(self, obj):
990 try:
991 return obj.getValidators()
992 except:
993 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700994 class Meta:
995 model = ServiceClass
Scott Baker96eb3fd2014-11-25 00:53:25 -0800996 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700997
Scott Baker515dc9e2014-12-22 09:29:05 -0800998class ServiceClassIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -0700999 id = serializers.Field()
1000
Scott Bakerb744f1c2014-11-21 11:32:24 -08001001 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001002 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001003 def getHumanReadableName(self, obj):
1004 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001005 def getValidators(self, obj):
1006 try:
1007 return obj.getValidators()
1008 except:
1009 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001010 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001011 model = ServiceClass
Scott Baker96eb3fd2014-11-25 00:53:25 -08001012 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001013
1014
Sapan Bhatiadea39432014-06-13 03:10:36 -04001015
1016
Scott Baker515dc9e2014-12-22 09:29:05 -08001017class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001018 id = serializers.Field()
1019
Scott Bakerb744f1c2014-11-21 11:32:24 -08001020 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001021 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001022 def getHumanReadableName(self, obj):
1023 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001024 def getValidators(self, obj):
1025 try:
1026 return obj.getValidators()
1027 except:
1028 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001029 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001030 model = ControllerNetworks
1031 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 -07001032
Scott Baker515dc9e2014-12-22 09:29:05 -08001033class ControllerNetworksIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001034 id = serializers.Field()
1035
Scott Bakerb744f1c2014-11-21 11:32:24 -08001036 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001037 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001038 def getHumanReadableName(self, obj):
1039 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001040 def getValidators(self, obj):
1041 try:
1042 return obj.getValidators()
1043 except:
1044 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001045 class Meta:
1046 model = ControllerNetworks
1047 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 -07001048
1049
Sapan Bhatiadea39432014-06-13 03:10:36 -04001050
1051
1052class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001053 id = serializers.Field()
1054
Scott Bakerb744f1c2014-11-21 11:32:24 -08001055 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001056 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001057 def getHumanReadableName(self, obj):
1058 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001059 def getValidators(self, obj):
1060 try:
1061 return obj.getValidators()
1062 except:
1063 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001064 class Meta:
1065 model = Charge
Scott Baker96eb3fd2014-11-25 00:53:25 -08001066 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 -07001067
Scott Baker515dc9e2014-12-22 09:29:05 -08001068class ChargeIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001069 id = serializers.Field()
1070
Scott Bakerb744f1c2014-11-21 11:32:24 -08001071 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001072 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001073 def getHumanReadableName(self, obj):
1074 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001075 def getValidators(self, obj):
1076 try:
1077 return obj.getValidators()
1078 except:
1079 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001080 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001081 model = Charge
Scott Baker96eb3fd2014-11-25 00:53:25 -08001082 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 -07001083
1084
Sapan Bhatiadea39432014-06-13 03:10:36 -04001085
1086
1087class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001088 id = serializers.Field()
1089
Scott Bakerb744f1c2014-11-21 11:32:24 -08001090 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001091 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001092 def getHumanReadableName(self, obj):
1093 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001094 def getValidators(self, obj):
1095 try:
1096 return obj.getValidators()
1097 except:
1098 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001099 class Meta:
1100 model = Role
Scott Baker96eb3fd2014-11-25 00:53:25 -08001101 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001102
Scott Baker515dc9e2014-12-22 09:29:05 -08001103class RoleIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001104 id = serializers.Field()
1105
Scott Bakerb744f1c2014-11-21 11:32:24 -08001106 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001107 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001108 def getHumanReadableName(self, obj):
1109 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001110 def getValidators(self, obj):
1111 try:
1112 return obj.getValidators()
1113 except:
1114 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001115 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001116 model = Role
Scott Baker96eb3fd2014-11-25 00:53:25 -08001117 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001118
1119
Sapan Bhatiadea39432014-06-13 03:10:36 -04001120
1121
Scott Baker0caeaf02014-06-19 11:12:55 -07001122class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001123 id = serializers.Field()
1124
Scott Bakerb744f1c2014-11-21 11:32:24 -08001125 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001126 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001127 def getHumanReadableName(self, obj):
1128 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001129 def getValidators(self, obj):
1130 try:
1131 return obj.getValidators()
1132 except:
1133 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001134 class Meta:
1135 model = UsableObject
Scott Baker96eb3fd2014-11-25 00:53:25 -08001136 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001137
Scott Baker515dc9e2014-12-22 09:29:05 -08001138class UsableObjectIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001139 id = serializers.Field()
1140
Scott Bakerb744f1c2014-11-21 11:32:24 -08001141 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001142 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001143 def getHumanReadableName(self, obj):
1144 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001145 def getValidators(self, obj):
1146 try:
1147 return obj.getValidators()
1148 except:
1149 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001150 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001151 model = UsableObject
Scott Baker96eb3fd2014-11-25 00:53:25 -08001152 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001153
1154
Sapan Bhatiadea39432014-06-13 03:10:36 -04001155
1156
Scott Baker515dc9e2014-12-22 09:29:05 -08001157class ControllerSiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
1158 id = serializers.Field()
1159
1160 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1161 validators = serializers.SerializerMethodField("getValidators")
1162 def getHumanReadableName(self, obj):
1163 return str(obj)
1164 def getValidators(self, obj):
1165 try:
1166 return obj.getValidators()
1167 except:
1168 return None
1169 class Meta:
1170 model = ControllerSiteDeployments
1171 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
1172
1173class ControllerSiteDeploymentsIdSerializer(XOSModelSerializer):
1174 id = serializers.Field()
1175
1176 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1177 validators = serializers.SerializerMethodField("getValidators")
1178 def getHumanReadableName(self, obj):
1179 return str(obj)
1180 def getValidators(self, obj):
1181 try:
1182 return obj.getValidators()
1183 except:
1184 return None
1185 class Meta:
1186 model = ControllerSiteDeployments
1187 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
1188
1189
1190
1191
Scott Baker0caeaf02014-06-19 11:12:55 -07001192class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001193 id = serializers.Field()
1194
Scott Bakerb744f1c2014-11-21 11:32:24 -08001195 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001196 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001197 def getHumanReadableName(self, obj):
1198 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001199 def getValidators(self, obj):
1200 try:
1201 return obj.getValidators()
1202 except:
1203 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001204 class Meta:
1205 model = SiteRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001206 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001207
Scott Baker515dc9e2014-12-22 09:29:05 -08001208class SiteRoleIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001209 id = serializers.Field()
1210
Scott Bakerb744f1c2014-11-21 11:32:24 -08001211 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001212 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001213 def getHumanReadableName(self, obj):
1214 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001215 def getValidators(self, obj):
1216 try:
1217 return obj.getValidators()
1218 except:
1219 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001220 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001221 model = SiteRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08001222 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001223
1224
Scott Baker0caeaf02014-06-19 11:12:55 -07001225
1226
Scott Baker89a7b7c2014-10-07 00:10:17 -07001227class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001228 id = serializers.Field()
1229
Scott Bakerb744f1c2014-11-21 11:32:24 -08001230 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001231 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001232 def getHumanReadableName(self, obj):
1233 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001234 def getValidators(self, obj):
1235 try:
1236 return obj.getValidators()
1237 except:
1238 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001239 class Meta:
1240 model = SliceCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001241 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001242
Scott Baker515dc9e2014-12-22 09:29:05 -08001243class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001244 id = serializers.Field()
1245
Scott Bakerb744f1c2014-11-21 11:32:24 -08001246 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001247 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001248 def getHumanReadableName(self, obj):
1249 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001250 def getValidators(self, obj):
1251 try:
1252 return obj.getValidators()
1253 except:
1254 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001255 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001256 model = SliceCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001257 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001258
1259
1260
1261
Sapan Bhatiadea39432014-06-13 03:10:36 -04001262class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001263 id = serializers.Field()
1264
1265
1266 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1267
1268
Scott Bakerb744f1c2014-11-21 11:32:24 -08001269 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001270 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001271 def getHumanReadableName(self, obj):
1272 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001273 def getValidators(self, obj):
1274 try:
1275 return obj.getValidators()
1276 except:
1277 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001278 class Meta:
1279 model = Sliver
Scott Baker515dc9e2014-12-22 09:29:05 -08001280 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001281
Scott Baker515dc9e2014-12-22 09:29:05 -08001282class SliverIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001283 id = serializers.Field()
1284
1285
Scott Baker515dc9e2014-12-22 09:29:05 -08001286 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -07001287
1288
Scott Bakerb744f1c2014-11-21 11:32:24 -08001289 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001290 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001291 def getHumanReadableName(self, obj):
1292 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001293 def getValidators(self, obj):
1294 try:
1295 return obj.getValidators()
1296 except:
1297 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001298 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001299 model = Sliver
Scott Baker515dc9e2014-12-22 09:29:05 -08001300 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001301
1302
Sapan Bhatiadea39432014-06-13 03:10:36 -04001303
1304
1305class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001306 id = serializers.Field()
1307
Scott Bakerb744f1c2014-11-21 11:32:24 -08001308 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001309 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001310 def getHumanReadableName(self, obj):
1311 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001312 def getValidators(self, obj):
1313 try:
1314 return obj.getValidators()
1315 except:
1316 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001317 class Meta:
1318 model = Node
Scott Baker515dc9e2014-12-22 09:29:05 -08001319 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001320
Scott Baker515dc9e2014-12-22 09:29:05 -08001321class NodeIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001322 id = serializers.Field()
1323
Scott Bakerb744f1c2014-11-21 11:32:24 -08001324 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001325 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001326 def getHumanReadableName(self, obj):
1327 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001328 def getValidators(self, obj):
1329 try:
1330 return obj.getValidators()
1331 except:
1332 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001333 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001334 model = Node
Scott Baker515dc9e2014-12-22 09:29:05 -08001335 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001336
1337
Sapan Bhatiadea39432014-06-13 03:10:36 -04001338
1339
Scott Baker0caeaf02014-06-19 11:12:55 -07001340class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001341 id = serializers.Field()
1342
Scott Baker515dc9e2014-12-22 09:29:05 -08001343
1344 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1345
1346
Scott Bakerb744f1c2014-11-21 11:32:24 -08001347 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001348 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001349 def getHumanReadableName(self, obj):
1350 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001351 def getValidators(self, obj):
1352 try:
1353 return obj.getValidators()
1354 except:
1355 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001356 class Meta:
1357 model = DashboardView
Scott Baker515dc9e2014-12-22 09:29:05 -08001358 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker46b58542014-08-11 17:26:12 -07001359
Scott Baker515dc9e2014-12-22 09:29:05 -08001360class DashboardViewIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001361 id = serializers.Field()
1362
Scott Baker515dc9e2014-12-22 09:29:05 -08001363
1364 controllers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='controller-detail')
1365
1366
Scott Bakerb744f1c2014-11-21 11:32:24 -08001367 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001368 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001369 def getHumanReadableName(self, obj):
1370 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001371 def getValidators(self, obj):
1372 try:
1373 return obj.getValidators()
1374 except:
1375 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001376 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001377 model = DashboardView
Scott Baker515dc9e2014-12-22 09:29:05 -08001378 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001379
1380
1381
1382
Scott Baker515dc9e2014-12-22 09:29:05 -08001383class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001384 id = serializers.Field()
1385
1386 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001387 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001388 def getHumanReadableName(self, obj):
1389 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001390 def getValidators(self, obj):
1391 try:
1392 return obj.getValidators()
1393 except:
1394 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001395 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001396 model = ImageDeployments
1397 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001398
Scott Baker515dc9e2014-12-22 09:29:05 -08001399class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001400 id = serializers.Field()
1401
1402 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001403 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001404 def getHumanReadableName(self, obj):
1405 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001406 def getValidators(self, obj):
1407 try:
1408 return obj.getValidators()
1409 except:
1410 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001411 class Meta:
1412 model = ImageDeployments
1413 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001414
1415
Sapan Bhatiadea39432014-06-13 03:10:36 -04001416
1417
Scott Baker0caeaf02014-06-19 11:12:55 -07001418class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001419 id = serializers.Field()
1420
Scott Bakerb744f1c2014-11-21 11:32:24 -08001421 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001422 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001423 def getHumanReadableName(self, obj):
1424 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001425 def getValidators(self, obj):
1426 try:
1427 return obj.getValidators()
1428 except:
1429 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001430 class Meta:
1431 model = ReservedResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08001432 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001433
Scott Baker515dc9e2014-12-22 09:29:05 -08001434class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001435 id = serializers.Field()
1436
Scott Bakerb744f1c2014-11-21 11:32:24 -08001437 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001438 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001439 def getHumanReadableName(self, obj):
1440 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001441 def getValidators(self, obj):
1442 try:
1443 return obj.getValidators()
1444 except:
1445 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001446 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001447 model = ReservedResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08001448 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker8b533192014-11-17 22:32:19 -08001449
1450
1451
1452
Scott Baker515dc9e2014-12-22 09:29:05 -08001453class PaymentSerializer(serializers.HyperlinkedModelSerializer):
1454 id = serializers.Field()
1455
1456 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1457 validators = serializers.SerializerMethodField("getValidators")
1458 def getHumanReadableName(self, obj):
1459 return str(obj)
1460 def getValidators(self, obj):
1461 try:
1462 return obj.getValidators()
1463 except:
1464 return None
1465 class Meta:
1466 model = Payment
1467 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1468
1469class PaymentIdSerializer(XOSModelSerializer):
1470 id = serializers.Field()
1471
1472 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1473 validators = serializers.SerializerMethodField("getValidators")
1474 def getHumanReadableName(self, obj):
1475 return str(obj)
1476 def getValidators(self, obj):
1477 try:
1478 return obj.getValidators()
1479 except:
1480 return None
1481 class Meta:
1482 model = Payment
1483 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1484
1485
1486
1487
1488class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
1489 id = serializers.Field()
1490
1491 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1492 validators = serializers.SerializerMethodField("getValidators")
1493 def getHumanReadableName(self, obj):
1494 return str(obj)
1495 def getValidators(self, obj):
1496 try:
1497 return obj.getValidators()
1498 except:
1499 return None
1500 class Meta:
1501 model = NetworkTemplate
1502 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
1503
1504class NetworkTemplateIdSerializer(XOSModelSerializer):
1505 id = serializers.Field()
1506
1507 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1508 validators = serializers.SerializerMethodField("getValidators")
1509 def getHumanReadableName(self, obj):
1510 return str(obj)
1511 def getValidators(self, obj):
1512 try:
1513 return obj.getValidators()
1514 except:
1515 return None
1516 class Meta:
1517 model = NetworkTemplate
1518 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
1519
1520
1521
1522
Scott Baker0caeaf02014-06-19 11:12:55 -07001523class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001524 id = serializers.Field()
1525
Scott Bakerb744f1c2014-11-21 11:32:24 -08001526 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001527 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001528 def getHumanReadableName(self, obj):
1529 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001530 def getValidators(self, obj):
1531 try:
1532 return obj.getValidators()
1533 except:
1534 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001535 class Meta:
1536 model = NetworkSlice
Scott Baker96eb3fd2014-11-25 00:53:25 -08001537 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001538
Scott Baker515dc9e2014-12-22 09:29:05 -08001539class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001540 id = serializers.Field()
1541
Scott Bakerb744f1c2014-11-21 11:32:24 -08001542 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001543 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001544 def getHumanReadableName(self, obj):
1545 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001546 def getValidators(self, obj):
1547 try:
1548 return obj.getValidators()
1549 except:
1550 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001551 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001552 model = NetworkSlice
Scott Baker96eb3fd2014-11-25 00:53:25 -08001553 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001554
1555
Scott Baker0caeaf02014-06-19 11:12:55 -07001556
1557
1558class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001559 id = serializers.Field()
1560
Scott Bakerb744f1c2014-11-21 11:32:24 -08001561 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001562 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001563 def getHumanReadableName(self, obj):
1564 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001565 def getValidators(self, obj):
1566 try:
1567 return obj.getValidators()
1568 except:
1569 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001570 class Meta:
1571 model = UserDashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001572 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001573
Scott Baker515dc9e2014-12-22 09:29:05 -08001574class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001575 id = serializers.Field()
1576
Scott Bakerb744f1c2014-11-21 11:32:24 -08001577 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001578 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001579 def getHumanReadableName(self, obj):
1580 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001581 def getValidators(self, obj):
1582 try:
1583 return obj.getValidators()
1584 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001585 return None
1586 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001587 model = UserDashboardView
Scott Baker96eb3fd2014-11-25 00:53:25 -08001588 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker8b533192014-11-17 22:32:19 -08001589
1590
1591
1592
Scott Baker515dc9e2014-12-22 09:29:05 -08001593class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001594 id = serializers.Field()
1595
Scott Baker515dc9e2014-12-22 09:29:05 -08001596
1597 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1598
1599
Scott Bakerb744f1c2014-11-21 11:32:24 -08001600 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001601 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001602 def getHumanReadableName(self, obj):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001603 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001604 def getValidators(self, obj):
1605 try:
1606 return obj.getValidators()
1607 except:
1608 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001609 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001610 model = Controller
1611 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 -07001612
Scott Baker515dc9e2014-12-22 09:29:05 -08001613class ControllerIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001614 id = serializers.Field()
1615
1616
Scott Baker515dc9e2014-12-22 09:29:05 -08001617 dashboardviews = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='dashboardview-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -07001618
1619
Scott Bakerb744f1c2014-11-21 11:32:24 -08001620 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001621 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001622 def getHumanReadableName(self, obj):
1623 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001624 def getValidators(self, obj):
1625 try:
1626 return obj.getValidators()
1627 except:
1628 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001629 class Meta:
1630 model = Controller
1631 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
1632
1633
1634
1635
1636class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1637 id = serializers.Field()
1638
1639 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1640 validators = serializers.SerializerMethodField("getValidators")
1641 def getHumanReadableName(self, obj):
1642 return str(obj)
1643 def getValidators(self, obj):
1644 try:
1645 return obj.getValidators()
1646 except:
1647 return None
1648 class Meta:
1649 model = PlanetStackPrivilege
1650 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1651
1652class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
1653 id = serializers.Field()
1654
1655 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1656 validators = serializers.SerializerMethodField("getValidators")
1657 def getHumanReadableName(self, obj):
1658 return str(obj)
1659 def getValidators(self, obj):
1660 try:
1661 return obj.getValidators()
1662 except:
1663 return None
1664 class Meta:
1665 model = PlanetStackPrivilege
1666 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1667
1668
1669
1670
1671class UserSerializer(serializers.HyperlinkedModelSerializer):
1672 id = serializers.Field()
1673
1674 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1675 validators = serializers.SerializerMethodField("getValidators")
1676 def getHumanReadableName(self, obj):
1677 return str(obj)
1678 def getValidators(self, obj):
1679 try:
1680 return obj.getValidators()
1681 except:
1682 return None
1683 class Meta:
1684 model = User
1685 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',)
1686
1687class UserIdSerializer(XOSModelSerializer):
1688 id = serializers.Field()
1689
1690 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1691 validators = serializers.SerializerMethodField("getValidators")
1692 def getHumanReadableName(self, obj):
1693 return str(obj)
1694 def getValidators(self, obj):
1695 try:
1696 return obj.getValidators()
1697 except:
1698 return None
1699 class Meta:
1700 model = User
1701 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',)
1702
1703
1704
1705
1706class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
1707 id = serializers.Field()
1708
1709
1710 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1711
1712
1713
1714 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1715
1716
1717 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1718 validators = serializers.SerializerMethodField("getValidators")
1719 def getHumanReadableName(self, obj):
1720 return str(obj)
1721 def getValidators(self, obj):
1722 try:
1723 return obj.getValidators()
1724 except:
1725 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001726 class Meta:
1727 model = Deployment
Scott Baker515dc9e2014-12-22 09:29:05 -08001728 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','sites',)
Scott Baker46b58542014-08-11 17:26:12 -07001729
Scott Baker515dc9e2014-12-22 09:29:05 -08001730class DeploymentIdSerializer(XOSModelSerializer):
Tony Mack06c8e472014-11-30 15:53:08 -05001731 id = serializers.Field()
Scott Baker515dc9e2014-12-22 09:29:05 -08001732
1733
1734 flavors = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='flavor-detail')
1735
1736
1737
1738 sites = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='site-detail')
1739
1740
Tony Mack06c8e472014-11-30 15:53:08 -05001741 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1742 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001743 def getHumanReadableName(self, obj):
1744 return str(obj)
1745 def getValidators(self, obj):
Tony Mack06c8e472014-11-30 15:53:08 -05001746 try:
1747 return obj.getValidators()
1748 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001749 return None
1750 class Meta:
1751 model = Deployment
1752 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','sites',)
Tony Mack06c8e472014-11-30 15:53:08 -05001753
1754
Sapan Bhatiadea39432014-06-13 03:10:36 -04001755
1756
1757class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001758 id = serializers.Field()
1759
Scott Bakerb744f1c2014-11-21 11:32:24 -08001760 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001761 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001762 def getHumanReadableName(self, obj):
1763 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001764 def getValidators(self, obj):
1765 try:
1766 return obj.getValidators()
1767 except:
1768 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001769 class Meta:
1770 model = Reservation
Scott Baker96eb3fd2014-11-25 00:53:25 -08001771 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001772
Scott Baker515dc9e2014-12-22 09:29:05 -08001773class ReservationIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001774 id = serializers.Field()
1775
Scott Bakerb744f1c2014-11-21 11:32:24 -08001776 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001777 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001778 def getHumanReadableName(self, obj):
1779 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001780 def getValidators(self, obj):
1781 try:
1782 return obj.getValidators()
1783 except:
1784 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001785 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001786 model = Reservation
Scott Baker96eb3fd2014-11-25 00:53:25 -08001787 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001788
1789
Scott Baker0caeaf02014-06-19 11:12:55 -07001790
1791
Scott Bakerb744f1c2014-11-21 11:32:24 -08001792class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1793 id = serializers.Field()
1794
1795 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001796 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001797 def getHumanReadableName(self, obj):
1798 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001799 def getValidators(self, obj):
1800 try:
1801 return obj.getValidators()
1802 except:
1803 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001804 class Meta:
1805 model = SitePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001806 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001807
Scott Baker515dc9e2014-12-22 09:29:05 -08001808class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001809 id = serializers.Field()
1810
1811 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001812 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001813 def getHumanReadableName(self, obj):
1814 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001815 def getValidators(self, obj):
1816 try:
1817 return obj.getValidators()
1818 except:
1819 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001820 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08001821 model = SitePrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08001822 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001823
1824
1825
1826
1827class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
1828 id = serializers.Field()
1829
1830 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001831 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001832 def getHumanReadableName(self, obj):
1833 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001834 def getValidators(self, obj):
1835 try:
1836 return obj.getValidators()
1837 except:
1838 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001839 class Meta:
1840 model = PlanetStack
Scott Baker96eb3fd2014-11-25 00:53:25 -08001841 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001842
Scott Baker515dc9e2014-12-22 09:29:05 -08001843class PlanetStackIdSerializer(XOSModelSerializer):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001844 id = serializers.Field()
1845
1846 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001847 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001848 def getHumanReadableName(self, obj):
1849 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001850 def getValidators(self, obj):
1851 try:
1852 return obj.getValidators()
1853 except:
1854 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001855 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08001856 model = PlanetStack
Scott Baker96eb3fd2014-11-25 00:53:25 -08001857 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001858
1859
Sapan Bhatiadea39432014-06-13 03:10:36 -04001860
1861
1862class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001863 id = serializers.Field()
1864
Scott Bakerb744f1c2014-11-21 11:32:24 -08001865 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001866 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001867 def getHumanReadableName(self, obj):
1868 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001869 def getValidators(self, obj):
1870 try:
1871 return obj.getValidators()
1872 except:
1873 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001874 class Meta:
1875 model = Account
Scott Baker96eb3fd2014-11-25 00:53:25 -08001876 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001877
Scott Baker515dc9e2014-12-22 09:29:05 -08001878class AccountIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001879 id = serializers.Field()
1880
Scott Bakerb744f1c2014-11-21 11:32:24 -08001881 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001882 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001883 def getHumanReadableName(self, obj):
1884 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001885 def getValidators(self, obj):
1886 try:
1887 return obj.getValidators()
1888 except:
1889 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001890 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001891 model = Account
Scott Baker96eb3fd2014-11-25 00:53:25 -08001892 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001893
1894
Sapan Bhatiadea39432014-06-13 03:10:36 -04001895
1896
Scott Baker515dc9e2014-12-22 09:29:05 -08001897class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
1898 id = serializers.Field()
1899
1900 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1901 validators = serializers.SerializerMethodField("getValidators")
1902 def getHumanReadableName(self, obj):
1903 return str(obj)
1904 def getValidators(self, obj):
1905 try:
1906 return obj.getValidators()
1907 except:
1908 return None
1909 class Meta:
1910 model = ControllerRole
1911 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1912
1913class ControllerRoleIdSerializer(XOSModelSerializer):
1914 id = serializers.Field()
1915
1916 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1917 validators = serializers.SerializerMethodField("getValidators")
1918 def getHumanReadableName(self, obj):
1919 return str(obj)
1920 def getValidators(self, obj):
1921 try:
1922 return obj.getValidators()
1923 except:
1924 return None
1925 class Meta:
1926 model = ControllerRole
1927 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1928
1929
1930
1931
Scott Baker0caeaf02014-06-19 11:12:55 -07001932class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001933 id = serializers.Field()
1934
Scott Bakerb744f1c2014-11-21 11:32:24 -08001935 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001936 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001937 def getHumanReadableName(self, obj):
1938 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001939 def getValidators(self, obj):
1940 try:
1941 return obj.getValidators()
1942 except:
1943 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001944 class Meta:
1945 model = NetworkParameterType
Scott Baker96eb3fd2014-11-25 00:53:25 -08001946 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001947
Scott Baker515dc9e2014-12-22 09:29:05 -08001948class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001949 id = serializers.Field()
1950
Scott Bakerb744f1c2014-11-21 11:32:24 -08001951 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001952 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001953 def getHumanReadableName(self, obj):
1954 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001955 def getValidators(self, obj):
1956 try:
1957 return obj.getValidators()
1958 except:
1959 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001960 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001961 model = NetworkParameterType
Scott Baker96eb3fd2014-11-25 00:53:25 -08001962 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001963
1964
Sapan Bhatiadea39432014-06-13 03:10:36 -04001965
1966
Scott Baker89a7b7c2014-10-07 00:10:17 -07001967class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001968 id = serializers.Field()
1969
Scott Bakerb744f1c2014-11-21 11:32:24 -08001970 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001971 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001972 def getHumanReadableName(self, obj):
1973 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001974 def getValidators(self, obj):
1975 try:
1976 return obj.getValidators()
1977 except:
1978 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001979 class Meta:
1980 model = SiteCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001981 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001982
Scott Baker515dc9e2014-12-22 09:29:05 -08001983class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07001984 id = serializers.Field()
1985
Scott Bakerb744f1c2014-11-21 11:32:24 -08001986 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001987 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001988 def getHumanReadableName(self, obj):
1989 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001990 def getValidators(self, obj):
1991 try:
1992 return obj.getValidators()
1993 except:
1994 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001995 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001996 model = SiteCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08001997 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001998
1999
Scott Baker0caeaf02014-06-19 11:12:55 -07002000
2001
Scott Baker515dc9e2014-12-22 09:29:05 -08002002class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002003 id = serializers.Field()
2004
Scott Bakerb744f1c2014-11-21 11:32:24 -08002005 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002006 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002007 def getHumanReadableName(self, obj):
2008 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002009 def getValidators(self, obj):
2010 try:
2011 return obj.getValidators()
2012 except:
2013 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002014 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08002015 model = DeploymentPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08002016 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002017
Scott Baker515dc9e2014-12-22 09:29:05 -08002018class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002019 id = serializers.Field()
2020
Scott Bakerb744f1c2014-11-21 11:32:24 -08002021 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002022 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002023 def getHumanReadableName(self, obj):
2024 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002025 def getValidators(self, obj):
2026 try:
2027 return obj.getValidators()
2028 except:
2029 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002030 class Meta:
2031 model = DeploymentPrivilege
Scott Baker96eb3fd2014-11-25 00:53:25 -08002032 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker8b533192014-11-17 22:32:19 -08002033
2034
2035
2036
Scott Baker515dc9e2014-12-22 09:29:05 -08002037class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002038 id = serializers.Field()
2039
Scott Bakerb744f1c2014-11-21 11:32:24 -08002040 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002041 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002042 def getHumanReadableName(self, obj):
2043 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002044 def getValidators(self, obj):
2045 try:
2046 return obj.getValidators()
2047 except:
2048 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002049 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08002050 model = ControllerUsers
2051 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2052
2053class ControllerUsersIdSerializer(XOSModelSerializer):
2054 id = serializers.Field()
2055
2056 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2057 validators = serializers.SerializerMethodField("getValidators")
2058 def getHumanReadableName(self, obj):
2059 return str(obj)
2060 def getValidators(self, obj):
2061 try:
2062 return obj.getValidators()
2063 except:
2064 return None
2065 class Meta:
2066 model = ControllerUsers
2067 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2068
2069
2070
2071
2072class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
2073 id = serializers.Field()
2074
2075 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2076 validators = serializers.SerializerMethodField("getValidators")
2077 def getHumanReadableName(self, obj):
2078 return str(obj)
2079 def getValidators(self, obj):
2080 try:
2081 return obj.getValidators()
2082 except:
2083 return None
2084 class Meta:
2085 model = DeploymentRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08002086 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002087
Scott Baker515dc9e2014-12-22 09:29:05 -08002088class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002089 id = serializers.Field()
2090
Scott Bakerb744f1c2014-11-21 11:32:24 -08002091 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002092 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002093 def getHumanReadableName(self, obj):
2094 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002095 def getValidators(self, obj):
2096 try:
2097 return obj.getValidators()
2098 except:
2099 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002100 class Meta:
2101 model = DeploymentRole
Scott Baker96eb3fd2014-11-25 00:53:25 -08002102 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002103
2104
Sapan Bhatiadea39432014-06-13 03:10:36 -04002105
2106
Scott Baker89a7b7c2014-10-07 00:10:17 -07002107class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002108 id = serializers.Field()
2109
Scott Bakerb744f1c2014-11-21 11:32:24 -08002110 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002111 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002112 def getHumanReadableName(self, obj):
2113 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002114 def getValidators(self, obj):
2115 try:
2116 return obj.getValidators()
2117 except:
2118 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002119 class Meta:
2120 model = UserCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08002121 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002122
Scott Baker515dc9e2014-12-22 09:29:05 -08002123class UserCredentialIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002124 id = serializers.Field()
2125
Scott Bakerb744f1c2014-11-21 11:32:24 -08002126 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002127 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002128 def getHumanReadableName(self, obj):
2129 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002130 def getValidators(self, obj):
2131 try:
2132 return obj.getValidators()
2133 except:
2134 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002135 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002136 model = UserCredential
Scott Baker96eb3fd2014-11-25 00:53:25 -08002137 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08002138
2139
2140
2141
2142class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
2143 id = serializers.Field()
2144
2145 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002146 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002147 def getHumanReadableName(self, obj):
2148 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002149 def getValidators(self, obj):
2150 try:
2151 return obj.getValidators()
2152 except:
2153 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08002154 class Meta:
2155 model = SiteDeployments
Scott Baker515dc9e2014-12-22 09:29:05 -08002156 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08002157
Scott Baker515dc9e2014-12-22 09:29:05 -08002158class SiteDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerb744f1c2014-11-21 11:32:24 -08002159 id = serializers.Field()
2160
2161 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002162 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002163 def getHumanReadableName(self, obj):
2164 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002165 def getValidators(self, obj):
2166 try:
2167 return obj.getValidators()
2168 except:
2169 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002170 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08002171 model = SiteDeployments
Scott Baker515dc9e2014-12-22 09:29:05 -08002172 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
2173
2174
Scott Baker89a7b7c2014-10-07 00:10:17 -07002175
2176
Scott Baker0caeaf02014-06-19 11:12:55 -07002177class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002178 id = serializers.Field()
2179
Scott Bakerb744f1c2014-11-21 11:32:24 -08002180 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002181 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002182 def getHumanReadableName(self, obj):
2183 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002184 def getValidators(self, obj):
2185 try:
2186 return obj.getValidators()
2187 except:
2188 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002189 class Meta:
2190 model = SliceTag
Scott Baker96eb3fd2014-11-25 00:53:25 -08002191 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002192
Scott Baker515dc9e2014-12-22 09:29:05 -08002193class SliceTagIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002194 id = serializers.Field()
2195
Scott Bakerb744f1c2014-11-21 11:32:24 -08002196 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002197 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002198 def getHumanReadableName(self, obj):
2199 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002200 def getValidators(self, obj):
2201 try:
2202 return obj.getValidators()
2203 except:
2204 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002205 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002206 model = SliceTag
Scott Baker96eb3fd2014-11-25 00:53:25 -08002207 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002208
2209
Scott Baker0caeaf02014-06-19 11:12:55 -07002210
2211
Scott Baker515dc9e2014-12-22 09:29:05 -08002212class ControllerDashboardSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002213 id = serializers.Field()
2214
Scott Bakerb744f1c2014-11-21 11:32:24 -08002215 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002216 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002217 def getHumanReadableName(self, obj):
2218 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002219 def getValidators(self, obj):
2220 try:
2221 return obj.getValidators()
2222 except:
2223 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002224 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08002225 model = ControllerDashboard
2226 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
Scott Baker46b58542014-08-11 17:26:12 -07002227
Scott Baker515dc9e2014-12-22 09:29:05 -08002228class ControllerDashboardIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002229 id = serializers.Field()
2230
Scott Bakerb744f1c2014-11-21 11:32:24 -08002231 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002232 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002233 def getHumanReadableName(self, obj):
2234 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002235 def getValidators(self, obj):
2236 try:
2237 return obj.getValidators()
2238 except:
2239 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002240 class Meta:
2241 model = ControllerDashboard
2242 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
Scott Baker46b58542014-08-11 17:26:12 -07002243
2244
Sapan Bhatiadea39432014-06-13 03:10:36 -04002245
2246
2247class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002248 id = serializers.Field()
2249
Scott Baker515dc9e2014-12-22 09:29:05 -08002250
2251 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2252
2253
2254
2255 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2256
2257
Scott Bakerb744f1c2014-11-21 11:32:24 -08002258 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002259 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002260 def getHumanReadableName(self, obj):
2261 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002262 def getValidators(self, obj):
2263 try:
2264 return obj.getValidators()
2265 except:
2266 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002267 class Meta:
2268 model = Router
Scott Baker515dc9e2014-12-22 09:29:05 -08002269 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002270
Scott Baker515dc9e2014-12-22 09:29:05 -08002271class RouterIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002272 id = serializers.Field()
2273
Scott Baker515dc9e2014-12-22 09:29:05 -08002274
2275 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
2276
2277
2278
2279 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
2280
2281
Scott Bakerb744f1c2014-11-21 11:32:24 -08002282 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002283 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002284 def getHumanReadableName(self, obj):
2285 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002286 def getValidators(self, obj):
2287 try:
2288 return obj.getValidators()
2289 except:
2290 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002291 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002292 model = Router
Scott Baker515dc9e2014-12-22 09:29:05 -08002293 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002294
2295
Sapan Bhatiadea39432014-06-13 03:10:36 -04002296
2297
Scott Baker0caeaf02014-06-19 11:12:55 -07002298class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002299 id = serializers.Field()
2300
Scott Bakerb744f1c2014-11-21 11:32:24 -08002301 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002302 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002303 def getHumanReadableName(self, obj):
2304 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002305 def getValidators(self, obj):
2306 try:
2307 return obj.getValidators()
2308 except:
2309 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002310 class Meta:
2311 model = ServiceResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08002312 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 -07002313
Scott Baker515dc9e2014-12-22 09:29:05 -08002314class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Baker2bcbf372014-10-29 23:41:11 -07002315 id = serializers.Field()
2316
Scott Bakerb744f1c2014-11-21 11:32:24 -08002317 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002318 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002319 def getHumanReadableName(self, obj):
2320 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002321 def getValidators(self, obj):
2322 try:
2323 return obj.getValidators()
2324 except:
2325 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002326 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002327 model = ServiceResource
Scott Baker96eb3fd2014-11-25 00:53:25 -08002328 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 -07002329
2330
Sapan Bhatiadea39432014-06-13 03:10:36 -04002331
2332
Scott Baker515dc9e2014-12-22 09:29:05 -08002333class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer):
2334 id = serializers.Field()
2335
2336 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2337 validators = serializers.SerializerMethodField("getValidators")
2338 def getHumanReadableName(self, obj):
2339 return str(obj)
2340 def getValidators(self, obj):
2341 try:
2342 return obj.getValidators()
2343 except:
2344 return None
2345 class Meta:
2346 model = ControllerSlices
2347 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2348
2349class ControllerSlicesIdSerializer(XOSModelSerializer):
2350 id = serializers.Field()
2351
2352 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2353 validators = serializers.SerializerMethodField("getValidators")
2354 def getHumanReadableName(self, obj):
2355 return str(obj)
2356 def getValidators(self, obj):
2357 try:
2358 return obj.getValidators()
2359 except:
2360 return None
2361 class Meta:
2362 model = ControllerSlices
2363 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2364
2365
2366
2367
Sapan Bhatiadea39432014-06-13 03:10:36 -04002368serializerLookUp = {
2369
Scott Baker515dc9e2014-12-22 09:29:05 -08002370 Flavor: FlavorSerializer,
2371
Scott Baker0caeaf02014-06-19 11:12:55 -07002372 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002373
Scott Baker515dc9e2014-12-22 09:29:05 -08002374 ControllerImages: ControllerImagesSerializer,
2375
Sapan Bhatiadea39432014-06-13 03:10:36 -04002376 Image: ImageSerializer,
2377
Scott Baker0caeaf02014-06-19 11:12:55 -07002378 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002379
2380 Site: SiteSerializer,
2381
Scott Baker0caeaf02014-06-19 11:12:55 -07002382 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002383
2384 Tag: TagSerializer,
2385
2386 Invoice: InvoiceSerializer,
2387
Scott Baker0caeaf02014-06-19 11:12:55 -07002388 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002389
Scott Baker89a7b7c2014-10-07 00:10:17 -07002390 PlanetStackRole: PlanetStackRoleSerializer,
2391
Scott Baker515dc9e2014-12-22 09:29:05 -08002392 ControllerPrivilege: ControllerPrivilegeSerializer,
2393
Scott Baker0caeaf02014-06-19 11:12:55 -07002394 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002395
Scott Baker89a7b7c2014-10-07 00:10:17 -07002396 Project: ProjectSerializer,
2397
Sapan Bhatiadea39432014-06-13 03:10:36 -04002398 Slice: SliceSerializer,
2399
2400 Network: NetworkSerializer,
2401
2402 Service: ServiceSerializer,
2403
Scott Baker0caeaf02014-06-19 11:12:55 -07002404 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002405
Scott Baker515dc9e2014-12-22 09:29:05 -08002406 ControllerNetworks: ControllerNetworksSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002407
2408 Charge: ChargeSerializer,
2409
2410 Role: RoleSerializer,
2411
Scott Baker0caeaf02014-06-19 11:12:55 -07002412 UsableObject: UsableObjectSerializer,
2413
Scott Baker515dc9e2014-12-22 09:29:05 -08002414 ControllerSiteDeployments: ControllerSiteDeploymentsSerializer,
2415
Scott Baker0caeaf02014-06-19 11:12:55 -07002416 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002417
Scott Baker89a7b7c2014-10-07 00:10:17 -07002418 SliceCredential: SliceCredentialSerializer,
2419
Sapan Bhatiadea39432014-06-13 03:10:36 -04002420 Sliver: SliverSerializer,
2421
2422 Node: NodeSerializer,
2423
Scott Baker0caeaf02014-06-19 11:12:55 -07002424 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002425
Scott Baker515dc9e2014-12-22 09:29:05 -08002426 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002427
Scott Bakerb744f1c2014-11-21 11:32:24 -08002428 ReservedResource: ReservedResourceSerializer,
Scott Baker8b533192014-11-17 22:32:19 -08002429
Scott Baker515dc9e2014-12-22 09:29:05 -08002430 Payment: PaymentSerializer,
2431
2432 NetworkTemplate: NetworkTemplateSerializer,
2433
Scott Baker0caeaf02014-06-19 11:12:55 -07002434 NetworkSlice: NetworkSliceSerializer,
2435
2436 UserDashboardView: UserDashboardViewSerializer,
2437
Scott Baker515dc9e2014-12-22 09:29:05 -08002438 Controller: ControllerSerializer,
2439
Scott Baker0caeaf02014-06-19 11:12:55 -07002440 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002441
2442 User: UserSerializer,
2443
2444 Deployment: DeploymentSerializer,
2445
2446 Reservation: ReservationSerializer,
2447
Scott Baker0caeaf02014-06-19 11:12:55 -07002448 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002449
Scott Bakerb744f1c2014-11-21 11:32:24 -08002450 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002451
Sapan Bhatiadea39432014-06-13 03:10:36 -04002452 Account: AccountSerializer,
2453
Scott Baker515dc9e2014-12-22 09:29:05 -08002454 ControllerRole: ControllerRoleSerializer,
2455
Scott Baker0caeaf02014-06-19 11:12:55 -07002456 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002457
Scott Baker89a7b7c2014-10-07 00:10:17 -07002458 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002459
Scott Baker515dc9e2014-12-22 09:29:05 -08002460 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002461
Scott Baker515dc9e2014-12-22 09:29:05 -08002462 ControllerUsers: ControllerUsersSerializer,
2463
2464 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002465
Scott Baker89a7b7c2014-10-07 00:10:17 -07002466 UserCredential: UserCredentialSerializer,
2467
Scott Bakerb744f1c2014-11-21 11:32:24 -08002468 SiteDeployments: SiteDeploymentsSerializer,
2469
Scott Baker0caeaf02014-06-19 11:12:55 -07002470 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002471
Scott Baker515dc9e2014-12-22 09:29:05 -08002472 ControllerDashboard: ControllerDashboardSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002473
2474 Router: RouterSerializer,
2475
Scott Baker0caeaf02014-06-19 11:12:55 -07002476 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002477
Scott Baker515dc9e2014-12-22 09:29:05 -08002478 ControllerSlices: ControllerSlicesSerializer,
2479
Sapan Bhatiadea39432014-06-13 03:10:36 -04002480 None: None,
2481 }
2482
Scott Baker89a7b7c2014-10-07 00:10:17 -07002483class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2484
2485 # To handle fine-grained field permissions, we have to check can_update
2486 # the object has been updated but before it has been saved.
2487
2488 def update(self, request, *args, **kwargs):
2489 partial = kwargs.pop('partial', False)
2490 self.object = self.get_object_or_none()
2491
2492 serializer = self.get_serializer(self.object, data=request.DATA,
2493 files=request.FILES, partial=partial)
2494
2495 if not serializer.is_valid():
Scott Baker96eb3fd2014-11-25 00:53:25 -08002496 response = {"error": "validation",
2497 "specific_error": "not serializer.is_valid()",
2498 "reasons": serializer.errors}
2499 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002500
2501 try:
2502 self.pre_save(serializer.object)
2503 except ValidationError as err:
2504 # full_clean on model instance may be called in pre_save,
2505 # so we have to handle eventual errors.
Scott Baker96eb3fd2014-11-25 00:53:25 -08002506 response = {"error": "validation",
2507 "specific_error": "ValidationError in pre_save",
2508 "reasons": err.message_dict}
2509 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002510
2511 if serializer.object is not None:
2512 if not serializer.object.can_update(request.user):
2513 return Response(status=status.HTTP_400_BAD_REQUEST)
2514
2515 if self.object is None:
2516 self.object = serializer.save(force_insert=True)
2517 self.post_save(self.object, created=True)
2518 return Response(serializer.data, status=status.HTTP_201_CREATED)
2519
2520 self.object = serializer.save(force_update=True)
2521 self.post_save(self.object, created=False)
2522 return Response(serializer.data, status=status.HTTP_200_OK)
2523
2524 def destroy(self, request, *args, **kwargs):
2525 obj = self.get_object()
2526 if obj.can_update(request.user):
Scott Baker2bcbf372014-10-29 23:41:11 -07002527 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002528 else:
2529 return Response(status=status.HTTP_400_BAD_REQUEST)
2530
2531
Sapan Bhatiadea39432014-06-13 03:10:36 -04002532# Based on core/views/*.py
2533
2534
Scott Baker515dc9e2014-12-22 09:29:05 -08002535class FlavorList(generics.ListCreateAPIView):
2536 queryset = Flavor.objects.select_related().all()
2537 serializer_class = FlavorSerializer
2538 id_serializer_class = FlavorIdSerializer
2539 filter_backends = (filters.DjangoFilterBackend,)
2540 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
2541
2542 def get_serializer_class(self):
2543 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2544 if (no_hyperlinks):
2545 return self.id_serializer_class
2546 else:
2547 return self.serializer_class
2548
2549 def get_queryset(self):
2550 return Flavor.select_by_user(self.request.user)
2551
2552 def create(self, request, *args, **kwargs):
2553 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2554 if not (serializer.is_valid()):
2555 response = {"error": "validation",
2556 "specific_error": "not serializer.is_valid()",
2557 "reasons": serializer.errors}
2558 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2559 obj = serializer.object
2560 obj.caller = request.user
2561 if obj.can_update(request.user):
2562 return super(FlavorList, self).create(request, *args, **kwargs)
2563 else:
2564 raise Exception("failed obj.can_update")
2565
2566 ret = super(FlavorList, self).create(request, *args, **kwargs)
2567 if (ret.status_code%100 != 200):
2568 raise Exception(ret.data)
2569
2570 return ret
2571
2572
2573class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2574 queryset = Flavor.objects.select_related().all()
2575 serializer_class = FlavorSerializer
2576 id_serializer_class = FlavorIdSerializer
2577
2578 def get_serializer_class(self):
2579 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2580 if (no_hyperlinks):
2581 return self.id_serializer_class
2582 else:
2583 return self.serializer_class
2584
2585 def get_queryset(self):
2586 return Flavor.select_by_user(self.request.user)
2587
2588 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2589
2590 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2591
2592
2593
Scott Baker0caeaf02014-06-19 11:12:55 -07002594class ServiceAttributeList(generics.ListCreateAPIView):
2595 queryset = ServiceAttribute.objects.select_related().all()
2596 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002597 id_serializer_class = ServiceAttributeIdSerializer
2598 filter_backends = (filters.DjangoFilterBackend,)
2599 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2600
2601 def get_serializer_class(self):
2602 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2603 if (no_hyperlinks):
2604 return self.id_serializer_class
2605 else:
2606 return self.serializer_class
2607
Scott Baker0caeaf02014-06-19 11:12:55 -07002608 def get_queryset(self):
2609 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002610
Scott Baker0caeaf02014-06-19 11:12:55 -07002611 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002612 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2613 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002614 response = {"error": "validation",
2615 "specific_error": "not serializer.is_valid()",
2616 "reasons": serializer.errors}
2617 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002618 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002619 obj.caller = request.user
2620 if obj.can_update(request.user):
2621 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2622 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002623 raise Exception("failed obj.can_update")
2624
2625 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2626 if (ret.status_code%100 != 200):
2627 raise Exception(ret.data)
2628
2629 return ret
2630
Scott Baker0caeaf02014-06-19 11:12:55 -07002631
Scott Baker89a7b7c2014-10-07 00:10:17 -07002632class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002633 queryset = ServiceAttribute.objects.select_related().all()
2634 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002635 id_serializer_class = ServiceAttributeIdSerializer
2636
2637 def get_serializer_class(self):
2638 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2639 if (no_hyperlinks):
2640 return self.id_serializer_class
2641 else:
2642 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002643
2644 def get_queryset(self):
2645 return ServiceAttribute.select_by_user(self.request.user)
2646
Scott Baker89a7b7c2014-10-07 00:10:17 -07002647 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002648
Scott Baker89a7b7c2014-10-07 00:10:17 -07002649 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002650
2651
2652
Scott Baker515dc9e2014-12-22 09:29:05 -08002653class ControllerImagesList(generics.ListCreateAPIView):
2654 queryset = ControllerImages.objects.select_related().all()
2655 serializer_class = ControllerImagesSerializer
2656 id_serializer_class = ControllerImagesIdSerializer
2657 filter_backends = (filters.DjangoFilterBackend,)
2658 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
2659
2660 def get_serializer_class(self):
2661 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2662 if (no_hyperlinks):
2663 return self.id_serializer_class
2664 else:
2665 return self.serializer_class
2666
2667 def get_queryset(self):
2668 return ControllerImages.select_by_user(self.request.user)
2669
2670 def create(self, request, *args, **kwargs):
2671 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2672 if not (serializer.is_valid()):
2673 response = {"error": "validation",
2674 "specific_error": "not serializer.is_valid()",
2675 "reasons": serializer.errors}
2676 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2677 obj = serializer.object
2678 obj.caller = request.user
2679 if obj.can_update(request.user):
2680 return super(ControllerImagesList, self).create(request, *args, **kwargs)
2681 else:
2682 raise Exception("failed obj.can_update")
2683
2684 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2685 if (ret.status_code%100 != 200):
2686 raise Exception(ret.data)
2687
2688 return ret
2689
2690
2691class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2692 queryset = ControllerImages.objects.select_related().all()
2693 serializer_class = ControllerImagesSerializer
2694 id_serializer_class = ControllerImagesIdSerializer
2695
2696 def get_serializer_class(self):
2697 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2698 if (no_hyperlinks):
2699 return self.id_serializer_class
2700 else:
2701 return self.serializer_class
2702
2703 def get_queryset(self):
2704 return ControllerImages.select_by_user(self.request.user)
2705
2706 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2707
2708 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2709
2710
2711
Sapan Bhatiadea39432014-06-13 03:10:36 -04002712class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002713 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002714 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002715 id_serializer_class = ImageIdSerializer
2716 filter_backends = (filters.DjangoFilterBackend,)
2717 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
2718
2719 def get_serializer_class(self):
2720 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2721 if (no_hyperlinks):
2722 return self.id_serializer_class
2723 else:
2724 return self.serializer_class
2725
Scott Baker0caeaf02014-06-19 11:12:55 -07002726 def get_queryset(self):
2727 return Image.select_by_user(self.request.user)
2728
2729 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002730 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2731 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002732 response = {"error": "validation",
2733 "specific_error": "not serializer.is_valid()",
2734 "reasons": serializer.errors}
2735 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002736 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002737 obj.caller = request.user
2738 if obj.can_update(request.user):
2739 return super(ImageList, self).create(request, *args, **kwargs)
2740 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002741 raise Exception("failed obj.can_update")
2742
2743 ret = super(ImageList, self).create(request, *args, **kwargs)
2744 if (ret.status_code%100 != 200):
2745 raise Exception(ret.data)
2746
2747 return ret
2748
Sapan Bhatiadea39432014-06-13 03:10:36 -04002749
Scott Baker89a7b7c2014-10-07 00:10:17 -07002750class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002751 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002752 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002753 id_serializer_class = ImageIdSerializer
2754
2755 def get_serializer_class(self):
2756 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2757 if (no_hyperlinks):
2758 return self.id_serializer_class
2759 else:
2760 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002761
2762 def get_queryset(self):
2763 return Image.select_by_user(self.request.user)
2764
Scott Baker89a7b7c2014-10-07 00:10:17 -07002765 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002766
Scott Baker89a7b7c2014-10-07 00:10:17 -07002767 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002768
2769
2770
Scott Baker0caeaf02014-06-19 11:12:55 -07002771class NetworkParameterList(generics.ListCreateAPIView):
2772 queryset = NetworkParameter.objects.select_related().all()
2773 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002774 id_serializer_class = NetworkParameterIdSerializer
2775 filter_backends = (filters.DjangoFilterBackend,)
2776 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2777
2778 def get_serializer_class(self):
2779 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2780 if (no_hyperlinks):
2781 return self.id_serializer_class
2782 else:
2783 return self.serializer_class
2784
Scott Baker0caeaf02014-06-19 11:12:55 -07002785 def get_queryset(self):
2786 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002787
Scott Baker0caeaf02014-06-19 11:12:55 -07002788 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002789 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2790 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002791 response = {"error": "validation",
2792 "specific_error": "not serializer.is_valid()",
2793 "reasons": serializer.errors}
2794 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002795 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002796 obj.caller = request.user
2797 if obj.can_update(request.user):
2798 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2799 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002800 raise Exception("failed obj.can_update")
2801
2802 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2803 if (ret.status_code%100 != 200):
2804 raise Exception(ret.data)
2805
2806 return ret
2807
Scott Baker0caeaf02014-06-19 11:12:55 -07002808
Scott Baker89a7b7c2014-10-07 00:10:17 -07002809class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002810 queryset = NetworkParameter.objects.select_related().all()
2811 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002812 id_serializer_class = NetworkParameterIdSerializer
2813
2814 def get_serializer_class(self):
2815 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2816 if (no_hyperlinks):
2817 return self.id_serializer_class
2818 else:
2819 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002820
2821 def get_queryset(self):
2822 return NetworkParameter.select_by_user(self.request.user)
2823
Scott Baker89a7b7c2014-10-07 00:10:17 -07002824 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002825
Scott Baker89a7b7c2014-10-07 00:10:17 -07002826 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002827
2828
2829
2830class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002831 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002832 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002833 id_serializer_class = SiteIdSerializer
2834 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08002835 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 -07002836
2837 def get_serializer_class(self):
2838 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2839 if (no_hyperlinks):
2840 return self.id_serializer_class
2841 else:
2842 return self.serializer_class
2843
Scott Baker0caeaf02014-06-19 11:12:55 -07002844 def get_queryset(self):
2845 return Site.select_by_user(self.request.user)
2846
2847 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002848 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2849 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002850 response = {"error": "validation",
2851 "specific_error": "not serializer.is_valid()",
2852 "reasons": serializer.errors}
2853 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002854 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002855 obj.caller = request.user
2856 if obj.can_update(request.user):
2857 return super(SiteList, self).create(request, *args, **kwargs)
2858 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002859 raise Exception("failed obj.can_update")
2860
2861 ret = super(SiteList, self).create(request, *args, **kwargs)
2862 if (ret.status_code%100 != 200):
2863 raise Exception(ret.data)
2864
2865 return ret
2866
Sapan Bhatiadea39432014-06-13 03:10:36 -04002867
Scott Baker89a7b7c2014-10-07 00:10:17 -07002868class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002869 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002870 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002871 id_serializer_class = SiteIdSerializer
2872
2873 def get_serializer_class(self):
2874 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2875 if (no_hyperlinks):
2876 return self.id_serializer_class
2877 else:
2878 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002879
2880 def get_queryset(self):
2881 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002882
Scott Baker89a7b7c2014-10-07 00:10:17 -07002883 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002884
Scott Baker89a7b7c2014-10-07 00:10:17 -07002885 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002886
2887
2888
2889class SliceRoleList(generics.ListCreateAPIView):
2890 queryset = SliceRole.objects.select_related().all()
2891 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002892 id_serializer_class = SliceRoleIdSerializer
2893 filter_backends = (filters.DjangoFilterBackend,)
2894 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2895
2896 def get_serializer_class(self):
2897 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2898 if (no_hyperlinks):
2899 return self.id_serializer_class
2900 else:
2901 return self.serializer_class
2902
Scott Baker0caeaf02014-06-19 11:12:55 -07002903 def get_queryset(self):
2904 return SliceRole.select_by_user(self.request.user)
2905
2906 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002907 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2908 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002909 response = {"error": "validation",
2910 "specific_error": "not serializer.is_valid()",
2911 "reasons": serializer.errors}
2912 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002913 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002914 obj.caller = request.user
2915 if obj.can_update(request.user):
2916 return super(SliceRoleList, self).create(request, *args, **kwargs)
2917 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002918 raise Exception("failed obj.can_update")
2919
2920 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2921 if (ret.status_code%100 != 200):
2922 raise Exception(ret.data)
2923
2924 return ret
2925
Scott Baker0caeaf02014-06-19 11:12:55 -07002926
Scott Baker89a7b7c2014-10-07 00:10:17 -07002927class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002928 queryset = SliceRole.objects.select_related().all()
2929 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002930 id_serializer_class = SliceRoleIdSerializer
2931
2932 def get_serializer_class(self):
2933 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2934 if (no_hyperlinks):
2935 return self.id_serializer_class
2936 else:
2937 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002938
2939 def get_queryset(self):
2940 return SliceRole.select_by_user(self.request.user)
2941
Scott Baker89a7b7c2014-10-07 00:10:17 -07002942 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002943
Scott Baker89a7b7c2014-10-07 00:10:17 -07002944 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002945
2946
2947
2948class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002949 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002950 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002951 id_serializer_class = TagIdSerializer
2952 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002953 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002954
2955 def get_serializer_class(self):
2956 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2957 if (no_hyperlinks):
2958 return self.id_serializer_class
2959 else:
2960 return self.serializer_class
2961
Scott Baker0caeaf02014-06-19 11:12:55 -07002962 def get_queryset(self):
2963 return Tag.select_by_user(self.request.user)
2964
2965 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002966 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2967 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002968 response = {"error": "validation",
2969 "specific_error": "not serializer.is_valid()",
2970 "reasons": serializer.errors}
2971 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002972 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002973 obj.caller = request.user
2974 if obj.can_update(request.user):
2975 return super(TagList, self).create(request, *args, **kwargs)
2976 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002977 raise Exception("failed obj.can_update")
2978
2979 ret = super(TagList, self).create(request, *args, **kwargs)
2980 if (ret.status_code%100 != 200):
2981 raise Exception(ret.data)
2982
2983 return ret
2984
Sapan Bhatiadea39432014-06-13 03:10:36 -04002985
Scott Baker89a7b7c2014-10-07 00:10:17 -07002986class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002987 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002988 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002989 id_serializer_class = TagIdSerializer
2990
2991 def get_serializer_class(self):
2992 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2993 if (no_hyperlinks):
2994 return self.id_serializer_class
2995 else:
2996 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002997
2998 def get_queryset(self):
2999 return Tag.select_by_user(self.request.user)
3000
Scott Baker89a7b7c2014-10-07 00:10:17 -07003001 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003002
Scott Baker89a7b7c2014-10-07 00:10:17 -07003003 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003004
3005
3006
3007class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003008 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003009 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003010 id_serializer_class = InvoiceIdSerializer
3011 filter_backends = (filters.DjangoFilterBackend,)
3012 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
3013
3014 def get_serializer_class(self):
3015 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3016 if (no_hyperlinks):
3017 return self.id_serializer_class
3018 else:
3019 return self.serializer_class
3020
Scott Baker0caeaf02014-06-19 11:12:55 -07003021 def get_queryset(self):
3022 return Invoice.select_by_user(self.request.user)
3023
3024 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003025 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3026 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003027 response = {"error": "validation",
3028 "specific_error": "not serializer.is_valid()",
3029 "reasons": serializer.errors}
3030 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003031 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003032 obj.caller = request.user
3033 if obj.can_update(request.user):
3034 return super(InvoiceList, self).create(request, *args, **kwargs)
3035 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003036 raise Exception("failed obj.can_update")
3037
3038 ret = super(InvoiceList, self).create(request, *args, **kwargs)
3039 if (ret.status_code%100 != 200):
3040 raise Exception(ret.data)
3041
3042 return ret
3043
Sapan Bhatiadea39432014-06-13 03:10:36 -04003044
Scott Baker89a7b7c2014-10-07 00:10:17 -07003045class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003046 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003047 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003048 id_serializer_class = InvoiceIdSerializer
3049
3050 def get_serializer_class(self):
3051 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3052 if (no_hyperlinks):
3053 return self.id_serializer_class
3054 else:
3055 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003056
3057 def get_queryset(self):
3058 return Invoice.select_by_user(self.request.user)
3059
Scott Baker89a7b7c2014-10-07 00:10:17 -07003060 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003061
Scott Baker89a7b7c2014-10-07 00:10:17 -07003062 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003063
3064
3065
Scott Baker0caeaf02014-06-19 11:12:55 -07003066class SlicePrivilegeList(generics.ListCreateAPIView):
3067 queryset = SlicePrivilege.objects.select_related().all()
3068 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003069 id_serializer_class = SlicePrivilegeIdSerializer
3070 filter_backends = (filters.DjangoFilterBackend,)
3071 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
3072
3073 def get_serializer_class(self):
3074 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3075 if (no_hyperlinks):
3076 return self.id_serializer_class
3077 else:
3078 return self.serializer_class
3079
Scott Baker0caeaf02014-06-19 11:12:55 -07003080 def get_queryset(self):
3081 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003082
Scott Baker0caeaf02014-06-19 11:12:55 -07003083 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003084 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3085 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003086 response = {"error": "validation",
3087 "specific_error": "not serializer.is_valid()",
3088 "reasons": serializer.errors}
3089 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003090 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003091 obj.caller = request.user
3092 if obj.can_update(request.user):
3093 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3094 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003095 raise Exception("failed obj.can_update")
3096
3097 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3098 if (ret.status_code%100 != 200):
3099 raise Exception(ret.data)
3100
3101 return ret
3102
Scott Baker0caeaf02014-06-19 11:12:55 -07003103
Scott Baker89a7b7c2014-10-07 00:10:17 -07003104class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003105 queryset = SlicePrivilege.objects.select_related().all()
3106 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003107 id_serializer_class = SlicePrivilegeIdSerializer
3108
3109 def get_serializer_class(self):
3110 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3111 if (no_hyperlinks):
3112 return self.id_serializer_class
3113 else:
3114 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003115
3116 def get_queryset(self):
3117 return SlicePrivilege.select_by_user(self.request.user)
3118
Scott Baker89a7b7c2014-10-07 00:10:17 -07003119 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3120
3121 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3122
3123
3124
3125class PlanetStackRoleList(generics.ListCreateAPIView):
3126 queryset = PlanetStackRole.objects.select_related().all()
3127 serializer_class = PlanetStackRoleSerializer
3128 id_serializer_class = PlanetStackRoleIdSerializer
3129 filter_backends = (filters.DjangoFilterBackend,)
3130 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3131
3132 def get_serializer_class(self):
3133 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3134 if (no_hyperlinks):
3135 return self.id_serializer_class
3136 else:
3137 return self.serializer_class
3138
3139 def get_queryset(self):
3140 return PlanetStackRole.select_by_user(self.request.user)
3141
3142 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003143 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3144 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003145 response = {"error": "validation",
3146 "specific_error": "not serializer.is_valid()",
3147 "reasons": serializer.errors}
3148 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003149 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003150 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003151 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003152 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003153 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003154 raise Exception("failed obj.can_update")
3155
3156 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3157 if (ret.status_code%100 != 200):
3158 raise Exception(ret.data)
3159
3160 return ret
3161
Scott Baker0caeaf02014-06-19 11:12:55 -07003162
Scott Baker89a7b7c2014-10-07 00:10:17 -07003163class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3164 queryset = PlanetStackRole.objects.select_related().all()
3165 serializer_class = PlanetStackRoleSerializer
3166 id_serializer_class = PlanetStackRoleIdSerializer
3167
3168 def get_serializer_class(self):
3169 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3170 if (no_hyperlinks):
3171 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003172 else:
Scott Baker89a7b7c2014-10-07 00:10:17 -07003173 return self.serializer_class
3174
3175 def get_queryset(self):
3176 return PlanetStackRole.select_by_user(self.request.user)
3177
3178 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3179
3180 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003181
3182
3183
Scott Baker515dc9e2014-12-22 09:29:05 -08003184class ControllerPrivilegeList(generics.ListCreateAPIView):
3185 queryset = ControllerPrivilege.objects.select_related().all()
3186 serializer_class = ControllerPrivilegeSerializer
3187 id_serializer_class = ControllerPrivilegeIdSerializer
3188 filter_backends = (filters.DjangoFilterBackend,)
3189 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','role',)
3190
3191 def get_serializer_class(self):
3192 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3193 if (no_hyperlinks):
3194 return self.id_serializer_class
3195 else:
3196 return self.serializer_class
3197
3198 def get_queryset(self):
3199 return ControllerPrivilege.select_by_user(self.request.user)
3200
3201 def create(self, request, *args, **kwargs):
3202 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3203 if not (serializer.is_valid()):
3204 response = {"error": "validation",
3205 "specific_error": "not serializer.is_valid()",
3206 "reasons": serializer.errors}
3207 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3208 obj = serializer.object
3209 obj.caller = request.user
3210 if obj.can_update(request.user):
3211 return super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
3212 else:
3213 raise Exception("failed obj.can_update")
3214
3215 ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
3216 if (ret.status_code%100 != 200):
3217 raise Exception(ret.data)
3218
3219 return ret
3220
3221
3222class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3223 queryset = ControllerPrivilege.objects.select_related().all()
3224 serializer_class = ControllerPrivilegeSerializer
3225 id_serializer_class = ControllerPrivilegeIdSerializer
3226
3227 def get_serializer_class(self):
3228 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3229 if (no_hyperlinks):
3230 return self.id_serializer_class
3231 else:
3232 return self.serializer_class
3233
3234 def get_queryset(self):
3235 return ControllerPrivilege.select_by_user(self.request.user)
3236
3237 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3238
3239 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3240
3241
3242
Scott Baker0caeaf02014-06-19 11:12:55 -07003243class NetworkSliverList(generics.ListCreateAPIView):
3244 queryset = NetworkSliver.objects.select_related().all()
3245 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003246 id_serializer_class = NetworkSliverIdSerializer
3247 filter_backends = (filters.DjangoFilterBackend,)
3248 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
3249
3250 def get_serializer_class(self):
3251 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3252 if (no_hyperlinks):
3253 return self.id_serializer_class
3254 else:
3255 return self.serializer_class
3256
Scott Baker0caeaf02014-06-19 11:12:55 -07003257 def get_queryset(self):
3258 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003259
Scott Baker0caeaf02014-06-19 11:12:55 -07003260 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003261 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3262 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003263 response = {"error": "validation",
3264 "specific_error": "not serializer.is_valid()",
3265 "reasons": serializer.errors}
3266 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003267 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003268 obj.caller = request.user
3269 if obj.can_update(request.user):
3270 return super(NetworkSliverList, self).create(request, *args, **kwargs)
3271 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003272 raise Exception("failed obj.can_update")
3273
3274 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3275 if (ret.status_code%100 != 200):
3276 raise Exception(ret.data)
3277
3278 return ret
3279
Scott Baker0caeaf02014-06-19 11:12:55 -07003280
Scott Baker89a7b7c2014-10-07 00:10:17 -07003281class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003282 queryset = NetworkSliver.objects.select_related().all()
3283 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003284 id_serializer_class = NetworkSliverIdSerializer
3285
3286 def get_serializer_class(self):
3287 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3288 if (no_hyperlinks):
3289 return self.id_serializer_class
3290 else:
3291 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003292
3293 def get_queryset(self):
3294 return NetworkSliver.select_by_user(self.request.user)
3295
Scott Baker89a7b7c2014-10-07 00:10:17 -07003296 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003297
Scott Baker89a7b7c2014-10-07 00:10:17 -07003298 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003299
3300
3301
Scott Baker0caeaf02014-06-19 11:12:55 -07003302class ProjectList(generics.ListCreateAPIView):
3303 queryset = Project.objects.select_related().all()
3304 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003305 id_serializer_class = ProjectIdSerializer
3306 filter_backends = (filters.DjangoFilterBackend,)
3307 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3308
3309 def get_serializer_class(self):
3310 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3311 if (no_hyperlinks):
3312 return self.id_serializer_class
3313 else:
3314 return self.serializer_class
3315
Scott Baker0caeaf02014-06-19 11:12:55 -07003316 def get_queryset(self):
3317 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003318
Scott Baker0caeaf02014-06-19 11:12:55 -07003319 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003320 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3321 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003322 response = {"error": "validation",
3323 "specific_error": "not serializer.is_valid()",
3324 "reasons": serializer.errors}
3325 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003326 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003327 obj.caller = request.user
3328 if obj.can_update(request.user):
3329 return super(ProjectList, self).create(request, *args, **kwargs)
3330 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003331 raise Exception("failed obj.can_update")
3332
3333 ret = super(ProjectList, self).create(request, *args, **kwargs)
3334 if (ret.status_code%100 != 200):
3335 raise Exception(ret.data)
3336
3337 return ret
3338
Scott Baker0caeaf02014-06-19 11:12:55 -07003339
Scott Baker89a7b7c2014-10-07 00:10:17 -07003340class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003341 queryset = Project.objects.select_related().all()
3342 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003343 id_serializer_class = ProjectIdSerializer
3344
3345 def get_serializer_class(self):
3346 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3347 if (no_hyperlinks):
3348 return self.id_serializer_class
3349 else:
3350 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003351
3352 def get_queryset(self):
3353 return Project.select_by_user(self.request.user)
3354
Scott Baker89a7b7c2014-10-07 00:10:17 -07003355 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3356
3357 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3358
3359
3360
3361class SliceList(generics.ListCreateAPIView):
3362 queryset = Slice.objects.select_related().all()
3363 serializer_class = SliceSerializer
3364 id_serializer_class = SliceIdSerializer
3365 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003366 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 -07003367
3368 def get_serializer_class(self):
3369 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3370 if (no_hyperlinks):
3371 return self.id_serializer_class
3372 else:
3373 return self.serializer_class
3374
3375 def get_queryset(self):
3376 return Slice.select_by_user(self.request.user)
3377
3378 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003379 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3380 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003381 response = {"error": "validation",
3382 "specific_error": "not serializer.is_valid()",
3383 "reasons": serializer.errors}
3384 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003385 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003386 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003387 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003388 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003389 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003390 raise Exception("failed obj.can_update")
3391
3392 ret = super(SliceList, self).create(request, *args, **kwargs)
3393 if (ret.status_code%100 != 200):
3394 raise Exception(ret.data)
3395
3396 return ret
3397
Scott Baker0caeaf02014-06-19 11:12:55 -07003398
Scott Baker89a7b7c2014-10-07 00:10:17 -07003399class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3400 queryset = Slice.objects.select_related().all()
3401 serializer_class = SliceSerializer
3402 id_serializer_class = SliceIdSerializer
3403
3404 def get_serializer_class(self):
3405 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3406 if (no_hyperlinks):
3407 return self.id_serializer_class
3408 else:
3409 return self.serializer_class
3410
3411 def get_queryset(self):
3412 return Slice.select_by_user(self.request.user)
3413
3414 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3415
3416 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3417
3418
3419
3420class NetworkList(generics.ListCreateAPIView):
3421 queryset = Network.objects.select_related().all()
3422 serializer_class = NetworkSerializer
3423 id_serializer_class = NetworkIdSerializer
3424 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003425 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003426
3427 def get_serializer_class(self):
3428 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3429 if (no_hyperlinks):
3430 return self.id_serializer_class
3431 else:
3432 return self.serializer_class
3433
3434 def get_queryset(self):
3435 return Network.select_by_user(self.request.user)
3436
3437 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003438 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3439 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003440 response = {"error": "validation",
3441 "specific_error": "not serializer.is_valid()",
3442 "reasons": serializer.errors}
3443 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003444 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003445 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003446 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003447 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003448 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003449 raise Exception("failed obj.can_update")
3450
3451 ret = super(NetworkList, self).create(request, *args, **kwargs)
3452 if (ret.status_code%100 != 200):
3453 raise Exception(ret.data)
3454
3455 return ret
3456
Scott Baker89a7b7c2014-10-07 00:10:17 -07003457
3458class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3459 queryset = Network.objects.select_related().all()
3460 serializer_class = NetworkSerializer
3461 id_serializer_class = NetworkIdSerializer
3462
3463 def get_serializer_class(self):
3464 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3465 if (no_hyperlinks):
3466 return self.id_serializer_class
3467 else:
3468 return self.serializer_class
3469
3470 def get_queryset(self):
3471 return Network.select_by_user(self.request.user)
3472
3473 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3474
3475 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3476
3477
3478
3479class ServiceList(generics.ListCreateAPIView):
3480 queryset = Service.objects.select_related().all()
3481 serializer_class = ServiceSerializer
3482 id_serializer_class = ServiceIdSerializer
3483 filter_backends = (filters.DjangoFilterBackend,)
3484 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3485
3486 def get_serializer_class(self):
3487 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3488 if (no_hyperlinks):
3489 return self.id_serializer_class
3490 else:
3491 return self.serializer_class
3492
3493 def get_queryset(self):
3494 return Service.select_by_user(self.request.user)
3495
3496 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003497 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3498 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003499 response = {"error": "validation",
3500 "specific_error": "not serializer.is_valid()",
3501 "reasons": serializer.errors}
3502 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003503 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003504 obj.caller = request.user
3505 if obj.can_update(request.user):
3506 return super(ServiceList, self).create(request, *args, **kwargs)
3507 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003508 raise Exception("failed obj.can_update")
3509
3510 ret = super(ServiceList, self).create(request, *args, **kwargs)
3511 if (ret.status_code%100 != 200):
3512 raise Exception(ret.data)
3513
3514 return ret
3515
Scott Baker89a7b7c2014-10-07 00:10:17 -07003516
3517class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3518 queryset = Service.objects.select_related().all()
3519 serializer_class = ServiceSerializer
3520 id_serializer_class = ServiceIdSerializer
3521
3522 def get_serializer_class(self):
3523 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3524 if (no_hyperlinks):
3525 return self.id_serializer_class
3526 else:
3527 return self.serializer_class
3528
3529 def get_queryset(self):
3530 return Service.select_by_user(self.request.user)
3531
3532 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3533
3534 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3535
3536
3537
3538class ServiceClassList(generics.ListCreateAPIView):
3539 queryset = ServiceClass.objects.select_related().all()
3540 serializer_class = ServiceClassSerializer
3541 id_serializer_class = ServiceClassIdSerializer
3542 filter_backends = (filters.DjangoFilterBackend,)
3543 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3544
3545 def get_serializer_class(self):
3546 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3547 if (no_hyperlinks):
3548 return self.id_serializer_class
3549 else:
3550 return self.serializer_class
3551
3552 def get_queryset(self):
3553 return ServiceClass.select_by_user(self.request.user)
3554
3555 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003556 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3557 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003558 response = {"error": "validation",
3559 "specific_error": "not serializer.is_valid()",
3560 "reasons": serializer.errors}
3561 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003562 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003563 obj.caller = request.user
3564 if obj.can_update(request.user):
3565 return super(ServiceClassList, self).create(request, *args, **kwargs)
3566 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003567 raise Exception("failed obj.can_update")
3568
3569 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3570 if (ret.status_code%100 != 200):
3571 raise Exception(ret.data)
3572
3573 return ret
3574
Scott Baker89a7b7c2014-10-07 00:10:17 -07003575
3576class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3577 queryset = ServiceClass.objects.select_related().all()
3578 serializer_class = ServiceClassSerializer
3579 id_serializer_class = ServiceClassIdSerializer
3580
3581 def get_serializer_class(self):
3582 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3583 if (no_hyperlinks):
3584 return self.id_serializer_class
3585 else:
3586 return self.serializer_class
3587
3588 def get_queryset(self):
3589 return ServiceClass.select_by_user(self.request.user)
3590
3591 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3592
3593 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3594
3595
3596
Scott Baker515dc9e2014-12-22 09:29:05 -08003597class ControllerNetworksList(generics.ListCreateAPIView):
3598 queryset = ControllerNetworks.objects.select_related().all()
3599 serializer_class = ControllerNetworksSerializer
3600 id_serializer_class = ControllerNetworksIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003601 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08003602 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 -07003603
3604 def get_serializer_class(self):
3605 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3606 if (no_hyperlinks):
3607 return self.id_serializer_class
3608 else:
3609 return self.serializer_class
3610
3611 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08003612 return ControllerNetworks.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003613
3614 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003615 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3616 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003617 response = {"error": "validation",
3618 "specific_error": "not serializer.is_valid()",
3619 "reasons": serializer.errors}
3620 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003621 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003622 obj.caller = request.user
3623 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08003624 return super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003625 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003626 raise Exception("failed obj.can_update")
3627
Scott Baker515dc9e2014-12-22 09:29:05 -08003628 ret = super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07003629 if (ret.status_code%100 != 200):
3630 raise Exception(ret.data)
3631
3632 return ret
3633
Scott Baker89a7b7c2014-10-07 00:10:17 -07003634
Scott Baker515dc9e2014-12-22 09:29:05 -08003635class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3636 queryset = ControllerNetworks.objects.select_related().all()
3637 serializer_class = ControllerNetworksSerializer
3638 id_serializer_class = ControllerNetworksIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003639
3640 def get_serializer_class(self):
3641 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3642 if (no_hyperlinks):
3643 return self.id_serializer_class
3644 else:
3645 return self.serializer_class
3646
3647 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08003648 return ControllerNetworks.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003649
3650 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3651
3652 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3653
3654
3655
3656class ChargeList(generics.ListCreateAPIView):
3657 queryset = Charge.objects.select_related().all()
3658 serializer_class = ChargeSerializer
3659 id_serializer_class = ChargeIdSerializer
3660 filter_backends = (filters.DjangoFilterBackend,)
3661 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3662
3663 def get_serializer_class(self):
3664 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3665 if (no_hyperlinks):
3666 return self.id_serializer_class
3667 else:
3668 return self.serializer_class
3669
3670 def get_queryset(self):
3671 return Charge.select_by_user(self.request.user)
3672
3673 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003674 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3675 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003676 response = {"error": "validation",
3677 "specific_error": "not serializer.is_valid()",
3678 "reasons": serializer.errors}
3679 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003680 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003681 obj.caller = request.user
3682 if obj.can_update(request.user):
3683 return super(ChargeList, self).create(request, *args, **kwargs)
3684 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003685 raise Exception("failed obj.can_update")
3686
3687 ret = super(ChargeList, self).create(request, *args, **kwargs)
3688 if (ret.status_code%100 != 200):
3689 raise Exception(ret.data)
3690
3691 return ret
3692
Scott Baker89a7b7c2014-10-07 00:10:17 -07003693
3694class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3695 queryset = Charge.objects.select_related().all()
3696 serializer_class = ChargeSerializer
3697 id_serializer_class = ChargeIdSerializer
3698
3699 def get_serializer_class(self):
3700 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3701 if (no_hyperlinks):
3702 return self.id_serializer_class
3703 else:
3704 return self.serializer_class
3705
3706 def get_queryset(self):
3707 return Charge.select_by_user(self.request.user)
3708
3709 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3710
3711 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3712
3713
3714
3715class RoleList(generics.ListCreateAPIView):
3716 queryset = Role.objects.select_related().all()
3717 serializer_class = RoleSerializer
3718 id_serializer_class = RoleIdSerializer
3719 filter_backends = (filters.DjangoFilterBackend,)
3720 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3721
3722 def get_serializer_class(self):
3723 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3724 if (no_hyperlinks):
3725 return self.id_serializer_class
3726 else:
3727 return self.serializer_class
3728
3729 def get_queryset(self):
3730 return Role.select_by_user(self.request.user)
3731
3732 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003733 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3734 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003735 response = {"error": "validation",
3736 "specific_error": "not serializer.is_valid()",
3737 "reasons": serializer.errors}
3738 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003739 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003740 obj.caller = request.user
3741 if obj.can_update(request.user):
3742 return super(RoleList, self).create(request, *args, **kwargs)
3743 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003744 raise Exception("failed obj.can_update")
3745
3746 ret = super(RoleList, self).create(request, *args, **kwargs)
3747 if (ret.status_code%100 != 200):
3748 raise Exception(ret.data)
3749
3750 return ret
3751
Scott Baker89a7b7c2014-10-07 00:10:17 -07003752
3753class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3754 queryset = Role.objects.select_related().all()
3755 serializer_class = RoleSerializer
3756 id_serializer_class = RoleIdSerializer
3757
3758 def get_serializer_class(self):
3759 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3760 if (no_hyperlinks):
3761 return self.id_serializer_class
3762 else:
3763 return self.serializer_class
3764
3765 def get_queryset(self):
3766 return Role.select_by_user(self.request.user)
3767
3768 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3769
3770 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3771
3772
3773
3774class UsableObjectList(generics.ListCreateAPIView):
3775 queryset = UsableObject.objects.select_related().all()
3776 serializer_class = UsableObjectSerializer
3777 id_serializer_class = UsableObjectIdSerializer
3778 filter_backends = (filters.DjangoFilterBackend,)
3779 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3780
3781 def get_serializer_class(self):
3782 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3783 if (no_hyperlinks):
3784 return self.id_serializer_class
3785 else:
3786 return self.serializer_class
3787
3788 def get_queryset(self):
3789 return UsableObject.select_by_user(self.request.user)
3790
3791 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003792 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3793 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003794 response = {"error": "validation",
3795 "specific_error": "not serializer.is_valid()",
3796 "reasons": serializer.errors}
3797 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003798 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003799 obj.caller = request.user
3800 if obj.can_update(request.user):
3801 return super(UsableObjectList, self).create(request, *args, **kwargs)
3802 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003803 raise Exception("failed obj.can_update")
3804
3805 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3806 if (ret.status_code%100 != 200):
3807 raise Exception(ret.data)
3808
3809 return ret
3810
Scott Baker89a7b7c2014-10-07 00:10:17 -07003811
3812class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3813 queryset = UsableObject.objects.select_related().all()
3814 serializer_class = UsableObjectSerializer
3815 id_serializer_class = UsableObjectIdSerializer
3816
3817 def get_serializer_class(self):
3818 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3819 if (no_hyperlinks):
3820 return self.id_serializer_class
3821 else:
3822 return self.serializer_class
3823
3824 def get_queryset(self):
3825 return UsableObject.select_by_user(self.request.user)
3826
3827 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3828
3829 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3830
3831
3832
Scott Baker515dc9e2014-12-22 09:29:05 -08003833class ControllerSiteDeploymentsList(generics.ListCreateAPIView):
3834 queryset = ControllerSiteDeployments.objects.select_related().all()
3835 serializer_class = ControllerSiteDeploymentsSerializer
3836 id_serializer_class = ControllerSiteDeploymentsIdSerializer
3837 filter_backends = (filters.DjangoFilterBackend,)
3838 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
3839
3840 def get_serializer_class(self):
3841 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3842 if (no_hyperlinks):
3843 return self.id_serializer_class
3844 else:
3845 return self.serializer_class
3846
3847 def get_queryset(self):
3848 return ControllerSiteDeployments.select_by_user(self.request.user)
3849
3850 def create(self, request, *args, **kwargs):
3851 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3852 if not (serializer.is_valid()):
3853 response = {"error": "validation",
3854 "specific_error": "not serializer.is_valid()",
3855 "reasons": serializer.errors}
3856 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3857 obj = serializer.object
3858 obj.caller = request.user
3859 if obj.can_update(request.user):
3860 return super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs)
3861 else:
3862 raise Exception("failed obj.can_update")
3863
3864 ret = super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs)
3865 if (ret.status_code%100 != 200):
3866 raise Exception(ret.data)
3867
3868 return ret
3869
3870
3871class ControllerSiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3872 queryset = ControllerSiteDeployments.objects.select_related().all()
3873 serializer_class = ControllerSiteDeploymentsSerializer
3874 id_serializer_class = ControllerSiteDeploymentsIdSerializer
3875
3876 def get_serializer_class(self):
3877 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3878 if (no_hyperlinks):
3879 return self.id_serializer_class
3880 else:
3881 return self.serializer_class
3882
3883 def get_queryset(self):
3884 return ControllerSiteDeployments.select_by_user(self.request.user)
3885
3886 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3887
3888 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3889
3890
3891
Scott Baker89a7b7c2014-10-07 00:10:17 -07003892class SiteRoleList(generics.ListCreateAPIView):
3893 queryset = SiteRole.objects.select_related().all()
3894 serializer_class = SiteRoleSerializer
3895 id_serializer_class = SiteRoleIdSerializer
3896 filter_backends = (filters.DjangoFilterBackend,)
3897 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3898
3899 def get_serializer_class(self):
3900 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3901 if (no_hyperlinks):
3902 return self.id_serializer_class
3903 else:
3904 return self.serializer_class
3905
3906 def get_queryset(self):
3907 return SiteRole.select_by_user(self.request.user)
3908
3909 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003910 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3911 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003912 response = {"error": "validation",
3913 "specific_error": "not serializer.is_valid()",
3914 "reasons": serializer.errors}
3915 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003916 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003917 obj.caller = request.user
3918 if obj.can_update(request.user):
3919 return super(SiteRoleList, self).create(request, *args, **kwargs)
3920 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003921 raise Exception("failed obj.can_update")
3922
3923 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3924 if (ret.status_code%100 != 200):
3925 raise Exception(ret.data)
3926
3927 return ret
3928
Scott Baker89a7b7c2014-10-07 00:10:17 -07003929
3930class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3931 queryset = SiteRole.objects.select_related().all()
3932 serializer_class = SiteRoleSerializer
3933 id_serializer_class = SiteRoleIdSerializer
3934
3935 def get_serializer_class(self):
3936 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3937 if (no_hyperlinks):
3938 return self.id_serializer_class
3939 else:
3940 return self.serializer_class
3941
3942 def get_queryset(self):
3943 return SiteRole.select_by_user(self.request.user)
3944
3945 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3946
3947 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3948
3949
3950
3951class SliceCredentialList(generics.ListCreateAPIView):
3952 queryset = SliceCredential.objects.select_related().all()
3953 serializer_class = SliceCredentialSerializer
3954 id_serializer_class = SliceCredentialIdSerializer
3955 filter_backends = (filters.DjangoFilterBackend,)
3956 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3957
3958 def get_serializer_class(self):
3959 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3960 if (no_hyperlinks):
3961 return self.id_serializer_class
3962 else:
3963 return self.serializer_class
3964
3965 def get_queryset(self):
3966 return SliceCredential.select_by_user(self.request.user)
3967
3968 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003969 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3970 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003971 response = {"error": "validation",
3972 "specific_error": "not serializer.is_valid()",
3973 "reasons": serializer.errors}
3974 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003975 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003976 obj.caller = request.user
3977 if obj.can_update(request.user):
3978 return super(SliceCredentialList, self).create(request, *args, **kwargs)
3979 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003980 raise Exception("failed obj.can_update")
3981
3982 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
3983 if (ret.status_code%100 != 200):
3984 raise Exception(ret.data)
3985
3986 return ret
3987
Scott Baker89a7b7c2014-10-07 00:10:17 -07003988
3989class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3990 queryset = SliceCredential.objects.select_related().all()
3991 serializer_class = SliceCredentialSerializer
3992 id_serializer_class = SliceCredentialIdSerializer
3993
3994 def get_serializer_class(self):
3995 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3996 if (no_hyperlinks):
3997 return self.id_serializer_class
3998 else:
3999 return self.serializer_class
4000
4001 def get_queryset(self):
4002 return SliceCredential.select_by_user(self.request.user)
4003
4004 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4005
4006 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4007
4008
4009
4010class SliverList(generics.ListCreateAPIView):
4011 queryset = Sliver.objects.select_related().all()
4012 serializer_class = SliverSerializer
4013 id_serializer_class = SliverIdSerializer
4014 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08004015 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004016
4017 def get_serializer_class(self):
4018 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4019 if (no_hyperlinks):
4020 return self.id_serializer_class
4021 else:
4022 return self.serializer_class
4023
4024 def get_queryset(self):
4025 return Sliver.select_by_user(self.request.user)
4026
4027 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004028 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4029 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004030 response = {"error": "validation",
4031 "specific_error": "not serializer.is_valid()",
4032 "reasons": serializer.errors}
4033 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004034 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004035 obj.caller = request.user
4036 if obj.can_update(request.user):
4037 return super(SliverList, self).create(request, *args, **kwargs)
4038 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004039 raise Exception("failed obj.can_update")
4040
4041 ret = super(SliverList, self).create(request, *args, **kwargs)
4042 if (ret.status_code%100 != 200):
4043 raise Exception(ret.data)
4044
4045 return ret
4046
Scott Baker89a7b7c2014-10-07 00:10:17 -07004047
4048class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4049 queryset = Sliver.objects.select_related().all()
4050 serializer_class = SliverSerializer
4051 id_serializer_class = SliverIdSerializer
4052
4053 def get_serializer_class(self):
4054 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4055 if (no_hyperlinks):
4056 return self.id_serializer_class
4057 else:
4058 return self.serializer_class
4059
4060 def get_queryset(self):
4061 return Sliver.select_by_user(self.request.user)
4062
4063 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4064
4065 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4066
4067
4068
4069class NodeList(generics.ListCreateAPIView):
4070 queryset = Node.objects.select_related().all()
4071 serializer_class = NodeSerializer
4072 id_serializer_class = NodeIdSerializer
4073 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08004074 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004075
4076 def get_serializer_class(self):
4077 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4078 if (no_hyperlinks):
4079 return self.id_serializer_class
4080 else:
4081 return self.serializer_class
4082
4083 def get_queryset(self):
4084 return Node.select_by_user(self.request.user)
4085
4086 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004087 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4088 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004089 response = {"error": "validation",
4090 "specific_error": "not serializer.is_valid()",
4091 "reasons": serializer.errors}
4092 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004093 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004094 obj.caller = request.user
4095 if obj.can_update(request.user):
4096 return super(NodeList, self).create(request, *args, **kwargs)
4097 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004098 raise Exception("failed obj.can_update")
4099
4100 ret = super(NodeList, self).create(request, *args, **kwargs)
4101 if (ret.status_code%100 != 200):
4102 raise Exception(ret.data)
4103
4104 return ret
4105
Scott Baker89a7b7c2014-10-07 00:10:17 -07004106
4107class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4108 queryset = Node.objects.select_related().all()
4109 serializer_class = NodeSerializer
4110 id_serializer_class = NodeIdSerializer
4111
4112 def get_serializer_class(self):
4113 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4114 if (no_hyperlinks):
4115 return self.id_serializer_class
4116 else:
4117 return self.serializer_class
4118
4119 def get_queryset(self):
4120 return Node.select_by_user(self.request.user)
4121
4122 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4123
4124 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4125
4126
4127
4128class DashboardViewList(generics.ListCreateAPIView):
4129 queryset = DashboardView.objects.select_related().all()
4130 serializer_class = DashboardViewSerializer
4131 id_serializer_class = DashboardViewIdSerializer
4132 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08004133 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004134
4135 def get_serializer_class(self):
4136 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4137 if (no_hyperlinks):
4138 return self.id_serializer_class
4139 else:
4140 return self.serializer_class
4141
4142 def get_queryset(self):
4143 return DashboardView.select_by_user(self.request.user)
4144
4145 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004146 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4147 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004148 response = {"error": "validation",
4149 "specific_error": "not serializer.is_valid()",
4150 "reasons": serializer.errors}
4151 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004152 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004153 obj.caller = request.user
4154 if obj.can_update(request.user):
4155 return super(DashboardViewList, self).create(request, *args, **kwargs)
4156 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004157 raise Exception("failed obj.can_update")
4158
4159 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
4160 if (ret.status_code%100 != 200):
4161 raise Exception(ret.data)
4162
4163 return ret
4164
Scott Baker89a7b7c2014-10-07 00:10:17 -07004165
4166class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4167 queryset = DashboardView.objects.select_related().all()
4168 serializer_class = DashboardViewSerializer
4169 id_serializer_class = DashboardViewIdSerializer
4170
4171 def get_serializer_class(self):
4172 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4173 if (no_hyperlinks):
4174 return self.id_serializer_class
4175 else:
4176 return self.serializer_class
4177
4178 def get_queryset(self):
4179 return DashboardView.select_by_user(self.request.user)
4180
4181 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4182
4183 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4184
Scott Baker89a7b7c2014-10-07 00:10:17 -07004185
Scott Baker57c725c2014-11-12 01:13:53 -08004186
Scott Baker515dc9e2014-12-22 09:29:05 -08004187class ImageDeploymentsList(generics.ListCreateAPIView):
4188 queryset = ImageDeployments.objects.select_related().all()
4189 serializer_class = ImageDeploymentsSerializer
4190 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004191 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08004192 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004193
4194 def get_serializer_class(self):
4195 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4196 if (no_hyperlinks):
4197 return self.id_serializer_class
4198 else:
4199 return self.serializer_class
4200
4201 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08004202 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004203
4204 def create(self, request, *args, **kwargs):
4205 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4206 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004207 response = {"error": "validation",
4208 "specific_error": "not serializer.is_valid()",
4209 "reasons": serializer.errors}
4210 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004211 obj = serializer.object
4212 obj.caller = request.user
4213 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08004214 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004215 else:
4216 raise Exception("failed obj.can_update")
4217
Scott Baker515dc9e2014-12-22 09:29:05 -08004218 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004219 if (ret.status_code%100 != 200):
4220 raise Exception(ret.data)
4221
4222 return ret
4223
4224
Scott Baker515dc9e2014-12-22 09:29:05 -08004225class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4226 queryset = ImageDeployments.objects.select_related().all()
4227 serializer_class = ImageDeploymentsSerializer
4228 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004229
4230 def get_serializer_class(self):
4231 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4232 if (no_hyperlinks):
4233 return self.id_serializer_class
4234 else:
4235 return self.serializer_class
4236
4237 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08004238 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004239
4240 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4241
4242 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4243
Scott Bakerb744f1c2014-11-21 11:32:24 -08004244
4245
Scott Baker89a7b7c2014-10-07 00:10:17 -07004246class ReservedResourceList(generics.ListCreateAPIView):
4247 queryset = ReservedResource.objects.select_related().all()
4248 serializer_class = ReservedResourceSerializer
4249 id_serializer_class = ReservedResourceIdSerializer
4250 filter_backends = (filters.DjangoFilterBackend,)
4251 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
4252
4253 def get_serializer_class(self):
4254 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4255 if (no_hyperlinks):
4256 return self.id_serializer_class
4257 else:
4258 return self.serializer_class
4259
4260 def get_queryset(self):
4261 return ReservedResource.select_by_user(self.request.user)
4262
4263 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004264 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4265 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004266 response = {"error": "validation",
4267 "specific_error": "not serializer.is_valid()",
4268 "reasons": serializer.errors}
4269 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004270 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004271 obj.caller = request.user
4272 if obj.can_update(request.user):
4273 return super(ReservedResourceList, self).create(request, *args, **kwargs)
4274 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004275 raise Exception("failed obj.can_update")
4276
4277 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4278 if (ret.status_code%100 != 200):
4279 raise Exception(ret.data)
4280
4281 return ret
4282
Scott Baker89a7b7c2014-10-07 00:10:17 -07004283
4284class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4285 queryset = ReservedResource.objects.select_related().all()
4286 serializer_class = ReservedResourceSerializer
4287 id_serializer_class = ReservedResourceIdSerializer
4288
4289 def get_serializer_class(self):
4290 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4291 if (no_hyperlinks):
4292 return self.id_serializer_class
4293 else:
4294 return self.serializer_class
4295
4296 def get_queryset(self):
4297 return ReservedResource.select_by_user(self.request.user)
4298
4299 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4300
4301 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4302
4303
4304
Scott Baker515dc9e2014-12-22 09:29:05 -08004305class PaymentList(generics.ListCreateAPIView):
4306 queryset = Payment.objects.select_related().all()
4307 serializer_class = PaymentSerializer
4308 id_serializer_class = PaymentIdSerializer
4309 filter_backends = (filters.DjangoFilterBackend,)
4310 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
4311
4312 def get_serializer_class(self):
4313 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4314 if (no_hyperlinks):
4315 return self.id_serializer_class
4316 else:
4317 return self.serializer_class
4318
4319 def get_queryset(self):
4320 return Payment.select_by_user(self.request.user)
4321
4322 def create(self, request, *args, **kwargs):
4323 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4324 if not (serializer.is_valid()):
4325 response = {"error": "validation",
4326 "specific_error": "not serializer.is_valid()",
4327 "reasons": serializer.errors}
4328 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4329 obj = serializer.object
4330 obj.caller = request.user
4331 if obj.can_update(request.user):
4332 return super(PaymentList, self).create(request, *args, **kwargs)
4333 else:
4334 raise Exception("failed obj.can_update")
4335
4336 ret = super(PaymentList, self).create(request, *args, **kwargs)
4337 if (ret.status_code%100 != 200):
4338 raise Exception(ret.data)
4339
4340 return ret
4341
4342
4343class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4344 queryset = Payment.objects.select_related().all()
4345 serializer_class = PaymentSerializer
4346 id_serializer_class = PaymentIdSerializer
4347
4348 def get_serializer_class(self):
4349 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4350 if (no_hyperlinks):
4351 return self.id_serializer_class
4352 else:
4353 return self.serializer_class
4354
4355 def get_queryset(self):
4356 return Payment.select_by_user(self.request.user)
4357
4358 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4359
4360 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4361
4362
4363
4364class NetworkTemplateList(generics.ListCreateAPIView):
4365 queryset = NetworkTemplate.objects.select_related().all()
4366 serializer_class = NetworkTemplateSerializer
4367 id_serializer_class = NetworkTemplateIdSerializer
4368 filter_backends = (filters.DjangoFilterBackend,)
4369 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
4370
4371 def get_serializer_class(self):
4372 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4373 if (no_hyperlinks):
4374 return self.id_serializer_class
4375 else:
4376 return self.serializer_class
4377
4378 def get_queryset(self):
4379 return NetworkTemplate.select_by_user(self.request.user)
4380
4381 def create(self, request, *args, **kwargs):
4382 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4383 if not (serializer.is_valid()):
4384 response = {"error": "validation",
4385 "specific_error": "not serializer.is_valid()",
4386 "reasons": serializer.errors}
4387 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4388 obj = serializer.object
4389 obj.caller = request.user
4390 if obj.can_update(request.user):
4391 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
4392 else:
4393 raise Exception("failed obj.can_update")
4394
4395 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
4396 if (ret.status_code%100 != 200):
4397 raise Exception(ret.data)
4398
4399 return ret
4400
4401
4402class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4403 queryset = NetworkTemplate.objects.select_related().all()
4404 serializer_class = NetworkTemplateSerializer
4405 id_serializer_class = NetworkTemplateIdSerializer
4406
4407 def get_serializer_class(self):
4408 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4409 if (no_hyperlinks):
4410 return self.id_serializer_class
4411 else:
4412 return self.serializer_class
4413
4414 def get_queryset(self):
4415 return NetworkTemplate.select_by_user(self.request.user)
4416
4417 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4418
4419 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4420
4421
4422
Scott Baker89a7b7c2014-10-07 00:10:17 -07004423class NetworkSliceList(generics.ListCreateAPIView):
4424 queryset = NetworkSlice.objects.select_related().all()
4425 serializer_class = NetworkSliceSerializer
4426 id_serializer_class = NetworkSliceIdSerializer
4427 filter_backends = (filters.DjangoFilterBackend,)
4428 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
4429
4430 def get_serializer_class(self):
4431 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4432 if (no_hyperlinks):
4433 return self.id_serializer_class
4434 else:
4435 return self.serializer_class
4436
4437 def get_queryset(self):
4438 return NetworkSlice.select_by_user(self.request.user)
4439
4440 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004441 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4442 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004443 response = {"error": "validation",
4444 "specific_error": "not serializer.is_valid()",
4445 "reasons": serializer.errors}
4446 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004447 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004448 obj.caller = request.user
4449 if obj.can_update(request.user):
4450 return super(NetworkSliceList, self).create(request, *args, **kwargs)
4451 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004452 raise Exception("failed obj.can_update")
4453
4454 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4455 if (ret.status_code%100 != 200):
4456 raise Exception(ret.data)
4457
4458 return ret
4459
Scott Baker89a7b7c2014-10-07 00:10:17 -07004460
4461class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4462 queryset = NetworkSlice.objects.select_related().all()
4463 serializer_class = NetworkSliceSerializer
4464 id_serializer_class = NetworkSliceIdSerializer
4465
4466 def get_serializer_class(self):
4467 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4468 if (no_hyperlinks):
4469 return self.id_serializer_class
4470 else:
4471 return self.serializer_class
4472
4473 def get_queryset(self):
4474 return NetworkSlice.select_by_user(self.request.user)
4475
4476 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4477
4478 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4479
4480
4481
4482class UserDashboardViewList(generics.ListCreateAPIView):
4483 queryset = UserDashboardView.objects.select_related().all()
4484 serializer_class = UserDashboardViewSerializer
4485 id_serializer_class = UserDashboardViewIdSerializer
4486 filter_backends = (filters.DjangoFilterBackend,)
4487 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4488
4489 def get_serializer_class(self):
4490 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4491 if (no_hyperlinks):
4492 return self.id_serializer_class
4493 else:
4494 return self.serializer_class
4495
4496 def get_queryset(self):
4497 return UserDashboardView.select_by_user(self.request.user)
4498
4499 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004500 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4501 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004502 response = {"error": "validation",
4503 "specific_error": "not serializer.is_valid()",
4504 "reasons": serializer.errors}
4505 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004506 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004507 obj.caller = request.user
4508 if obj.can_update(request.user):
4509 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4510 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004511 raise Exception("failed obj.can_update")
4512
4513 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4514 if (ret.status_code%100 != 200):
4515 raise Exception(ret.data)
4516
4517 return ret
4518
Scott Baker89a7b7c2014-10-07 00:10:17 -07004519
4520class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4521 queryset = UserDashboardView.objects.select_related().all()
4522 serializer_class = UserDashboardViewSerializer
4523 id_serializer_class = UserDashboardViewIdSerializer
4524
4525 def get_serializer_class(self):
4526 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4527 if (no_hyperlinks):
4528 return self.id_serializer_class
4529 else:
4530 return self.serializer_class
4531
4532 def get_queryset(self):
4533 return UserDashboardView.select_by_user(self.request.user)
4534
4535 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4536
4537 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4538
4539
4540
Scott Baker515dc9e2014-12-22 09:29:05 -08004541class ControllerList(generics.ListCreateAPIView):
4542 queryset = Controller.objects.select_related().all()
4543 serializer_class = ControllerSerializer
4544 id_serializer_class = ControllerIdSerializer
4545 filter_backends = (filters.DjangoFilterBackend,)
4546 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
4547
4548 def get_serializer_class(self):
4549 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4550 if (no_hyperlinks):
4551 return self.id_serializer_class
4552 else:
4553 return self.serializer_class
4554
4555 def get_queryset(self):
4556 return Controller.select_by_user(self.request.user)
4557
4558 def create(self, request, *args, **kwargs):
4559 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4560 if not (serializer.is_valid()):
4561 response = {"error": "validation",
4562 "specific_error": "not serializer.is_valid()",
4563 "reasons": serializer.errors}
4564 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4565 obj = serializer.object
4566 obj.caller = request.user
4567 if obj.can_update(request.user):
4568 return super(ControllerList, self).create(request, *args, **kwargs)
4569 else:
4570 raise Exception("failed obj.can_update")
4571
4572 ret = super(ControllerList, self).create(request, *args, **kwargs)
4573 if (ret.status_code%100 != 200):
4574 raise Exception(ret.data)
4575
4576 return ret
4577
4578
4579class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4580 queryset = Controller.objects.select_related().all()
4581 serializer_class = ControllerSerializer
4582 id_serializer_class = ControllerIdSerializer
4583
4584 def get_serializer_class(self):
4585 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4586 if (no_hyperlinks):
4587 return self.id_serializer_class
4588 else:
4589 return self.serializer_class
4590
4591 def get_queryset(self):
4592 return Controller.select_by_user(self.request.user)
4593
4594 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4595
4596 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4597
4598
4599
Scott Baker89a7b7c2014-10-07 00:10:17 -07004600class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4601 queryset = PlanetStackPrivilege.objects.select_related().all()
4602 serializer_class = PlanetStackPrivilegeSerializer
4603 id_serializer_class = PlanetStackPrivilegeIdSerializer
4604 filter_backends = (filters.DjangoFilterBackend,)
4605 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4606
4607 def get_serializer_class(self):
4608 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4609 if (no_hyperlinks):
4610 return self.id_serializer_class
4611 else:
4612 return self.serializer_class
4613
4614 def get_queryset(self):
4615 return PlanetStackPrivilege.select_by_user(self.request.user)
4616
4617 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004618 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4619 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004620 response = {"error": "validation",
4621 "specific_error": "not serializer.is_valid()",
4622 "reasons": serializer.errors}
4623 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004624 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004625 obj.caller = request.user
4626 if obj.can_update(request.user):
4627 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4628 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004629 raise Exception("failed obj.can_update")
4630
4631 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4632 if (ret.status_code%100 != 200):
4633 raise Exception(ret.data)
4634
4635 return ret
4636
Scott Baker89a7b7c2014-10-07 00:10:17 -07004637
4638class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4639 queryset = PlanetStackPrivilege.objects.select_related().all()
4640 serializer_class = PlanetStackPrivilegeSerializer
4641 id_serializer_class = PlanetStackPrivilegeIdSerializer
4642
4643 def get_serializer_class(self):
4644 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4645 if (no_hyperlinks):
4646 return self.id_serializer_class
4647 else:
4648 return self.serializer_class
4649
4650 def get_queryset(self):
4651 return PlanetStackPrivilege.select_by_user(self.request.user)
4652
4653 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4654
4655 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4656
4657
4658
4659class UserList(generics.ListCreateAPIView):
4660 queryset = User.objects.select_related().all()
4661 serializer_class = UserSerializer
4662 id_serializer_class = UserIdSerializer
4663 filter_backends = (filters.DjangoFilterBackend,)
4664 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',)
4665
4666 def get_serializer_class(self):
4667 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4668 if (no_hyperlinks):
4669 return self.id_serializer_class
4670 else:
4671 return self.serializer_class
4672
4673 def get_queryset(self):
4674 return User.select_by_user(self.request.user)
4675
4676 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004677 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4678 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004679 response = {"error": "validation",
4680 "specific_error": "not serializer.is_valid()",
4681 "reasons": serializer.errors}
4682 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004683 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004684 obj.caller = request.user
4685 if obj.can_update(request.user):
4686 return super(UserList, self).create(request, *args, **kwargs)
4687 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004688 raise Exception("failed obj.can_update")
4689
4690 ret = super(UserList, self).create(request, *args, **kwargs)
4691 if (ret.status_code%100 != 200):
4692 raise Exception(ret.data)
4693
4694 return ret
4695
Scott Baker89a7b7c2014-10-07 00:10:17 -07004696
4697class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4698 queryset = User.objects.select_related().all()
4699 serializer_class = UserSerializer
4700 id_serializer_class = UserIdSerializer
4701
4702 def get_serializer_class(self):
4703 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4704 if (no_hyperlinks):
4705 return self.id_serializer_class
4706 else:
4707 return self.serializer_class
4708
4709 def get_queryset(self):
4710 return User.select_by_user(self.request.user)
4711
4712 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4713
4714 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4715
4716
4717
4718class DeploymentList(generics.ListCreateAPIView):
4719 queryset = Deployment.objects.select_related().all()
4720 serializer_class = DeploymentSerializer
4721 id_serializer_class = DeploymentIdSerializer
4722 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08004723 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','sites',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004724
4725 def get_serializer_class(self):
4726 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4727 if (no_hyperlinks):
4728 return self.id_serializer_class
4729 else:
4730 return self.serializer_class
4731
4732 def get_queryset(self):
4733 return Deployment.select_by_user(self.request.user)
4734
4735 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004736 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4737 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004738 response = {"error": "validation",
4739 "specific_error": "not serializer.is_valid()",
4740 "reasons": serializer.errors}
4741 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004742 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004743 obj.caller = request.user
4744 if obj.can_update(request.user):
4745 return super(DeploymentList, self).create(request, *args, **kwargs)
4746 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004747 raise Exception("failed obj.can_update")
4748
4749 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4750 if (ret.status_code%100 != 200):
4751 raise Exception(ret.data)
4752
4753 return ret
4754
Scott Baker89a7b7c2014-10-07 00:10:17 -07004755
4756class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4757 queryset = Deployment.objects.select_related().all()
4758 serializer_class = DeploymentSerializer
4759 id_serializer_class = DeploymentIdSerializer
4760
4761 def get_serializer_class(self):
4762 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4763 if (no_hyperlinks):
4764 return self.id_serializer_class
4765 else:
4766 return self.serializer_class
4767
4768 def get_queryset(self):
4769 return Deployment.select_by_user(self.request.user)
4770
4771 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4772
4773 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4774
4775
4776
4777class ReservationList(generics.ListCreateAPIView):
4778 queryset = Reservation.objects.select_related().all()
4779 serializer_class = ReservationSerializer
4780 id_serializer_class = ReservationIdSerializer
4781 filter_backends = (filters.DjangoFilterBackend,)
4782 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4783
4784 def get_serializer_class(self):
4785 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4786 if (no_hyperlinks):
4787 return self.id_serializer_class
4788 else:
4789 return self.serializer_class
4790
4791 def get_queryset(self):
4792 return Reservation.select_by_user(self.request.user)
4793
4794 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004795 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4796 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004797 response = {"error": "validation",
4798 "specific_error": "not serializer.is_valid()",
4799 "reasons": serializer.errors}
4800 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004801 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004802 obj.caller = request.user
4803 if obj.can_update(request.user):
4804 return super(ReservationList, self).create(request, *args, **kwargs)
4805 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004806 raise Exception("failed obj.can_update")
4807
4808 ret = super(ReservationList, self).create(request, *args, **kwargs)
4809 if (ret.status_code%100 != 200):
4810 raise Exception(ret.data)
4811
4812 return ret
4813
Scott Baker89a7b7c2014-10-07 00:10:17 -07004814
4815class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4816 queryset = Reservation.objects.select_related().all()
4817 serializer_class = ReservationSerializer
4818 id_serializer_class = ReservationIdSerializer
4819
4820 def get_serializer_class(self):
4821 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4822 if (no_hyperlinks):
4823 return self.id_serializer_class
4824 else:
4825 return self.serializer_class
4826
4827 def get_queryset(self):
4828 return Reservation.select_by_user(self.request.user)
4829
4830 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4831
4832 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4833
Scott Baker89a7b7c2014-10-07 00:10:17 -07004834
Scott Baker57c725c2014-11-12 01:13:53 -08004835
Scott Baker89a7b7c2014-10-07 00:10:17 -07004836class SitePrivilegeList(generics.ListCreateAPIView):
4837 queryset = SitePrivilege.objects.select_related().all()
4838 serializer_class = SitePrivilegeSerializer
4839 id_serializer_class = SitePrivilegeIdSerializer
4840 filter_backends = (filters.DjangoFilterBackend,)
4841 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4842
4843 def get_serializer_class(self):
4844 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4845 if (no_hyperlinks):
4846 return self.id_serializer_class
4847 else:
4848 return self.serializer_class
4849
4850 def get_queryset(self):
4851 return SitePrivilege.select_by_user(self.request.user)
4852
4853 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004854 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4855 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004856 response = {"error": "validation",
4857 "specific_error": "not serializer.is_valid()",
4858 "reasons": serializer.errors}
4859 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004860 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004861 obj.caller = request.user
4862 if obj.can_update(request.user):
4863 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4864 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004865 raise Exception("failed obj.can_update")
4866
4867 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4868 if (ret.status_code%100 != 200):
4869 raise Exception(ret.data)
4870
4871 return ret
4872
Scott Baker89a7b7c2014-10-07 00:10:17 -07004873
4874class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4875 queryset = SitePrivilege.objects.select_related().all()
4876 serializer_class = SitePrivilegeSerializer
4877 id_serializer_class = SitePrivilegeIdSerializer
4878
4879 def get_serializer_class(self):
4880 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4881 if (no_hyperlinks):
4882 return self.id_serializer_class
4883 else:
4884 return self.serializer_class
4885
4886 def get_queryset(self):
4887 return SitePrivilege.select_by_user(self.request.user)
4888
4889 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4890
4891 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4892
4893
4894
Scott Bakerb744f1c2014-11-21 11:32:24 -08004895class PlanetStackList(generics.ListCreateAPIView):
4896 queryset = PlanetStack.objects.select_related().all()
4897 serializer_class = PlanetStackSerializer
4898 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004899 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004900 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004901
4902 def get_serializer_class(self):
4903 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4904 if (no_hyperlinks):
4905 return self.id_serializer_class
4906 else:
4907 return self.serializer_class
4908
4909 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004910 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004911
4912 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004913 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4914 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004915 response = {"error": "validation",
4916 "specific_error": "not serializer.is_valid()",
4917 "reasons": serializer.errors}
4918 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004919 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004920 obj.caller = request.user
4921 if obj.can_update(request.user):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004922 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004923 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004924 raise Exception("failed obj.can_update")
4925
Scott Bakerb744f1c2014-11-21 11:32:24 -08004926 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07004927 if (ret.status_code%100 != 200):
4928 raise Exception(ret.data)
4929
4930 return ret
4931
Scott Baker89a7b7c2014-10-07 00:10:17 -07004932
Scott Bakerb744f1c2014-11-21 11:32:24 -08004933class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4934 queryset = PlanetStack.objects.select_related().all()
4935 serializer_class = PlanetStackSerializer
4936 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07004937
4938 def get_serializer_class(self):
4939 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4940 if (no_hyperlinks):
4941 return self.id_serializer_class
4942 else:
4943 return self.serializer_class
4944
4945 def get_queryset(self):
Scott Bakerb744f1c2014-11-21 11:32:24 -08004946 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004947
4948 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4949
4950 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4951
Scott Baker89a7b7c2014-10-07 00:10:17 -07004952
Scott Baker57c725c2014-11-12 01:13:53 -08004953
Scott Baker89a7b7c2014-10-07 00:10:17 -07004954class AccountList(generics.ListCreateAPIView):
4955 queryset = Account.objects.select_related().all()
4956 serializer_class = AccountSerializer
4957 id_serializer_class = AccountIdSerializer
4958 filter_backends = (filters.DjangoFilterBackend,)
4959 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4960
4961 def get_serializer_class(self):
4962 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4963 if (no_hyperlinks):
4964 return self.id_serializer_class
4965 else:
4966 return self.serializer_class
4967
4968 def get_queryset(self):
4969 return Account.select_by_user(self.request.user)
4970
4971 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004972 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4973 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004974 response = {"error": "validation",
4975 "specific_error": "not serializer.is_valid()",
4976 "reasons": serializer.errors}
4977 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004978 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004979 obj.caller = request.user
4980 if obj.can_update(request.user):
4981 return super(AccountList, self).create(request, *args, **kwargs)
4982 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004983 raise Exception("failed obj.can_update")
4984
4985 ret = super(AccountList, self).create(request, *args, **kwargs)
4986 if (ret.status_code%100 != 200):
4987 raise Exception(ret.data)
4988
4989 return ret
4990
Scott Baker89a7b7c2014-10-07 00:10:17 -07004991
4992class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4993 queryset = Account.objects.select_related().all()
4994 serializer_class = AccountSerializer
4995 id_serializer_class = AccountIdSerializer
4996
4997 def get_serializer_class(self):
4998 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4999 if (no_hyperlinks):
5000 return self.id_serializer_class
5001 else:
5002 return self.serializer_class
5003
5004 def get_queryset(self):
5005 return Account.select_by_user(self.request.user)
5006
5007 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5008
5009 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5010
5011
5012
Scott Baker515dc9e2014-12-22 09:29:05 -08005013class ControllerRoleList(generics.ListCreateAPIView):
5014 queryset = ControllerRole.objects.select_related().all()
5015 serializer_class = ControllerRoleSerializer
5016 id_serializer_class = ControllerRoleIdSerializer
5017 filter_backends = (filters.DjangoFilterBackend,)
5018 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5019
5020 def get_serializer_class(self):
5021 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5022 if (no_hyperlinks):
5023 return self.id_serializer_class
5024 else:
5025 return self.serializer_class
5026
5027 def get_queryset(self):
5028 return ControllerRole.select_by_user(self.request.user)
5029
5030 def create(self, request, *args, **kwargs):
5031 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5032 if not (serializer.is_valid()):
5033 response = {"error": "validation",
5034 "specific_error": "not serializer.is_valid()",
5035 "reasons": serializer.errors}
5036 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5037 obj = serializer.object
5038 obj.caller = request.user
5039 if obj.can_update(request.user):
5040 return super(ControllerRoleList, self).create(request, *args, **kwargs)
5041 else:
5042 raise Exception("failed obj.can_update")
5043
5044 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
5045 if (ret.status_code%100 != 200):
5046 raise Exception(ret.data)
5047
5048 return ret
5049
5050
5051class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5052 queryset = ControllerRole.objects.select_related().all()
5053 serializer_class = ControllerRoleSerializer
5054 id_serializer_class = ControllerRoleIdSerializer
5055
5056 def get_serializer_class(self):
5057 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5058 if (no_hyperlinks):
5059 return self.id_serializer_class
5060 else:
5061 return self.serializer_class
5062
5063 def get_queryset(self):
5064 return ControllerRole.select_by_user(self.request.user)
5065
5066 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5067
5068 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5069
5070
5071
Scott Baker89a7b7c2014-10-07 00:10:17 -07005072class NetworkParameterTypeList(generics.ListCreateAPIView):
5073 queryset = NetworkParameterType.objects.select_related().all()
5074 serializer_class = NetworkParameterTypeSerializer
5075 id_serializer_class = NetworkParameterTypeIdSerializer
5076 filter_backends = (filters.DjangoFilterBackend,)
5077 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
5078
5079 def get_serializer_class(self):
5080 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5081 if (no_hyperlinks):
5082 return self.id_serializer_class
5083 else:
5084 return self.serializer_class
5085
5086 def get_queryset(self):
5087 return NetworkParameterType.select_by_user(self.request.user)
5088
5089 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005090 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5091 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005092 response = {"error": "validation",
5093 "specific_error": "not serializer.is_valid()",
5094 "reasons": serializer.errors}
5095 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005096 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005097 obj.caller = request.user
5098 if obj.can_update(request.user):
5099 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5100 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005101 raise Exception("failed obj.can_update")
5102
5103 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5104 if (ret.status_code%100 != 200):
5105 raise Exception(ret.data)
5106
5107 return ret
5108
Scott Baker89a7b7c2014-10-07 00:10:17 -07005109
5110class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5111 queryset = NetworkParameterType.objects.select_related().all()
5112 serializer_class = NetworkParameterTypeSerializer
5113 id_serializer_class = NetworkParameterTypeIdSerializer
5114
5115 def get_serializer_class(self):
5116 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5117 if (no_hyperlinks):
5118 return self.id_serializer_class
5119 else:
5120 return self.serializer_class
5121
5122 def get_queryset(self):
5123 return NetworkParameterType.select_by_user(self.request.user)
5124
5125 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5126
5127 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5128
5129
5130
5131class SiteCredentialList(generics.ListCreateAPIView):
5132 queryset = SiteCredential.objects.select_related().all()
5133 serializer_class = SiteCredentialSerializer
5134 id_serializer_class = SiteCredentialIdSerializer
5135 filter_backends = (filters.DjangoFilterBackend,)
5136 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
5137
5138 def get_serializer_class(self):
5139 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5140 if (no_hyperlinks):
5141 return self.id_serializer_class
5142 else:
5143 return self.serializer_class
5144
5145 def get_queryset(self):
5146 return SiteCredential.select_by_user(self.request.user)
5147
5148 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005149 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5150 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005151 response = {"error": "validation",
5152 "specific_error": "not serializer.is_valid()",
5153 "reasons": serializer.errors}
5154 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005155 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005156 obj.caller = request.user
5157 if obj.can_update(request.user):
5158 return super(SiteCredentialList, self).create(request, *args, **kwargs)
5159 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005160 raise Exception("failed obj.can_update")
5161
5162 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
5163 if (ret.status_code%100 != 200):
5164 raise Exception(ret.data)
5165
5166 return ret
5167
Scott Baker89a7b7c2014-10-07 00:10:17 -07005168
5169class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5170 queryset = SiteCredential.objects.select_related().all()
5171 serializer_class = SiteCredentialSerializer
5172 id_serializer_class = SiteCredentialIdSerializer
5173
5174 def get_serializer_class(self):
5175 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5176 if (no_hyperlinks):
5177 return self.id_serializer_class
5178 else:
5179 return self.serializer_class
5180
5181 def get_queryset(self):
5182 return SiteCredential.select_by_user(self.request.user)
5183
5184 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5185
5186 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5187
5188
5189
Scott Baker515dc9e2014-12-22 09:29:05 -08005190class DeploymentPrivilegeList(generics.ListCreateAPIView):
5191 queryset = DeploymentPrivilege.objects.select_related().all()
5192 serializer_class = DeploymentPrivilegeSerializer
5193 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005194 filter_backends = (filters.DjangoFilterBackend,)
5195 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
5196
5197 def get_serializer_class(self):
5198 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5199 if (no_hyperlinks):
5200 return self.id_serializer_class
5201 else:
5202 return self.serializer_class
5203
5204 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005205 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005206
5207 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005208 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5209 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005210 response = {"error": "validation",
5211 "specific_error": "not serializer.is_valid()",
5212 "reasons": serializer.errors}
5213 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005214 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005215 obj.caller = request.user
5216 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005217 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005218 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005219 raise Exception("failed obj.can_update")
5220
Scott Baker515dc9e2014-12-22 09:29:05 -08005221 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005222 if (ret.status_code%100 != 200):
5223 raise Exception(ret.data)
5224
5225 return ret
5226
Scott Baker89a7b7c2014-10-07 00:10:17 -07005227
Scott Baker515dc9e2014-12-22 09:29:05 -08005228class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5229 queryset = DeploymentPrivilege.objects.select_related().all()
5230 serializer_class = DeploymentPrivilegeSerializer
5231 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005232
5233 def get_serializer_class(self):
5234 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5235 if (no_hyperlinks):
5236 return self.id_serializer_class
5237 else:
5238 return self.serializer_class
5239
5240 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005241 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005242
5243 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5244
5245 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5246
5247
5248
Scott Baker515dc9e2014-12-22 09:29:05 -08005249class ControllerUsersList(generics.ListCreateAPIView):
5250 queryset = ControllerUsers.objects.select_related().all()
5251 serializer_class = ControllerUsersSerializer
5252 id_serializer_class = ControllerUsersIdSerializer
5253 filter_backends = (filters.DjangoFilterBackend,)
5254 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
5255
5256 def get_serializer_class(self):
5257 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5258 if (no_hyperlinks):
5259 return self.id_serializer_class
5260 else:
5261 return self.serializer_class
5262
5263 def get_queryset(self):
5264 return ControllerUsers.select_by_user(self.request.user)
5265
5266 def create(self, request, *args, **kwargs):
5267 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5268 if not (serializer.is_valid()):
5269 response = {"error": "validation",
5270 "specific_error": "not serializer.is_valid()",
5271 "reasons": serializer.errors}
5272 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5273 obj = serializer.object
5274 obj.caller = request.user
5275 if obj.can_update(request.user):
5276 return super(ControllerUsersList, self).create(request, *args, **kwargs)
5277 else:
5278 raise Exception("failed obj.can_update")
5279
5280 ret = super(ControllerUsersList, self).create(request, *args, **kwargs)
5281 if (ret.status_code%100 != 200):
5282 raise Exception(ret.data)
5283
5284 return ret
5285
5286
5287class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5288 queryset = ControllerUsers.objects.select_related().all()
5289 serializer_class = ControllerUsersSerializer
5290 id_serializer_class = ControllerUsersIdSerializer
5291
5292 def get_serializer_class(self):
5293 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5294 if (no_hyperlinks):
5295 return self.id_serializer_class
5296 else:
5297 return self.serializer_class
5298
5299 def get_queryset(self):
5300 return ControllerUsers.select_by_user(self.request.user)
5301
5302 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5303
5304 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5305
5306
5307
5308class DeploymentRoleList(generics.ListCreateAPIView):
5309 queryset = DeploymentRole.objects.select_related().all()
5310 serializer_class = DeploymentRoleSerializer
5311 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005312 filter_backends = (filters.DjangoFilterBackend,)
5313 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5314
5315 def get_serializer_class(self):
5316 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5317 if (no_hyperlinks):
5318 return self.id_serializer_class
5319 else:
5320 return self.serializer_class
5321
5322 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005323 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005324
5325 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005326 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5327 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005328 response = {"error": "validation",
5329 "specific_error": "not serializer.is_valid()",
5330 "reasons": serializer.errors}
5331 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005332 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005333 obj.caller = request.user
5334 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005335 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005336 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005337 raise Exception("failed obj.can_update")
5338
Scott Baker515dc9e2014-12-22 09:29:05 -08005339 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005340 if (ret.status_code%100 != 200):
5341 raise Exception(ret.data)
5342
5343 return ret
5344
Scott Baker89a7b7c2014-10-07 00:10:17 -07005345
Scott Baker515dc9e2014-12-22 09:29:05 -08005346class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5347 queryset = DeploymentRole.objects.select_related().all()
5348 serializer_class = DeploymentRoleSerializer
5349 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005350
5351 def get_serializer_class(self):
5352 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5353 if (no_hyperlinks):
5354 return self.id_serializer_class
5355 else:
5356 return self.serializer_class
5357
5358 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005359 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005360
5361 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5362
5363 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5364
5365
5366
5367class UserCredentialList(generics.ListCreateAPIView):
5368 queryset = UserCredential.objects.select_related().all()
5369 serializer_class = UserCredentialSerializer
5370 id_serializer_class = UserCredentialIdSerializer
5371 filter_backends = (filters.DjangoFilterBackend,)
5372 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
5373
5374 def get_serializer_class(self):
5375 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5376 if (no_hyperlinks):
5377 return self.id_serializer_class
5378 else:
5379 return self.serializer_class
5380
5381 def get_queryset(self):
5382 return UserCredential.select_by_user(self.request.user)
5383
5384 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005385 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5386 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005387 response = {"error": "validation",
5388 "specific_error": "not serializer.is_valid()",
5389 "reasons": serializer.errors}
5390 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005391 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005392 obj.caller = request.user
5393 if obj.can_update(request.user):
5394 return super(UserCredentialList, self).create(request, *args, **kwargs)
5395 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005396 raise Exception("failed obj.can_update")
5397
5398 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
5399 if (ret.status_code%100 != 200):
5400 raise Exception(ret.data)
5401
5402 return ret
5403
Scott Baker89a7b7c2014-10-07 00:10:17 -07005404
5405class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5406 queryset = UserCredential.objects.select_related().all()
5407 serializer_class = UserCredentialSerializer
5408 id_serializer_class = UserCredentialIdSerializer
5409
5410 def get_serializer_class(self):
5411 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5412 if (no_hyperlinks):
5413 return self.id_serializer_class
5414 else:
5415 return self.serializer_class
5416
5417 def get_queryset(self):
5418 return UserCredential.select_by_user(self.request.user)
5419
5420 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5421
5422 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5423
Scott Baker89a7b7c2014-10-07 00:10:17 -07005424
Scott Baker57c725c2014-11-12 01:13:53 -08005425
Scott Bakerb744f1c2014-11-21 11:32:24 -08005426class SiteDeploymentsList(generics.ListCreateAPIView):
5427 queryset = SiteDeployments.objects.select_related().all()
5428 serializer_class = SiteDeploymentsSerializer
5429 id_serializer_class = SiteDeploymentsIdSerializer
5430 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08005431 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005432
5433 def get_serializer_class(self):
5434 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5435 if (no_hyperlinks):
5436 return self.id_serializer_class
5437 else:
5438 return self.serializer_class
5439
5440 def get_queryset(self):
5441 return SiteDeployments.select_by_user(self.request.user)
5442
5443 def create(self, request, *args, **kwargs):
5444 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5445 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005446 response = {"error": "validation",
5447 "specific_error": "not serializer.is_valid()",
5448 "reasons": serializer.errors}
5449 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08005450 obj = serializer.object
5451 obj.caller = request.user
5452 if obj.can_update(request.user):
5453 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
5454 else:
5455 raise Exception("failed obj.can_update")
5456
5457 ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
5458 if (ret.status_code%100 != 200):
5459 raise Exception(ret.data)
5460
5461 return ret
5462
5463
5464class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5465 queryset = SiteDeployments.objects.select_related().all()
5466 serializer_class = SiteDeploymentsSerializer
5467 id_serializer_class = SiteDeploymentsIdSerializer
5468
5469 def get_serializer_class(self):
5470 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5471 if (no_hyperlinks):
5472 return self.id_serializer_class
5473 else:
5474 return self.serializer_class
5475
5476 def get_queryset(self):
5477 return SiteDeployments.select_by_user(self.request.user)
5478
5479 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5480
5481 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5482
Scott Baker515dc9e2014-12-22 09:29:05 -08005483
5484
Scott Baker0caeaf02014-06-19 11:12:55 -07005485class SliceTagList(generics.ListCreateAPIView):
5486 queryset = SliceTag.objects.select_related().all()
5487 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005488 id_serializer_class = SliceTagIdSerializer
5489 filter_backends = (filters.DjangoFilterBackend,)
5490 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5491
5492 def get_serializer_class(self):
5493 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5494 if (no_hyperlinks):
5495 return self.id_serializer_class
5496 else:
5497 return self.serializer_class
5498
Scott Baker0caeaf02014-06-19 11:12:55 -07005499 def get_queryset(self):
5500 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005501
Scott Baker0caeaf02014-06-19 11:12:55 -07005502 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005503 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5504 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005505 response = {"error": "validation",
5506 "specific_error": "not serializer.is_valid()",
5507 "reasons": serializer.errors}
5508 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005509 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005510 obj.caller = request.user
5511 if obj.can_update(request.user):
5512 return super(SliceTagList, self).create(request, *args, **kwargs)
5513 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005514 raise Exception("failed obj.can_update")
5515
5516 ret = super(SliceTagList, self).create(request, *args, **kwargs)
5517 if (ret.status_code%100 != 200):
5518 raise Exception(ret.data)
5519
5520 return ret
5521
Scott Baker0caeaf02014-06-19 11:12:55 -07005522
Scott Baker89a7b7c2014-10-07 00:10:17 -07005523class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005524 queryset = SliceTag.objects.select_related().all()
5525 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005526 id_serializer_class = SliceTagIdSerializer
5527
5528 def get_serializer_class(self):
5529 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5530 if (no_hyperlinks):
5531 return self.id_serializer_class
5532 else:
5533 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005534
5535 def get_queryset(self):
5536 return SliceTag.select_by_user(self.request.user)
5537
Scott Baker89a7b7c2014-10-07 00:10:17 -07005538 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005539
Scott Baker89a7b7c2014-10-07 00:10:17 -07005540 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005541
5542
5543
Scott Baker515dc9e2014-12-22 09:29:05 -08005544class ControllerDashboardList(generics.ListCreateAPIView):
5545 queryset = ControllerDashboard.objects.select_related().all()
5546 serializer_class = ControllerDashboardSerializer
5547 id_serializer_class = ControllerDashboardIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005548 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08005549 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
Scott Baker46b58542014-08-11 17:26:12 -07005550
5551 def get_serializer_class(self):
5552 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5553 if (no_hyperlinks):
5554 return self.id_serializer_class
5555 else:
5556 return self.serializer_class
5557
Scott Baker0caeaf02014-06-19 11:12:55 -07005558 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005559 return ControllerDashboard.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005560
Scott Baker0caeaf02014-06-19 11:12:55 -07005561 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005562 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5563 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005564 response = {"error": "validation",
5565 "specific_error": "not serializer.is_valid()",
5566 "reasons": serializer.errors}
5567 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005568 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005569 obj.caller = request.user
5570 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005571 return super(ControllerDashboardList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07005572 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005573 raise Exception("failed obj.can_update")
5574
Scott Baker515dc9e2014-12-22 09:29:05 -08005575 ret = super(ControllerDashboardList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005576 if (ret.status_code%100 != 200):
5577 raise Exception(ret.data)
5578
5579 return ret
5580
Scott Baker0caeaf02014-06-19 11:12:55 -07005581
Scott Baker515dc9e2014-12-22 09:29:05 -08005582class ControllerDashboardDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5583 queryset = ControllerDashboard.objects.select_related().all()
5584 serializer_class = ControllerDashboardSerializer
5585 id_serializer_class = ControllerDashboardIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005586
5587 def get_serializer_class(self):
5588 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5589 if (no_hyperlinks):
5590 return self.id_serializer_class
5591 else:
5592 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005593
5594 def get_queryset(self):
Scott Baker515dc9e2014-12-22 09:29:05 -08005595 return ControllerDashboard.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07005596
Scott Baker89a7b7c2014-10-07 00:10:17 -07005597 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005598
Scott Baker89a7b7c2014-10-07 00:10:17 -07005599 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005600
5601
5602
5603class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005604 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005605 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005606 id_serializer_class = RouterIdSerializer
5607 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker515dc9e2014-12-22 09:29:05 -08005608 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07005609
5610 def get_serializer_class(self):
5611 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5612 if (no_hyperlinks):
5613 return self.id_serializer_class
5614 else:
5615 return self.serializer_class
5616
Scott Baker0caeaf02014-06-19 11:12:55 -07005617 def get_queryset(self):
5618 return Router.select_by_user(self.request.user)
5619
5620 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005621 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5622 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005623 response = {"error": "validation",
5624 "specific_error": "not serializer.is_valid()",
5625 "reasons": serializer.errors}
5626 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005627 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005628 obj.caller = request.user
5629 if obj.can_update(request.user):
5630 return super(RouterList, self).create(request, *args, **kwargs)
5631 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005632 raise Exception("failed obj.can_update")
5633
5634 ret = super(RouterList, self).create(request, *args, **kwargs)
5635 if (ret.status_code%100 != 200):
5636 raise Exception(ret.data)
5637
5638 return ret
5639
Sapan Bhatiadea39432014-06-13 03:10:36 -04005640
Scott Baker89a7b7c2014-10-07 00:10:17 -07005641class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005642 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005643 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005644 id_serializer_class = RouterIdSerializer
5645
5646 def get_serializer_class(self):
5647 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5648 if (no_hyperlinks):
5649 return self.id_serializer_class
5650 else:
5651 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005652
5653 def get_queryset(self):
5654 return Router.select_by_user(self.request.user)
5655
Scott Baker89a7b7c2014-10-07 00:10:17 -07005656 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005657
Scott Baker89a7b7c2014-10-07 00:10:17 -07005658 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005659
5660
5661
Scott Baker0caeaf02014-06-19 11:12:55 -07005662class ServiceResourceList(generics.ListCreateAPIView):
5663 queryset = ServiceResource.objects.select_related().all()
5664 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005665 id_serializer_class = ServiceResourceIdSerializer
5666 filter_backends = (filters.DjangoFilterBackend,)
5667 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5668
5669 def get_serializer_class(self):
5670 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5671 if (no_hyperlinks):
5672 return self.id_serializer_class
5673 else:
5674 return self.serializer_class
5675
Scott Baker0caeaf02014-06-19 11:12:55 -07005676 def get_queryset(self):
5677 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005678
Scott Baker0caeaf02014-06-19 11:12:55 -07005679 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005680 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5681 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005682 response = {"error": "validation",
5683 "specific_error": "not serializer.is_valid()",
5684 "reasons": serializer.errors}
5685 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005686 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005687 obj.caller = request.user
5688 if obj.can_update(request.user):
5689 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5690 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005691 raise Exception("failed obj.can_update")
5692
5693 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5694 if (ret.status_code%100 != 200):
5695 raise Exception(ret.data)
5696
5697 return ret
5698
Scott Baker0caeaf02014-06-19 11:12:55 -07005699
Scott Baker89a7b7c2014-10-07 00:10:17 -07005700class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005701 queryset = ServiceResource.objects.select_related().all()
5702 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005703 id_serializer_class = ServiceResourceIdSerializer
5704
5705 def get_serializer_class(self):
5706 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5707 if (no_hyperlinks):
5708 return self.id_serializer_class
5709 else:
5710 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005711
5712 def get_queryset(self):
5713 return ServiceResource.select_by_user(self.request.user)
5714
Scott Baker89a7b7c2014-10-07 00:10:17 -07005715 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005716
Scott Baker89a7b7c2014-10-07 00:10:17 -07005717 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005718
Sapan Bhatiadea39432014-06-13 03:10:36 -04005719
5720
Scott Baker515dc9e2014-12-22 09:29:05 -08005721class ControllerSlicesList(generics.ListCreateAPIView):
5722 queryset = ControllerSlices.objects.select_related().all()
5723 serializer_class = ControllerSlicesSerializer
5724 id_serializer_class = ControllerSlicesIdSerializer
5725 filter_backends = (filters.DjangoFilterBackend,)
5726 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
5727
5728 def get_serializer_class(self):
5729 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5730 if (no_hyperlinks):
5731 return self.id_serializer_class
5732 else:
5733 return self.serializer_class
5734
5735 def get_queryset(self):
5736 return ControllerSlices.select_by_user(self.request.user)
5737
5738 def create(self, request, *args, **kwargs):
5739 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5740 if not (serializer.is_valid()):
5741 response = {"error": "validation",
5742 "specific_error": "not serializer.is_valid()",
5743 "reasons": serializer.errors}
5744 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5745 obj = serializer.object
5746 obj.caller = request.user
5747 if obj.can_update(request.user):
5748 return super(ControllerSlicesList, self).create(request, *args, **kwargs)
5749 else:
5750 raise Exception("failed obj.can_update")
5751
5752 ret = super(ControllerSlicesList, self).create(request, *args, **kwargs)
5753 if (ret.status_code%100 != 200):
5754 raise Exception(ret.data)
5755
5756 return ret
5757
5758
5759class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5760 queryset = ControllerSlices.objects.select_related().all()
5761 serializer_class = ControllerSlicesSerializer
5762 id_serializer_class = ControllerSlicesIdSerializer
5763
5764 def get_serializer_class(self):
5765 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5766 if (no_hyperlinks):
5767 return self.id_serializer_class
5768 else:
5769 return self.serializer_class
5770
5771 def get_queryset(self):
5772 return ControllerSlices.select_by_user(self.request.user)
5773
5774 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5775
5776 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5777
5778
5779