blob: 805a983a051d5c7e40ae46d8583c4c0bd2edf6c8 [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 Bakerdcb9b5d2014-10-07 00:10:17 -07006from rest_framework import status
Scott Bakerf3816ac2014-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 Baker55a2e292014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Sapan Bhatiadea39432014-06-13 03:10:36 -040012
13"""
Scott Baker08898c12014-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 Bakerf3816ac2014-11-12 01:13:53 -080017
Scott Baker08898c12014-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 Baker08898c12014-10-29 23:41:11 -070024 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040025"""
26
Scott Baker55a2e292014-11-10 16:31:15 -080027def get_REST_patterns():
28 return patterns('',
29 url(r'^plstackapi/$', api_root),
30
Scott Bakerc1d11912014-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 Baker55a2e292014-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 Bakerc1d11912014-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 Baker55a2e292014-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 Bakerc1d11912014-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 Baker55a2e292014-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 Baker55a2e292014-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 Bakerc1d11912014-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 Baker55a2e292014-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 Bakerc1d11912014-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 Baker55a2e292014-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 Bakerc1d11912014-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 Baker196ffef2014-11-21 11:32:24 -0800117
Scott Baker55a2e292014-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 Bakerc1d11912014-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
Scott Baker55a2e292014-11-10 16:31:15 -0800124 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
125 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
126
127 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
128 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
129
Scott Bakerc1d11912014-12-22 09:29:05 -0800130 url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'),
131 url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
132
Scott Baker55a2e292014-11-10 16:31:15 -0800133 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
134 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
135
136 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
137 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
138
139 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
140 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
141
142 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
143 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
144
Scott Baker55a2e292014-11-10 16:31:15 -0800145 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
146 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
147
Scott Baker196ffef2014-11-21 11:32:24 -0800148 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
149 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800150
Scott Bakera6a0c772014-12-22 17:35:34 -0800151 url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'),
152 url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'),
153
Scott Baker55a2e292014-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 Bakerc1d11912014-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 Baker55a2e292014-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 Bakerc1d11912014-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 Baker55a2e292014-11-10 16:31:15 -0800168
Scott Bakerc1d11912014-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 Baker55a2e292014-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 Baker196ffef2014-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 Baker196ffef2014-11-21 11:32:24 -0800180
Scott Baker55a2e292014-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 Bakera6a0c772014-12-22 17:35:34 -0800184 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
185 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
Scott Baker55a2e292014-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 Bakerc1d11912014-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 Baker55a2e292014-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 Bakerc1d11912014-12-22 09:29:05 -0800201 'flavors': reverse('flavor-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700202 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800203 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker08898c12014-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 Bakerc1d11912014-12-22 09:29:05 -0800212 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700213 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker08898c12014-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 Bakerc1d11912014-12-22 09:29:05 -0800219 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format),
Scott Baker08898c12014-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 Bakerc1d11912014-12-22 09:29:05 -0800223 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format),
Scott Baker08898c12014-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 Bakerc1d11912014-12-22 09:29:05 -0800229 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700230 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800231 'payments': reverse('payment-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700232 'networkslices': reverse('networkslice-list', request=request, format=format),
233 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800234 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700235 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
236 'users': reverse('user-list', request=request, format=format),
237 'deployments': reverse('deployment-list', request=request, format=format),
238 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700239 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800240 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Bakera6a0c772014-12-22 17:35:34 -0800241 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700242 'accounts': reverse('account-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800243 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700244 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
245 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Bakerc1d11912014-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 Baker08898c12014-10-29 23:41:11 -0700249 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800250 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700251 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Bakera6a0c772014-12-22 17:35:34 -0800252 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700253 'routers': reverse('router-list', request=request, format=format),
254 'serviceresources': reverse('serviceresource-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800255 'controllersliceses': reverse('controllerslices-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700256
Sapan Bhatiadea39432014-06-13 03:10:36 -0400257 })
258
259# Based on serializers.py
260
Scott Bakerc1d11912014-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 Baker08898c12014-10-29 23:41:11 -0700359 id = serializers.Field()
360
Scott Baker196ffef2014-11-21 11:32:24 -0800361 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800362 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800363 def getHumanReadableName(self, obj):
364 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800365 def getValidators(self, obj):
366 try:
367 return obj.getValidators()
368 except:
369 return None
Scott Baker08898c12014-10-29 23:41:11 -0700370 class Meta:
371 model = ServiceAttribute
Scott Baker351148c2014-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 Bakerc1d11912014-12-22 09:29:05 -0800374class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700375 id = serializers.Field()
376
Scott Baker196ffef2014-11-21 11:32:24 -0800377 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800378 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800379 def getHumanReadableName(self, obj):
380 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800381 def getValidators(self, obj):
382 try:
383 return obj.getValidators()
384 except:
385 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800386 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700387 model = ServiceAttribute
Scott Baker351148c2014-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 Bakerc1d11912014-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 Baker08898c12014-10-29 23:41:11 -0700429 id = serializers.Field()
430
Scott Baker93a79a92014-12-22 15:59:33 -0800431
432 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
433
434
Scott Baker196ffef2014-11-21 11:32:24 -0800435 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800436 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800437 def getHumanReadableName(self, obj):
438 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800439 def getValidators(self, obj):
440 try:
441 return obj.getValidators()
442 except:
443 return None
Scott Baker08898c12014-10-29 23:41:11 -0700444 class Meta:
445 model = Image
Scott Baker93a79a92014-12-22 15:59:33 -0800446 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700447
Scott Bakerc1d11912014-12-22 09:29:05 -0800448class ImageIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700449 id = serializers.Field()
450
Scott Baker93a79a92014-12-22 15:59:33 -0800451
452 deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail')
453
454
Scott Baker196ffef2014-11-21 11:32:24 -0800455 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800456 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800457 def getHumanReadableName(self, obj):
458 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800459 def getValidators(self, obj):
460 try:
461 return obj.getValidators()
462 except:
463 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800464 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700465 model = Image
Scott Baker93a79a92014-12-22 15:59:33 -0800466 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700467
468
Sapan Bhatiadea39432014-06-13 03:10:36 -0400469
470
Scott Baker0caeaf02014-06-19 11:12:55 -0700471class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700472 id = serializers.Field()
473
Scott Baker196ffef2014-11-21 11:32:24 -0800474 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800475 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800476 def getHumanReadableName(self, obj):
477 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800478 def getValidators(self, obj):
479 try:
480 return obj.getValidators()
481 except:
482 return None
Scott Baker08898c12014-10-29 23:41:11 -0700483 class Meta:
484 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800485 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700486
Scott Bakerc1d11912014-12-22 09:29:05 -0800487class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700488 id = serializers.Field()
489
Scott Baker196ffef2014-11-21 11:32:24 -0800490 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800491 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800492 def getHumanReadableName(self, obj):
493 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800494 def getValidators(self, obj):
495 try:
496 return obj.getValidators()
497 except:
498 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800499 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700500 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800501 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700502
503
Sapan Bhatiadea39432014-06-13 03:10:36 -0400504
505
506class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700507 id = serializers.Field()
508
Scott Bakerc1d11912014-12-22 09:29:05 -0800509
510 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
511
512
Scott Baker196ffef2014-11-21 11:32:24 -0800513 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800514 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800515 def getHumanReadableName(self, obj):
516 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800517 def getValidators(self, obj):
518 try:
519 return obj.getValidators()
520 except:
521 return None
Scott Baker08898c12014-10-29 23:41:11 -0700522 class Meta:
523 model = Site
Scott Bakerc1d11912014-12-22 09:29:05 -0800524 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 -0700525
Scott Bakerc1d11912014-12-22 09:29:05 -0800526class SiteIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700527 id = serializers.Field()
528
Scott Bakerc1d11912014-12-22 09:29:05 -0800529
530 deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail')
531
532
Scott Baker196ffef2014-11-21 11:32:24 -0800533 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800534 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800535 def getHumanReadableName(self, obj):
536 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800537 def getValidators(self, obj):
538 try:
539 return obj.getValidators()
540 except:
541 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800542 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700543 model = Site
Scott Bakerc1d11912014-12-22 09:29:05 -0800544 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 -0700545
546
Sapan Bhatiadea39432014-06-13 03:10:36 -0400547
548
Scott Baker0caeaf02014-06-19 11:12:55 -0700549class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700550 id = serializers.Field()
551
Scott Baker196ffef2014-11-21 11:32:24 -0800552 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800553 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800554 def getHumanReadableName(self, obj):
555 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800556 def getValidators(self, obj):
557 try:
558 return obj.getValidators()
559 except:
560 return None
Scott Baker08898c12014-10-29 23:41:11 -0700561 class Meta:
562 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800563 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700564
Scott Bakerc1d11912014-12-22 09:29:05 -0800565class SliceRoleIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700566 id = serializers.Field()
567
Scott Baker196ffef2014-11-21 11:32:24 -0800568 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800569 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800570 def getHumanReadableName(self, obj):
571 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800572 def getValidators(self, obj):
573 try:
574 return obj.getValidators()
575 except:
576 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800577 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700578 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800579 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700580
581
Sapan Bhatiadea39432014-06-13 03:10:36 -0400582
583
584class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700585 id = serializers.Field()
586
Scott Baker196ffef2014-11-21 11:32:24 -0800587 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800588 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800589 def getHumanReadableName(self, obj):
590 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800591 def getValidators(self, obj):
592 try:
593 return obj.getValidators()
594 except:
595 return None
Scott Baker08898c12014-10-29 23:41:11 -0700596 class Meta:
597 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800598 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700599
Scott Bakerc1d11912014-12-22 09:29:05 -0800600class TagIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700601 id = serializers.Field()
602
Scott Baker196ffef2014-11-21 11:32:24 -0800603 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800604 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800605 def getHumanReadableName(self, obj):
606 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800607 def getValidators(self, obj):
608 try:
609 return obj.getValidators()
610 except:
611 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800612 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700613 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800614 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700615
616
Sapan Bhatiadea39432014-06-13 03:10:36 -0400617
618
619class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700620 id = serializers.Field()
621
Scott Baker196ffef2014-11-21 11:32:24 -0800622 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800623 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800624 def getHumanReadableName(self, obj):
625 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800626 def getValidators(self, obj):
627 try:
628 return obj.getValidators()
629 except:
630 return None
Scott Baker08898c12014-10-29 23:41:11 -0700631 class Meta:
632 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800633 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700634
Scott Bakerc1d11912014-12-22 09:29:05 -0800635class InvoiceIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700636 id = serializers.Field()
637
Scott Baker196ffef2014-11-21 11:32:24 -0800638 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800639 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800640 def getHumanReadableName(self, obj):
641 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800642 def getValidators(self, obj):
643 try:
644 return obj.getValidators()
645 except:
646 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800647 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700648 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800649 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700650
651
Sapan Bhatiadea39432014-06-13 03:10:36 -0400652
653
Scott Baker0caeaf02014-06-19 11:12:55 -0700654class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700655 id = serializers.Field()
656
Scott Baker196ffef2014-11-21 11:32:24 -0800657 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800658 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800659 def getHumanReadableName(self, obj):
660 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800661 def getValidators(self, obj):
662 try:
663 return obj.getValidators()
664 except:
665 return None
Scott Baker08898c12014-10-29 23:41:11 -0700666 class Meta:
667 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800668 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700669
Scott Bakerc1d11912014-12-22 09:29:05 -0800670class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700671 id = serializers.Field()
672
Scott Baker196ffef2014-11-21 11:32:24 -0800673 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800674 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800675 def getHumanReadableName(self, obj):
676 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800677 def getValidators(self, obj):
678 try:
679 return obj.getValidators()
680 except:
681 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800682 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700683 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800684 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700685
686
Scott Baker0caeaf02014-06-19 11:12:55 -0700687
688
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700689class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700690 id = serializers.Field()
691
Scott Baker196ffef2014-11-21 11:32:24 -0800692 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800693 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800694 def getHumanReadableName(self, obj):
695 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800696 def getValidators(self, obj):
697 try:
698 return obj.getValidators()
699 except:
700 return None
Scott Baker08898c12014-10-29 23:41:11 -0700701 class Meta:
702 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800703 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700704
Scott Bakerc1d11912014-12-22 09:29:05 -0800705class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700706 id = serializers.Field()
707
Scott Baker196ffef2014-11-21 11:32:24 -0800708 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800709 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800710 def getHumanReadableName(self, obj):
711 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800712 def getValidators(self, obj):
713 try:
714 return obj.getValidators()
715 except:
716 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800717 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700718 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800719 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700720
721
722
723
Scott Bakerc1d11912014-12-22 09:29:05 -0800724class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
725 id = serializers.Field()
726
727 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
728 validators = serializers.SerializerMethodField("getValidators")
729 def getHumanReadableName(self, obj):
730 return str(obj)
731 def getValidators(self, obj):
732 try:
733 return obj.getValidators()
734 except:
735 return None
736 class Meta:
737 model = ControllerPrivilege
738 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',)
739
740class ControllerPrivilegeIdSerializer(XOSModelSerializer):
741 id = serializers.Field()
742
743 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
744 validators = serializers.SerializerMethodField("getValidators")
745 def getHumanReadableName(self, obj):
746 return str(obj)
747 def getValidators(self, obj):
748 try:
749 return obj.getValidators()
750 except:
751 return None
752 class Meta:
753 model = ControllerPrivilege
754 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',)
755
756
757
758
Scott Baker0caeaf02014-06-19 11:12:55 -0700759class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700760 id = serializers.Field()
761
Scott Baker196ffef2014-11-21 11:32:24 -0800762 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800763 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800764 def getHumanReadableName(self, obj):
765 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800766 def getValidators(self, obj):
767 try:
768 return obj.getValidators()
769 except:
770 return None
Scott Baker08898c12014-10-29 23:41:11 -0700771 class Meta:
772 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800773 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700774
Scott Bakerc1d11912014-12-22 09:29:05 -0800775class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700776 id = serializers.Field()
777
Scott Baker196ffef2014-11-21 11:32:24 -0800778 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800779 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800780 def getHumanReadableName(self, obj):
781 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800782 def getValidators(self, obj):
783 try:
784 return obj.getValidators()
785 except:
786 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800787 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700788 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800789 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700790
791
Scott Baker0caeaf02014-06-19 11:12:55 -0700792
793
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700794class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700795 id = serializers.Field()
796
Scott Baker196ffef2014-11-21 11:32:24 -0800797 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800798 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800799 def getHumanReadableName(self, obj):
800 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800801 def getValidators(self, obj):
802 try:
803 return obj.getValidators()
804 except:
805 return None
Scott Baker08898c12014-10-29 23:41:11 -0700806 class Meta:
807 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800808 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700809
Scott Bakerc1d11912014-12-22 09:29:05 -0800810class ProjectIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700811 id = serializers.Field()
812
Scott Baker196ffef2014-11-21 11:32:24 -0800813 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800814 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800815 def getHumanReadableName(self, obj):
816 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800817 def getValidators(self, obj):
818 try:
819 return obj.getValidators()
820 except:
821 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800822 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700823 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800824 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700825
826
827
828
Sapan Bhatiadea39432014-06-13 03:10:36 -0400829class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700830 id = serializers.Field()
831
832
833 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
834
835
836
Scott Baker08898c12014-10-29 23:41:11 -0700837 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
838
839
Scott Baker196ffef2014-11-21 11:32:24 -0800840 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800841 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800842 def getHumanReadableName(self, obj):
843 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800844 def getValidators(self, obj):
845 try:
846 return obj.getValidators()
847 except:
848 return None
Scott Baker08898c12014-10-29 23:41:11 -0700849 class Meta:
850 model = Slice
Scott Bakerc1d11912014-12-22 09:29:05 -0800851 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 -0700852
Scott Bakerc1d11912014-12-22 09:29:05 -0800853class SliceIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700854 id = serializers.Field()
855
856
Scott Bakerc1d11912014-12-22 09:29:05 -0800857 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700858
859
860
Scott Bakerc1d11912014-12-22 09:29:05 -0800861 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700862
863
Scott Baker196ffef2014-11-21 11:32:24 -0800864 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800865 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800866 def getHumanReadableName(self, obj):
867 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800868 def getValidators(self, obj):
869 try:
870 return obj.getValidators()
871 except:
872 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800873 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700874 model = Slice
Scott Bakerc1d11912014-12-22 09:29:05 -0800875 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 -0700876
877
Sapan Bhatiadea39432014-06-13 03:10:36 -0400878
879
880class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700881 id = serializers.Field()
882
883
Scott Bakerc1d11912014-12-22 09:29:05 -0800884 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700885
886
887
Scott Bakerc1d11912014-12-22 09:29:05 -0800888 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
889
890
891
892 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700893
894
895
896 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
897
898
899
900 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
901
902
Scott Baker196ffef2014-11-21 11:32:24 -0800903 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800904 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800905 def getHumanReadableName(self, obj):
906 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800907 def getValidators(self, obj):
908 try:
909 return obj.getValidators()
910 except:
911 return None
Scott Baker08898c12014-10-29 23:41:11 -0700912 class Meta:
913 model = Network
Scott Bakerc1d11912014-12-22 09:29:05 -0800914 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 -0700915
Scott Bakerc1d11912014-12-22 09:29:05 -0800916class NetworkIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700917 id = serializers.Field()
918
919
Scott Bakerc1d11912014-12-22 09:29:05 -0800920 slices = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='slice-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700921
922
923
Scott Bakerc1d11912014-12-22 09:29:05 -0800924 slices = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='slice-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700925
926
927
Scott Bakerc1d11912014-12-22 09:29:05 -0800928 slivers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='sliver-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700929
930
931
Scott Bakerc1d11912014-12-22 09:29:05 -0800932 routers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='router-detail')
933
934
935
936 routers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='router-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700937
938
Scott Baker196ffef2014-11-21 11:32:24 -0800939 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800940 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800941 def getHumanReadableName(self, obj):
942 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800943 def getValidators(self, obj):
944 try:
945 return obj.getValidators()
946 except:
947 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800948 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700949 model = Network
Scott Bakerc1d11912014-12-22 09:29:05 -0800950 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 -0700951
952
Sapan Bhatiadea39432014-06-13 03:10:36 -0400953
954
955class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700956 id = serializers.Field()
957
Scott Baker196ffef2014-11-21 11:32:24 -0800958 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800959 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800960 def getHumanReadableName(self, obj):
961 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800962 def getValidators(self, obj):
963 try:
964 return obj.getValidators()
965 except:
966 return None
Scott Baker08898c12014-10-29 23:41:11 -0700967 class Meta:
968 model = Service
Scott Baker351148c2014-11-25 00:53:25 -0800969 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700970
Scott Bakerc1d11912014-12-22 09:29:05 -0800971class ServiceIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700972 id = serializers.Field()
973
Scott Baker196ffef2014-11-21 11:32:24 -0800974 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800975 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800976 def getHumanReadableName(self, obj):
977 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800978 def getValidators(self, obj):
979 try:
980 return obj.getValidators()
981 except:
982 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800983 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700984 model = Service
Scott Baker351148c2014-11-25 00:53:25 -0800985 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700986
987
Sapan Bhatiadea39432014-06-13 03:10:36 -0400988
989
Scott Baker0caeaf02014-06-19 11:12:55 -0700990class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700991 id = serializers.Field()
992
Scott Baker196ffef2014-11-21 11:32:24 -0800993 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800994 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800995 def getHumanReadableName(self, obj):
996 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800997 def getValidators(self, obj):
998 try:
999 return obj.getValidators()
1000 except:
1001 return None
Scott Baker08898c12014-10-29 23:41:11 -07001002 class Meta:
1003 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -08001004 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001005
Scott Bakerc1d11912014-12-22 09:29:05 -08001006class ServiceClassIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001007 id = serializers.Field()
1008
Scott Baker196ffef2014-11-21 11:32:24 -08001009 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001010 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001011 def getHumanReadableName(self, obj):
1012 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001013 def getValidators(self, obj):
1014 try:
1015 return obj.getValidators()
1016 except:
1017 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001018 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001019 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -08001020 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001021
1022
Sapan Bhatiadea39432014-06-13 03:10:36 -04001023
1024
Scott Bakerc1d11912014-12-22 09:29:05 -08001025class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001026 id = serializers.Field()
1027
Scott Baker196ffef2014-11-21 11:32:24 -08001028 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001029 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001030 def getHumanReadableName(self, obj):
1031 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001032 def getValidators(self, obj):
1033 try:
1034 return obj.getValidators()
1035 except:
1036 return None
Scott Baker08898c12014-10-29 23:41:11 -07001037 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001038 model = ControllerNetworks
1039 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 -07001040
Scott Bakerc1d11912014-12-22 09:29:05 -08001041class ControllerNetworksIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001042 id = serializers.Field()
1043
Scott Baker196ffef2014-11-21 11:32:24 -08001044 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001045 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001046 def getHumanReadableName(self, obj):
1047 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001048 def getValidators(self, obj):
1049 try:
1050 return obj.getValidators()
1051 except:
1052 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001053 class Meta:
1054 model = ControllerNetworks
1055 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 -07001056
1057
Sapan Bhatiadea39432014-06-13 03:10:36 -04001058
1059
1060class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001061 id = serializers.Field()
1062
Scott Baker196ffef2014-11-21 11:32:24 -08001063 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001064 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001065 def getHumanReadableName(self, obj):
1066 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001067 def getValidators(self, obj):
1068 try:
1069 return obj.getValidators()
1070 except:
1071 return None
Scott Baker08898c12014-10-29 23:41:11 -07001072 class Meta:
1073 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -08001074 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 -07001075
Scott Bakerc1d11912014-12-22 09:29:05 -08001076class ChargeIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001077 id = serializers.Field()
1078
Scott Baker196ffef2014-11-21 11:32:24 -08001079 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001080 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001081 def getHumanReadableName(self, obj):
1082 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001083 def getValidators(self, obj):
1084 try:
1085 return obj.getValidators()
1086 except:
1087 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001088 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001089 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -08001090 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 -07001091
1092
Sapan Bhatiadea39432014-06-13 03:10:36 -04001093
1094
1095class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001096 id = serializers.Field()
1097
Scott Baker196ffef2014-11-21 11:32:24 -08001098 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001099 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001100 def getHumanReadableName(self, obj):
1101 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001102 def getValidators(self, obj):
1103 try:
1104 return obj.getValidators()
1105 except:
1106 return None
Scott Baker08898c12014-10-29 23:41:11 -07001107 class Meta:
1108 model = Role
Scott Baker351148c2014-11-25 00:53:25 -08001109 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001110
Scott Bakerc1d11912014-12-22 09:29:05 -08001111class RoleIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001112 id = serializers.Field()
1113
Scott Baker196ffef2014-11-21 11:32:24 -08001114 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001115 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001116 def getHumanReadableName(self, obj):
1117 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001118 def getValidators(self, obj):
1119 try:
1120 return obj.getValidators()
1121 except:
1122 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001123 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001124 model = Role
Scott Baker351148c2014-11-25 00:53:25 -08001125 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001126
1127
Sapan Bhatiadea39432014-06-13 03:10:36 -04001128
1129
Scott Baker0caeaf02014-06-19 11:12:55 -07001130class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001131 id = serializers.Field()
1132
Scott Baker196ffef2014-11-21 11:32:24 -08001133 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001134 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001135 def getHumanReadableName(self, obj):
1136 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001137 def getValidators(self, obj):
1138 try:
1139 return obj.getValidators()
1140 except:
1141 return None
Scott Baker08898c12014-10-29 23:41:11 -07001142 class Meta:
1143 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001144 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001145
Scott Bakerc1d11912014-12-22 09:29:05 -08001146class UsableObjectIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001147 id = serializers.Field()
1148
Scott Baker196ffef2014-11-21 11:32:24 -08001149 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001150 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001151 def getHumanReadableName(self, obj):
1152 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001153 def getValidators(self, obj):
1154 try:
1155 return obj.getValidators()
1156 except:
1157 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001158 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001159 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001160 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001161
1162
Sapan Bhatiadea39432014-06-13 03:10:36 -04001163
1164
Scott Bakerc1d11912014-12-22 09:29:05 -08001165class ControllerSiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
1166 id = serializers.Field()
1167
1168 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1169 validators = serializers.SerializerMethodField("getValidators")
1170 def getHumanReadableName(self, obj):
1171 return str(obj)
1172 def getValidators(self, obj):
1173 try:
1174 return obj.getValidators()
1175 except:
1176 return None
1177 class Meta:
1178 model = ControllerSiteDeployments
1179 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
1180
1181class ControllerSiteDeploymentsIdSerializer(XOSModelSerializer):
1182 id = serializers.Field()
1183
1184 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1185 validators = serializers.SerializerMethodField("getValidators")
1186 def getHumanReadableName(self, obj):
1187 return str(obj)
1188 def getValidators(self, obj):
1189 try:
1190 return obj.getValidators()
1191 except:
1192 return None
1193 class Meta:
1194 model = ControllerSiteDeployments
1195 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
1196
1197
1198
1199
Scott Baker0caeaf02014-06-19 11:12:55 -07001200class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001201 id = serializers.Field()
1202
Scott Baker196ffef2014-11-21 11:32:24 -08001203 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001204 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001205 def getHumanReadableName(self, obj):
1206 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001207 def getValidators(self, obj):
1208 try:
1209 return obj.getValidators()
1210 except:
1211 return None
Scott Baker08898c12014-10-29 23:41:11 -07001212 class Meta:
1213 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001214 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001215
Scott Bakerc1d11912014-12-22 09:29:05 -08001216class SiteRoleIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001217 id = serializers.Field()
1218
Scott Baker196ffef2014-11-21 11:32:24 -08001219 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001220 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001221 def getHumanReadableName(self, obj):
1222 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001223 def getValidators(self, obj):
1224 try:
1225 return obj.getValidators()
1226 except:
1227 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001228 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001229 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001230 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001231
1232
Scott Baker0caeaf02014-06-19 11:12:55 -07001233
1234
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001235class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001236 id = serializers.Field()
1237
Scott Baker196ffef2014-11-21 11:32:24 -08001238 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001239 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001240 def getHumanReadableName(self, obj):
1241 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001242 def getValidators(self, obj):
1243 try:
1244 return obj.getValidators()
1245 except:
1246 return None
Scott Baker08898c12014-10-29 23:41:11 -07001247 class Meta:
1248 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001249 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001250
Scott Bakerc1d11912014-12-22 09:29:05 -08001251class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001252 id = serializers.Field()
1253
Scott Baker196ffef2014-11-21 11:32:24 -08001254 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001255 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001256 def getHumanReadableName(self, obj):
1257 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001258 def getValidators(self, obj):
1259 try:
1260 return obj.getValidators()
1261 except:
1262 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001263 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001264 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001265 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001266
1267
1268
1269
Sapan Bhatiadea39432014-06-13 03:10:36 -04001270class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001271 id = serializers.Field()
1272
1273
1274 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1275
1276
Scott Baker196ffef2014-11-21 11:32:24 -08001277 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001278 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001279 def getHumanReadableName(self, obj):
1280 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001281 def getValidators(self, obj):
1282 try:
1283 return obj.getValidators()
1284 except:
1285 return None
Scott Baker08898c12014-10-29 23:41:11 -07001286 class Meta:
1287 model = Sliver
Scott Bakerc1d11912014-12-22 09:29:05 -08001288 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 -07001289
Scott Bakerc1d11912014-12-22 09:29:05 -08001290class SliverIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001291 id = serializers.Field()
1292
1293
Scott Bakerc1d11912014-12-22 09:29:05 -08001294 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
Scott Baker08898c12014-10-29 23:41:11 -07001295
1296
Scott Baker196ffef2014-11-21 11:32:24 -08001297 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001298 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001299 def getHumanReadableName(self, obj):
1300 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001301 def getValidators(self, obj):
1302 try:
1303 return obj.getValidators()
1304 except:
1305 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001306 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001307 model = Sliver
Scott Bakerc1d11912014-12-22 09:29:05 -08001308 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 -07001309
1310
Sapan Bhatiadea39432014-06-13 03:10:36 -04001311
1312
1313class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001314 id = serializers.Field()
1315
Scott Baker196ffef2014-11-21 11:32:24 -08001316 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001317 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001318 def getHumanReadableName(self, obj):
1319 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001320 def getValidators(self, obj):
1321 try:
1322 return obj.getValidators()
1323 except:
1324 return None
Scott Baker08898c12014-10-29 23:41:11 -07001325 class Meta:
1326 model = Node
Scott Bakerc1d11912014-12-22 09:29:05 -08001327 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001328
Scott Bakerc1d11912014-12-22 09:29:05 -08001329class NodeIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001330 id = serializers.Field()
1331
Scott Baker196ffef2014-11-21 11:32:24 -08001332 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001333 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001334 def getHumanReadableName(self, obj):
1335 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001336 def getValidators(self, obj):
1337 try:
1338 return obj.getValidators()
1339 except:
1340 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001341 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001342 model = Node
Scott Bakerc1d11912014-12-22 09:29:05 -08001343 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001344
1345
Sapan Bhatiadea39432014-06-13 03:10:36 -04001346
1347
Scott Baker0caeaf02014-06-19 11:12:55 -07001348class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001349 id = serializers.Field()
1350
Scott Bakerc1d11912014-12-22 09:29:05 -08001351
1352 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1353
1354
Scott Baker196ffef2014-11-21 11:32:24 -08001355 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001356 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001357 def getHumanReadableName(self, obj):
1358 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001359 def getValidators(self, obj):
1360 try:
1361 return obj.getValidators()
1362 except:
1363 return None
Scott Baker08898c12014-10-29 23:41:11 -07001364 class Meta:
1365 model = DashboardView
Scott Bakerc1d11912014-12-22 09:29:05 -08001366 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker46b58542014-08-11 17:26:12 -07001367
Scott Bakerc1d11912014-12-22 09:29:05 -08001368class DashboardViewIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001369 id = serializers.Field()
1370
Scott Bakerc1d11912014-12-22 09:29:05 -08001371
1372 controllers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='controller-detail')
1373
1374
Scott Baker196ffef2014-11-21 11:32:24 -08001375 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001376 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001377 def getHumanReadableName(self, obj):
1378 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001379 def getValidators(self, obj):
1380 try:
1381 return obj.getValidators()
1382 except:
1383 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001384 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001385 model = DashboardView
Scott Bakerc1d11912014-12-22 09:29:05 -08001386 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker196ffef2014-11-21 11:32:24 -08001387
1388
1389
1390
Scott Bakerc1d11912014-12-22 09:29:05 -08001391class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker196ffef2014-11-21 11:32:24 -08001392 id = serializers.Field()
1393
1394 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001395 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001396 def getHumanReadableName(self, obj):
1397 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001398 def getValidators(self, obj):
1399 try:
1400 return obj.getValidators()
1401 except:
1402 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001403 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001404 model = ImageDeployments
1405 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker196ffef2014-11-21 11:32:24 -08001406
Scott Bakerc1d11912014-12-22 09:29:05 -08001407class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Baker196ffef2014-11-21 11:32:24 -08001408 id = serializers.Field()
1409
1410 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001411 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001412 def getHumanReadableName(self, obj):
1413 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001414 def getValidators(self, obj):
1415 try:
1416 return obj.getValidators()
1417 except:
1418 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001419 class Meta:
1420 model = ImageDeployments
1421 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001422
1423
Sapan Bhatiadea39432014-06-13 03:10:36 -04001424
1425
Scott Baker0caeaf02014-06-19 11:12:55 -07001426class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001427 id = serializers.Field()
1428
Scott Baker196ffef2014-11-21 11:32:24 -08001429 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001430 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001431 def getHumanReadableName(self, obj):
1432 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001433 def getValidators(self, obj):
1434 try:
1435 return obj.getValidators()
1436 except:
1437 return None
Scott Baker08898c12014-10-29 23:41:11 -07001438 class Meta:
1439 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001440 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001441
Scott Bakerc1d11912014-12-22 09:29:05 -08001442class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001443 id = serializers.Field()
1444
Scott Baker196ffef2014-11-21 11:32:24 -08001445 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001446 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001447 def getHumanReadableName(self, obj):
1448 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001449 def getValidators(self, obj):
1450 try:
1451 return obj.getValidators()
1452 except:
1453 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001454 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001455 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001456 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001457
1458
1459
1460
Scott Bakerc1d11912014-12-22 09:29:05 -08001461class PaymentSerializer(serializers.HyperlinkedModelSerializer):
1462 id = serializers.Field()
1463
1464 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1465 validators = serializers.SerializerMethodField("getValidators")
1466 def getHumanReadableName(self, obj):
1467 return str(obj)
1468 def getValidators(self, obj):
1469 try:
1470 return obj.getValidators()
1471 except:
1472 return None
1473 class Meta:
1474 model = Payment
1475 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1476
1477class PaymentIdSerializer(XOSModelSerializer):
1478 id = serializers.Field()
1479
1480 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1481 validators = serializers.SerializerMethodField("getValidators")
1482 def getHumanReadableName(self, obj):
1483 return str(obj)
1484 def getValidators(self, obj):
1485 try:
1486 return obj.getValidators()
1487 except:
1488 return None
1489 class Meta:
1490 model = Payment
1491 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1492
1493
1494
1495
Scott Baker0caeaf02014-06-19 11:12:55 -07001496class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001497 id = serializers.Field()
1498
Scott Baker196ffef2014-11-21 11:32:24 -08001499 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001500 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001501 def getHumanReadableName(self, obj):
1502 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001503 def getValidators(self, obj):
1504 try:
1505 return obj.getValidators()
1506 except:
1507 return None
Scott Baker08898c12014-10-29 23:41:11 -07001508 class Meta:
1509 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001510 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001511
Scott Bakerc1d11912014-12-22 09:29:05 -08001512class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001513 id = serializers.Field()
1514
Scott Baker196ffef2014-11-21 11:32:24 -08001515 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001516 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001517 def getHumanReadableName(self, obj):
1518 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001519 def getValidators(self, obj):
1520 try:
1521 return obj.getValidators()
1522 except:
1523 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001524 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001525 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001526 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001527
1528
Scott Baker0caeaf02014-06-19 11:12:55 -07001529
1530
1531class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001532 id = serializers.Field()
1533
Scott Baker196ffef2014-11-21 11:32:24 -08001534 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001535 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001536 def getHumanReadableName(self, obj):
1537 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001538 def getValidators(self, obj):
1539 try:
1540 return obj.getValidators()
1541 except:
1542 return None
Scott Baker08898c12014-10-29 23:41:11 -07001543 class Meta:
1544 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001545 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001546
Scott Bakerc1d11912014-12-22 09:29:05 -08001547class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001548 id = serializers.Field()
1549
Scott Baker196ffef2014-11-21 11:32:24 -08001550 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001551 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001552 def getHumanReadableName(self, obj):
1553 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001554 def getValidators(self, obj):
1555 try:
1556 return obj.getValidators()
1557 except:
Scott Bakerc1d11912014-12-22 09:29:05 -08001558 return None
1559 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001560 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001561 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001562
1563
1564
1565
Scott Bakerc1d11912014-12-22 09:29:05 -08001566class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001567 id = serializers.Field()
1568
Scott Bakerc1d11912014-12-22 09:29:05 -08001569
1570 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1571
1572
Scott Baker196ffef2014-11-21 11:32:24 -08001573 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001574 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerc1d11912014-12-22 09:29:05 -08001575 def getHumanReadableName(self, obj):
Scott Baker196ffef2014-11-21 11:32:24 -08001576 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001577 def getValidators(self, obj):
1578 try:
1579 return obj.getValidators()
1580 except:
1581 return None
Scott Baker08898c12014-10-29 23:41:11 -07001582 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001583 model = Controller
1584 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 -07001585
Scott Bakerc1d11912014-12-22 09:29:05 -08001586class ControllerIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001587 id = serializers.Field()
1588
1589
Scott Bakerc1d11912014-12-22 09:29:05 -08001590 dashboardviews = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='dashboardview-detail')
Scott Baker08898c12014-10-29 23:41:11 -07001591
1592
Scott Baker196ffef2014-11-21 11:32:24 -08001593 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001594 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001595 def getHumanReadableName(self, obj):
1596 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001597 def getValidators(self, obj):
1598 try:
1599 return obj.getValidators()
1600 except:
1601 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001602 class Meta:
1603 model = Controller
1604 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
1605
1606
1607
1608
1609class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1610 id = serializers.Field()
1611
1612 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1613 validators = serializers.SerializerMethodField("getValidators")
1614 def getHumanReadableName(self, obj):
1615 return str(obj)
1616 def getValidators(self, obj):
1617 try:
1618 return obj.getValidators()
1619 except:
1620 return None
1621 class Meta:
1622 model = PlanetStackPrivilege
1623 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1624
1625class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
1626 id = serializers.Field()
1627
1628 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1629 validators = serializers.SerializerMethodField("getValidators")
1630 def getHumanReadableName(self, obj):
1631 return str(obj)
1632 def getValidators(self, obj):
1633 try:
1634 return obj.getValidators()
1635 except:
1636 return None
1637 class Meta:
1638 model = PlanetStackPrivilege
1639 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1640
1641
1642
1643
1644class UserSerializer(serializers.HyperlinkedModelSerializer):
1645 id = serializers.Field()
1646
1647 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1648 validators = serializers.SerializerMethodField("getValidators")
1649 def getHumanReadableName(self, obj):
1650 return str(obj)
1651 def getValidators(self, obj):
1652 try:
1653 return obj.getValidators()
1654 except:
1655 return None
1656 class Meta:
1657 model = User
1658 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',)
1659
1660class UserIdSerializer(XOSModelSerializer):
1661 id = serializers.Field()
1662
1663 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1664 validators = serializers.SerializerMethodField("getValidators")
1665 def getHumanReadableName(self, obj):
1666 return str(obj)
1667 def getValidators(self, obj):
1668 try:
1669 return obj.getValidators()
1670 except:
1671 return None
1672 class Meta:
1673 model = User
1674 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',)
1675
1676
1677
1678
1679class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
1680 id = serializers.Field()
1681
1682
1683 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1684
1685
1686
Scott Baker93a79a92014-12-22 15:59:33 -08001687 images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1688
1689
1690
Scott Bakerc1d11912014-12-22 09:29:05 -08001691 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1692
1693
1694 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1695 validators = serializers.SerializerMethodField("getValidators")
1696 def getHumanReadableName(self, obj):
1697 return str(obj)
1698 def getValidators(self, obj):
1699 try:
1700 return obj.getValidators()
1701 except:
1702 return None
Scott Baker08898c12014-10-29 23:41:11 -07001703 class Meta:
1704 model = Deployment
Scott Baker93a79a92014-12-22 15:59:33 -08001705 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Scott Baker46b58542014-08-11 17:26:12 -07001706
Scott Bakerc1d11912014-12-22 09:29:05 -08001707class DeploymentIdSerializer(XOSModelSerializer):
Tony Mack336e0f92014-11-30 15:53:08 -05001708 id = serializers.Field()
Scott Bakerc1d11912014-12-22 09:29:05 -08001709
1710
1711 flavors = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='flavor-detail')
1712
1713
1714
Scott Baker93a79a92014-12-22 15:59:33 -08001715 images = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='image-detail')
1716
1717
1718
Scott Bakerc1d11912014-12-22 09:29:05 -08001719 sites = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='site-detail')
1720
1721
Tony Mack336e0f92014-11-30 15:53:08 -05001722 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1723 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerc1d11912014-12-22 09:29:05 -08001724 def getHumanReadableName(self, obj):
1725 return str(obj)
1726 def getValidators(self, obj):
Tony Mack336e0f92014-11-30 15:53:08 -05001727 try:
1728 return obj.getValidators()
1729 except:
Scott Bakerc1d11912014-12-22 09:29:05 -08001730 return None
1731 class Meta:
1732 model = Deployment
Scott Baker93a79a92014-12-22 15:59:33 -08001733 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Tony Mack336e0f92014-11-30 15:53:08 -05001734
1735
Sapan Bhatiadea39432014-06-13 03:10:36 -04001736
1737
1738class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001739 id = serializers.Field()
1740
Scott Baker196ffef2014-11-21 11:32:24 -08001741 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001742 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001743 def getHumanReadableName(self, obj):
1744 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001745 def getValidators(self, obj):
1746 try:
1747 return obj.getValidators()
1748 except:
1749 return None
Scott Baker08898c12014-10-29 23:41:11 -07001750 class Meta:
1751 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001752 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001753
Scott Bakerc1d11912014-12-22 09:29:05 -08001754class ReservationIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001755 id = serializers.Field()
1756
Scott Baker196ffef2014-11-21 11:32:24 -08001757 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001758 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001759 def getHumanReadableName(self, obj):
1760 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001761 def getValidators(self, obj):
1762 try:
1763 return obj.getValidators()
1764 except:
1765 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001766 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001767 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001768 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001769
1770
Scott Baker0caeaf02014-06-19 11:12:55 -07001771
1772
Scott Baker196ffef2014-11-21 11:32:24 -08001773class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1774 id = serializers.Field()
1775
1776 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001777 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001778 def getHumanReadableName(self, obj):
1779 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001780 def getValidators(self, obj):
1781 try:
1782 return obj.getValidators()
1783 except:
1784 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001785 class Meta:
1786 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001787 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001788
Scott Bakerc1d11912014-12-22 09:29:05 -08001789class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Baker196ffef2014-11-21 11:32:24 -08001790 id = serializers.Field()
1791
1792 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001793 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001794 def getHumanReadableName(self, obj):
1795 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001796 def getValidators(self, obj):
1797 try:
1798 return obj.getValidators()
1799 except:
1800 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001801 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -08001802 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001803 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001804
1805
1806
1807
1808class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
1809 id = serializers.Field()
1810
1811 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001812 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001813 def getHumanReadableName(self, obj):
1814 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001815 def getValidators(self, obj):
1816 try:
1817 return obj.getValidators()
1818 except:
1819 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001820 class Meta:
1821 model = PlanetStack
Scott Baker351148c2014-11-25 00:53:25 -08001822 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker196ffef2014-11-21 11:32:24 -08001823
Scott Bakerc1d11912014-12-22 09:29:05 -08001824class PlanetStackIdSerializer(XOSModelSerializer):
Scott Baker196ffef2014-11-21 11:32:24 -08001825 id = serializers.Field()
1826
1827 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001828 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001829 def getHumanReadableName(self, obj):
1830 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001831 def getValidators(self, obj):
1832 try:
1833 return obj.getValidators()
1834 except:
1835 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001836 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -08001837 model = PlanetStack
Scott Baker351148c2014-11-25 00:53:25 -08001838 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001839
1840
Sapan Bhatiadea39432014-06-13 03:10:36 -04001841
1842
Scott Bakera6a0c772014-12-22 17:35:34 -08001843class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
1844 id = serializers.Field()
1845
1846 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1847 validators = serializers.SerializerMethodField("getValidators")
1848 def getHumanReadableName(self, obj):
1849 return str(obj)
1850 def getValidators(self, obj):
1851 try:
1852 return obj.getValidators()
1853 except:
1854 return None
1855 class Meta:
1856 model = ControllerDashboardView
1857 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1858
1859class ControllerDashboardViewIdSerializer(XOSModelSerializer):
1860 id = serializers.Field()
1861
1862 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1863 validators = serializers.SerializerMethodField("getValidators")
1864 def getHumanReadableName(self, obj):
1865 return str(obj)
1866 def getValidators(self, obj):
1867 try:
1868 return obj.getValidators()
1869 except:
1870 return None
1871 class Meta:
1872 model = ControllerDashboardView
1873 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1874
1875
1876
1877
Sapan Bhatiadea39432014-06-13 03:10:36 -04001878class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001879 id = serializers.Field()
1880
Scott Baker196ffef2014-11-21 11:32:24 -08001881 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001882 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001883 def getHumanReadableName(self, obj):
1884 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001885 def getValidators(self, obj):
1886 try:
1887 return obj.getValidators()
1888 except:
1889 return None
Scott Baker08898c12014-10-29 23:41:11 -07001890 class Meta:
1891 model = Account
Scott Baker351148c2014-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
Scott Bakerc1d11912014-12-22 09:29:05 -08001894class AccountIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001895 id = serializers.Field()
1896
Scott Baker196ffef2014-11-21 11:32:24 -08001897 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001898 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001899 def getHumanReadableName(self, obj):
1900 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001901 def getValidators(self, obj):
1902 try:
1903 return obj.getValidators()
1904 except:
1905 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001906 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001907 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001908 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001909
1910
Sapan Bhatiadea39432014-06-13 03:10:36 -04001911
1912
Scott Bakerc1d11912014-12-22 09:29:05 -08001913class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
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
1929class ControllerRoleIdSerializer(XOSModelSerializer):
1930 id = serializers.Field()
1931
1932 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1933 validators = serializers.SerializerMethodField("getValidators")
1934 def getHumanReadableName(self, obj):
1935 return str(obj)
1936 def getValidators(self, obj):
1937 try:
1938 return obj.getValidators()
1939 except:
1940 return None
1941 class Meta:
1942 model = ControllerRole
1943 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1944
1945
1946
1947
Scott Baker0caeaf02014-06-19 11:12:55 -07001948class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001949 id = serializers.Field()
1950
Scott Baker196ffef2014-11-21 11:32:24 -08001951 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001952 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001953 def getHumanReadableName(self, obj):
1954 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001955 def getValidators(self, obj):
1956 try:
1957 return obj.getValidators()
1958 except:
1959 return None
Scott Baker08898c12014-10-29 23:41:11 -07001960 class Meta:
1961 model = NetworkParameterType
Scott Baker351148c2014-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
Scott Bakerc1d11912014-12-22 09:29:05 -08001964class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001965 id = serializers.Field()
1966
Scott Baker196ffef2014-11-21 11:32:24 -08001967 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001968 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001969 def getHumanReadableName(self, obj):
1970 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001971 def getValidators(self, obj):
1972 try:
1973 return obj.getValidators()
1974 except:
1975 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001976 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001977 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08001978 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001979
1980
Sapan Bhatiadea39432014-06-13 03:10:36 -04001981
1982
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001983class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001984 id = serializers.Field()
1985
Scott Baker196ffef2014-11-21 11:32:24 -08001986 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001987 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001988 def getHumanReadableName(self, obj):
1989 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001990 def getValidators(self, obj):
1991 try:
1992 return obj.getValidators()
1993 except:
1994 return None
Scott Baker08898c12014-10-29 23:41:11 -07001995 class Meta:
1996 model = SiteCredential
Scott Baker351148c2014-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
Scott Bakerc1d11912014-12-22 09:29:05 -08001999class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002000 id = serializers.Field()
2001
Scott Baker196ffef2014-11-21 11:32:24 -08002002 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002003 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002004 def getHumanReadableName(self, obj):
2005 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002006 def getValidators(self, obj):
2007 try:
2008 return obj.getValidators()
2009 except:
2010 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002011 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002012 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08002013 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002014
2015
Scott Baker0caeaf02014-06-19 11:12:55 -07002016
2017
Scott Bakerc1d11912014-12-22 09:29:05 -08002018class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002019 id = serializers.Field()
2020
Scott Baker196ffef2014-11-21 11:32:24 -08002021 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002022 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002023 def getHumanReadableName(self, obj):
2024 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002025 def getValidators(self, obj):
2026 try:
2027 return obj.getValidators()
2028 except:
2029 return None
Scott Baker08898c12014-10-29 23:41:11 -07002030 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08002031 model = DeploymentPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08002032 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002033
Scott Bakerc1d11912014-12-22 09:29:05 -08002034class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002035 id = serializers.Field()
2036
Scott Baker196ffef2014-11-21 11:32:24 -08002037 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002038 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002039 def getHumanReadableName(self, obj):
2040 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002041 def getValidators(self, obj):
2042 try:
2043 return obj.getValidators()
2044 except:
2045 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002046 class Meta:
2047 model = DeploymentPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08002048 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker645dc9d2014-11-17 22:32:19 -08002049
2050
2051
2052
Scott Bakerc1d11912014-12-22 09:29:05 -08002053class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002054 id = serializers.Field()
2055
Scott Baker196ffef2014-11-21 11:32:24 -08002056 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002057 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002058 def getHumanReadableName(self, obj):
2059 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002060 def getValidators(self, obj):
2061 try:
2062 return obj.getValidators()
2063 except:
2064 return None
Scott Baker08898c12014-10-29 23:41:11 -07002065 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08002066 model = ControllerUsers
2067 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2068
2069class ControllerUsersIdSerializer(XOSModelSerializer):
2070 id = serializers.Field()
2071
2072 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2073 validators = serializers.SerializerMethodField("getValidators")
2074 def getHumanReadableName(self, obj):
2075 return str(obj)
2076 def getValidators(self, obj):
2077 try:
2078 return obj.getValidators()
2079 except:
2080 return None
2081 class Meta:
2082 model = ControllerUsers
2083 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2084
2085
2086
2087
2088class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
2089 id = serializers.Field()
2090
2091 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2092 validators = serializers.SerializerMethodField("getValidators")
2093 def getHumanReadableName(self, obj):
2094 return str(obj)
2095 def getValidators(self, obj):
2096 try:
2097 return obj.getValidators()
2098 except:
2099 return None
2100 class Meta:
2101 model = DeploymentRole
Scott Baker351148c2014-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
Scott Bakerc1d11912014-12-22 09:29:05 -08002104class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002105 id = serializers.Field()
2106
Scott Baker196ffef2014-11-21 11:32:24 -08002107 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002108 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002109 def getHumanReadableName(self, obj):
2110 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002111 def getValidators(self, obj):
2112 try:
2113 return obj.getValidators()
2114 except:
2115 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002116 class Meta:
2117 model = DeploymentRole
Scott Baker351148c2014-11-25 00:53:25 -08002118 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002119
2120
Sapan Bhatiadea39432014-06-13 03:10:36 -04002121
2122
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002123class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002124 id = serializers.Field()
2125
Scott Baker196ffef2014-11-21 11:32:24 -08002126 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002127 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002128 def getHumanReadableName(self, obj):
2129 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002130 def getValidators(self, obj):
2131 try:
2132 return obj.getValidators()
2133 except:
2134 return None
Scott Baker08898c12014-10-29 23:41:11 -07002135 class Meta:
2136 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08002137 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002138
Scott Bakerc1d11912014-12-22 09:29:05 -08002139class UserCredentialIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002140 id = serializers.Field()
2141
Scott Baker196ffef2014-11-21 11:32:24 -08002142 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002143 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002144 def getHumanReadableName(self, obj):
2145 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002146 def getValidators(self, obj):
2147 try:
2148 return obj.getValidators()
2149 except:
2150 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002151 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002152 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08002153 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker196ffef2014-11-21 11:32:24 -08002154
2155
2156
2157
2158class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
2159 id = serializers.Field()
2160
2161 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002162 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002163 def getHumanReadableName(self, obj):
2164 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002165 def getValidators(self, obj):
2166 try:
2167 return obj.getValidators()
2168 except:
2169 return None
Scott Baker196ffef2014-11-21 11:32:24 -08002170 class Meta:
2171 model = SiteDeployments
Scott Bakerc1d11912014-12-22 09:29:05 -08002172 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker196ffef2014-11-21 11:32:24 -08002173
Scott Bakerc1d11912014-12-22 09:29:05 -08002174class SiteDeploymentsIdSerializer(XOSModelSerializer):
Scott Baker196ffef2014-11-21 11:32:24 -08002175 id = serializers.Field()
2176
2177 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002178 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002179 def getHumanReadableName(self, obj):
2180 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002181 def getValidators(self, obj):
2182 try:
2183 return obj.getValidators()
2184 except:
2185 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002186 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -08002187 model = SiteDeployments
Scott Bakerc1d11912014-12-22 09:29:05 -08002188 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
2189
2190
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002191
2192
Scott Baker0caeaf02014-06-19 11:12:55 -07002193class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002194 id = serializers.Field()
2195
Scott Baker196ffef2014-11-21 11:32:24 -08002196 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002197 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002198 def getHumanReadableName(self, obj):
2199 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002200 def getValidators(self, obj):
2201 try:
2202 return obj.getValidators()
2203 except:
2204 return None
Scott Baker08898c12014-10-29 23:41:11 -07002205 class Meta:
2206 model = SliceTag
Scott Baker351148c2014-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
Scott Bakerc1d11912014-12-22 09:29:05 -08002209class SliceTagIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002210 id = serializers.Field()
2211
Scott Baker196ffef2014-11-21 11:32:24 -08002212 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002213 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002214 def getHumanReadableName(self, obj):
2215 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002216 def getValidators(self, obj):
2217 try:
2218 return obj.getValidators()
2219 except:
2220 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002221 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002222 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08002223 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002224
2225
Scott Baker0caeaf02014-06-19 11:12:55 -07002226
2227
Scott Bakera6a0c772014-12-22 17:35:34 -08002228class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002229 id = serializers.Field()
2230
Scott Baker196ffef2014-11-21 11:32:24 -08002231 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002232 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002233 def getHumanReadableName(self, obj):
2234 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002235 def getValidators(self, obj):
2236 try:
2237 return obj.getValidators()
2238 except:
2239 return None
Scott Baker08898c12014-10-29 23:41:11 -07002240 class Meta:
Scott Bakera6a0c772014-12-22 17:35:34 -08002241 model = NetworkTemplate
2242 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07002243
Scott Bakera6a0c772014-12-22 17:35:34 -08002244class NetworkTemplateIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002245 id = serializers.Field()
2246
Scott Baker196ffef2014-11-21 11:32:24 -08002247 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002248 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002249 def getHumanReadableName(self, obj):
2250 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002251 def getValidators(self, obj):
2252 try:
2253 return obj.getValidators()
2254 except:
2255 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002256 class Meta:
Scott Bakera6a0c772014-12-22 17:35:34 -08002257 model = NetworkTemplate
2258 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07002259
2260
Sapan Bhatiadea39432014-06-13 03:10:36 -04002261
2262
2263class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002264 id = serializers.Field()
2265
Scott Bakerc1d11912014-12-22 09:29:05 -08002266
2267 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2268
2269
2270
2271 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2272
2273
Scott Baker196ffef2014-11-21 11:32:24 -08002274 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002275 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002276 def getHumanReadableName(self, obj):
2277 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002278 def getValidators(self, obj):
2279 try:
2280 return obj.getValidators()
2281 except:
2282 return None
Scott Baker08898c12014-10-29 23:41:11 -07002283 class Meta:
2284 model = Router
Scott Bakerc1d11912014-12-22 09:29:05 -08002285 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002286
Scott Bakerc1d11912014-12-22 09:29:05 -08002287class RouterIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002288 id = serializers.Field()
2289
Scott Bakerc1d11912014-12-22 09:29:05 -08002290
2291 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
2292
2293
2294
2295 networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail')
2296
2297
Scott Baker196ffef2014-11-21 11:32:24 -08002298 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002299 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002300 def getHumanReadableName(self, obj):
2301 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002302 def getValidators(self, obj):
2303 try:
2304 return obj.getValidators()
2305 except:
2306 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002307 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002308 model = Router
Scott Bakerc1d11912014-12-22 09:29:05 -08002309 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002310
2311
Sapan Bhatiadea39432014-06-13 03:10:36 -04002312
2313
Scott Baker0caeaf02014-06-19 11:12:55 -07002314class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002315 id = serializers.Field()
2316
Scott Baker196ffef2014-11-21 11:32:24 -08002317 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002318 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002319 def getHumanReadableName(self, obj):
2320 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002321 def getValidators(self, obj):
2322 try:
2323 return obj.getValidators()
2324 except:
2325 return None
Scott Baker08898c12014-10-29 23:41:11 -07002326 class Meta:
2327 model = ServiceResource
Scott Baker351148c2014-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
Scott Bakerc1d11912014-12-22 09:29:05 -08002330class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002331 id = serializers.Field()
2332
Scott Baker196ffef2014-11-21 11:32:24 -08002333 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002334 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002335 def getHumanReadableName(self, obj):
2336 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002337 def getValidators(self, obj):
2338 try:
2339 return obj.getValidators()
2340 except:
2341 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002342 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002343 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002344 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 -07002345
2346
Sapan Bhatiadea39432014-06-13 03:10:36 -04002347
2348
Scott Bakerc1d11912014-12-22 09:29:05 -08002349class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer):
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
2365class ControllerSlicesIdSerializer(XOSModelSerializer):
2366 id = serializers.Field()
2367
2368 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2369 validators = serializers.SerializerMethodField("getValidators")
2370 def getHumanReadableName(self, obj):
2371 return str(obj)
2372 def getValidators(self, obj):
2373 try:
2374 return obj.getValidators()
2375 except:
2376 return None
2377 class Meta:
2378 model = ControllerSlices
2379 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2380
2381
2382
2383
Sapan Bhatiadea39432014-06-13 03:10:36 -04002384serializerLookUp = {
2385
Scott Bakerc1d11912014-12-22 09:29:05 -08002386 Flavor: FlavorSerializer,
2387
Scott Baker0caeaf02014-06-19 11:12:55 -07002388 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002389
Scott Bakerc1d11912014-12-22 09:29:05 -08002390 ControllerImages: ControllerImagesSerializer,
2391
Sapan Bhatiadea39432014-06-13 03:10:36 -04002392 Image: ImageSerializer,
2393
Scott Baker0caeaf02014-06-19 11:12:55 -07002394 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002395
2396 Site: SiteSerializer,
2397
Scott Baker0caeaf02014-06-19 11:12:55 -07002398 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002399
2400 Tag: TagSerializer,
2401
2402 Invoice: InvoiceSerializer,
2403
Scott Baker0caeaf02014-06-19 11:12:55 -07002404 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002405
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002406 PlanetStackRole: PlanetStackRoleSerializer,
2407
Scott Bakerc1d11912014-12-22 09:29:05 -08002408 ControllerPrivilege: ControllerPrivilegeSerializer,
2409
Scott Baker0caeaf02014-06-19 11:12:55 -07002410 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002411
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002412 Project: ProjectSerializer,
2413
Sapan Bhatiadea39432014-06-13 03:10:36 -04002414 Slice: SliceSerializer,
2415
2416 Network: NetworkSerializer,
2417
2418 Service: ServiceSerializer,
2419
Scott Baker0caeaf02014-06-19 11:12:55 -07002420 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002421
Scott Bakerc1d11912014-12-22 09:29:05 -08002422 ControllerNetworks: ControllerNetworksSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002423
2424 Charge: ChargeSerializer,
2425
2426 Role: RoleSerializer,
2427
Scott Baker0caeaf02014-06-19 11:12:55 -07002428 UsableObject: UsableObjectSerializer,
2429
Scott Bakerc1d11912014-12-22 09:29:05 -08002430 ControllerSiteDeployments: ControllerSiteDeploymentsSerializer,
2431
Scott Baker0caeaf02014-06-19 11:12:55 -07002432 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002433
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002434 SliceCredential: SliceCredentialSerializer,
2435
Sapan Bhatiadea39432014-06-13 03:10:36 -04002436 Sliver: SliverSerializer,
2437
2438 Node: NodeSerializer,
2439
Scott Baker0caeaf02014-06-19 11:12:55 -07002440 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002441
Scott Bakerc1d11912014-12-22 09:29:05 -08002442 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002443
Scott Baker196ffef2014-11-21 11:32:24 -08002444 ReservedResource: ReservedResourceSerializer,
Scott Baker645dc9d2014-11-17 22:32:19 -08002445
Scott Bakerc1d11912014-12-22 09:29:05 -08002446 Payment: PaymentSerializer,
2447
Scott Baker0caeaf02014-06-19 11:12:55 -07002448 NetworkSlice: NetworkSliceSerializer,
2449
2450 UserDashboardView: UserDashboardViewSerializer,
2451
Scott Bakerc1d11912014-12-22 09:29:05 -08002452 Controller: ControllerSerializer,
2453
Scott Baker0caeaf02014-06-19 11:12:55 -07002454 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002455
2456 User: UserSerializer,
2457
2458 Deployment: DeploymentSerializer,
2459
2460 Reservation: ReservationSerializer,
2461
Scott Baker0caeaf02014-06-19 11:12:55 -07002462 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002463
Scott Baker196ffef2014-11-21 11:32:24 -08002464 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002465
Scott Bakera6a0c772014-12-22 17:35:34 -08002466 ControllerDashboardView: ControllerDashboardViewSerializer,
2467
Sapan Bhatiadea39432014-06-13 03:10:36 -04002468 Account: AccountSerializer,
2469
Scott Bakerc1d11912014-12-22 09:29:05 -08002470 ControllerRole: ControllerRoleSerializer,
2471
Scott Baker0caeaf02014-06-19 11:12:55 -07002472 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002473
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002474 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002475
Scott Bakerc1d11912014-12-22 09:29:05 -08002476 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002477
Scott Bakerc1d11912014-12-22 09:29:05 -08002478 ControllerUsers: ControllerUsersSerializer,
2479
2480 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002481
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002482 UserCredential: UserCredentialSerializer,
2483
Scott Baker196ffef2014-11-21 11:32:24 -08002484 SiteDeployments: SiteDeploymentsSerializer,
2485
Scott Baker0caeaf02014-06-19 11:12:55 -07002486 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002487
Scott Bakera6a0c772014-12-22 17:35:34 -08002488 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002489
2490 Router: RouterSerializer,
2491
Scott Baker0caeaf02014-06-19 11:12:55 -07002492 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002493
Scott Bakerc1d11912014-12-22 09:29:05 -08002494 ControllerSlices: ControllerSlicesSerializer,
2495
Sapan Bhatiadea39432014-06-13 03:10:36 -04002496 None: None,
2497 }
2498
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002499class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2500
2501 # To handle fine-grained field permissions, we have to check can_update
2502 # the object has been updated but before it has been saved.
2503
2504 def update(self, request, *args, **kwargs):
2505 partial = kwargs.pop('partial', False)
2506 self.object = self.get_object_or_none()
2507
2508 serializer = self.get_serializer(self.object, data=request.DATA,
2509 files=request.FILES, partial=partial)
2510
2511 if not serializer.is_valid():
Scott Baker351148c2014-11-25 00:53:25 -08002512 response = {"error": "validation",
2513 "specific_error": "not serializer.is_valid()",
2514 "reasons": serializer.errors}
2515 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002516
2517 try:
2518 self.pre_save(serializer.object)
2519 except ValidationError as err:
2520 # full_clean on model instance may be called in pre_save,
2521 # so we have to handle eventual errors.
Scott Baker351148c2014-11-25 00:53:25 -08002522 response = {"error": "validation",
2523 "specific_error": "ValidationError in pre_save",
2524 "reasons": err.message_dict}
2525 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002526
2527 if serializer.object is not None:
2528 if not serializer.object.can_update(request.user):
2529 return Response(status=status.HTTP_400_BAD_REQUEST)
2530
2531 if self.object is None:
2532 self.object = serializer.save(force_insert=True)
2533 self.post_save(self.object, created=True)
2534 return Response(serializer.data, status=status.HTTP_201_CREATED)
2535
2536 self.object = serializer.save(force_update=True)
2537 self.post_save(self.object, created=False)
2538 return Response(serializer.data, status=status.HTTP_200_OK)
2539
2540 def destroy(self, request, *args, **kwargs):
2541 obj = self.get_object()
2542 if obj.can_update(request.user):
Scott Baker08898c12014-10-29 23:41:11 -07002543 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002544 else:
2545 return Response(status=status.HTTP_400_BAD_REQUEST)
2546
2547
Sapan Bhatiadea39432014-06-13 03:10:36 -04002548# Based on core/views/*.py
2549
2550
Scott Bakerc1d11912014-12-22 09:29:05 -08002551class FlavorList(generics.ListCreateAPIView):
2552 queryset = Flavor.objects.select_related().all()
2553 serializer_class = FlavorSerializer
2554 id_serializer_class = FlavorIdSerializer
2555 filter_backends = (filters.DjangoFilterBackend,)
2556 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
2557
2558 def get_serializer_class(self):
2559 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2560 if (no_hyperlinks):
2561 return self.id_serializer_class
2562 else:
2563 return self.serializer_class
2564
2565 def get_queryset(self):
2566 return Flavor.select_by_user(self.request.user)
2567
2568 def create(self, request, *args, **kwargs):
2569 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2570 if not (serializer.is_valid()):
2571 response = {"error": "validation",
2572 "specific_error": "not serializer.is_valid()",
2573 "reasons": serializer.errors}
2574 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2575 obj = serializer.object
2576 obj.caller = request.user
2577 if obj.can_update(request.user):
2578 return super(FlavorList, self).create(request, *args, **kwargs)
2579 else:
2580 raise Exception("failed obj.can_update")
2581
2582 ret = super(FlavorList, self).create(request, *args, **kwargs)
2583 if (ret.status_code%100 != 200):
2584 raise Exception(ret.data)
2585
2586 return ret
2587
2588
2589class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2590 queryset = Flavor.objects.select_related().all()
2591 serializer_class = FlavorSerializer
2592 id_serializer_class = FlavorIdSerializer
2593
2594 def get_serializer_class(self):
2595 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2596 if (no_hyperlinks):
2597 return self.id_serializer_class
2598 else:
2599 return self.serializer_class
2600
2601 def get_queryset(self):
2602 return Flavor.select_by_user(self.request.user)
2603
2604 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2605
2606 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2607
2608
2609
Scott Baker0caeaf02014-06-19 11:12:55 -07002610class ServiceAttributeList(generics.ListCreateAPIView):
2611 queryset = ServiceAttribute.objects.select_related().all()
2612 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002613 id_serializer_class = ServiceAttributeIdSerializer
2614 filter_backends = (filters.DjangoFilterBackend,)
2615 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2616
2617 def get_serializer_class(self):
2618 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2619 if (no_hyperlinks):
2620 return self.id_serializer_class
2621 else:
2622 return self.serializer_class
2623
Scott Baker0caeaf02014-06-19 11:12:55 -07002624 def get_queryset(self):
2625 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002626
Scott Baker0caeaf02014-06-19 11:12:55 -07002627 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002628 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2629 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002630 response = {"error": "validation",
2631 "specific_error": "not serializer.is_valid()",
2632 "reasons": serializer.errors}
2633 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002634 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002635 obj.caller = request.user
2636 if obj.can_update(request.user):
2637 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2638 else:
Scott Baker08898c12014-10-29 23:41:11 -07002639 raise Exception("failed obj.can_update")
2640
2641 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2642 if (ret.status_code%100 != 200):
2643 raise Exception(ret.data)
2644
2645 return ret
2646
Scott Baker0caeaf02014-06-19 11:12:55 -07002647
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002648class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002649 queryset = ServiceAttribute.objects.select_related().all()
2650 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002651 id_serializer_class = ServiceAttributeIdSerializer
2652
2653 def get_serializer_class(self):
2654 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2655 if (no_hyperlinks):
2656 return self.id_serializer_class
2657 else:
2658 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002659
2660 def get_queryset(self):
2661 return ServiceAttribute.select_by_user(self.request.user)
2662
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002663 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002664
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002665 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002666
2667
2668
Scott Bakerc1d11912014-12-22 09:29:05 -08002669class ControllerImagesList(generics.ListCreateAPIView):
2670 queryset = ControllerImages.objects.select_related().all()
2671 serializer_class = ControllerImagesSerializer
2672 id_serializer_class = ControllerImagesIdSerializer
2673 filter_backends = (filters.DjangoFilterBackend,)
2674 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
2675
2676 def get_serializer_class(self):
2677 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2678 if (no_hyperlinks):
2679 return self.id_serializer_class
2680 else:
2681 return self.serializer_class
2682
2683 def get_queryset(self):
2684 return ControllerImages.select_by_user(self.request.user)
2685
2686 def create(self, request, *args, **kwargs):
2687 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2688 if not (serializer.is_valid()):
2689 response = {"error": "validation",
2690 "specific_error": "not serializer.is_valid()",
2691 "reasons": serializer.errors}
2692 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2693 obj = serializer.object
2694 obj.caller = request.user
2695 if obj.can_update(request.user):
2696 return super(ControllerImagesList, self).create(request, *args, **kwargs)
2697 else:
2698 raise Exception("failed obj.can_update")
2699
2700 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2701 if (ret.status_code%100 != 200):
2702 raise Exception(ret.data)
2703
2704 return ret
2705
2706
2707class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2708 queryset = ControllerImages.objects.select_related().all()
2709 serializer_class = ControllerImagesSerializer
2710 id_serializer_class = ControllerImagesIdSerializer
2711
2712 def get_serializer_class(self):
2713 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2714 if (no_hyperlinks):
2715 return self.id_serializer_class
2716 else:
2717 return self.serializer_class
2718
2719 def get_queryset(self):
2720 return ControllerImages.select_by_user(self.request.user)
2721
2722 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2723
2724 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2725
2726
2727
Sapan Bhatiadea39432014-06-13 03:10:36 -04002728class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002729 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002730 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002731 id_serializer_class = ImageIdSerializer
2732 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker93a79a92014-12-22 15:59:33 -08002733 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002734
2735 def get_serializer_class(self):
2736 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2737 if (no_hyperlinks):
2738 return self.id_serializer_class
2739 else:
2740 return self.serializer_class
2741
Scott Baker0caeaf02014-06-19 11:12:55 -07002742 def get_queryset(self):
2743 return Image.select_by_user(self.request.user)
2744
2745 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002746 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2747 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002748 response = {"error": "validation",
2749 "specific_error": "not serializer.is_valid()",
2750 "reasons": serializer.errors}
2751 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002752 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002753 obj.caller = request.user
2754 if obj.can_update(request.user):
2755 return super(ImageList, self).create(request, *args, **kwargs)
2756 else:
Scott Baker08898c12014-10-29 23:41:11 -07002757 raise Exception("failed obj.can_update")
2758
2759 ret = super(ImageList, self).create(request, *args, **kwargs)
2760 if (ret.status_code%100 != 200):
2761 raise Exception(ret.data)
2762
2763 return ret
2764
Sapan Bhatiadea39432014-06-13 03:10:36 -04002765
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002766class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002767 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002768 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002769 id_serializer_class = ImageIdSerializer
2770
2771 def get_serializer_class(self):
2772 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2773 if (no_hyperlinks):
2774 return self.id_serializer_class
2775 else:
2776 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002777
2778 def get_queryset(self):
2779 return Image.select_by_user(self.request.user)
2780
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002781 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002782
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002783 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002784
2785
2786
Scott Baker0caeaf02014-06-19 11:12:55 -07002787class NetworkParameterList(generics.ListCreateAPIView):
2788 queryset = NetworkParameter.objects.select_related().all()
2789 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002790 id_serializer_class = NetworkParameterIdSerializer
2791 filter_backends = (filters.DjangoFilterBackend,)
2792 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2793
2794 def get_serializer_class(self):
2795 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2796 if (no_hyperlinks):
2797 return self.id_serializer_class
2798 else:
2799 return self.serializer_class
2800
Scott Baker0caeaf02014-06-19 11:12:55 -07002801 def get_queryset(self):
2802 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002803
Scott Baker0caeaf02014-06-19 11:12:55 -07002804 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002805 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2806 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002807 response = {"error": "validation",
2808 "specific_error": "not serializer.is_valid()",
2809 "reasons": serializer.errors}
2810 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002811 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002812 obj.caller = request.user
2813 if obj.can_update(request.user):
2814 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2815 else:
Scott Baker08898c12014-10-29 23:41:11 -07002816 raise Exception("failed obj.can_update")
2817
2818 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2819 if (ret.status_code%100 != 200):
2820 raise Exception(ret.data)
2821
2822 return ret
2823
Scott Baker0caeaf02014-06-19 11:12:55 -07002824
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002825class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002826 queryset = NetworkParameter.objects.select_related().all()
2827 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002828 id_serializer_class = NetworkParameterIdSerializer
2829
2830 def get_serializer_class(self):
2831 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2832 if (no_hyperlinks):
2833 return self.id_serializer_class
2834 else:
2835 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002836
2837 def get_queryset(self):
2838 return NetworkParameter.select_by_user(self.request.user)
2839
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002840 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002841
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002842 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002843
2844
2845
2846class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002847 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002848 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002849 id_serializer_class = SiteIdSerializer
2850 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08002851 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 -07002852
2853 def get_serializer_class(self):
2854 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2855 if (no_hyperlinks):
2856 return self.id_serializer_class
2857 else:
2858 return self.serializer_class
2859
Scott Baker0caeaf02014-06-19 11:12:55 -07002860 def get_queryset(self):
2861 return Site.select_by_user(self.request.user)
2862
2863 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002864 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2865 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002866 response = {"error": "validation",
2867 "specific_error": "not serializer.is_valid()",
2868 "reasons": serializer.errors}
2869 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002870 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002871 obj.caller = request.user
2872 if obj.can_update(request.user):
2873 return super(SiteList, self).create(request, *args, **kwargs)
2874 else:
Scott Baker08898c12014-10-29 23:41:11 -07002875 raise Exception("failed obj.can_update")
2876
2877 ret = super(SiteList, self).create(request, *args, **kwargs)
2878 if (ret.status_code%100 != 200):
2879 raise Exception(ret.data)
2880
2881 return ret
2882
Sapan Bhatiadea39432014-06-13 03:10:36 -04002883
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002884class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002885 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002886 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002887 id_serializer_class = SiteIdSerializer
2888
2889 def get_serializer_class(self):
2890 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2891 if (no_hyperlinks):
2892 return self.id_serializer_class
2893 else:
2894 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002895
2896 def get_queryset(self):
2897 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002898
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002899 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002900
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002901 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002902
2903
2904
2905class SliceRoleList(generics.ListCreateAPIView):
2906 queryset = SliceRole.objects.select_related().all()
2907 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002908 id_serializer_class = SliceRoleIdSerializer
2909 filter_backends = (filters.DjangoFilterBackend,)
2910 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2911
2912 def get_serializer_class(self):
2913 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2914 if (no_hyperlinks):
2915 return self.id_serializer_class
2916 else:
2917 return self.serializer_class
2918
Scott Baker0caeaf02014-06-19 11:12:55 -07002919 def get_queryset(self):
2920 return SliceRole.select_by_user(self.request.user)
2921
2922 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002923 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2924 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002925 response = {"error": "validation",
2926 "specific_error": "not serializer.is_valid()",
2927 "reasons": serializer.errors}
2928 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002929 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002930 obj.caller = request.user
2931 if obj.can_update(request.user):
2932 return super(SliceRoleList, self).create(request, *args, **kwargs)
2933 else:
Scott Baker08898c12014-10-29 23:41:11 -07002934 raise Exception("failed obj.can_update")
2935
2936 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2937 if (ret.status_code%100 != 200):
2938 raise Exception(ret.data)
2939
2940 return ret
2941
Scott Baker0caeaf02014-06-19 11:12:55 -07002942
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002943class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002944 queryset = SliceRole.objects.select_related().all()
2945 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002946 id_serializer_class = SliceRoleIdSerializer
2947
2948 def get_serializer_class(self):
2949 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2950 if (no_hyperlinks):
2951 return self.id_serializer_class
2952 else:
2953 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002954
2955 def get_queryset(self):
2956 return SliceRole.select_by_user(self.request.user)
2957
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002958 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002959
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002960 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002961
2962
2963
2964class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002965 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002966 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002967 id_serializer_class = TagIdSerializer
2968 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002969 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002970
2971 def get_serializer_class(self):
2972 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2973 if (no_hyperlinks):
2974 return self.id_serializer_class
2975 else:
2976 return self.serializer_class
2977
Scott Baker0caeaf02014-06-19 11:12:55 -07002978 def get_queryset(self):
2979 return Tag.select_by_user(self.request.user)
2980
2981 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002982 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2983 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002984 response = {"error": "validation",
2985 "specific_error": "not serializer.is_valid()",
2986 "reasons": serializer.errors}
2987 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002988 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002989 obj.caller = request.user
2990 if obj.can_update(request.user):
2991 return super(TagList, self).create(request, *args, **kwargs)
2992 else:
Scott Baker08898c12014-10-29 23:41:11 -07002993 raise Exception("failed obj.can_update")
2994
2995 ret = super(TagList, self).create(request, *args, **kwargs)
2996 if (ret.status_code%100 != 200):
2997 raise Exception(ret.data)
2998
2999 return ret
3000
Sapan Bhatiadea39432014-06-13 03:10:36 -04003001
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003002class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003003 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003004 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003005 id_serializer_class = TagIdSerializer
3006
3007 def get_serializer_class(self):
3008 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3009 if (no_hyperlinks):
3010 return self.id_serializer_class
3011 else:
3012 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003013
3014 def get_queryset(self):
3015 return Tag.select_by_user(self.request.user)
3016
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003017 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003018
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003019 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003020
3021
3022
3023class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003024 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003025 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003026 id_serializer_class = InvoiceIdSerializer
3027 filter_backends = (filters.DjangoFilterBackend,)
3028 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
3029
3030 def get_serializer_class(self):
3031 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3032 if (no_hyperlinks):
3033 return self.id_serializer_class
3034 else:
3035 return self.serializer_class
3036
Scott Baker0caeaf02014-06-19 11:12:55 -07003037 def get_queryset(self):
3038 return Invoice.select_by_user(self.request.user)
3039
3040 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003041 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3042 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003043 response = {"error": "validation",
3044 "specific_error": "not serializer.is_valid()",
3045 "reasons": serializer.errors}
3046 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003047 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003048 obj.caller = request.user
3049 if obj.can_update(request.user):
3050 return super(InvoiceList, self).create(request, *args, **kwargs)
3051 else:
Scott Baker08898c12014-10-29 23:41:11 -07003052 raise Exception("failed obj.can_update")
3053
3054 ret = super(InvoiceList, self).create(request, *args, **kwargs)
3055 if (ret.status_code%100 != 200):
3056 raise Exception(ret.data)
3057
3058 return ret
3059
Sapan Bhatiadea39432014-06-13 03:10:36 -04003060
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003061class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003062 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003063 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003064 id_serializer_class = InvoiceIdSerializer
3065
3066 def get_serializer_class(self):
3067 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3068 if (no_hyperlinks):
3069 return self.id_serializer_class
3070 else:
3071 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003072
3073 def get_queryset(self):
3074 return Invoice.select_by_user(self.request.user)
3075
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003076 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003077
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003078 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003079
3080
3081
Scott Baker0caeaf02014-06-19 11:12:55 -07003082class SlicePrivilegeList(generics.ListCreateAPIView):
3083 queryset = SlicePrivilege.objects.select_related().all()
3084 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003085 id_serializer_class = SlicePrivilegeIdSerializer
3086 filter_backends = (filters.DjangoFilterBackend,)
3087 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
3088
3089 def get_serializer_class(self):
3090 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3091 if (no_hyperlinks):
3092 return self.id_serializer_class
3093 else:
3094 return self.serializer_class
3095
Scott Baker0caeaf02014-06-19 11:12:55 -07003096 def get_queryset(self):
3097 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003098
Scott Baker0caeaf02014-06-19 11:12:55 -07003099 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003100 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3101 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003102 response = {"error": "validation",
3103 "specific_error": "not serializer.is_valid()",
3104 "reasons": serializer.errors}
3105 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003106 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003107 obj.caller = request.user
3108 if obj.can_update(request.user):
3109 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3110 else:
Scott Baker08898c12014-10-29 23:41:11 -07003111 raise Exception("failed obj.can_update")
3112
3113 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3114 if (ret.status_code%100 != 200):
3115 raise Exception(ret.data)
3116
3117 return ret
3118
Scott Baker0caeaf02014-06-19 11:12:55 -07003119
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003120class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003121 queryset = SlicePrivilege.objects.select_related().all()
3122 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003123 id_serializer_class = SlicePrivilegeIdSerializer
3124
3125 def get_serializer_class(self):
3126 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3127 if (no_hyperlinks):
3128 return self.id_serializer_class
3129 else:
3130 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003131
3132 def get_queryset(self):
3133 return SlicePrivilege.select_by_user(self.request.user)
3134
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003135 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3136
3137 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3138
3139
3140
3141class PlanetStackRoleList(generics.ListCreateAPIView):
3142 queryset = PlanetStackRole.objects.select_related().all()
3143 serializer_class = PlanetStackRoleSerializer
3144 id_serializer_class = PlanetStackRoleIdSerializer
3145 filter_backends = (filters.DjangoFilterBackend,)
3146 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3147
3148 def get_serializer_class(self):
3149 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3150 if (no_hyperlinks):
3151 return self.id_serializer_class
3152 else:
3153 return self.serializer_class
3154
3155 def get_queryset(self):
3156 return PlanetStackRole.select_by_user(self.request.user)
3157
3158 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003159 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3160 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003161 response = {"error": "validation",
3162 "specific_error": "not serializer.is_valid()",
3163 "reasons": serializer.errors}
3164 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003165 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003166 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003167 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003168 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003169 else:
Scott Baker08898c12014-10-29 23:41:11 -07003170 raise Exception("failed obj.can_update")
3171
3172 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3173 if (ret.status_code%100 != 200):
3174 raise Exception(ret.data)
3175
3176 return ret
3177
Scott Baker0caeaf02014-06-19 11:12:55 -07003178
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003179class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3180 queryset = PlanetStackRole.objects.select_related().all()
3181 serializer_class = PlanetStackRoleSerializer
3182 id_serializer_class = PlanetStackRoleIdSerializer
3183
3184 def get_serializer_class(self):
3185 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3186 if (no_hyperlinks):
3187 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003188 else:
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003189 return self.serializer_class
3190
3191 def get_queryset(self):
3192 return PlanetStackRole.select_by_user(self.request.user)
3193
3194 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3195
3196 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003197
3198
3199
Scott Bakerc1d11912014-12-22 09:29:05 -08003200class ControllerPrivilegeList(generics.ListCreateAPIView):
3201 queryset = ControllerPrivilege.objects.select_related().all()
3202 serializer_class = ControllerPrivilegeSerializer
3203 id_serializer_class = ControllerPrivilegeIdSerializer
3204 filter_backends = (filters.DjangoFilterBackend,)
3205 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','role',)
3206
3207 def get_serializer_class(self):
3208 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3209 if (no_hyperlinks):
3210 return self.id_serializer_class
3211 else:
3212 return self.serializer_class
3213
3214 def get_queryset(self):
3215 return ControllerPrivilege.select_by_user(self.request.user)
3216
3217 def create(self, request, *args, **kwargs):
3218 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3219 if not (serializer.is_valid()):
3220 response = {"error": "validation",
3221 "specific_error": "not serializer.is_valid()",
3222 "reasons": serializer.errors}
3223 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3224 obj = serializer.object
3225 obj.caller = request.user
3226 if obj.can_update(request.user):
3227 return super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
3228 else:
3229 raise Exception("failed obj.can_update")
3230
3231 ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
3232 if (ret.status_code%100 != 200):
3233 raise Exception(ret.data)
3234
3235 return ret
3236
3237
3238class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3239 queryset = ControllerPrivilege.objects.select_related().all()
3240 serializer_class = ControllerPrivilegeSerializer
3241 id_serializer_class = ControllerPrivilegeIdSerializer
3242
3243 def get_serializer_class(self):
3244 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3245 if (no_hyperlinks):
3246 return self.id_serializer_class
3247 else:
3248 return self.serializer_class
3249
3250 def get_queryset(self):
3251 return ControllerPrivilege.select_by_user(self.request.user)
3252
3253 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3254
3255 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3256
3257
3258
Scott Baker0caeaf02014-06-19 11:12:55 -07003259class NetworkSliverList(generics.ListCreateAPIView):
3260 queryset = NetworkSliver.objects.select_related().all()
3261 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003262 id_serializer_class = NetworkSliverIdSerializer
3263 filter_backends = (filters.DjangoFilterBackend,)
3264 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
3265
3266 def get_serializer_class(self):
3267 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3268 if (no_hyperlinks):
3269 return self.id_serializer_class
3270 else:
3271 return self.serializer_class
3272
Scott Baker0caeaf02014-06-19 11:12:55 -07003273 def get_queryset(self):
3274 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003275
Scott Baker0caeaf02014-06-19 11:12:55 -07003276 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003277 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3278 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003279 response = {"error": "validation",
3280 "specific_error": "not serializer.is_valid()",
3281 "reasons": serializer.errors}
3282 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003283 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003284 obj.caller = request.user
3285 if obj.can_update(request.user):
3286 return super(NetworkSliverList, self).create(request, *args, **kwargs)
3287 else:
Scott Baker08898c12014-10-29 23:41:11 -07003288 raise Exception("failed obj.can_update")
3289
3290 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3291 if (ret.status_code%100 != 200):
3292 raise Exception(ret.data)
3293
3294 return ret
3295
Scott Baker0caeaf02014-06-19 11:12:55 -07003296
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003297class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003298 queryset = NetworkSliver.objects.select_related().all()
3299 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003300 id_serializer_class = NetworkSliverIdSerializer
3301
3302 def get_serializer_class(self):
3303 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3304 if (no_hyperlinks):
3305 return self.id_serializer_class
3306 else:
3307 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003308
3309 def get_queryset(self):
3310 return NetworkSliver.select_by_user(self.request.user)
3311
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003312 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003313
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003314 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003315
3316
3317
Scott Baker0caeaf02014-06-19 11:12:55 -07003318class ProjectList(generics.ListCreateAPIView):
3319 queryset = Project.objects.select_related().all()
3320 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003321 id_serializer_class = ProjectIdSerializer
3322 filter_backends = (filters.DjangoFilterBackend,)
3323 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3324
3325 def get_serializer_class(self):
3326 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3327 if (no_hyperlinks):
3328 return self.id_serializer_class
3329 else:
3330 return self.serializer_class
3331
Scott Baker0caeaf02014-06-19 11:12:55 -07003332 def get_queryset(self):
3333 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003334
Scott Baker0caeaf02014-06-19 11:12:55 -07003335 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003336 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3337 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003338 response = {"error": "validation",
3339 "specific_error": "not serializer.is_valid()",
3340 "reasons": serializer.errors}
3341 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003342 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003343 obj.caller = request.user
3344 if obj.can_update(request.user):
3345 return super(ProjectList, self).create(request, *args, **kwargs)
3346 else:
Scott Baker08898c12014-10-29 23:41:11 -07003347 raise Exception("failed obj.can_update")
3348
3349 ret = super(ProjectList, self).create(request, *args, **kwargs)
3350 if (ret.status_code%100 != 200):
3351 raise Exception(ret.data)
3352
3353 return ret
3354
Scott Baker0caeaf02014-06-19 11:12:55 -07003355
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003356class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003357 queryset = Project.objects.select_related().all()
3358 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003359 id_serializer_class = ProjectIdSerializer
3360
3361 def get_serializer_class(self):
3362 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3363 if (no_hyperlinks):
3364 return self.id_serializer_class
3365 else:
3366 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003367
3368 def get_queryset(self):
3369 return Project.select_by_user(self.request.user)
3370
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003371 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3372
3373 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3374
3375
3376
3377class SliceList(generics.ListCreateAPIView):
3378 queryset = Slice.objects.select_related().all()
3379 serializer_class = SliceSerializer
3380 id_serializer_class = SliceIdSerializer
3381 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08003382 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 Bakerdcb9b5d2014-10-07 00:10:17 -07003383
3384 def get_serializer_class(self):
3385 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3386 if (no_hyperlinks):
3387 return self.id_serializer_class
3388 else:
3389 return self.serializer_class
3390
3391 def get_queryset(self):
3392 return Slice.select_by_user(self.request.user)
3393
3394 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003395 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3396 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003397 response = {"error": "validation",
3398 "specific_error": "not serializer.is_valid()",
3399 "reasons": serializer.errors}
3400 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003401 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003402 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003403 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003404 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003405 else:
Scott Baker08898c12014-10-29 23:41:11 -07003406 raise Exception("failed obj.can_update")
3407
3408 ret = super(SliceList, self).create(request, *args, **kwargs)
3409 if (ret.status_code%100 != 200):
3410 raise Exception(ret.data)
3411
3412 return ret
3413
Scott Baker0caeaf02014-06-19 11:12:55 -07003414
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003415class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3416 queryset = Slice.objects.select_related().all()
3417 serializer_class = SliceSerializer
3418 id_serializer_class = SliceIdSerializer
3419
3420 def get_serializer_class(self):
3421 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3422 if (no_hyperlinks):
3423 return self.id_serializer_class
3424 else:
3425 return self.serializer_class
3426
3427 def get_queryset(self):
3428 return Slice.select_by_user(self.request.user)
3429
3430 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3431
3432 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3433
3434
3435
3436class NetworkList(generics.ListCreateAPIView):
3437 queryset = Network.objects.select_related().all()
3438 serializer_class = NetworkSerializer
3439 id_serializer_class = NetworkIdSerializer
3440 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08003441 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 Bakerdcb9b5d2014-10-07 00:10:17 -07003442
3443 def get_serializer_class(self):
3444 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3445 if (no_hyperlinks):
3446 return self.id_serializer_class
3447 else:
3448 return self.serializer_class
3449
3450 def get_queryset(self):
3451 return Network.select_by_user(self.request.user)
3452
3453 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003454 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3455 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003456 response = {"error": "validation",
3457 "specific_error": "not serializer.is_valid()",
3458 "reasons": serializer.errors}
3459 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003460 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003461 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003462 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003463 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003464 else:
Scott Baker08898c12014-10-29 23:41:11 -07003465 raise Exception("failed obj.can_update")
3466
3467 ret = super(NetworkList, self).create(request, *args, **kwargs)
3468 if (ret.status_code%100 != 200):
3469 raise Exception(ret.data)
3470
3471 return ret
3472
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003473
3474class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3475 queryset = Network.objects.select_related().all()
3476 serializer_class = NetworkSerializer
3477 id_serializer_class = NetworkIdSerializer
3478
3479 def get_serializer_class(self):
3480 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3481 if (no_hyperlinks):
3482 return self.id_serializer_class
3483 else:
3484 return self.serializer_class
3485
3486 def get_queryset(self):
3487 return Network.select_by_user(self.request.user)
3488
3489 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3490
3491 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3492
3493
3494
3495class ServiceList(generics.ListCreateAPIView):
3496 queryset = Service.objects.select_related().all()
3497 serializer_class = ServiceSerializer
3498 id_serializer_class = ServiceIdSerializer
3499 filter_backends = (filters.DjangoFilterBackend,)
3500 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3501
3502 def get_serializer_class(self):
3503 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3504 if (no_hyperlinks):
3505 return self.id_serializer_class
3506 else:
3507 return self.serializer_class
3508
3509 def get_queryset(self):
3510 return Service.select_by_user(self.request.user)
3511
3512 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003513 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3514 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003515 response = {"error": "validation",
3516 "specific_error": "not serializer.is_valid()",
3517 "reasons": serializer.errors}
3518 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003519 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003520 obj.caller = request.user
3521 if obj.can_update(request.user):
3522 return super(ServiceList, self).create(request, *args, **kwargs)
3523 else:
Scott Baker08898c12014-10-29 23:41:11 -07003524 raise Exception("failed obj.can_update")
3525
3526 ret = super(ServiceList, self).create(request, *args, **kwargs)
3527 if (ret.status_code%100 != 200):
3528 raise Exception(ret.data)
3529
3530 return ret
3531
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003532
3533class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3534 queryset = Service.objects.select_related().all()
3535 serializer_class = ServiceSerializer
3536 id_serializer_class = ServiceIdSerializer
3537
3538 def get_serializer_class(self):
3539 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3540 if (no_hyperlinks):
3541 return self.id_serializer_class
3542 else:
3543 return self.serializer_class
3544
3545 def get_queryset(self):
3546 return Service.select_by_user(self.request.user)
3547
3548 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3549
3550 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3551
3552
3553
3554class ServiceClassList(generics.ListCreateAPIView):
3555 queryset = ServiceClass.objects.select_related().all()
3556 serializer_class = ServiceClassSerializer
3557 id_serializer_class = ServiceClassIdSerializer
3558 filter_backends = (filters.DjangoFilterBackend,)
3559 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3560
3561 def get_serializer_class(self):
3562 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3563 if (no_hyperlinks):
3564 return self.id_serializer_class
3565 else:
3566 return self.serializer_class
3567
3568 def get_queryset(self):
3569 return ServiceClass.select_by_user(self.request.user)
3570
3571 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003572 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3573 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003574 response = {"error": "validation",
3575 "specific_error": "not serializer.is_valid()",
3576 "reasons": serializer.errors}
3577 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003578 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003579 obj.caller = request.user
3580 if obj.can_update(request.user):
3581 return super(ServiceClassList, self).create(request, *args, **kwargs)
3582 else:
Scott Baker08898c12014-10-29 23:41:11 -07003583 raise Exception("failed obj.can_update")
3584
3585 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3586 if (ret.status_code%100 != 200):
3587 raise Exception(ret.data)
3588
3589 return ret
3590
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003591
3592class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3593 queryset = ServiceClass.objects.select_related().all()
3594 serializer_class = ServiceClassSerializer
3595 id_serializer_class = ServiceClassIdSerializer
3596
3597 def get_serializer_class(self):
3598 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3599 if (no_hyperlinks):
3600 return self.id_serializer_class
3601 else:
3602 return self.serializer_class
3603
3604 def get_queryset(self):
3605 return ServiceClass.select_by_user(self.request.user)
3606
3607 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3608
3609 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3610
3611
3612
Scott Bakerc1d11912014-12-22 09:29:05 -08003613class ControllerNetworksList(generics.ListCreateAPIView):
3614 queryset = ControllerNetworks.objects.select_related().all()
3615 serializer_class = ControllerNetworksSerializer
3616 id_serializer_class = ControllerNetworksIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003617 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08003618 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003619
3620 def get_serializer_class(self):
3621 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3622 if (no_hyperlinks):
3623 return self.id_serializer_class
3624 else:
3625 return self.serializer_class
3626
3627 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08003628 return ControllerNetworks.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003629
3630 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003631 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3632 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003633 response = {"error": "validation",
3634 "specific_error": "not serializer.is_valid()",
3635 "reasons": serializer.errors}
3636 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003637 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003638 obj.caller = request.user
3639 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08003640 return super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003641 else:
Scott Baker08898c12014-10-29 23:41:11 -07003642 raise Exception("failed obj.can_update")
3643
Scott Bakerc1d11912014-12-22 09:29:05 -08003644 ret = super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003645 if (ret.status_code%100 != 200):
3646 raise Exception(ret.data)
3647
3648 return ret
3649
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003650
Scott Bakerc1d11912014-12-22 09:29:05 -08003651class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3652 queryset = ControllerNetworks.objects.select_related().all()
3653 serializer_class = ControllerNetworksSerializer
3654 id_serializer_class = ControllerNetworksIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003655
3656 def get_serializer_class(self):
3657 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3658 if (no_hyperlinks):
3659 return self.id_serializer_class
3660 else:
3661 return self.serializer_class
3662
3663 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08003664 return ControllerNetworks.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003665
3666 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3667
3668 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3669
3670
3671
3672class ChargeList(generics.ListCreateAPIView):
3673 queryset = Charge.objects.select_related().all()
3674 serializer_class = ChargeSerializer
3675 id_serializer_class = ChargeIdSerializer
3676 filter_backends = (filters.DjangoFilterBackend,)
3677 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3678
3679 def get_serializer_class(self):
3680 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3681 if (no_hyperlinks):
3682 return self.id_serializer_class
3683 else:
3684 return self.serializer_class
3685
3686 def get_queryset(self):
3687 return Charge.select_by_user(self.request.user)
3688
3689 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003690 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3691 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003692 response = {"error": "validation",
3693 "specific_error": "not serializer.is_valid()",
3694 "reasons": serializer.errors}
3695 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003696 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003697 obj.caller = request.user
3698 if obj.can_update(request.user):
3699 return super(ChargeList, self).create(request, *args, **kwargs)
3700 else:
Scott Baker08898c12014-10-29 23:41:11 -07003701 raise Exception("failed obj.can_update")
3702
3703 ret = super(ChargeList, self).create(request, *args, **kwargs)
3704 if (ret.status_code%100 != 200):
3705 raise Exception(ret.data)
3706
3707 return ret
3708
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003709
3710class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3711 queryset = Charge.objects.select_related().all()
3712 serializer_class = ChargeSerializer
3713 id_serializer_class = ChargeIdSerializer
3714
3715 def get_serializer_class(self):
3716 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3717 if (no_hyperlinks):
3718 return self.id_serializer_class
3719 else:
3720 return self.serializer_class
3721
3722 def get_queryset(self):
3723 return Charge.select_by_user(self.request.user)
3724
3725 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3726
3727 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3728
3729
3730
3731class RoleList(generics.ListCreateAPIView):
3732 queryset = Role.objects.select_related().all()
3733 serializer_class = RoleSerializer
3734 id_serializer_class = RoleIdSerializer
3735 filter_backends = (filters.DjangoFilterBackend,)
3736 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3737
3738 def get_serializer_class(self):
3739 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3740 if (no_hyperlinks):
3741 return self.id_serializer_class
3742 else:
3743 return self.serializer_class
3744
3745 def get_queryset(self):
3746 return Role.select_by_user(self.request.user)
3747
3748 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003749 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3750 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003751 response = {"error": "validation",
3752 "specific_error": "not serializer.is_valid()",
3753 "reasons": serializer.errors}
3754 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003755 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003756 obj.caller = request.user
3757 if obj.can_update(request.user):
3758 return super(RoleList, self).create(request, *args, **kwargs)
3759 else:
Scott Baker08898c12014-10-29 23:41:11 -07003760 raise Exception("failed obj.can_update")
3761
3762 ret = super(RoleList, self).create(request, *args, **kwargs)
3763 if (ret.status_code%100 != 200):
3764 raise Exception(ret.data)
3765
3766 return ret
3767
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003768
3769class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3770 queryset = Role.objects.select_related().all()
3771 serializer_class = RoleSerializer
3772 id_serializer_class = RoleIdSerializer
3773
3774 def get_serializer_class(self):
3775 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3776 if (no_hyperlinks):
3777 return self.id_serializer_class
3778 else:
3779 return self.serializer_class
3780
3781 def get_queryset(self):
3782 return Role.select_by_user(self.request.user)
3783
3784 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3785
3786 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3787
3788
3789
3790class UsableObjectList(generics.ListCreateAPIView):
3791 queryset = UsableObject.objects.select_related().all()
3792 serializer_class = UsableObjectSerializer
3793 id_serializer_class = UsableObjectIdSerializer
3794 filter_backends = (filters.DjangoFilterBackend,)
3795 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3796
3797 def get_serializer_class(self):
3798 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3799 if (no_hyperlinks):
3800 return self.id_serializer_class
3801 else:
3802 return self.serializer_class
3803
3804 def get_queryset(self):
3805 return UsableObject.select_by_user(self.request.user)
3806
3807 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003808 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3809 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003810 response = {"error": "validation",
3811 "specific_error": "not serializer.is_valid()",
3812 "reasons": serializer.errors}
3813 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003814 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003815 obj.caller = request.user
3816 if obj.can_update(request.user):
3817 return super(UsableObjectList, self).create(request, *args, **kwargs)
3818 else:
Scott Baker08898c12014-10-29 23:41:11 -07003819 raise Exception("failed obj.can_update")
3820
3821 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3822 if (ret.status_code%100 != 200):
3823 raise Exception(ret.data)
3824
3825 return ret
3826
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003827
3828class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3829 queryset = UsableObject.objects.select_related().all()
3830 serializer_class = UsableObjectSerializer
3831 id_serializer_class = UsableObjectIdSerializer
3832
3833 def get_serializer_class(self):
3834 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3835 if (no_hyperlinks):
3836 return self.id_serializer_class
3837 else:
3838 return self.serializer_class
3839
3840 def get_queryset(self):
3841 return UsableObject.select_by_user(self.request.user)
3842
3843 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3844
3845 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3846
3847
3848
Scott Bakerc1d11912014-12-22 09:29:05 -08003849class ControllerSiteDeploymentsList(generics.ListCreateAPIView):
3850 queryset = ControllerSiteDeployments.objects.select_related().all()
3851 serializer_class = ControllerSiteDeploymentsSerializer
3852 id_serializer_class = ControllerSiteDeploymentsIdSerializer
3853 filter_backends = (filters.DjangoFilterBackend,)
3854 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
3855
3856 def get_serializer_class(self):
3857 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3858 if (no_hyperlinks):
3859 return self.id_serializer_class
3860 else:
3861 return self.serializer_class
3862
3863 def get_queryset(self):
3864 return ControllerSiteDeployments.select_by_user(self.request.user)
3865
3866 def create(self, request, *args, **kwargs):
3867 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3868 if not (serializer.is_valid()):
3869 response = {"error": "validation",
3870 "specific_error": "not serializer.is_valid()",
3871 "reasons": serializer.errors}
3872 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3873 obj = serializer.object
3874 obj.caller = request.user
3875 if obj.can_update(request.user):
3876 return super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs)
3877 else:
3878 raise Exception("failed obj.can_update")
3879
3880 ret = super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs)
3881 if (ret.status_code%100 != 200):
3882 raise Exception(ret.data)
3883
3884 return ret
3885
3886
3887class ControllerSiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3888 queryset = ControllerSiteDeployments.objects.select_related().all()
3889 serializer_class = ControllerSiteDeploymentsSerializer
3890 id_serializer_class = ControllerSiteDeploymentsIdSerializer
3891
3892 def get_serializer_class(self):
3893 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3894 if (no_hyperlinks):
3895 return self.id_serializer_class
3896 else:
3897 return self.serializer_class
3898
3899 def get_queryset(self):
3900 return ControllerSiteDeployments.select_by_user(self.request.user)
3901
3902 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3903
3904 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3905
3906
3907
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003908class SiteRoleList(generics.ListCreateAPIView):
3909 queryset = SiteRole.objects.select_related().all()
3910 serializer_class = SiteRoleSerializer
3911 id_serializer_class = SiteRoleIdSerializer
3912 filter_backends = (filters.DjangoFilterBackend,)
3913 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3914
3915 def get_serializer_class(self):
3916 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3917 if (no_hyperlinks):
3918 return self.id_serializer_class
3919 else:
3920 return self.serializer_class
3921
3922 def get_queryset(self):
3923 return SiteRole.select_by_user(self.request.user)
3924
3925 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003926 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3927 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003928 response = {"error": "validation",
3929 "specific_error": "not serializer.is_valid()",
3930 "reasons": serializer.errors}
3931 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003932 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003933 obj.caller = request.user
3934 if obj.can_update(request.user):
3935 return super(SiteRoleList, self).create(request, *args, **kwargs)
3936 else:
Scott Baker08898c12014-10-29 23:41:11 -07003937 raise Exception("failed obj.can_update")
3938
3939 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3940 if (ret.status_code%100 != 200):
3941 raise Exception(ret.data)
3942
3943 return ret
3944
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003945
3946class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3947 queryset = SiteRole.objects.select_related().all()
3948 serializer_class = SiteRoleSerializer
3949 id_serializer_class = SiteRoleIdSerializer
3950
3951 def get_serializer_class(self):
3952 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3953 if (no_hyperlinks):
3954 return self.id_serializer_class
3955 else:
3956 return self.serializer_class
3957
3958 def get_queryset(self):
3959 return SiteRole.select_by_user(self.request.user)
3960
3961 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3962
3963 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3964
3965
3966
3967class SliceCredentialList(generics.ListCreateAPIView):
3968 queryset = SliceCredential.objects.select_related().all()
3969 serializer_class = SliceCredentialSerializer
3970 id_serializer_class = SliceCredentialIdSerializer
3971 filter_backends = (filters.DjangoFilterBackend,)
3972 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3973
3974 def get_serializer_class(self):
3975 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3976 if (no_hyperlinks):
3977 return self.id_serializer_class
3978 else:
3979 return self.serializer_class
3980
3981 def get_queryset(self):
3982 return SliceCredential.select_by_user(self.request.user)
3983
3984 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003985 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3986 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003987 response = {"error": "validation",
3988 "specific_error": "not serializer.is_valid()",
3989 "reasons": serializer.errors}
3990 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003991 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003992 obj.caller = request.user
3993 if obj.can_update(request.user):
3994 return super(SliceCredentialList, self).create(request, *args, **kwargs)
3995 else:
Scott Baker08898c12014-10-29 23:41:11 -07003996 raise Exception("failed obj.can_update")
3997
3998 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
3999 if (ret.status_code%100 != 200):
4000 raise Exception(ret.data)
4001
4002 return ret
4003
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004004
4005class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4006 queryset = SliceCredential.objects.select_related().all()
4007 serializer_class = SliceCredentialSerializer
4008 id_serializer_class = SliceCredentialIdSerializer
4009
4010 def get_serializer_class(self):
4011 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4012 if (no_hyperlinks):
4013 return self.id_serializer_class
4014 else:
4015 return self.serializer_class
4016
4017 def get_queryset(self):
4018 return SliceCredential.select_by_user(self.request.user)
4019
4020 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4021
4022 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4023
4024
4025
4026class SliverList(generics.ListCreateAPIView):
4027 queryset = Sliver.objects.select_related().all()
4028 serializer_class = SliverSerializer
4029 id_serializer_class = SliverIdSerializer
4030 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004031 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 Bakerdcb9b5d2014-10-07 00:10:17 -07004032
4033 def get_serializer_class(self):
4034 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4035 if (no_hyperlinks):
4036 return self.id_serializer_class
4037 else:
4038 return self.serializer_class
4039
4040 def get_queryset(self):
4041 return Sliver.select_by_user(self.request.user)
4042
4043 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004044 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4045 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004046 response = {"error": "validation",
4047 "specific_error": "not serializer.is_valid()",
4048 "reasons": serializer.errors}
4049 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004050 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004051 obj.caller = request.user
4052 if obj.can_update(request.user):
4053 return super(SliverList, self).create(request, *args, **kwargs)
4054 else:
Scott Baker08898c12014-10-29 23:41:11 -07004055 raise Exception("failed obj.can_update")
4056
4057 ret = super(SliverList, self).create(request, *args, **kwargs)
4058 if (ret.status_code%100 != 200):
4059 raise Exception(ret.data)
4060
4061 return ret
4062
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004063
4064class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4065 queryset = Sliver.objects.select_related().all()
4066 serializer_class = SliverSerializer
4067 id_serializer_class = SliverIdSerializer
4068
4069 def get_serializer_class(self):
4070 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4071 if (no_hyperlinks):
4072 return self.id_serializer_class
4073 else:
4074 return self.serializer_class
4075
4076 def get_queryset(self):
4077 return Sliver.select_by_user(self.request.user)
4078
4079 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4080
4081 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4082
4083
4084
4085class NodeList(generics.ListCreateAPIView):
4086 queryset = Node.objects.select_related().all()
4087 serializer_class = NodeSerializer
4088 id_serializer_class = NodeIdSerializer
4089 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004090 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004091
4092 def get_serializer_class(self):
4093 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4094 if (no_hyperlinks):
4095 return self.id_serializer_class
4096 else:
4097 return self.serializer_class
4098
4099 def get_queryset(self):
4100 return Node.select_by_user(self.request.user)
4101
4102 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004103 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4104 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004105 response = {"error": "validation",
4106 "specific_error": "not serializer.is_valid()",
4107 "reasons": serializer.errors}
4108 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004109 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004110 obj.caller = request.user
4111 if obj.can_update(request.user):
4112 return super(NodeList, self).create(request, *args, **kwargs)
4113 else:
Scott Baker08898c12014-10-29 23:41:11 -07004114 raise Exception("failed obj.can_update")
4115
4116 ret = super(NodeList, self).create(request, *args, **kwargs)
4117 if (ret.status_code%100 != 200):
4118 raise Exception(ret.data)
4119
4120 return ret
4121
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004122
4123class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4124 queryset = Node.objects.select_related().all()
4125 serializer_class = NodeSerializer
4126 id_serializer_class = NodeIdSerializer
4127
4128 def get_serializer_class(self):
4129 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4130 if (no_hyperlinks):
4131 return self.id_serializer_class
4132 else:
4133 return self.serializer_class
4134
4135 def get_queryset(self):
4136 return Node.select_by_user(self.request.user)
4137
4138 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4139
4140 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4141
4142
4143
4144class DashboardViewList(generics.ListCreateAPIView):
4145 queryset = DashboardView.objects.select_related().all()
4146 serializer_class = DashboardViewSerializer
4147 id_serializer_class = DashboardViewIdSerializer
4148 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004149 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004150
4151 def get_serializer_class(self):
4152 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4153 if (no_hyperlinks):
4154 return self.id_serializer_class
4155 else:
4156 return self.serializer_class
4157
4158 def get_queryset(self):
4159 return DashboardView.select_by_user(self.request.user)
4160
4161 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004162 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4163 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004164 response = {"error": "validation",
4165 "specific_error": "not serializer.is_valid()",
4166 "reasons": serializer.errors}
4167 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004168 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004169 obj.caller = request.user
4170 if obj.can_update(request.user):
4171 return super(DashboardViewList, self).create(request, *args, **kwargs)
4172 else:
Scott Baker08898c12014-10-29 23:41:11 -07004173 raise Exception("failed obj.can_update")
4174
4175 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
4176 if (ret.status_code%100 != 200):
4177 raise Exception(ret.data)
4178
4179 return ret
4180
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004181
4182class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4183 queryset = DashboardView.objects.select_related().all()
4184 serializer_class = DashboardViewSerializer
4185 id_serializer_class = DashboardViewIdSerializer
4186
4187 def get_serializer_class(self):
4188 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4189 if (no_hyperlinks):
4190 return self.id_serializer_class
4191 else:
4192 return self.serializer_class
4193
4194 def get_queryset(self):
4195 return DashboardView.select_by_user(self.request.user)
4196
4197 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4198
4199 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4200
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004201
Scott Bakerf3816ac2014-11-12 01:13:53 -08004202
Scott Bakerc1d11912014-12-22 09:29:05 -08004203class ImageDeploymentsList(generics.ListCreateAPIView):
4204 queryset = ImageDeployments.objects.select_related().all()
4205 serializer_class = ImageDeploymentsSerializer
4206 id_serializer_class = ImageDeploymentsIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004207 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004208 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker196ffef2014-11-21 11:32:24 -08004209
4210 def get_serializer_class(self):
4211 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4212 if (no_hyperlinks):
4213 return self.id_serializer_class
4214 else:
4215 return self.serializer_class
4216
4217 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08004218 return ImageDeployments.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004219
4220 def create(self, request, *args, **kwargs):
4221 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4222 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004223 response = {"error": "validation",
4224 "specific_error": "not serializer.is_valid()",
4225 "reasons": serializer.errors}
4226 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08004227 obj = serializer.object
4228 obj.caller = request.user
4229 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08004230 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08004231 else:
4232 raise Exception("failed obj.can_update")
4233
Scott Bakerc1d11912014-12-22 09:29:05 -08004234 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08004235 if (ret.status_code%100 != 200):
4236 raise Exception(ret.data)
4237
4238 return ret
4239
4240
Scott Bakerc1d11912014-12-22 09:29:05 -08004241class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4242 queryset = ImageDeployments.objects.select_related().all()
4243 serializer_class = ImageDeploymentsSerializer
4244 id_serializer_class = ImageDeploymentsIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004245
4246 def get_serializer_class(self):
4247 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4248 if (no_hyperlinks):
4249 return self.id_serializer_class
4250 else:
4251 return self.serializer_class
4252
4253 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08004254 return ImageDeployments.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004255
4256 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4257
4258 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4259
Scott Baker196ffef2014-11-21 11:32:24 -08004260
4261
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004262class ReservedResourceList(generics.ListCreateAPIView):
4263 queryset = ReservedResource.objects.select_related().all()
4264 serializer_class = ReservedResourceSerializer
4265 id_serializer_class = ReservedResourceIdSerializer
4266 filter_backends = (filters.DjangoFilterBackend,)
4267 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
4268
4269 def get_serializer_class(self):
4270 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4271 if (no_hyperlinks):
4272 return self.id_serializer_class
4273 else:
4274 return self.serializer_class
4275
4276 def get_queryset(self):
4277 return ReservedResource.select_by_user(self.request.user)
4278
4279 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004280 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4281 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004282 response = {"error": "validation",
4283 "specific_error": "not serializer.is_valid()",
4284 "reasons": serializer.errors}
4285 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004286 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004287 obj.caller = request.user
4288 if obj.can_update(request.user):
4289 return super(ReservedResourceList, self).create(request, *args, **kwargs)
4290 else:
Scott Baker08898c12014-10-29 23:41:11 -07004291 raise Exception("failed obj.can_update")
4292
4293 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4294 if (ret.status_code%100 != 200):
4295 raise Exception(ret.data)
4296
4297 return ret
4298
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004299
4300class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4301 queryset = ReservedResource.objects.select_related().all()
4302 serializer_class = ReservedResourceSerializer
4303 id_serializer_class = ReservedResourceIdSerializer
4304
4305 def get_serializer_class(self):
4306 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4307 if (no_hyperlinks):
4308 return self.id_serializer_class
4309 else:
4310 return self.serializer_class
4311
4312 def get_queryset(self):
4313 return ReservedResource.select_by_user(self.request.user)
4314
4315 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4316
4317 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4318
4319
4320
Scott Bakerc1d11912014-12-22 09:29:05 -08004321class PaymentList(generics.ListCreateAPIView):
4322 queryset = Payment.objects.select_related().all()
4323 serializer_class = PaymentSerializer
4324 id_serializer_class = PaymentIdSerializer
4325 filter_backends = (filters.DjangoFilterBackend,)
4326 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
4327
4328 def get_serializer_class(self):
4329 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4330 if (no_hyperlinks):
4331 return self.id_serializer_class
4332 else:
4333 return self.serializer_class
4334
4335 def get_queryset(self):
4336 return Payment.select_by_user(self.request.user)
4337
4338 def create(self, request, *args, **kwargs):
4339 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4340 if not (serializer.is_valid()):
4341 response = {"error": "validation",
4342 "specific_error": "not serializer.is_valid()",
4343 "reasons": serializer.errors}
4344 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4345 obj = serializer.object
4346 obj.caller = request.user
4347 if obj.can_update(request.user):
4348 return super(PaymentList, self).create(request, *args, **kwargs)
4349 else:
4350 raise Exception("failed obj.can_update")
4351
4352 ret = super(PaymentList, self).create(request, *args, **kwargs)
4353 if (ret.status_code%100 != 200):
4354 raise Exception(ret.data)
4355
4356 return ret
4357
4358
4359class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4360 queryset = Payment.objects.select_related().all()
4361 serializer_class = PaymentSerializer
4362 id_serializer_class = PaymentIdSerializer
4363
4364 def get_serializer_class(self):
4365 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4366 if (no_hyperlinks):
4367 return self.id_serializer_class
4368 else:
4369 return self.serializer_class
4370
4371 def get_queryset(self):
4372 return Payment.select_by_user(self.request.user)
4373
4374 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4375
4376 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4377
4378
4379
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004380class NetworkSliceList(generics.ListCreateAPIView):
4381 queryset = NetworkSlice.objects.select_related().all()
4382 serializer_class = NetworkSliceSerializer
4383 id_serializer_class = NetworkSliceIdSerializer
4384 filter_backends = (filters.DjangoFilterBackend,)
4385 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
4386
4387 def get_serializer_class(self):
4388 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4389 if (no_hyperlinks):
4390 return self.id_serializer_class
4391 else:
4392 return self.serializer_class
4393
4394 def get_queryset(self):
4395 return NetworkSlice.select_by_user(self.request.user)
4396
4397 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004398 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4399 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004400 response = {"error": "validation",
4401 "specific_error": "not serializer.is_valid()",
4402 "reasons": serializer.errors}
4403 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004404 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004405 obj.caller = request.user
4406 if obj.can_update(request.user):
4407 return super(NetworkSliceList, self).create(request, *args, **kwargs)
4408 else:
Scott Baker08898c12014-10-29 23:41:11 -07004409 raise Exception("failed obj.can_update")
4410
4411 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4412 if (ret.status_code%100 != 200):
4413 raise Exception(ret.data)
4414
4415 return ret
4416
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004417
4418class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4419 queryset = NetworkSlice.objects.select_related().all()
4420 serializer_class = NetworkSliceSerializer
4421 id_serializer_class = NetworkSliceIdSerializer
4422
4423 def get_serializer_class(self):
4424 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4425 if (no_hyperlinks):
4426 return self.id_serializer_class
4427 else:
4428 return self.serializer_class
4429
4430 def get_queryset(self):
4431 return NetworkSlice.select_by_user(self.request.user)
4432
4433 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4434
4435 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4436
4437
4438
4439class UserDashboardViewList(generics.ListCreateAPIView):
4440 queryset = UserDashboardView.objects.select_related().all()
4441 serializer_class = UserDashboardViewSerializer
4442 id_serializer_class = UserDashboardViewIdSerializer
4443 filter_backends = (filters.DjangoFilterBackend,)
4444 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4445
4446 def get_serializer_class(self):
4447 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4448 if (no_hyperlinks):
4449 return self.id_serializer_class
4450 else:
4451 return self.serializer_class
4452
4453 def get_queryset(self):
4454 return UserDashboardView.select_by_user(self.request.user)
4455
4456 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004457 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4458 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004459 response = {"error": "validation",
4460 "specific_error": "not serializer.is_valid()",
4461 "reasons": serializer.errors}
4462 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004463 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004464 obj.caller = request.user
4465 if obj.can_update(request.user):
4466 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4467 else:
Scott Baker08898c12014-10-29 23:41:11 -07004468 raise Exception("failed obj.can_update")
4469
4470 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4471 if (ret.status_code%100 != 200):
4472 raise Exception(ret.data)
4473
4474 return ret
4475
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004476
4477class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4478 queryset = UserDashboardView.objects.select_related().all()
4479 serializer_class = UserDashboardViewSerializer
4480 id_serializer_class = UserDashboardViewIdSerializer
4481
4482 def get_serializer_class(self):
4483 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4484 if (no_hyperlinks):
4485 return self.id_serializer_class
4486 else:
4487 return self.serializer_class
4488
4489 def get_queryset(self):
4490 return UserDashboardView.select_by_user(self.request.user)
4491
4492 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4493
4494 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4495
4496
4497
Scott Bakerc1d11912014-12-22 09:29:05 -08004498class ControllerList(generics.ListCreateAPIView):
4499 queryset = Controller.objects.select_related().all()
4500 serializer_class = ControllerSerializer
4501 id_serializer_class = ControllerIdSerializer
4502 filter_backends = (filters.DjangoFilterBackend,)
4503 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
4504
4505 def get_serializer_class(self):
4506 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4507 if (no_hyperlinks):
4508 return self.id_serializer_class
4509 else:
4510 return self.serializer_class
4511
4512 def get_queryset(self):
4513 return Controller.select_by_user(self.request.user)
4514
4515 def create(self, request, *args, **kwargs):
4516 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4517 if not (serializer.is_valid()):
4518 response = {"error": "validation",
4519 "specific_error": "not serializer.is_valid()",
4520 "reasons": serializer.errors}
4521 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4522 obj = serializer.object
4523 obj.caller = request.user
4524 if obj.can_update(request.user):
4525 return super(ControllerList, self).create(request, *args, **kwargs)
4526 else:
4527 raise Exception("failed obj.can_update")
4528
4529 ret = super(ControllerList, self).create(request, *args, **kwargs)
4530 if (ret.status_code%100 != 200):
4531 raise Exception(ret.data)
4532
4533 return ret
4534
4535
4536class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4537 queryset = Controller.objects.select_related().all()
4538 serializer_class = ControllerSerializer
4539 id_serializer_class = ControllerIdSerializer
4540
4541 def get_serializer_class(self):
4542 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4543 if (no_hyperlinks):
4544 return self.id_serializer_class
4545 else:
4546 return self.serializer_class
4547
4548 def get_queryset(self):
4549 return Controller.select_by_user(self.request.user)
4550
4551 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4552
4553 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4554
4555
4556
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004557class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4558 queryset = PlanetStackPrivilege.objects.select_related().all()
4559 serializer_class = PlanetStackPrivilegeSerializer
4560 id_serializer_class = PlanetStackPrivilegeIdSerializer
4561 filter_backends = (filters.DjangoFilterBackend,)
4562 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4563
4564 def get_serializer_class(self):
4565 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4566 if (no_hyperlinks):
4567 return self.id_serializer_class
4568 else:
4569 return self.serializer_class
4570
4571 def get_queryset(self):
4572 return PlanetStackPrivilege.select_by_user(self.request.user)
4573
4574 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004575 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4576 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004577 response = {"error": "validation",
4578 "specific_error": "not serializer.is_valid()",
4579 "reasons": serializer.errors}
4580 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004581 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004582 obj.caller = request.user
4583 if obj.can_update(request.user):
4584 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4585 else:
Scott Baker08898c12014-10-29 23:41:11 -07004586 raise Exception("failed obj.can_update")
4587
4588 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4589 if (ret.status_code%100 != 200):
4590 raise Exception(ret.data)
4591
4592 return ret
4593
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004594
4595class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4596 queryset = PlanetStackPrivilege.objects.select_related().all()
4597 serializer_class = PlanetStackPrivilegeSerializer
4598 id_serializer_class = PlanetStackPrivilegeIdSerializer
4599
4600 def get_serializer_class(self):
4601 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4602 if (no_hyperlinks):
4603 return self.id_serializer_class
4604 else:
4605 return self.serializer_class
4606
4607 def get_queryset(self):
4608 return PlanetStackPrivilege.select_by_user(self.request.user)
4609
4610 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4611
4612 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4613
4614
4615
4616class UserList(generics.ListCreateAPIView):
4617 queryset = User.objects.select_related().all()
4618 serializer_class = UserSerializer
4619 id_serializer_class = UserIdSerializer
4620 filter_backends = (filters.DjangoFilterBackend,)
4621 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',)
4622
4623 def get_serializer_class(self):
4624 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4625 if (no_hyperlinks):
4626 return self.id_serializer_class
4627 else:
4628 return self.serializer_class
4629
4630 def get_queryset(self):
4631 return User.select_by_user(self.request.user)
4632
4633 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004634 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4635 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004636 response = {"error": "validation",
4637 "specific_error": "not serializer.is_valid()",
4638 "reasons": serializer.errors}
4639 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004640 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004641 obj.caller = request.user
4642 if obj.can_update(request.user):
4643 return super(UserList, self).create(request, *args, **kwargs)
4644 else:
Scott Baker08898c12014-10-29 23:41:11 -07004645 raise Exception("failed obj.can_update")
4646
4647 ret = super(UserList, self).create(request, *args, **kwargs)
4648 if (ret.status_code%100 != 200):
4649 raise Exception(ret.data)
4650
4651 return ret
4652
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004653
4654class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4655 queryset = User.objects.select_related().all()
4656 serializer_class = UserSerializer
4657 id_serializer_class = UserIdSerializer
4658
4659 def get_serializer_class(self):
4660 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4661 if (no_hyperlinks):
4662 return self.id_serializer_class
4663 else:
4664 return self.serializer_class
4665
4666 def get_queryset(self):
4667 return User.select_by_user(self.request.user)
4668
4669 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4670
4671 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4672
4673
4674
4675class DeploymentList(generics.ListCreateAPIView):
4676 queryset = Deployment.objects.select_related().all()
4677 serializer_class = DeploymentSerializer
4678 id_serializer_class = DeploymentIdSerializer
4679 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker93a79a92014-12-22 15:59:33 -08004680 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004681
4682 def get_serializer_class(self):
4683 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4684 if (no_hyperlinks):
4685 return self.id_serializer_class
4686 else:
4687 return self.serializer_class
4688
4689 def get_queryset(self):
4690 return Deployment.select_by_user(self.request.user)
4691
4692 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004693 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4694 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004695 response = {"error": "validation",
4696 "specific_error": "not serializer.is_valid()",
4697 "reasons": serializer.errors}
4698 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004699 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004700 obj.caller = request.user
4701 if obj.can_update(request.user):
4702 return super(DeploymentList, self).create(request, *args, **kwargs)
4703 else:
Scott Baker08898c12014-10-29 23:41:11 -07004704 raise Exception("failed obj.can_update")
4705
4706 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4707 if (ret.status_code%100 != 200):
4708 raise Exception(ret.data)
4709
4710 return ret
4711
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004712
4713class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4714 queryset = Deployment.objects.select_related().all()
4715 serializer_class = DeploymentSerializer
4716 id_serializer_class = DeploymentIdSerializer
4717
4718 def get_serializer_class(self):
4719 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4720 if (no_hyperlinks):
4721 return self.id_serializer_class
4722 else:
4723 return self.serializer_class
4724
4725 def get_queryset(self):
4726 return Deployment.select_by_user(self.request.user)
4727
4728 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4729
4730 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4731
4732
4733
4734class ReservationList(generics.ListCreateAPIView):
4735 queryset = Reservation.objects.select_related().all()
4736 serializer_class = ReservationSerializer
4737 id_serializer_class = ReservationIdSerializer
4738 filter_backends = (filters.DjangoFilterBackend,)
4739 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4740
4741 def get_serializer_class(self):
4742 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4743 if (no_hyperlinks):
4744 return self.id_serializer_class
4745 else:
4746 return self.serializer_class
4747
4748 def get_queryset(self):
4749 return Reservation.select_by_user(self.request.user)
4750
4751 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004752 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4753 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004754 response = {"error": "validation",
4755 "specific_error": "not serializer.is_valid()",
4756 "reasons": serializer.errors}
4757 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004758 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004759 obj.caller = request.user
4760 if obj.can_update(request.user):
4761 return super(ReservationList, self).create(request, *args, **kwargs)
4762 else:
Scott Baker08898c12014-10-29 23:41:11 -07004763 raise Exception("failed obj.can_update")
4764
4765 ret = super(ReservationList, self).create(request, *args, **kwargs)
4766 if (ret.status_code%100 != 200):
4767 raise Exception(ret.data)
4768
4769 return ret
4770
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004771
4772class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4773 queryset = Reservation.objects.select_related().all()
4774 serializer_class = ReservationSerializer
4775 id_serializer_class = ReservationIdSerializer
4776
4777 def get_serializer_class(self):
4778 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4779 if (no_hyperlinks):
4780 return self.id_serializer_class
4781 else:
4782 return self.serializer_class
4783
4784 def get_queryset(self):
4785 return Reservation.select_by_user(self.request.user)
4786
4787 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4788
4789 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4790
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004791
Scott Bakerf3816ac2014-11-12 01:13:53 -08004792
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004793class SitePrivilegeList(generics.ListCreateAPIView):
4794 queryset = SitePrivilege.objects.select_related().all()
4795 serializer_class = SitePrivilegeSerializer
4796 id_serializer_class = SitePrivilegeIdSerializer
4797 filter_backends = (filters.DjangoFilterBackend,)
4798 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4799
4800 def get_serializer_class(self):
4801 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4802 if (no_hyperlinks):
4803 return self.id_serializer_class
4804 else:
4805 return self.serializer_class
4806
4807 def get_queryset(self):
4808 return SitePrivilege.select_by_user(self.request.user)
4809
4810 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004811 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4812 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004813 response = {"error": "validation",
4814 "specific_error": "not serializer.is_valid()",
4815 "reasons": serializer.errors}
4816 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004817 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004818 obj.caller = request.user
4819 if obj.can_update(request.user):
4820 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4821 else:
Scott Baker08898c12014-10-29 23:41:11 -07004822 raise Exception("failed obj.can_update")
4823
4824 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4825 if (ret.status_code%100 != 200):
4826 raise Exception(ret.data)
4827
4828 return ret
4829
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004830
4831class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4832 queryset = SitePrivilege.objects.select_related().all()
4833 serializer_class = SitePrivilegeSerializer
4834 id_serializer_class = SitePrivilegeIdSerializer
4835
4836 def get_serializer_class(self):
4837 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4838 if (no_hyperlinks):
4839 return self.id_serializer_class
4840 else:
4841 return self.serializer_class
4842
4843 def get_queryset(self):
4844 return SitePrivilege.select_by_user(self.request.user)
4845
4846 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4847
4848 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4849
4850
4851
Scott Baker196ffef2014-11-21 11:32:24 -08004852class PlanetStackList(generics.ListCreateAPIView):
4853 queryset = PlanetStack.objects.select_related().all()
4854 serializer_class = PlanetStackSerializer
4855 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004856 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker196ffef2014-11-21 11:32:24 -08004857 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004858
4859 def get_serializer_class(self):
4860 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4861 if (no_hyperlinks):
4862 return self.id_serializer_class
4863 else:
4864 return self.serializer_class
4865
4866 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004867 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004868
4869 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004870 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4871 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004872 response = {"error": "validation",
4873 "specific_error": "not serializer.is_valid()",
4874 "reasons": serializer.errors}
4875 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004876 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004877 obj.caller = request.user
4878 if obj.can_update(request.user):
Scott Baker196ffef2014-11-21 11:32:24 -08004879 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004880 else:
Scott Baker08898c12014-10-29 23:41:11 -07004881 raise Exception("failed obj.can_update")
4882
Scott Baker196ffef2014-11-21 11:32:24 -08004883 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004884 if (ret.status_code%100 != 200):
4885 raise Exception(ret.data)
4886
4887 return ret
4888
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004889
Scott Baker196ffef2014-11-21 11:32:24 -08004890class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4891 queryset = PlanetStack.objects.select_related().all()
4892 serializer_class = PlanetStackSerializer
4893 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004894
4895 def get_serializer_class(self):
4896 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4897 if (no_hyperlinks):
4898 return self.id_serializer_class
4899 else:
4900 return self.serializer_class
4901
4902 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004903 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004904
4905 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4906
4907 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4908
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004909
Scott Bakerf3816ac2014-11-12 01:13:53 -08004910
Scott Bakera6a0c772014-12-22 17:35:34 -08004911class ControllerDashboardViewList(generics.ListCreateAPIView):
4912 queryset = ControllerDashboardView.objects.select_related().all()
4913 serializer_class = ControllerDashboardViewSerializer
4914 id_serializer_class = ControllerDashboardViewIdSerializer
4915 filter_backends = (filters.DjangoFilterBackend,)
4916 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
4917
4918 def get_serializer_class(self):
4919 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4920 if (no_hyperlinks):
4921 return self.id_serializer_class
4922 else:
4923 return self.serializer_class
4924
4925 def get_queryset(self):
4926 return ControllerDashboardView.select_by_user(self.request.user)
4927
4928 def create(self, request, *args, **kwargs):
4929 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4930 if not (serializer.is_valid()):
4931 response = {"error": "validation",
4932 "specific_error": "not serializer.is_valid()",
4933 "reasons": serializer.errors}
4934 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4935 obj = serializer.object
4936 obj.caller = request.user
4937 if obj.can_update(request.user):
4938 return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
4939 else:
4940 raise Exception("failed obj.can_update")
4941
4942 ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
4943 if (ret.status_code%100 != 200):
4944 raise Exception(ret.data)
4945
4946 return ret
4947
4948
4949class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4950 queryset = ControllerDashboardView.objects.select_related().all()
4951 serializer_class = ControllerDashboardViewSerializer
4952 id_serializer_class = ControllerDashboardViewIdSerializer
4953
4954 def get_serializer_class(self):
4955 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4956 if (no_hyperlinks):
4957 return self.id_serializer_class
4958 else:
4959 return self.serializer_class
4960
4961 def get_queryset(self):
4962 return ControllerDashboardView.select_by_user(self.request.user)
4963
4964 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4965
4966 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4967
4968
4969
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004970class AccountList(generics.ListCreateAPIView):
4971 queryset = Account.objects.select_related().all()
4972 serializer_class = AccountSerializer
4973 id_serializer_class = AccountIdSerializer
4974 filter_backends = (filters.DjangoFilterBackend,)
4975 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4976
4977 def get_serializer_class(self):
4978 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4979 if (no_hyperlinks):
4980 return self.id_serializer_class
4981 else:
4982 return self.serializer_class
4983
4984 def get_queryset(self):
4985 return Account.select_by_user(self.request.user)
4986
4987 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004988 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4989 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004990 response = {"error": "validation",
4991 "specific_error": "not serializer.is_valid()",
4992 "reasons": serializer.errors}
4993 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004994 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004995 obj.caller = request.user
4996 if obj.can_update(request.user):
4997 return super(AccountList, self).create(request, *args, **kwargs)
4998 else:
Scott Baker08898c12014-10-29 23:41:11 -07004999 raise Exception("failed obj.can_update")
5000
5001 ret = super(AccountList, self).create(request, *args, **kwargs)
5002 if (ret.status_code%100 != 200):
5003 raise Exception(ret.data)
5004
5005 return ret
5006
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005007
5008class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5009 queryset = Account.objects.select_related().all()
5010 serializer_class = AccountSerializer
5011 id_serializer_class = AccountIdSerializer
5012
5013 def get_serializer_class(self):
5014 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5015 if (no_hyperlinks):
5016 return self.id_serializer_class
5017 else:
5018 return self.serializer_class
5019
5020 def get_queryset(self):
5021 return Account.select_by_user(self.request.user)
5022
5023 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5024
5025 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5026
5027
5028
Scott Bakerc1d11912014-12-22 09:29:05 -08005029class ControllerRoleList(generics.ListCreateAPIView):
5030 queryset = ControllerRole.objects.select_related().all()
5031 serializer_class = ControllerRoleSerializer
5032 id_serializer_class = ControllerRoleIdSerializer
5033 filter_backends = (filters.DjangoFilterBackend,)
5034 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5035
5036 def get_serializer_class(self):
5037 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5038 if (no_hyperlinks):
5039 return self.id_serializer_class
5040 else:
5041 return self.serializer_class
5042
5043 def get_queryset(self):
5044 return ControllerRole.select_by_user(self.request.user)
5045
5046 def create(self, request, *args, **kwargs):
5047 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5048 if not (serializer.is_valid()):
5049 response = {"error": "validation",
5050 "specific_error": "not serializer.is_valid()",
5051 "reasons": serializer.errors}
5052 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5053 obj = serializer.object
5054 obj.caller = request.user
5055 if obj.can_update(request.user):
5056 return super(ControllerRoleList, self).create(request, *args, **kwargs)
5057 else:
5058 raise Exception("failed obj.can_update")
5059
5060 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
5061 if (ret.status_code%100 != 200):
5062 raise Exception(ret.data)
5063
5064 return ret
5065
5066
5067class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5068 queryset = ControllerRole.objects.select_related().all()
5069 serializer_class = ControllerRoleSerializer
5070 id_serializer_class = ControllerRoleIdSerializer
5071
5072 def get_serializer_class(self):
5073 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5074 if (no_hyperlinks):
5075 return self.id_serializer_class
5076 else:
5077 return self.serializer_class
5078
5079 def get_queryset(self):
5080 return ControllerRole.select_by_user(self.request.user)
5081
5082 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5083
5084 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5085
5086
5087
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005088class NetworkParameterTypeList(generics.ListCreateAPIView):
5089 queryset = NetworkParameterType.objects.select_related().all()
5090 serializer_class = NetworkParameterTypeSerializer
5091 id_serializer_class = NetworkParameterTypeIdSerializer
5092 filter_backends = (filters.DjangoFilterBackend,)
5093 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
5094
5095 def get_serializer_class(self):
5096 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5097 if (no_hyperlinks):
5098 return self.id_serializer_class
5099 else:
5100 return self.serializer_class
5101
5102 def get_queryset(self):
5103 return NetworkParameterType.select_by_user(self.request.user)
5104
5105 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005106 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5107 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005108 response = {"error": "validation",
5109 "specific_error": "not serializer.is_valid()",
5110 "reasons": serializer.errors}
5111 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005112 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005113 obj.caller = request.user
5114 if obj.can_update(request.user):
5115 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5116 else:
Scott Baker08898c12014-10-29 23:41:11 -07005117 raise Exception("failed obj.can_update")
5118
5119 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5120 if (ret.status_code%100 != 200):
5121 raise Exception(ret.data)
5122
5123 return ret
5124
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005125
5126class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5127 queryset = NetworkParameterType.objects.select_related().all()
5128 serializer_class = NetworkParameterTypeSerializer
5129 id_serializer_class = NetworkParameterTypeIdSerializer
5130
5131 def get_serializer_class(self):
5132 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5133 if (no_hyperlinks):
5134 return self.id_serializer_class
5135 else:
5136 return self.serializer_class
5137
5138 def get_queryset(self):
5139 return NetworkParameterType.select_by_user(self.request.user)
5140
5141 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5142
5143 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5144
5145
5146
5147class SiteCredentialList(generics.ListCreateAPIView):
5148 queryset = SiteCredential.objects.select_related().all()
5149 serializer_class = SiteCredentialSerializer
5150 id_serializer_class = SiteCredentialIdSerializer
5151 filter_backends = (filters.DjangoFilterBackend,)
5152 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
5153
5154 def get_serializer_class(self):
5155 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5156 if (no_hyperlinks):
5157 return self.id_serializer_class
5158 else:
5159 return self.serializer_class
5160
5161 def get_queryset(self):
5162 return SiteCredential.select_by_user(self.request.user)
5163
5164 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005165 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5166 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005167 response = {"error": "validation",
5168 "specific_error": "not serializer.is_valid()",
5169 "reasons": serializer.errors}
5170 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005171 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005172 obj.caller = request.user
5173 if obj.can_update(request.user):
5174 return super(SiteCredentialList, self).create(request, *args, **kwargs)
5175 else:
Scott Baker08898c12014-10-29 23:41:11 -07005176 raise Exception("failed obj.can_update")
5177
5178 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
5179 if (ret.status_code%100 != 200):
5180 raise Exception(ret.data)
5181
5182 return ret
5183
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005184
5185class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5186 queryset = SiteCredential.objects.select_related().all()
5187 serializer_class = SiteCredentialSerializer
5188 id_serializer_class = SiteCredentialIdSerializer
5189
5190 def get_serializer_class(self):
5191 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5192 if (no_hyperlinks):
5193 return self.id_serializer_class
5194 else:
5195 return self.serializer_class
5196
5197 def get_queryset(self):
5198 return SiteCredential.select_by_user(self.request.user)
5199
5200 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5201
5202 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5203
5204
5205
Scott Bakerc1d11912014-12-22 09:29:05 -08005206class DeploymentPrivilegeList(generics.ListCreateAPIView):
5207 queryset = DeploymentPrivilege.objects.select_related().all()
5208 serializer_class = DeploymentPrivilegeSerializer
5209 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005210 filter_backends = (filters.DjangoFilterBackend,)
5211 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
5212
5213 def get_serializer_class(self):
5214 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5215 if (no_hyperlinks):
5216 return self.id_serializer_class
5217 else:
5218 return self.serializer_class
5219
5220 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005221 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005222
5223 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005224 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5225 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005226 response = {"error": "validation",
5227 "specific_error": "not serializer.is_valid()",
5228 "reasons": serializer.errors}
5229 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005230 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005231 obj.caller = request.user
5232 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08005233 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005234 else:
Scott Baker08898c12014-10-29 23:41:11 -07005235 raise Exception("failed obj.can_update")
5236
Scott Bakerc1d11912014-12-22 09:29:05 -08005237 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005238 if (ret.status_code%100 != 200):
5239 raise Exception(ret.data)
5240
5241 return ret
5242
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005243
Scott Bakerc1d11912014-12-22 09:29:05 -08005244class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5245 queryset = DeploymentPrivilege.objects.select_related().all()
5246 serializer_class = DeploymentPrivilegeSerializer
5247 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005248
5249 def get_serializer_class(self):
5250 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5251 if (no_hyperlinks):
5252 return self.id_serializer_class
5253 else:
5254 return self.serializer_class
5255
5256 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005257 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005258
5259 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5260
5261 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5262
5263
5264
Scott Bakerc1d11912014-12-22 09:29:05 -08005265class ControllerUsersList(generics.ListCreateAPIView):
5266 queryset = ControllerUsers.objects.select_related().all()
5267 serializer_class = ControllerUsersSerializer
5268 id_serializer_class = ControllerUsersIdSerializer
5269 filter_backends = (filters.DjangoFilterBackend,)
5270 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
5271
5272 def get_serializer_class(self):
5273 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5274 if (no_hyperlinks):
5275 return self.id_serializer_class
5276 else:
5277 return self.serializer_class
5278
5279 def get_queryset(self):
5280 return ControllerUsers.select_by_user(self.request.user)
5281
5282 def create(self, request, *args, **kwargs):
5283 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5284 if not (serializer.is_valid()):
5285 response = {"error": "validation",
5286 "specific_error": "not serializer.is_valid()",
5287 "reasons": serializer.errors}
5288 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5289 obj = serializer.object
5290 obj.caller = request.user
5291 if obj.can_update(request.user):
5292 return super(ControllerUsersList, self).create(request, *args, **kwargs)
5293 else:
5294 raise Exception("failed obj.can_update")
5295
5296 ret = super(ControllerUsersList, self).create(request, *args, **kwargs)
5297 if (ret.status_code%100 != 200):
5298 raise Exception(ret.data)
5299
5300 return ret
5301
5302
5303class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5304 queryset = ControllerUsers.objects.select_related().all()
5305 serializer_class = ControllerUsersSerializer
5306 id_serializer_class = ControllerUsersIdSerializer
5307
5308 def get_serializer_class(self):
5309 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5310 if (no_hyperlinks):
5311 return self.id_serializer_class
5312 else:
5313 return self.serializer_class
5314
5315 def get_queryset(self):
5316 return ControllerUsers.select_by_user(self.request.user)
5317
5318 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5319
5320 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5321
5322
5323
5324class DeploymentRoleList(generics.ListCreateAPIView):
5325 queryset = DeploymentRole.objects.select_related().all()
5326 serializer_class = DeploymentRoleSerializer
5327 id_serializer_class = DeploymentRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005328 filter_backends = (filters.DjangoFilterBackend,)
5329 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5330
5331 def get_serializer_class(self):
5332 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5333 if (no_hyperlinks):
5334 return self.id_serializer_class
5335 else:
5336 return self.serializer_class
5337
5338 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005339 return DeploymentRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005340
5341 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005342 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5343 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005344 response = {"error": "validation",
5345 "specific_error": "not serializer.is_valid()",
5346 "reasons": serializer.errors}
5347 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005348 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005349 obj.caller = request.user
5350 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08005351 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005352 else:
Scott Baker08898c12014-10-29 23:41:11 -07005353 raise Exception("failed obj.can_update")
5354
Scott Bakerc1d11912014-12-22 09:29:05 -08005355 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005356 if (ret.status_code%100 != 200):
5357 raise Exception(ret.data)
5358
5359 return ret
5360
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005361
Scott Bakerc1d11912014-12-22 09:29:05 -08005362class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5363 queryset = DeploymentRole.objects.select_related().all()
5364 serializer_class = DeploymentRoleSerializer
5365 id_serializer_class = DeploymentRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005366
5367 def get_serializer_class(self):
5368 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5369 if (no_hyperlinks):
5370 return self.id_serializer_class
5371 else:
5372 return self.serializer_class
5373
5374 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005375 return DeploymentRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005376
5377 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5378
5379 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5380
5381
5382
5383class UserCredentialList(generics.ListCreateAPIView):
5384 queryset = UserCredential.objects.select_related().all()
5385 serializer_class = UserCredentialSerializer
5386 id_serializer_class = UserCredentialIdSerializer
5387 filter_backends = (filters.DjangoFilterBackend,)
5388 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
5389
5390 def get_serializer_class(self):
5391 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5392 if (no_hyperlinks):
5393 return self.id_serializer_class
5394 else:
5395 return self.serializer_class
5396
5397 def get_queryset(self):
5398 return UserCredential.select_by_user(self.request.user)
5399
5400 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005401 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5402 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005403 response = {"error": "validation",
5404 "specific_error": "not serializer.is_valid()",
5405 "reasons": serializer.errors}
5406 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005407 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005408 obj.caller = request.user
5409 if obj.can_update(request.user):
5410 return super(UserCredentialList, self).create(request, *args, **kwargs)
5411 else:
Scott Baker08898c12014-10-29 23:41:11 -07005412 raise Exception("failed obj.can_update")
5413
5414 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
5415 if (ret.status_code%100 != 200):
5416 raise Exception(ret.data)
5417
5418 return ret
5419
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005420
5421class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5422 queryset = UserCredential.objects.select_related().all()
5423 serializer_class = UserCredentialSerializer
5424 id_serializer_class = UserCredentialIdSerializer
5425
5426 def get_serializer_class(self):
5427 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5428 if (no_hyperlinks):
5429 return self.id_serializer_class
5430 else:
5431 return self.serializer_class
5432
5433 def get_queryset(self):
5434 return UserCredential.select_by_user(self.request.user)
5435
5436 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5437
5438 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5439
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005440
Scott Bakerf3816ac2014-11-12 01:13:53 -08005441
Scott Baker196ffef2014-11-21 11:32:24 -08005442class SiteDeploymentsList(generics.ListCreateAPIView):
5443 queryset = SiteDeployments.objects.select_related().all()
5444 serializer_class = SiteDeploymentsSerializer
5445 id_serializer_class = SiteDeploymentsIdSerializer
5446 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08005447 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker196ffef2014-11-21 11:32:24 -08005448
5449 def get_serializer_class(self):
5450 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5451 if (no_hyperlinks):
5452 return self.id_serializer_class
5453 else:
5454 return self.serializer_class
5455
5456 def get_queryset(self):
5457 return SiteDeployments.select_by_user(self.request.user)
5458
5459 def create(self, request, *args, **kwargs):
5460 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5461 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005462 response = {"error": "validation",
5463 "specific_error": "not serializer.is_valid()",
5464 "reasons": serializer.errors}
5465 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08005466 obj = serializer.object
5467 obj.caller = request.user
5468 if obj.can_update(request.user):
5469 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
5470 else:
5471 raise Exception("failed obj.can_update")
5472
5473 ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
5474 if (ret.status_code%100 != 200):
5475 raise Exception(ret.data)
5476
5477 return ret
5478
5479
5480class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5481 queryset = SiteDeployments.objects.select_related().all()
5482 serializer_class = SiteDeploymentsSerializer
5483 id_serializer_class = SiteDeploymentsIdSerializer
5484
5485 def get_serializer_class(self):
5486 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5487 if (no_hyperlinks):
5488 return self.id_serializer_class
5489 else:
5490 return self.serializer_class
5491
5492 def get_queryset(self):
5493 return SiteDeployments.select_by_user(self.request.user)
5494
5495 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5496
5497 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5498
Scott Bakerc1d11912014-12-22 09:29:05 -08005499
5500
Scott Baker0caeaf02014-06-19 11:12:55 -07005501class SliceTagList(generics.ListCreateAPIView):
5502 queryset = SliceTag.objects.select_related().all()
5503 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005504 id_serializer_class = SliceTagIdSerializer
5505 filter_backends = (filters.DjangoFilterBackend,)
5506 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5507
5508 def get_serializer_class(self):
5509 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5510 if (no_hyperlinks):
5511 return self.id_serializer_class
5512 else:
5513 return self.serializer_class
5514
Scott Baker0caeaf02014-06-19 11:12:55 -07005515 def get_queryset(self):
5516 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005517
Scott Baker0caeaf02014-06-19 11:12:55 -07005518 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005519 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5520 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005521 response = {"error": "validation",
5522 "specific_error": "not serializer.is_valid()",
5523 "reasons": serializer.errors}
5524 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005525 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005526 obj.caller = request.user
5527 if obj.can_update(request.user):
5528 return super(SliceTagList, self).create(request, *args, **kwargs)
5529 else:
Scott Baker08898c12014-10-29 23:41:11 -07005530 raise Exception("failed obj.can_update")
5531
5532 ret = super(SliceTagList, self).create(request, *args, **kwargs)
5533 if (ret.status_code%100 != 200):
5534 raise Exception(ret.data)
5535
5536 return ret
5537
Scott Baker0caeaf02014-06-19 11:12:55 -07005538
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005539class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005540 queryset = SliceTag.objects.select_related().all()
5541 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005542 id_serializer_class = SliceTagIdSerializer
5543
5544 def get_serializer_class(self):
5545 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5546 if (no_hyperlinks):
5547 return self.id_serializer_class
5548 else:
5549 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005550
5551 def get_queryset(self):
5552 return SliceTag.select_by_user(self.request.user)
5553
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005554 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005555
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005556 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005557
5558
5559
Scott Bakera6a0c772014-12-22 17:35:34 -08005560class NetworkTemplateList(generics.ListCreateAPIView):
5561 queryset = NetworkTemplate.objects.select_related().all()
5562 serializer_class = NetworkTemplateSerializer
5563 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005564 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakera6a0c772014-12-22 17:35:34 -08005565 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07005566
5567 def get_serializer_class(self):
5568 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5569 if (no_hyperlinks):
5570 return self.id_serializer_class
5571 else:
5572 return self.serializer_class
5573
Scott Baker0caeaf02014-06-19 11:12:55 -07005574 def get_queryset(self):
Scott Bakera6a0c772014-12-22 17:35:34 -08005575 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005576
Scott Baker0caeaf02014-06-19 11:12:55 -07005577 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005578 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5579 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005580 response = {"error": "validation",
5581 "specific_error": "not serializer.is_valid()",
5582 "reasons": serializer.errors}
5583 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005584 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005585 obj.caller = request.user
5586 if obj.can_update(request.user):
Scott Bakera6a0c772014-12-22 17:35:34 -08005587 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07005588 else:
Scott Baker08898c12014-10-29 23:41:11 -07005589 raise Exception("failed obj.can_update")
5590
Scott Bakera6a0c772014-12-22 17:35:34 -08005591 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005592 if (ret.status_code%100 != 200):
5593 raise Exception(ret.data)
5594
5595 return ret
5596
Scott Baker0caeaf02014-06-19 11:12:55 -07005597
Scott Bakera6a0c772014-12-22 17:35:34 -08005598class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5599 queryset = NetworkTemplate.objects.select_related().all()
5600 serializer_class = NetworkTemplateSerializer
5601 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005602
5603 def get_serializer_class(self):
5604 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5605 if (no_hyperlinks):
5606 return self.id_serializer_class
5607 else:
5608 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005609
5610 def get_queryset(self):
Scott Bakera6a0c772014-12-22 17:35:34 -08005611 return NetworkTemplate.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07005612
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005613 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005614
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005615 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005616
5617
5618
5619class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005620 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005621 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005622 id_serializer_class = RouterIdSerializer
5623 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08005624 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07005625
5626 def get_serializer_class(self):
5627 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5628 if (no_hyperlinks):
5629 return self.id_serializer_class
5630 else:
5631 return self.serializer_class
5632
Scott Baker0caeaf02014-06-19 11:12:55 -07005633 def get_queryset(self):
5634 return Router.select_by_user(self.request.user)
5635
5636 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005637 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5638 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005639 response = {"error": "validation",
5640 "specific_error": "not serializer.is_valid()",
5641 "reasons": serializer.errors}
5642 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005643 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005644 obj.caller = request.user
5645 if obj.can_update(request.user):
5646 return super(RouterList, self).create(request, *args, **kwargs)
5647 else:
Scott Baker08898c12014-10-29 23:41:11 -07005648 raise Exception("failed obj.can_update")
5649
5650 ret = super(RouterList, self).create(request, *args, **kwargs)
5651 if (ret.status_code%100 != 200):
5652 raise Exception(ret.data)
5653
5654 return ret
5655
Sapan Bhatiadea39432014-06-13 03:10:36 -04005656
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005657class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005658 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005659 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005660 id_serializer_class = RouterIdSerializer
5661
5662 def get_serializer_class(self):
5663 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5664 if (no_hyperlinks):
5665 return self.id_serializer_class
5666 else:
5667 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005668
5669 def get_queryset(self):
5670 return Router.select_by_user(self.request.user)
5671
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005672 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005673
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005674 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005675
5676
5677
Scott Baker0caeaf02014-06-19 11:12:55 -07005678class ServiceResourceList(generics.ListCreateAPIView):
5679 queryset = ServiceResource.objects.select_related().all()
5680 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005681 id_serializer_class = ServiceResourceIdSerializer
5682 filter_backends = (filters.DjangoFilterBackend,)
5683 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5684
5685 def get_serializer_class(self):
5686 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5687 if (no_hyperlinks):
5688 return self.id_serializer_class
5689 else:
5690 return self.serializer_class
5691
Scott Baker0caeaf02014-06-19 11:12:55 -07005692 def get_queryset(self):
5693 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005694
Scott Baker0caeaf02014-06-19 11:12:55 -07005695 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005696 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5697 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005698 response = {"error": "validation",
5699 "specific_error": "not serializer.is_valid()",
5700 "reasons": serializer.errors}
5701 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005702 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005703 obj.caller = request.user
5704 if obj.can_update(request.user):
5705 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5706 else:
Scott Baker08898c12014-10-29 23:41:11 -07005707 raise Exception("failed obj.can_update")
5708
5709 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5710 if (ret.status_code%100 != 200):
5711 raise Exception(ret.data)
5712
5713 return ret
5714
Scott Baker0caeaf02014-06-19 11:12:55 -07005715
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005716class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005717 queryset = ServiceResource.objects.select_related().all()
5718 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005719 id_serializer_class = ServiceResourceIdSerializer
5720
5721 def get_serializer_class(self):
5722 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5723 if (no_hyperlinks):
5724 return self.id_serializer_class
5725 else:
5726 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005727
5728 def get_queryset(self):
5729 return ServiceResource.select_by_user(self.request.user)
5730
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005731 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005732
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005733 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005734
Sapan Bhatiadea39432014-06-13 03:10:36 -04005735
5736
Scott Bakerc1d11912014-12-22 09:29:05 -08005737class ControllerSlicesList(generics.ListCreateAPIView):
5738 queryset = ControllerSlices.objects.select_related().all()
5739 serializer_class = ControllerSlicesSerializer
5740 id_serializer_class = ControllerSlicesIdSerializer
5741 filter_backends = (filters.DjangoFilterBackend,)
5742 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
5743
5744 def get_serializer_class(self):
5745 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5746 if (no_hyperlinks):
5747 return self.id_serializer_class
5748 else:
5749 return self.serializer_class
5750
5751 def get_queryset(self):
5752 return ControllerSlices.select_by_user(self.request.user)
5753
5754 def create(self, request, *args, **kwargs):
5755 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5756 if not (serializer.is_valid()):
5757 response = {"error": "validation",
5758 "specific_error": "not serializer.is_valid()",
5759 "reasons": serializer.errors}
5760 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5761 obj = serializer.object
5762 obj.caller = request.user
5763 if obj.can_update(request.user):
5764 return super(ControllerSlicesList, self).create(request, *args, **kwargs)
5765 else:
5766 raise Exception("failed obj.can_update")
5767
5768 ret = super(ControllerSlicesList, self).create(request, *args, **kwargs)
5769 if (ret.status_code%100 != 200):
5770 raise Exception(ret.data)
5771
5772 return ret
5773
5774
5775class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5776 queryset = ControllerSlices.objects.select_related().all()
5777 serializer_class = ControllerSlicesSerializer
5778 id_serializer_class = ControllerSlicesIdSerializer
5779
5780 def get_serializer_class(self):
5781 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5782 if (no_hyperlinks):
5783 return self.id_serializer_class
5784 else:
5785 return self.serializer_class
5786
5787 def get_queryset(self):
5788 return ControllerSlices.select_by_user(self.request.user)
5789
5790 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5791
5792 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5793
5794
5795