blob: fdd74d32f3c189f61ff2f0ada5889633cb3ff81a [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
Scott Bakerc8af5752014-12-23 11:12:07 -080013if hasattr(serializers, "ReadOnlyField"):
14 # rest_framework 3.x
15 IdField = serializers.ReadOnlyField
16else:
17 # rest_framework 2.x
18 IdField = serializers.Field
19
Sapan Bhatiadea39432014-06-13 03:10:36 -040020"""
Scott Baker08898c12014-10-29 23:41:11 -070021 Schema of the generator object:
22 all: Set of all Model objects
23 all_if(regex): Set of Model objects that match regex
Scott Bakerf3816ac2014-11-12 01:13:53 -080024
Scott Baker08898c12014-10-29 23:41:11 -070025 Model object:
26 plural: English plural of object name
27 camel: CamelCase version of object name
28 refs: list of references to other Model objects
29 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040030
Scott Baker08898c12014-10-29 23:41:11 -070031 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040032"""
33
Scott Baker55a2e292014-11-10 16:31:15 -080034def get_REST_patterns():
35 return patterns('',
36 url(r'^plstackapi/$', api_root),
37
38 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
39 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
40
Scott Bakerc1d11912014-12-22 09:29:05 -080041 url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
42 url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
43
Scott Bakeree9c5bf2015-01-12 13:16:39 -080044 url(r'plstackapi/controllersiteprivileges/$', ControllerSitePrivilegeList.as_view(), name='controllersiteprivilege-list'),
45 url(r'plstackapi/controllersiteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSitePrivilegeDetail.as_view(), name ='controllersiteprivilege-detail'),
46
Scott Baker55a2e292014-11-10 16:31:15 -080047 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
48 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
49
50 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
51 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
52
53 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
54 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
55
56 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
57 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
58
59 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
60 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
61
62 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
63 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
64
65 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
66 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
67
68 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
69 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
70
71 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
72 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
73
Scott Bakeree9c5bf2015-01-12 13:16:39 -080074 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
75 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
76
77 url(r'plstackapi/controllersites/$', ControllerSiteList.as_view(), name='controllersite-list'),
78 url(r'plstackapi/controllersites/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDetail.as_view(), name ='controllersite-detail'),
79
Scott Baker55a2e292014-11-10 16:31:15 -080080 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
81 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
82
83 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
84 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
85
86 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
87 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
88
89 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
90 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
91
92 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
93 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
94
Scott Bakeree9c5bf2015-01-12 13:16:39 -080095 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
96 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -080097
98 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
99 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
100
101 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
102 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
103
104 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
105 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
106
107 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
108 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
109
110 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
111 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
112
113 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
114 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
115
116 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
117 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
118
119 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
120 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
121
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800122 url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetwork-list'),
123 url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetwork-detail'),
124
Scott Bakerc1d11912014-12-22 09:29:05 -0800125 url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
126 url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800127
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800128 url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controlleruser-list'),
129 url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controlleruser-detail'),
130
Scott Baker55a2e292014-11-10 16:31:15 -0800131 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
132 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
133
Scott Bakerc1d11912014-12-22 09:29:05 -0800134 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
135 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
136
Scott Baker55a2e292014-11-10 16:31:15 -0800137 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
138 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
139
140 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
141 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
142
Scott Bakerc1d11912014-12-22 09:29:05 -0800143 url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'),
144 url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
145
Scott Baker55a2e292014-11-10 16:31:15 -0800146 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
147 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
148
149 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
150 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
151
152 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
153 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
154
155 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
156 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
157
Scott Baker55a2e292014-11-10 16:31:15 -0800158 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
159 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
160
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800161 url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslice-list'),
162 url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslice-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800163
Scott Bakera6a0c772014-12-22 17:35:34 -0800164 url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'),
165 url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'),
166
Scott Baker55a2e292014-11-10 16:31:15 -0800167 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
168 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
169
Scott Bakerc1d11912014-12-22 09:29:05 -0800170 url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
171 url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
172
Scott Baker55a2e292014-11-10 16:31:15 -0800173 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
174 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
175
176 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
177 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
178
Scott Bakerc1d11912014-12-22 09:29:05 -0800179 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
180 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800181
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800182 url(r'plstackapi/controllersliceprivileges/$', ControllerSlicePrivilegeList.as_view(), name='controllersliceprivilege-list'),
183 url(r'plstackapi/controllersliceprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicePrivilegeDetail.as_view(), name ='controllersliceprivilege-detail'),
184
185 url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployment-list'),
186 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployment-detail'),
Scott Bakerc1d11912014-12-22 09:29:05 -0800187
188 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
189 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800190
191 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
192 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
193
Scott Baker55a2e292014-11-10 16:31:15 -0800194 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
195 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
196
Scott Bakera6a0c772014-12-22 17:35:34 -0800197 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
198 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800199
200 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
201 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
202
203 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
204 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
205
206 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400207
208@api_view(['GET'])
209def api_root(request, format=None):
210 return Response({
Scott Baker08898c12014-10-29 23:41:11 -0700211 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800212 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800213 'controllersiteprivileges': reverse('controllersiteprivilege-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700214 'images': reverse('image-list', request=request, format=format),
215 'networkparameters': reverse('networkparameter-list', request=request, format=format),
216 'sites': reverse('site-list', request=request, format=format),
217 'sliceroles': reverse('slicerole-list', request=request, format=format),
218 'tags': reverse('tag-list', request=request, format=format),
219 'invoices': reverse('invoice-list', request=request, format=format),
220 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
221 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
222 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800223 'flavors': reverse('flavor-list', request=request, format=format),
224 'controllersites': reverse('controllersite-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700225 'projects': reverse('project-list', request=request, format=format),
226 'slices': reverse('slice-list', request=request, format=format),
227 'networks': reverse('network-list', request=request, format=format),
228 'services': reverse('service-list', request=request, format=format),
229 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800230 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700231 'charges': reverse('charge-list', request=request, format=format),
232 'roles': reverse('role-list', request=request, format=format),
233 'usableobjects': reverse('usableobject-list', request=request, format=format),
234 'siteroles': reverse('siterole-list', request=request, format=format),
235 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
236 'slivers': reverse('sliver-list', request=request, format=format),
237 'nodes': reverse('node-list', request=request, format=format),
238 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800239 'controllernetworks': reverse('controllernetwork-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800240 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800241 'controllerusers': reverse('controlleruser-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700242 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800243 'payments': reverse('payment-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700244 'networkslices': reverse('networkslice-list', request=request, format=format),
245 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800246 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700247 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
248 'users': reverse('user-list', request=request, format=format),
249 'deployments': reverse('deployment-list', request=request, format=format),
250 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700251 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800252 'controllerslices': reverse('controllerslice-list', request=request, format=format),
Scott Bakera6a0c772014-12-22 17:35:34 -0800253 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700254 'accounts': reverse('account-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800255 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700256 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
257 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800258 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800259 'controllersliceprivileges': reverse('controllersliceprivilege-list', request=request, format=format),
260 'sitedeployments': reverse('sitedeployment-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800261 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700262 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700263 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Bakera6a0c772014-12-22 17:35:34 -0800264 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700265 'routers': reverse('router-list', request=request, format=format),
266 'serviceresources': reverse('serviceresource-list', request=request, format=format),
267
Sapan Bhatiadea39432014-06-13 03:10:36 -0400268 })
269
270# Based on serializers.py
271
Scott Bakerc1d11912014-12-22 09:29:05 -0800272class XOSModelSerializer(serializers.ModelSerializer):
273 def save_object(self, obj, **kwargs):
274
275 """ rest_framework can't deal with ManyToMany relations that have a
276 through table. In plstackapi, most of the through tables we have
277 use defaults or blank fields, so there's no reason why we shouldn't
278 be able to save these objects.
279
280 So, let's strip out these m2m relations, and deal with them ourself.
281 """
282 obj._complex_m2m_data={};
283 if getattr(obj, '_m2m_data', None):
284 for relatedObject in obj._meta.get_all_related_many_to_many_objects():
285 if (relatedObject.field.rel.through._meta.auto_created):
286 # These are non-trough ManyToMany relations and
287 # can be updated just fine
288 continue
289 fieldName = relatedObject.get_accessor_name()
290 if fieldName in obj._m2m_data.keys():
291 obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
292 del obj._m2m_data[fieldName]
293
294 serializers.ModelSerializer.save_object(self, obj, **kwargs);
295
296 for (accessor, stuff) in obj._complex_m2m_data.items():
297 (relatedObject, data) = stuff
298 through = relatedObject.field.rel.through
299 local_fieldName = relatedObject.field.m2m_reverse_field_name()
300 remote_fieldName = relatedObject.field.m2m_field_name()
301
302 # get the current set of existing relations
303 existing = through.objects.filter(**{local_fieldName: obj});
304
305 data_ids = [item.id for item in data]
306 existing_ids = [getattr(item,remote_fieldName).id for item in existing]
307
308 #print "data_ids", data_ids
309 #print "existing_ids", existing_ids
310
311 # remove relations that are in 'existing' but not in 'data'
312 for item in list(existing):
313 if (getattr(item,remote_fieldName).id not in data_ids):
314 print "delete", getattr(item,remote_fieldName)
315 item.delete() #(purge=True)
316
317 # add relations that are in 'data' but not in 'existing'
318 for item in data:
319 if (item.id not in existing_ids):
320 #print "add", item
321 newModel = through(**{local_fieldName: obj, remote_fieldName: item})
322 newModel.save()
323
324
325
Scott Baker0caeaf02014-06-19 11:12:55 -0700326class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800327 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700328
Scott Baker196ffef2014-11-21 11:32:24 -0800329 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800330 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800331 def getHumanReadableName(self, obj):
332 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800333 def getValidators(self, obj):
334 try:
335 return obj.getValidators()
336 except:
337 return None
Scott Baker08898c12014-10-29 23:41:11 -0700338 class Meta:
339 model = ServiceAttribute
Scott Baker351148c2014-11-25 00:53:25 -0800340 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700341
Scott Bakerc1d11912014-12-22 09:29:05 -0800342class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800343 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700344
Scott Baker196ffef2014-11-21 11:32:24 -0800345 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800346 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800347 def getHumanReadableName(self, obj):
348 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800349 def getValidators(self, obj):
350 try:
351 return obj.getValidators()
352 except:
353 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800354 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700355 model = ServiceAttribute
Scott Baker351148c2014-11-25 00:53:25 -0800356 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700357
358
Sapan Bhatiadea39432014-06-13 03:10:36 -0400359
360
Scott Bakerc1d11912014-12-22 09:29:05 -0800361class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800362 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -0800363
364 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
365 validators = serializers.SerializerMethodField("getValidators")
366 def getHumanReadableName(self, obj):
367 return str(obj)
368 def getValidators(self, obj):
369 try:
370 return obj.getValidators()
371 except:
372 return None
373 class Meta:
374 model = ControllerImages
375 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
376
377class ControllerImagesIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800378 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -0800379
380 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
381 validators = serializers.SerializerMethodField("getValidators")
382 def getHumanReadableName(self, obj):
383 return str(obj)
384 def getValidators(self, obj):
385 try:
386 return obj.getValidators()
387 except:
388 return None
389 class Meta:
390 model = ControllerImages
391 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
392
393
394
395
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800396class ControllerSitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
397 id = IdField()
398
399 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
400 validators = serializers.SerializerMethodField("getValidators")
401 def getHumanReadableName(self, obj):
402 return str(obj)
403 def getValidators(self, obj):
404 try:
405 return obj.getValidators()
406 except:
407 return None
408 class Meta:
409 model = ControllerSitePrivilege
410 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',)
411
412class ControllerSitePrivilegeIdSerializer(XOSModelSerializer):
413 id = IdField()
414
415 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
416 validators = serializers.SerializerMethodField("getValidators")
417 def getHumanReadableName(self, obj):
418 return str(obj)
419 def getValidators(self, obj):
420 try:
421 return obj.getValidators()
422 except:
423 return None
424 class Meta:
425 model = ControllerSitePrivilege
426 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',)
427
428
429
430
Sapan Bhatiadea39432014-06-13 03:10:36 -0400431class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800432 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700433
Scott Baker93a79a92014-12-22 15:59:33 -0800434
435 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
436
437
Scott Baker196ffef2014-11-21 11:32:24 -0800438 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800439 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800440 def getHumanReadableName(self, obj):
441 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800442 def getValidators(self, obj):
443 try:
444 return obj.getValidators()
445 except:
446 return None
Scott Baker08898c12014-10-29 23:41:11 -0700447 class Meta:
448 model = Image
Scott Baker93a79a92014-12-22 15:59:33 -0800449 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700450
Scott Bakerc1d11912014-12-22 09:29:05 -0800451class ImageIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800452 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700453
Scott Baker93a79a92014-12-22 15:59:33 -0800454
Scott Bakera3134fe2014-12-23 10:56:06 -0800455 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker93a79a92014-12-22 15:59:33 -0800456
457
Scott Baker196ffef2014-11-21 11:32:24 -0800458 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800459 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800460 def getHumanReadableName(self, obj):
461 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800462 def getValidators(self, obj):
463 try:
464 return obj.getValidators()
465 except:
466 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800467 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700468 model = Image
Scott Baker93a79a92014-12-22 15:59:33 -0800469 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700470
471
Sapan Bhatiadea39432014-06-13 03:10:36 -0400472
473
Scott Baker0caeaf02014-06-19 11:12:55 -0700474class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800475 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700476
Scott Baker196ffef2014-11-21 11:32:24 -0800477 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800478 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800479 def getHumanReadableName(self, obj):
480 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800481 def getValidators(self, obj):
482 try:
483 return obj.getValidators()
484 except:
485 return None
Scott Baker08898c12014-10-29 23:41:11 -0700486 class Meta:
487 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800488 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700489
Scott Bakerc1d11912014-12-22 09:29:05 -0800490class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800491 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700492
Scott Baker196ffef2014-11-21 11:32:24 -0800493 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800494 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800495 def getHumanReadableName(self, obj):
496 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800497 def getValidators(self, obj):
498 try:
499 return obj.getValidators()
500 except:
501 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800502 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700503 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800504 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700505
506
Sapan Bhatiadea39432014-06-13 03:10:36 -0400507
508
509class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800510 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700511
Scott Bakerc1d11912014-12-22 09:29:05 -0800512
513 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
514
515
Scott Baker196ffef2014-11-21 11:32:24 -0800516 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800517 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800518 def getHumanReadableName(self, obj):
519 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800520 def getValidators(self, obj):
521 try:
522 return obj.getValidators()
523 except:
524 return None
Scott Baker08898c12014-10-29 23:41:11 -0700525 class Meta:
526 model = Site
Scott Bakerc1d11912014-12-22 09:29:05 -0800527 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 -0700528
Scott Bakerc1d11912014-12-22 09:29:05 -0800529class SiteIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800530 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700531
Scott Bakerc1d11912014-12-22 09:29:05 -0800532
Scott Bakera3134fe2014-12-23 10:56:06 -0800533 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -0800534
535
Scott Baker196ffef2014-11-21 11:32:24 -0800536 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800537 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800538 def getHumanReadableName(self, obj):
539 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800540 def getValidators(self, obj):
541 try:
542 return obj.getValidators()
543 except:
544 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800545 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700546 model = Site
Scott Bakerc1d11912014-12-22 09:29:05 -0800547 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 -0700548
549
Sapan Bhatiadea39432014-06-13 03:10:36 -0400550
551
Scott Baker0caeaf02014-06-19 11:12:55 -0700552class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800553 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700554
Scott Baker196ffef2014-11-21 11:32:24 -0800555 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800556 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800557 def getHumanReadableName(self, obj):
558 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800559 def getValidators(self, obj):
560 try:
561 return obj.getValidators()
562 except:
563 return None
Scott Baker08898c12014-10-29 23:41:11 -0700564 class Meta:
565 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800566 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700567
Scott Bakerc1d11912014-12-22 09:29:05 -0800568class SliceRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800569 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700570
Scott Baker196ffef2014-11-21 11:32:24 -0800571 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800572 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800573 def getHumanReadableName(self, obj):
574 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800575 def getValidators(self, obj):
576 try:
577 return obj.getValidators()
578 except:
579 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800580 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700581 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800582 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700583
584
Sapan Bhatiadea39432014-06-13 03:10:36 -0400585
586
587class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800588 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700589
Scott Baker196ffef2014-11-21 11:32:24 -0800590 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800591 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800592 def getHumanReadableName(self, obj):
593 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800594 def getValidators(self, obj):
595 try:
596 return obj.getValidators()
597 except:
598 return None
Scott Baker08898c12014-10-29 23:41:11 -0700599 class Meta:
600 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800601 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700602
Scott Bakerc1d11912014-12-22 09:29:05 -0800603class TagIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800604 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700605
Scott Baker196ffef2014-11-21 11:32:24 -0800606 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800607 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800608 def getHumanReadableName(self, obj):
609 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800610 def getValidators(self, obj):
611 try:
612 return obj.getValidators()
613 except:
614 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800615 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700616 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800617 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700618
619
Sapan Bhatiadea39432014-06-13 03:10:36 -0400620
621
622class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800623 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700624
Scott Baker196ffef2014-11-21 11:32:24 -0800625 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800626 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800627 def getHumanReadableName(self, obj):
628 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800629 def getValidators(self, obj):
630 try:
631 return obj.getValidators()
632 except:
633 return None
Scott Baker08898c12014-10-29 23:41:11 -0700634 class Meta:
635 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800636 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700637
Scott Bakerc1d11912014-12-22 09:29:05 -0800638class InvoiceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800639 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700640
Scott Baker196ffef2014-11-21 11:32:24 -0800641 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800642 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800643 def getHumanReadableName(self, obj):
644 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800645 def getValidators(self, obj):
646 try:
647 return obj.getValidators()
648 except:
649 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800650 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700651 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800652 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700653
654
Sapan Bhatiadea39432014-06-13 03:10:36 -0400655
656
Scott Baker0caeaf02014-06-19 11:12:55 -0700657class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800658 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700659
Scott Baker196ffef2014-11-21 11:32:24 -0800660 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800661 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800662 def getHumanReadableName(self, obj):
663 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800664 def getValidators(self, obj):
665 try:
666 return obj.getValidators()
667 except:
668 return None
Scott Baker08898c12014-10-29 23:41:11 -0700669 class Meta:
670 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800671 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700672
Scott Bakerc1d11912014-12-22 09:29:05 -0800673class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800674 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700675
Scott Baker196ffef2014-11-21 11:32:24 -0800676 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800677 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800678 def getHumanReadableName(self, obj):
679 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800680 def getValidators(self, obj):
681 try:
682 return obj.getValidators()
683 except:
684 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800685 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700686 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800687 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700688
689
Scott Baker0caeaf02014-06-19 11:12:55 -0700690
691
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700692class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800693 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700694
Scott Baker196ffef2014-11-21 11:32:24 -0800695 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800696 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800697 def getHumanReadableName(self, obj):
698 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800699 def getValidators(self, obj):
700 try:
701 return obj.getValidators()
702 except:
703 return None
Scott Baker08898c12014-10-29 23:41:11 -0700704 class Meta:
705 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800706 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700707
Scott Bakerc1d11912014-12-22 09:29:05 -0800708class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800709 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700710
Scott Baker196ffef2014-11-21 11:32:24 -0800711 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800712 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800713 def getHumanReadableName(self, obj):
714 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800715 def getValidators(self, obj):
716 try:
717 return obj.getValidators()
718 except:
719 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800720 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700721 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800722 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700723
724
725
726
Scott Baker0caeaf02014-06-19 11:12:55 -0700727class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800728 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700729
Scott Baker196ffef2014-11-21 11:32:24 -0800730 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800731 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800732 def getHumanReadableName(self, obj):
733 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800734 def getValidators(self, obj):
735 try:
736 return obj.getValidators()
737 except:
738 return None
Scott Baker08898c12014-10-29 23:41:11 -0700739 class Meta:
740 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800741 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700742
Scott Bakerc1d11912014-12-22 09:29:05 -0800743class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800744 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700745
Scott Baker196ffef2014-11-21 11:32:24 -0800746 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800747 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800748 def getHumanReadableName(self, obj):
749 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800750 def getValidators(self, obj):
751 try:
752 return obj.getValidators()
753 except:
754 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800755 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700756 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800757 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700758
759
Scott Baker0caeaf02014-06-19 11:12:55 -0700760
761
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800762class FlavorSerializer(serializers.HyperlinkedModelSerializer):
763 id = IdField()
764
765
766 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
767
768
769 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
770 validators = serializers.SerializerMethodField("getValidators")
771 def getHumanReadableName(self, obj):
772 return str(obj)
773 def getValidators(self, obj):
774 try:
775 return obj.getValidators()
776 except:
777 return None
778 class Meta:
779 model = Flavor
780 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
781
782class FlavorIdSerializer(XOSModelSerializer):
783 id = IdField()
784
785
786 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
787
788
789 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
790 validators = serializers.SerializerMethodField("getValidators")
791 def getHumanReadableName(self, obj):
792 return str(obj)
793 def getValidators(self, obj):
794 try:
795 return obj.getValidators()
796 except:
797 return None
798 class Meta:
799 model = Flavor
800 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
801
802
803
804
805class ControllerSiteSerializer(serializers.HyperlinkedModelSerializer):
806 id = IdField()
807
808 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
809 validators = serializers.SerializerMethodField("getValidators")
810 def getHumanReadableName(self, obj):
811 return str(obj)
812 def getValidators(self, obj):
813 try:
814 return obj.getValidators()
815 except:
816 return None
817 class Meta:
818 model = ControllerSite
819 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',)
820
821class ControllerSiteIdSerializer(XOSModelSerializer):
822 id = IdField()
823
824 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
825 validators = serializers.SerializerMethodField("getValidators")
826 def getHumanReadableName(self, obj):
827 return str(obj)
828 def getValidators(self, obj):
829 try:
830 return obj.getValidators()
831 except:
832 return None
833 class Meta:
834 model = ControllerSite
835 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',)
836
837
838
839
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700840class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800841 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700842
Scott Baker196ffef2014-11-21 11:32:24 -0800843 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800844 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800845 def getHumanReadableName(self, obj):
846 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800847 def getValidators(self, obj):
848 try:
849 return obj.getValidators()
850 except:
851 return None
Scott Baker08898c12014-10-29 23:41:11 -0700852 class Meta:
853 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800854 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700855
Scott Bakerc1d11912014-12-22 09:29:05 -0800856class ProjectIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800857 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700858
Scott Baker196ffef2014-11-21 11:32:24 -0800859 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800860 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800861 def getHumanReadableName(self, obj):
862 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800863 def getValidators(self, obj):
864 try:
865 return obj.getValidators()
866 except:
867 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800868 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700869 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800870 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700871
872
873
874
Sapan Bhatiadea39432014-06-13 03:10:36 -0400875class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800876 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700877
878
879 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
880
881
882
Scott Baker08898c12014-10-29 23:41:11 -0700883 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
884
885
Scott Baker196ffef2014-11-21 11:32:24 -0800886 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800887 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800888 def getHumanReadableName(self, obj):
889 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800890 def getValidators(self, obj):
891 try:
892 return obj.getValidators()
893 except:
894 return None
Scott Baker08898c12014-10-29 23:41:11 -0700895 class Meta:
896 model = Slice
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800897 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700898
Scott Bakerc1d11912014-12-22 09:29:05 -0800899class SliceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800900 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700901
902
Scott Bakera3134fe2014-12-23 10:56:06 -0800903 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700904
905
906
Scott Bakera3134fe2014-12-23 10:56:06 -0800907 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700908
909
Scott Baker196ffef2014-11-21 11:32:24 -0800910 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800911 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800912 def getHumanReadableName(self, obj):
913 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800914 def getValidators(self, obj):
915 try:
916 return obj.getValidators()
917 except:
918 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800919 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700920 model = Slice
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800921 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700922
923
Sapan Bhatiadea39432014-06-13 03:10:36 -0400924
925
926class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800927 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700928
929
Scott Bakerc1d11912014-12-22 09:29:05 -0800930 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700931
932
933
Scott Bakerc1d11912014-12-22 09:29:05 -0800934 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
935
936
937
938 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700939
940
941
942 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
943
944
945
946 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
947
948
Scott Baker196ffef2014-11-21 11:32:24 -0800949 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800950 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800951 def getHumanReadableName(self, obj):
952 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800953 def getValidators(self, obj):
954 try:
955 return obj.getValidators()
956 except:
957 return None
Scott Baker08898c12014-10-29 23:41:11 -0700958 class Meta:
959 model = Network
Scott Baker95bdf0a2015-01-03 12:32:45 -0800960 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700961
Scott Bakerc1d11912014-12-22 09:29:05 -0800962class NetworkIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800963 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700964
965
Scott Bakera3134fe2014-12-23 10:56:06 -0800966 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700967
968
969
Scott Bakera3134fe2014-12-23 10:56:06 -0800970 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700971
972
973
Scott Bakera3134fe2014-12-23 10:56:06 -0800974 slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700975
976
977
Scott Bakera3134fe2014-12-23 10:56:06 -0800978 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -0800979
980
981
Scott Bakera3134fe2014-12-23 10:56:06 -0800982 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700983
984
Scott Baker196ffef2014-11-21 11:32:24 -0800985 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800986 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800987 def getHumanReadableName(self, obj):
988 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800989 def getValidators(self, obj):
990 try:
991 return obj.getValidators()
992 except:
993 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800994 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700995 model = Network
Scott Baker95bdf0a2015-01-03 12:32:45 -0800996 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700997
998
Sapan Bhatiadea39432014-06-13 03:10:36 -0400999
1000
1001class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001002 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001003
Scott Baker196ffef2014-11-21 11:32:24 -08001004 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001005 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001006 def getHumanReadableName(self, obj):
1007 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001008 def getValidators(self, obj):
1009 try:
1010 return obj.getValidators()
1011 except:
1012 return None
Scott Baker08898c12014-10-29 23:41:11 -07001013 class Meta:
1014 model = Service
Scott Baker351148c2014-11-25 00:53:25 -08001015 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -07001016
Scott Bakerc1d11912014-12-22 09:29:05 -08001017class ServiceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001018 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001019
Scott Baker196ffef2014-11-21 11:32:24 -08001020 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001021 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001022 def getHumanReadableName(self, obj):
1023 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001024 def getValidators(self, obj):
1025 try:
1026 return obj.getValidators()
1027 except:
1028 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001029 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001030 model = Service
Scott Baker351148c2014-11-25 00:53:25 -08001031 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -07001032
1033
Sapan Bhatiadea39432014-06-13 03:10:36 -04001034
1035
Scott Baker0caeaf02014-06-19 11:12:55 -07001036class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001037 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001038
Scott Baker196ffef2014-11-21 11:32:24 -08001039 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001040 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001041 def getHumanReadableName(self, obj):
1042 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001043 def getValidators(self, obj):
1044 try:
1045 return obj.getValidators()
1046 except:
1047 return None
Scott Baker08898c12014-10-29 23:41:11 -07001048 class Meta:
1049 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -08001050 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001051
Scott Bakerc1d11912014-12-22 09:29:05 -08001052class ServiceClassIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001053 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001054
Scott Baker196ffef2014-11-21 11:32:24 -08001055 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001056 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001057 def getHumanReadableName(self, obj):
1058 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001059 def getValidators(self, obj):
1060 try:
1061 return obj.getValidators()
1062 except:
1063 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001064 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001065 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -08001066 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001067
1068
Sapan Bhatiadea39432014-06-13 03:10:36 -04001069
1070
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001071class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001072 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001073
Scott Baker196ffef2014-11-21 11:32:24 -08001074 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001075 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001076 def getHumanReadableName(self, obj):
1077 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001078 def getValidators(self, obj):
1079 try:
1080 return obj.getValidators()
1081 except:
1082 return None
Scott Baker08898c12014-10-29 23:41:11 -07001083 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001084 model = PlanetStack
1085 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001086
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001087class PlanetStackIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001088 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001089
Scott Baker196ffef2014-11-21 11:32:24 -08001090 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001091 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001092 def getHumanReadableName(self, obj):
1093 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001094 def getValidators(self, obj):
1095 try:
1096 return obj.getValidators()
1097 except:
1098 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001099 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001100 model = PlanetStack
1101 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001102
1103
Sapan Bhatiadea39432014-06-13 03:10:36 -04001104
1105
1106class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001107 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001108
Scott Baker196ffef2014-11-21 11:32:24 -08001109 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001110 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001111 def getHumanReadableName(self, obj):
1112 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001113 def getValidators(self, obj):
1114 try:
1115 return obj.getValidators()
1116 except:
1117 return None
Scott Baker08898c12014-10-29 23:41:11 -07001118 class Meta:
1119 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -08001120 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 -07001121
Scott Bakerc1d11912014-12-22 09:29:05 -08001122class ChargeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001123 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001124
Scott Baker196ffef2014-11-21 11:32:24 -08001125 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001126 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001127 def getHumanReadableName(self, obj):
1128 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001129 def getValidators(self, obj):
1130 try:
1131 return obj.getValidators()
1132 except:
1133 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001134 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001135 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -08001136 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 -07001137
1138
Sapan Bhatiadea39432014-06-13 03:10:36 -04001139
1140
1141class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001142 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001143
Scott Baker196ffef2014-11-21 11:32:24 -08001144 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001145 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001146 def getHumanReadableName(self, obj):
1147 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001148 def getValidators(self, obj):
1149 try:
1150 return obj.getValidators()
1151 except:
1152 return None
Scott Baker08898c12014-10-29 23:41:11 -07001153 class Meta:
1154 model = Role
Scott Baker351148c2014-11-25 00:53:25 -08001155 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001156
Scott Bakerc1d11912014-12-22 09:29:05 -08001157class RoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001158 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001159
Scott Baker196ffef2014-11-21 11:32:24 -08001160 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001161 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001162 def getHumanReadableName(self, obj):
1163 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001164 def getValidators(self, obj):
1165 try:
1166 return obj.getValidators()
1167 except:
1168 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001169 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001170 model = Role
Scott Baker351148c2014-11-25 00:53:25 -08001171 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001172
1173
Sapan Bhatiadea39432014-06-13 03:10:36 -04001174
1175
Scott Baker0caeaf02014-06-19 11:12:55 -07001176class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001177 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001178
Scott Baker196ffef2014-11-21 11:32:24 -08001179 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001180 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001181 def getHumanReadableName(self, obj):
1182 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001183 def getValidators(self, obj):
1184 try:
1185 return obj.getValidators()
1186 except:
1187 return None
Scott Baker08898c12014-10-29 23:41:11 -07001188 class Meta:
1189 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001190 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001191
Scott Bakerc1d11912014-12-22 09:29:05 -08001192class UsableObjectIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001193 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001194
Scott Baker196ffef2014-11-21 11:32:24 -08001195 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001196 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001197 def getHumanReadableName(self, obj):
1198 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001199 def getValidators(self, obj):
1200 try:
1201 return obj.getValidators()
1202 except:
1203 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001204 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001205 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001206 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001207
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001208
1209
1210
Scott Baker0caeaf02014-06-19 11:12:55 -07001211class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001212 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001213
Scott Baker196ffef2014-11-21 11:32:24 -08001214 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001215 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001216 def getHumanReadableName(self, obj):
1217 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001218 def getValidators(self, obj):
1219 try:
1220 return obj.getValidators()
1221 except:
1222 return None
Scott Baker08898c12014-10-29 23:41:11 -07001223 class Meta:
1224 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001225 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001226
Scott Bakerc1d11912014-12-22 09:29:05 -08001227class SiteRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001228 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001229
Scott Baker196ffef2014-11-21 11:32:24 -08001230 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001231 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001232 def getHumanReadableName(self, obj):
1233 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001234 def getValidators(self, obj):
1235 try:
1236 return obj.getValidators()
1237 except:
1238 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001239 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001240 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001241 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001242
1243
Scott Baker0caeaf02014-06-19 11:12:55 -07001244
1245
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001246class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001247 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001248
Scott Baker196ffef2014-11-21 11:32:24 -08001249 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001250 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001251 def getHumanReadableName(self, obj):
1252 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001253 def getValidators(self, obj):
1254 try:
1255 return obj.getValidators()
1256 except:
1257 return None
Scott Baker08898c12014-10-29 23:41:11 -07001258 class Meta:
1259 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001260 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001261
Scott Bakerc1d11912014-12-22 09:29:05 -08001262class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001263 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001264
Scott Baker196ffef2014-11-21 11:32:24 -08001265 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001266 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001267 def getHumanReadableName(self, obj):
1268 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001269 def getValidators(self, obj):
1270 try:
1271 return obj.getValidators()
1272 except:
1273 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001274 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001275 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001276 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001277
1278
1279
1280
Sapan Bhatiadea39432014-06-13 03:10:36 -04001281class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001282 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001283
1284
1285 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1286
1287
Scott Baker196ffef2014-11-21 11:32:24 -08001288 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001289 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001290 def getHumanReadableName(self, obj):
1291 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001292 def getValidators(self, obj):
1293 try:
1294 return obj.getValidators()
1295 except:
1296 return None
Scott Baker08898c12014-10-29 23:41:11 -07001297 class Meta:
1298 model = Sliver
Scott Baker6c958402015-01-03 12:05:21 -08001299 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001300
Scott Bakerc1d11912014-12-22 09:29:05 -08001301class SliverIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001302 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001303
1304
Scott Bakera3134fe2014-12-23 10:56:06 -08001305 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -07001306
1307
Scott Baker196ffef2014-11-21 11:32:24 -08001308 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001309 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001310 def getHumanReadableName(self, obj):
1311 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001312 def getValidators(self, obj):
1313 try:
1314 return obj.getValidators()
1315 except:
1316 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001317 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001318 model = Sliver
Scott Baker6c958402015-01-03 12:05:21 -08001319 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001320
1321
Sapan Bhatiadea39432014-06-13 03:10:36 -04001322
1323
1324class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001325 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001326
Scott Baker196ffef2014-11-21 11:32:24 -08001327 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001328 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001329 def getHumanReadableName(self, obj):
1330 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001331 def getValidators(self, obj):
1332 try:
1333 return obj.getValidators()
1334 except:
1335 return None
Scott Baker08898c12014-10-29 23:41:11 -07001336 class Meta:
1337 model = Node
Scott Bakerc1d11912014-12-22 09:29:05 -08001338 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001339
Scott Bakerc1d11912014-12-22 09:29:05 -08001340class NodeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001341 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001342
Scott Baker196ffef2014-11-21 11:32:24 -08001343 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001344 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001345 def getHumanReadableName(self, obj):
1346 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001347 def getValidators(self, obj):
1348 try:
1349 return obj.getValidators()
1350 except:
1351 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001352 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001353 model = Node
Scott Bakerc1d11912014-12-22 09:29:05 -08001354 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001355
1356
Sapan Bhatiadea39432014-06-13 03:10:36 -04001357
1358
Scott Baker0caeaf02014-06-19 11:12:55 -07001359class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001360 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001361
Scott Bakerc1d11912014-12-22 09:29:05 -08001362
1363 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1364
1365
Scott Baker196ffef2014-11-21 11:32:24 -08001366 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001367 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001368 def getHumanReadableName(self, obj):
1369 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001370 def getValidators(self, obj):
1371 try:
1372 return obj.getValidators()
1373 except:
1374 return None
Scott Baker08898c12014-10-29 23:41:11 -07001375 class Meta:
1376 model = DashboardView
Scott Bakerc1d11912014-12-22 09:29:05 -08001377 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker46b58542014-08-11 17:26:12 -07001378
Scott Bakerc1d11912014-12-22 09:29:05 -08001379class DashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001380 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001381
Scott Bakerc1d11912014-12-22 09:29:05 -08001382
Scott Bakera3134fe2014-12-23 10:56:06 -08001383 controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08001384
1385
Scott Baker196ffef2014-11-21 11:32:24 -08001386 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001387 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001388 def getHumanReadableName(self, obj):
1389 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001390 def getValidators(self, obj):
1391 try:
1392 return obj.getValidators()
1393 except:
1394 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001395 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001396 model = DashboardView
Scott Bakerc1d11912014-12-22 09:29:05 -08001397 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker196ffef2014-11-21 11:32:24 -08001398
1399
1400
1401
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001402class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer):
1403 id = IdField()
1404
1405 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1406 validators = serializers.SerializerMethodField("getValidators")
1407 def getHumanReadableName(self, obj):
1408 return str(obj)
1409 def getValidators(self, obj):
1410 try:
1411 return obj.getValidators()
1412 except:
1413 return None
1414 class Meta:
1415 model = ControllerNetwork
1416 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
1417
1418class ControllerNetworkIdSerializer(XOSModelSerializer):
1419 id = IdField()
1420
1421 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1422 validators = serializers.SerializerMethodField("getValidators")
1423 def getHumanReadableName(self, obj):
1424 return str(obj)
1425 def getValidators(self, obj):
1426 try:
1427 return obj.getValidators()
1428 except:
1429 return None
1430 class Meta:
1431 model = ControllerNetwork
1432 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
1433
1434
1435
1436
Scott Bakerc1d11912014-12-22 09:29:05 -08001437class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001438 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001439
1440 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001441 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001442 def getHumanReadableName(self, obj):
1443 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001444 def getValidators(self, obj):
1445 try:
1446 return obj.getValidators()
1447 except:
1448 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001449 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001450 model = ImageDeployments
1451 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker196ffef2014-11-21 11:32:24 -08001452
Scott Bakerc1d11912014-12-22 09:29:05 -08001453class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001454 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001455
1456 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001457 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001458 def getHumanReadableName(self, obj):
1459 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001460 def getValidators(self, obj):
1461 try:
1462 return obj.getValidators()
1463 except:
1464 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001465 class Meta:
1466 model = ImageDeployments
1467 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001468
1469
Sapan Bhatiadea39432014-06-13 03:10:36 -04001470
1471
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001472class ControllerUserSerializer(serializers.HyperlinkedModelSerializer):
1473 id = IdField()
1474
1475 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1476 validators = serializers.SerializerMethodField("getValidators")
1477 def getHumanReadableName(self, obj):
1478 return str(obj)
1479 def getValidators(self, obj):
1480 try:
1481 return obj.getValidators()
1482 except:
1483 return None
1484 class Meta:
1485 model = ControllerUser
1486 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
1487
1488class ControllerUserIdSerializer(XOSModelSerializer):
1489 id = IdField()
1490
1491 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1492 validators = serializers.SerializerMethodField("getValidators")
1493 def getHumanReadableName(self, obj):
1494 return str(obj)
1495 def getValidators(self, obj):
1496 try:
1497 return obj.getValidators()
1498 except:
1499 return None
1500 class Meta:
1501 model = ControllerUser
1502 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
1503
1504
1505
1506
Scott Baker0caeaf02014-06-19 11:12:55 -07001507class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001508 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001509
Scott Baker196ffef2014-11-21 11:32:24 -08001510 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001511 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001512 def getHumanReadableName(self, obj):
1513 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001514 def getValidators(self, obj):
1515 try:
1516 return obj.getValidators()
1517 except:
1518 return None
Scott Baker08898c12014-10-29 23:41:11 -07001519 class Meta:
1520 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001521 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001522
Scott Bakerc1d11912014-12-22 09:29:05 -08001523class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001524 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001525
Scott Baker196ffef2014-11-21 11:32:24 -08001526 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001527 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001528 def getHumanReadableName(self, obj):
1529 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001530 def getValidators(self, obj):
1531 try:
1532 return obj.getValidators()
1533 except:
1534 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001535 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001536 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001537 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001538
1539
1540
1541
Scott Bakerc1d11912014-12-22 09:29:05 -08001542class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001543 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001544
1545 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1546 validators = serializers.SerializerMethodField("getValidators")
1547 def getHumanReadableName(self, obj):
1548 return str(obj)
1549 def getValidators(self, obj):
1550 try:
1551 return obj.getValidators()
1552 except:
1553 return None
1554 class Meta:
1555 model = Payment
1556 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1557
1558class PaymentIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001559 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001560
1561 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1562 validators = serializers.SerializerMethodField("getValidators")
1563 def getHumanReadableName(self, obj):
1564 return str(obj)
1565 def getValidators(self, obj):
1566 try:
1567 return obj.getValidators()
1568 except:
1569 return None
1570 class Meta:
1571 model = Payment
1572 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1573
1574
1575
1576
Scott Baker0caeaf02014-06-19 11:12:55 -07001577class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001578 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001579
Scott Baker196ffef2014-11-21 11:32:24 -08001580 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001581 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001582 def getHumanReadableName(self, obj):
1583 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001584 def getValidators(self, obj):
1585 try:
1586 return obj.getValidators()
1587 except:
1588 return None
Scott Baker08898c12014-10-29 23:41:11 -07001589 class Meta:
1590 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001591 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001592
Scott Bakerc1d11912014-12-22 09:29:05 -08001593class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001594 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001595
Scott Baker196ffef2014-11-21 11:32:24 -08001596 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001597 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001598 def getHumanReadableName(self, obj):
1599 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001600 def getValidators(self, obj):
1601 try:
1602 return obj.getValidators()
1603 except:
1604 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001605 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001606 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001607 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001608
1609
Scott Baker0caeaf02014-06-19 11:12:55 -07001610
1611
1612class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001613 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001614
Scott Baker196ffef2014-11-21 11:32:24 -08001615 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001616 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001617 def getHumanReadableName(self, obj):
1618 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001619 def getValidators(self, obj):
1620 try:
1621 return obj.getValidators()
1622 except:
1623 return None
Scott Baker08898c12014-10-29 23:41:11 -07001624 class Meta:
1625 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001626 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001627
Scott Bakerc1d11912014-12-22 09:29:05 -08001628class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001629 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001630
Scott Baker196ffef2014-11-21 11:32:24 -08001631 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001632 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001633 def getHumanReadableName(self, obj):
1634 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001635 def getValidators(self, obj):
1636 try:
1637 return obj.getValidators()
1638 except:
Scott Bakerc1d11912014-12-22 09:29:05 -08001639 return None
1640 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001641 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001642 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001643
1644
1645
1646
Scott Bakerc1d11912014-12-22 09:29:05 -08001647class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001648 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001649
Scott Bakerc1d11912014-12-22 09:29:05 -08001650
1651 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1652
1653
Scott Baker196ffef2014-11-21 11:32:24 -08001654 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001655 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerc1d11912014-12-22 09:29:05 -08001656 def getHumanReadableName(self, obj):
Scott Baker196ffef2014-11-21 11:32:24 -08001657 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001658 def getValidators(self, obj):
1659 try:
1660 return obj.getValidators()
1661 except:
1662 return None
Scott Baker08898c12014-10-29 23:41:11 -07001663 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001664 model = Controller
1665 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 -07001666
Scott Bakerc1d11912014-12-22 09:29:05 -08001667class ControllerIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001668 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001669
1670
Scott Bakera3134fe2014-12-23 10:56:06 -08001671 dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -07001672
1673
Scott Baker196ffef2014-11-21 11:32:24 -08001674 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001675 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001676 def getHumanReadableName(self, obj):
1677 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001678 def getValidators(self, obj):
1679 try:
1680 return obj.getValidators()
1681 except:
1682 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001683 class Meta:
1684 model = Controller
1685 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
1686
1687
1688
1689
1690class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001691 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001692
1693 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1694 validators = serializers.SerializerMethodField("getValidators")
1695 def getHumanReadableName(self, obj):
1696 return str(obj)
1697 def getValidators(self, obj):
1698 try:
1699 return obj.getValidators()
1700 except:
1701 return None
1702 class Meta:
1703 model = PlanetStackPrivilege
1704 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1705
1706class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001707 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001708
1709 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1710 validators = serializers.SerializerMethodField("getValidators")
1711 def getHumanReadableName(self, obj):
1712 return str(obj)
1713 def getValidators(self, obj):
1714 try:
1715 return obj.getValidators()
1716 except:
1717 return None
1718 class Meta:
1719 model = PlanetStackPrivilege
1720 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1721
1722
1723
1724
1725class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001726 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001727
1728 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1729 validators = serializers.SerializerMethodField("getValidators")
1730 def getHumanReadableName(self, obj):
1731 return str(obj)
1732 def getValidators(self, obj):
1733 try:
1734 return obj.getValidators()
1735 except:
1736 return None
1737 class Meta:
1738 model = User
1739 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',)
1740
1741class UserIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001742 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001743
1744 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1745 validators = serializers.SerializerMethodField("getValidators")
1746 def getHumanReadableName(self, obj):
1747 return str(obj)
1748 def getValidators(self, obj):
1749 try:
1750 return obj.getValidators()
1751 except:
1752 return None
1753 class Meta:
1754 model = User
1755 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',)
1756
1757
1758
1759
1760class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001761 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001762
1763
Scott Baker93a79a92014-12-22 15:59:33 -08001764 images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1765
1766
1767
Scott Bakerc1d11912014-12-22 09:29:05 -08001768 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1769
1770
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001771
1772 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1773
1774
Scott Bakerc1d11912014-12-22 09:29:05 -08001775 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1776 validators = serializers.SerializerMethodField("getValidators")
1777 def getHumanReadableName(self, obj):
1778 return str(obj)
1779 def getValidators(self, obj):
1780 try:
1781 return obj.getValidators()
1782 except:
1783 return None
Scott Baker08898c12014-10-29 23:41:11 -07001784 class Meta:
1785 model = Deployment
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001786 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001787
Scott Bakerc1d11912014-12-22 09:29:05 -08001788class DeploymentIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001789 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001790
1791
Scott Bakera3134fe2014-12-23 10:56:06 -08001792 images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all())
Scott Baker93a79a92014-12-22 15:59:33 -08001793
1794
1795
Scott Bakera3134fe2014-12-23 10:56:06 -08001796 sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08001797
1798
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001799
1800 flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all())
1801
1802
Tony Mack336e0f92014-11-30 15:53:08 -05001803 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1804 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerc1d11912014-12-22 09:29:05 -08001805 def getHumanReadableName(self, obj):
1806 return str(obj)
1807 def getValidators(self, obj):
Tony Mack336e0f92014-11-30 15:53:08 -05001808 try:
1809 return obj.getValidators()
1810 except:
Scott Bakerc1d11912014-12-22 09:29:05 -08001811 return None
1812 class Meta:
1813 model = Deployment
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001814 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',)
Tony Mack336e0f92014-11-30 15:53:08 -05001815
1816
Sapan Bhatiadea39432014-06-13 03:10:36 -04001817
1818
1819class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001820 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001821
Scott Baker196ffef2014-11-21 11:32:24 -08001822 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001823 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001824 def getHumanReadableName(self, obj):
1825 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001826 def getValidators(self, obj):
1827 try:
1828 return obj.getValidators()
1829 except:
1830 return None
Scott Baker08898c12014-10-29 23:41:11 -07001831 class Meta:
1832 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001833 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001834
Scott Bakerc1d11912014-12-22 09:29:05 -08001835class ReservationIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001836 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001837
Scott Baker196ffef2014-11-21 11:32:24 -08001838 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001839 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001840 def getHumanReadableName(self, obj):
1841 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001842 def getValidators(self, obj):
1843 try:
1844 return obj.getValidators()
1845 except:
1846 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001847 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001848 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001849 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001850
1851
Scott Baker0caeaf02014-06-19 11:12:55 -07001852
1853
Scott Baker196ffef2014-11-21 11:32:24 -08001854class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001855 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001856
1857 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001858 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001859 def getHumanReadableName(self, obj):
1860 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001861 def getValidators(self, obj):
1862 try:
1863 return obj.getValidators()
1864 except:
1865 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001866 class Meta:
1867 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001868 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001869
Scott Bakerc1d11912014-12-22 09:29:05 -08001870class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001871 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001872
1873 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001874 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001875 def getHumanReadableName(self, obj):
1876 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001877 def getValidators(self, obj):
1878 try:
1879 return obj.getValidators()
1880 except:
1881 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001882 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -08001883 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001884 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001885
1886
1887
1888
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001889class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001890 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001891
1892 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001893 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001894 def getHumanReadableName(self, obj):
1895 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001896 def getValidators(self, obj):
1897 try:
1898 return obj.getValidators()
1899 except:
1900 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001901 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001902 model = ControllerSlice
1903 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08001904
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001905class ControllerSliceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001906 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001907
1908 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001909 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001910 def getHumanReadableName(self, obj):
1911 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001912 def getValidators(self, obj):
1913 try:
1914 return obj.getValidators()
1915 except:
1916 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001917 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001918 model = ControllerSlice
1919 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001920
1921
Sapan Bhatiadea39432014-06-13 03:10:36 -04001922
1923
Scott Bakera6a0c772014-12-22 17:35:34 -08001924class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001925 id = IdField()
Scott Bakera6a0c772014-12-22 17:35:34 -08001926
1927 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1928 validators = serializers.SerializerMethodField("getValidators")
1929 def getHumanReadableName(self, obj):
1930 return str(obj)
1931 def getValidators(self, obj):
1932 try:
1933 return obj.getValidators()
1934 except:
1935 return None
1936 class Meta:
1937 model = ControllerDashboardView
1938 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1939
1940class ControllerDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001941 id = IdField()
Scott Bakera6a0c772014-12-22 17:35:34 -08001942
1943 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1944 validators = serializers.SerializerMethodField("getValidators")
1945 def getHumanReadableName(self, obj):
1946 return str(obj)
1947 def getValidators(self, obj):
1948 try:
1949 return obj.getValidators()
1950 except:
1951 return None
1952 class Meta:
1953 model = ControllerDashboardView
1954 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1955
1956
1957
1958
Sapan Bhatiadea39432014-06-13 03:10:36 -04001959class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001960 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001961
Scott Baker196ffef2014-11-21 11:32:24 -08001962 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001963 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001964 def getHumanReadableName(self, obj):
1965 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001966 def getValidators(self, obj):
1967 try:
1968 return obj.getValidators()
1969 except:
1970 return None
Scott Baker08898c12014-10-29 23:41:11 -07001971 class Meta:
1972 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001973 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001974
Scott Bakerc1d11912014-12-22 09:29:05 -08001975class AccountIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001976 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001977
Scott Baker196ffef2014-11-21 11:32:24 -08001978 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001979 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001980 def getHumanReadableName(self, obj):
1981 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001982 def getValidators(self, obj):
1983 try:
1984 return obj.getValidators()
1985 except:
1986 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001987 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001988 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001989 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001990
1991
Sapan Bhatiadea39432014-06-13 03:10:36 -04001992
1993
Scott Bakerc1d11912014-12-22 09:29:05 -08001994class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001995 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001996
1997 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1998 validators = serializers.SerializerMethodField("getValidators")
1999 def getHumanReadableName(self, obj):
2000 return str(obj)
2001 def getValidators(self, obj):
2002 try:
2003 return obj.getValidators()
2004 except:
2005 return None
2006 class Meta:
2007 model = ControllerRole
2008 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
2009
2010class ControllerRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002011 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08002012
2013 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2014 validators = serializers.SerializerMethodField("getValidators")
2015 def getHumanReadableName(self, obj):
2016 return str(obj)
2017 def getValidators(self, obj):
2018 try:
2019 return obj.getValidators()
2020 except:
2021 return None
2022 class Meta:
2023 model = ControllerRole
2024 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
2025
2026
2027
2028
Scott Baker0caeaf02014-06-19 11:12:55 -07002029class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002030 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002031
Scott Baker196ffef2014-11-21 11:32:24 -08002032 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002033 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002034 def getHumanReadableName(self, obj):
2035 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002036 def getValidators(self, obj):
2037 try:
2038 return obj.getValidators()
2039 except:
2040 return None
Scott Baker08898c12014-10-29 23:41:11 -07002041 class Meta:
2042 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08002043 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07002044
Scott Bakerc1d11912014-12-22 09:29:05 -08002045class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002046 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002047
Scott Baker196ffef2014-11-21 11:32:24 -08002048 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002049 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002050 def getHumanReadableName(self, obj):
2051 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002052 def getValidators(self, obj):
2053 try:
2054 return obj.getValidators()
2055 except:
2056 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002057 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002058 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08002059 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07002060
2061
Sapan Bhatiadea39432014-06-13 03:10:36 -04002062
2063
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002064class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002065 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002066
Scott Baker196ffef2014-11-21 11:32:24 -08002067 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002068 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002069 def getHumanReadableName(self, obj):
2070 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002071 def getValidators(self, obj):
2072 try:
2073 return obj.getValidators()
2074 except:
2075 return None
Scott Baker08898c12014-10-29 23:41:11 -07002076 class Meta:
2077 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08002078 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002079
Scott Bakerc1d11912014-12-22 09:29:05 -08002080class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002081 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002082
Scott Baker196ffef2014-11-21 11:32:24 -08002083 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002084 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002085 def getHumanReadableName(self, obj):
2086 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002087 def getValidators(self, obj):
2088 try:
2089 return obj.getValidators()
2090 except:
2091 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002092 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002093 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08002094 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002095
2096
Scott Baker0caeaf02014-06-19 11:12:55 -07002097
2098
Scott Bakerc1d11912014-12-22 09:29:05 -08002099class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002100 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002101
Scott Baker196ffef2014-11-21 11:32:24 -08002102 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002103 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002104 def getHumanReadableName(self, obj):
2105 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002106 def getValidators(self, obj):
2107 try:
2108 return obj.getValidators()
2109 except:
2110 return None
Scott Baker08898c12014-10-29 23:41:11 -07002111 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08002112 model = DeploymentPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08002113 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002114
Scott Bakerc1d11912014-12-22 09:29:05 -08002115class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002116 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002117
Scott Baker196ffef2014-11-21 11:32:24 -08002118 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002119 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002120 def getHumanReadableName(self, obj):
2121 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002122 def getValidators(self, obj):
2123 try:
2124 return obj.getValidators()
2125 except:
2126 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002127 class Meta:
2128 model = DeploymentPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08002129 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker645dc9d2014-11-17 22:32:19 -08002130
2131
2132
2133
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002134class ControllerSlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002135 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002136
Scott Baker196ffef2014-11-21 11:32:24 -08002137 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002138 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002139 def getHumanReadableName(self, obj):
2140 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002141 def getValidators(self, obj):
2142 try:
2143 return obj.getValidators()
2144 except:
2145 return None
Scott Baker08898c12014-10-29 23:41:11 -07002146 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002147 model = ControllerSlicePrivilege
2148 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Bakerc1d11912014-12-22 09:29:05 -08002149
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002150class ControllerSlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002151 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08002152
2153 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2154 validators = serializers.SerializerMethodField("getValidators")
2155 def getHumanReadableName(self, obj):
2156 return str(obj)
2157 def getValidators(self, obj):
2158 try:
2159 return obj.getValidators()
2160 except:
2161 return None
2162 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002163 model = ControllerSlicePrivilege
2164 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',)
2165
2166
2167
2168
2169class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer):
2170 id = IdField()
2171
2172 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2173 validators = serializers.SerializerMethodField("getValidators")
2174 def getHumanReadableName(self, obj):
2175 return str(obj)
2176 def getValidators(self, obj):
2177 try:
2178 return obj.getValidators()
2179 except:
2180 return None
2181 class Meta:
2182 model = SiteDeployment
2183 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
2184
2185class SiteDeploymentIdSerializer(XOSModelSerializer):
2186 id = IdField()
2187
2188 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2189 validators = serializers.SerializerMethodField("getValidators")
2190 def getHumanReadableName(self, obj):
2191 return str(obj)
2192 def getValidators(self, obj):
2193 try:
2194 return obj.getValidators()
2195 except:
2196 return None
2197 class Meta:
2198 model = SiteDeployment
2199 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Bakerc1d11912014-12-22 09:29:05 -08002200
2201
2202
2203
2204class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002205 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08002206
2207 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2208 validators = serializers.SerializerMethodField("getValidators")
2209 def getHumanReadableName(self, obj):
2210 return str(obj)
2211 def getValidators(self, obj):
2212 try:
2213 return obj.getValidators()
2214 except:
2215 return None
2216 class Meta:
2217 model = DeploymentRole
Scott Baker351148c2014-11-25 00:53:25 -08002218 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002219
Scott Bakerc1d11912014-12-22 09:29:05 -08002220class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002221 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002222
Scott Baker196ffef2014-11-21 11:32:24 -08002223 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002224 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002225 def getHumanReadableName(self, obj):
2226 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002227 def getValidators(self, obj):
2228 try:
2229 return obj.getValidators()
2230 except:
2231 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002232 class Meta:
2233 model = DeploymentRole
Scott Baker351148c2014-11-25 00:53:25 -08002234 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002235
2236
Sapan Bhatiadea39432014-06-13 03:10:36 -04002237
2238
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002239class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002240 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002241
Scott Baker196ffef2014-11-21 11:32:24 -08002242 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002243 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002244 def getHumanReadableName(self, obj):
2245 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002246 def getValidators(self, obj):
2247 try:
2248 return obj.getValidators()
2249 except:
2250 return None
Scott Baker08898c12014-10-29 23:41:11 -07002251 class Meta:
2252 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08002253 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002254
Scott Bakerc1d11912014-12-22 09:29:05 -08002255class UserCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002256 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002257
Scott Baker196ffef2014-11-21 11:32:24 -08002258 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002259 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002260 def getHumanReadableName(self, obj):
2261 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002262 def getValidators(self, obj):
2263 try:
2264 return obj.getValidators()
2265 except:
2266 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002267 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002268 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08002269 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker196ffef2014-11-21 11:32:24 -08002270
2271
2272
2273
Scott Baker0caeaf02014-06-19 11:12:55 -07002274class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002275 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002276
Scott Baker196ffef2014-11-21 11:32:24 -08002277 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002278 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002279 def getHumanReadableName(self, obj):
2280 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002281 def getValidators(self, obj):
2282 try:
2283 return obj.getValidators()
2284 except:
2285 return None
Scott Baker08898c12014-10-29 23:41:11 -07002286 class Meta:
2287 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08002288 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002289
Scott Bakerc1d11912014-12-22 09:29:05 -08002290class SliceTagIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002291 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002292
Scott Baker196ffef2014-11-21 11:32:24 -08002293 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002294 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002295 def getHumanReadableName(self, obj):
2296 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002297 def getValidators(self, obj):
2298 try:
2299 return obj.getValidators()
2300 except:
2301 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002302 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002303 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08002304 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002305
2306
Scott Baker0caeaf02014-06-19 11:12:55 -07002307
2308
Scott Bakera6a0c772014-12-22 17:35:34 -08002309class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002310 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002311
Scott Baker196ffef2014-11-21 11:32:24 -08002312 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002313 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002314 def getHumanReadableName(self, obj):
2315 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002316 def getValidators(self, obj):
2317 try:
2318 return obj.getValidators()
2319 except:
2320 return None
Scott Baker08898c12014-10-29 23:41:11 -07002321 class Meta:
Scott Bakera6a0c772014-12-22 17:35:34 -08002322 model = NetworkTemplate
Scott Baker6c958402015-01-03 12:05:21 -08002323 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07002324
Scott Bakera6a0c772014-12-22 17:35:34 -08002325class NetworkTemplateIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002326 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002327
Scott Baker196ffef2014-11-21 11:32:24 -08002328 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002329 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002330 def getHumanReadableName(self, obj):
2331 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002332 def getValidators(self, obj):
2333 try:
2334 return obj.getValidators()
2335 except:
2336 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002337 class Meta:
Scott Bakera6a0c772014-12-22 17:35:34 -08002338 model = NetworkTemplate
Scott Baker6c958402015-01-03 12:05:21 -08002339 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07002340
2341
Sapan Bhatiadea39432014-06-13 03:10:36 -04002342
2343
2344class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002345 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002346
Scott Bakerc1d11912014-12-22 09:29:05 -08002347
2348 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2349
2350
2351
2352 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2353
2354
Scott Baker196ffef2014-11-21 11:32:24 -08002355 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002356 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002357 def getHumanReadableName(self, obj):
2358 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002359 def getValidators(self, obj):
2360 try:
2361 return obj.getValidators()
2362 except:
2363 return None
Scott Baker08898c12014-10-29 23:41:11 -07002364 class Meta:
2365 model = Router
Scott Bakerc1d11912014-12-22 09:29:05 -08002366 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002367
Scott Bakerc1d11912014-12-22 09:29:05 -08002368class RouterIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002369 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002370
Scott Bakerc1d11912014-12-22 09:29:05 -08002371
Scott Bakera3134fe2014-12-23 10:56:06 -08002372 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08002373
2374
2375
Scott Bakera3134fe2014-12-23 10:56:06 -08002376 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08002377
2378
Scott Baker196ffef2014-11-21 11:32:24 -08002379 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002380 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002381 def getHumanReadableName(self, obj):
2382 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002383 def getValidators(self, obj):
2384 try:
2385 return obj.getValidators()
2386 except:
2387 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002388 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002389 model = Router
Scott Bakerc1d11912014-12-22 09:29:05 -08002390 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002391
2392
Sapan Bhatiadea39432014-06-13 03:10:36 -04002393
2394
Scott Baker0caeaf02014-06-19 11:12:55 -07002395class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002396 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002397
Scott Baker196ffef2014-11-21 11:32:24 -08002398 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002399 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002400 def getHumanReadableName(self, obj):
2401 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002402 def getValidators(self, obj):
2403 try:
2404 return obj.getValidators()
2405 except:
2406 return None
Scott Baker08898c12014-10-29 23:41:11 -07002407 class Meta:
2408 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002409 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 -07002410
Scott Bakerc1d11912014-12-22 09:29:05 -08002411class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002412 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002413
Scott Baker196ffef2014-11-21 11:32:24 -08002414 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002415 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002416 def getHumanReadableName(self, obj):
2417 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002418 def getValidators(self, obj):
2419 try:
2420 return obj.getValidators()
2421 except:
2422 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002423 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002424 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002425 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 -07002426
2427
Sapan Bhatiadea39432014-06-13 03:10:36 -04002428
2429
2430serializerLookUp = {
2431
Scott Baker0caeaf02014-06-19 11:12:55 -07002432 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002433
Scott Bakerc1d11912014-12-22 09:29:05 -08002434 ControllerImages: ControllerImagesSerializer,
2435
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002436 ControllerSitePrivilege: ControllerSitePrivilegeSerializer,
2437
Sapan Bhatiadea39432014-06-13 03:10:36 -04002438 Image: ImageSerializer,
2439
Scott Baker0caeaf02014-06-19 11:12:55 -07002440 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002441
2442 Site: SiteSerializer,
2443
Scott Baker0caeaf02014-06-19 11:12:55 -07002444 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002445
2446 Tag: TagSerializer,
2447
2448 Invoice: InvoiceSerializer,
2449
Scott Baker0caeaf02014-06-19 11:12:55 -07002450 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002451
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002452 PlanetStackRole: PlanetStackRoleSerializer,
2453
Scott Baker0caeaf02014-06-19 11:12:55 -07002454 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002455
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002456 Flavor: FlavorSerializer,
2457
2458 ControllerSite: ControllerSiteSerializer,
2459
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002460 Project: ProjectSerializer,
2461
Sapan Bhatiadea39432014-06-13 03:10:36 -04002462 Slice: SliceSerializer,
2463
2464 Network: NetworkSerializer,
2465
2466 Service: ServiceSerializer,
2467
Scott Baker0caeaf02014-06-19 11:12:55 -07002468 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002469
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002470 PlanetStack: PlanetStackSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002471
2472 Charge: ChargeSerializer,
2473
2474 Role: RoleSerializer,
2475
Scott Baker0caeaf02014-06-19 11:12:55 -07002476 UsableObject: UsableObjectSerializer,
2477
2478 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002479
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002480 SliceCredential: SliceCredentialSerializer,
2481
Sapan Bhatiadea39432014-06-13 03:10:36 -04002482 Sliver: SliverSerializer,
2483
2484 Node: NodeSerializer,
2485
Scott Baker0caeaf02014-06-19 11:12:55 -07002486 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002487
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002488 ControllerNetwork: ControllerNetworkSerializer,
2489
Scott Bakerc1d11912014-12-22 09:29:05 -08002490 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002491
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002492 ControllerUser: ControllerUserSerializer,
2493
Scott Baker196ffef2014-11-21 11:32:24 -08002494 ReservedResource: ReservedResourceSerializer,
Scott Baker645dc9d2014-11-17 22:32:19 -08002495
Scott Bakerc1d11912014-12-22 09:29:05 -08002496 Payment: PaymentSerializer,
2497
Scott Baker0caeaf02014-06-19 11:12:55 -07002498 NetworkSlice: NetworkSliceSerializer,
2499
2500 UserDashboardView: UserDashboardViewSerializer,
2501
Scott Bakerc1d11912014-12-22 09:29:05 -08002502 Controller: ControllerSerializer,
2503
Scott Baker0caeaf02014-06-19 11:12:55 -07002504 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002505
2506 User: UserSerializer,
2507
2508 Deployment: DeploymentSerializer,
2509
2510 Reservation: ReservationSerializer,
2511
Scott Baker0caeaf02014-06-19 11:12:55 -07002512 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002513
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002514 ControllerSlice: ControllerSliceSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002515
Scott Bakera6a0c772014-12-22 17:35:34 -08002516 ControllerDashboardView: ControllerDashboardViewSerializer,
2517
Sapan Bhatiadea39432014-06-13 03:10:36 -04002518 Account: AccountSerializer,
2519
Scott Bakerc1d11912014-12-22 09:29:05 -08002520 ControllerRole: ControllerRoleSerializer,
2521
Scott Baker0caeaf02014-06-19 11:12:55 -07002522 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002523
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002524 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002525
Scott Bakerc1d11912014-12-22 09:29:05 -08002526 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002527
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002528 ControllerSlicePrivilege: ControllerSlicePrivilegeSerializer,
2529
2530 SiteDeployment: SiteDeploymentSerializer,
Scott Bakerc1d11912014-12-22 09:29:05 -08002531
2532 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002533
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002534 UserCredential: UserCredentialSerializer,
2535
Scott Baker0caeaf02014-06-19 11:12:55 -07002536 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002537
Scott Bakera6a0c772014-12-22 17:35:34 -08002538 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002539
2540 Router: RouterSerializer,
2541
Scott Baker0caeaf02014-06-19 11:12:55 -07002542 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002543
2544 None: None,
2545 }
2546
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002547class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2548
2549 # To handle fine-grained field permissions, we have to check can_update
2550 # the object has been updated but before it has been saved.
2551
2552 def update(self, request, *args, **kwargs):
2553 partial = kwargs.pop('partial', False)
2554 self.object = self.get_object_or_none()
2555
2556 serializer = self.get_serializer(self.object, data=request.DATA,
2557 files=request.FILES, partial=partial)
2558
2559 if not serializer.is_valid():
Scott Baker351148c2014-11-25 00:53:25 -08002560 response = {"error": "validation",
2561 "specific_error": "not serializer.is_valid()",
2562 "reasons": serializer.errors}
2563 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002564
2565 try:
2566 self.pre_save(serializer.object)
2567 except ValidationError as err:
2568 # full_clean on model instance may be called in pre_save,
2569 # so we have to handle eventual errors.
Scott Baker351148c2014-11-25 00:53:25 -08002570 response = {"error": "validation",
2571 "specific_error": "ValidationError in pre_save",
2572 "reasons": err.message_dict}
2573 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002574
2575 if serializer.object is not None:
2576 if not serializer.object.can_update(request.user):
2577 return Response(status=status.HTTP_400_BAD_REQUEST)
2578
2579 if self.object is None:
2580 self.object = serializer.save(force_insert=True)
2581 self.post_save(self.object, created=True)
2582 return Response(serializer.data, status=status.HTTP_201_CREATED)
2583
2584 self.object = serializer.save(force_update=True)
2585 self.post_save(self.object, created=False)
2586 return Response(serializer.data, status=status.HTTP_200_OK)
2587
2588 def destroy(self, request, *args, **kwargs):
2589 obj = self.get_object()
2590 if obj.can_update(request.user):
Scott Baker08898c12014-10-29 23:41:11 -07002591 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002592 else:
2593 return Response(status=status.HTTP_400_BAD_REQUEST)
2594
2595
Sapan Bhatiadea39432014-06-13 03:10:36 -04002596# Based on core/views/*.py
2597
2598
Scott Baker0caeaf02014-06-19 11:12:55 -07002599class ServiceAttributeList(generics.ListCreateAPIView):
2600 queryset = ServiceAttribute.objects.select_related().all()
2601 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002602 id_serializer_class = ServiceAttributeIdSerializer
2603 filter_backends = (filters.DjangoFilterBackend,)
2604 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2605
2606 def get_serializer_class(self):
2607 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2608 if (no_hyperlinks):
2609 return self.id_serializer_class
2610 else:
2611 return self.serializer_class
2612
Scott Baker0caeaf02014-06-19 11:12:55 -07002613 def get_queryset(self):
2614 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002615
Scott Baker0caeaf02014-06-19 11:12:55 -07002616 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002617 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2618 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002619 response = {"error": "validation",
2620 "specific_error": "not serializer.is_valid()",
2621 "reasons": serializer.errors}
2622 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002623 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002624 obj.caller = request.user
2625 if obj.can_update(request.user):
2626 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2627 else:
Scott Baker08898c12014-10-29 23:41:11 -07002628 raise Exception("failed obj.can_update")
2629
2630 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2631 if (ret.status_code%100 != 200):
2632 raise Exception(ret.data)
2633
2634 return ret
2635
Scott Baker0caeaf02014-06-19 11:12:55 -07002636
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002637class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002638 queryset = ServiceAttribute.objects.select_related().all()
2639 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002640 id_serializer_class = ServiceAttributeIdSerializer
2641
2642 def get_serializer_class(self):
2643 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2644 if (no_hyperlinks):
2645 return self.id_serializer_class
2646 else:
2647 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002648
2649 def get_queryset(self):
2650 return ServiceAttribute.select_by_user(self.request.user)
2651
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002652 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002653
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002654 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002655
2656
2657
Scott Bakerc1d11912014-12-22 09:29:05 -08002658class ControllerImagesList(generics.ListCreateAPIView):
2659 queryset = ControllerImages.objects.select_related().all()
2660 serializer_class = ControllerImagesSerializer
2661 id_serializer_class = ControllerImagesIdSerializer
2662 filter_backends = (filters.DjangoFilterBackend,)
2663 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
2664
2665 def get_serializer_class(self):
2666 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2667 if (no_hyperlinks):
2668 return self.id_serializer_class
2669 else:
2670 return self.serializer_class
2671
2672 def get_queryset(self):
2673 return ControllerImages.select_by_user(self.request.user)
2674
2675 def create(self, request, *args, **kwargs):
2676 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2677 if not (serializer.is_valid()):
2678 response = {"error": "validation",
2679 "specific_error": "not serializer.is_valid()",
2680 "reasons": serializer.errors}
2681 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2682 obj = serializer.object
2683 obj.caller = request.user
2684 if obj.can_update(request.user):
2685 return super(ControllerImagesList, self).create(request, *args, **kwargs)
2686 else:
2687 raise Exception("failed obj.can_update")
2688
2689 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2690 if (ret.status_code%100 != 200):
2691 raise Exception(ret.data)
2692
2693 return ret
2694
2695
2696class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2697 queryset = ControllerImages.objects.select_related().all()
2698 serializer_class = ControllerImagesSerializer
2699 id_serializer_class = ControllerImagesIdSerializer
2700
2701 def get_serializer_class(self):
2702 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2703 if (no_hyperlinks):
2704 return self.id_serializer_class
2705 else:
2706 return self.serializer_class
2707
2708 def get_queryset(self):
2709 return ControllerImages.select_by_user(self.request.user)
2710
2711 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2712
2713 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2714
2715
2716
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002717class ControllerSitePrivilegeList(generics.ListCreateAPIView):
2718 queryset = ControllerSitePrivilege.objects.select_related().all()
2719 serializer_class = ControllerSitePrivilegeSerializer
2720 id_serializer_class = ControllerSitePrivilegeIdSerializer
2721 filter_backends = (filters.DjangoFilterBackend,)
2722 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_privilege','role_id',)
2723
2724 def get_serializer_class(self):
2725 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2726 if (no_hyperlinks):
2727 return self.id_serializer_class
2728 else:
2729 return self.serializer_class
2730
2731 def get_queryset(self):
2732 return ControllerSitePrivilege.select_by_user(self.request.user)
2733
2734 def create(self, request, *args, **kwargs):
2735 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2736 if not (serializer.is_valid()):
2737 response = {"error": "validation",
2738 "specific_error": "not serializer.is_valid()",
2739 "reasons": serializer.errors}
2740 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2741 obj = serializer.object
2742 obj.caller = request.user
2743 if obj.can_update(request.user):
2744 return super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
2745 else:
2746 raise Exception("failed obj.can_update")
2747
2748 ret = super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
2749 if (ret.status_code%100 != 200):
2750 raise Exception(ret.data)
2751
2752 return ret
2753
2754
2755class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2756 queryset = ControllerSitePrivilege.objects.select_related().all()
2757 serializer_class = ControllerSitePrivilegeSerializer
2758 id_serializer_class = ControllerSitePrivilegeIdSerializer
2759
2760 def get_serializer_class(self):
2761 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2762 if (no_hyperlinks):
2763 return self.id_serializer_class
2764 else:
2765 return self.serializer_class
2766
2767 def get_queryset(self):
2768 return ControllerSitePrivilege.select_by_user(self.request.user)
2769
2770 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2771
2772 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2773
2774
2775
Sapan Bhatiadea39432014-06-13 03:10:36 -04002776class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002777 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002778 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002779 id_serializer_class = ImageIdSerializer
2780 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker93a79a92014-12-22 15:59:33 -08002781 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002782
2783 def get_serializer_class(self):
2784 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2785 if (no_hyperlinks):
2786 return self.id_serializer_class
2787 else:
2788 return self.serializer_class
2789
Scott Baker0caeaf02014-06-19 11:12:55 -07002790 def get_queryset(self):
2791 return Image.select_by_user(self.request.user)
2792
2793 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002794 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2795 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002796 response = {"error": "validation",
2797 "specific_error": "not serializer.is_valid()",
2798 "reasons": serializer.errors}
2799 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002800 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002801 obj.caller = request.user
2802 if obj.can_update(request.user):
2803 return super(ImageList, self).create(request, *args, **kwargs)
2804 else:
Scott Baker08898c12014-10-29 23:41:11 -07002805 raise Exception("failed obj.can_update")
2806
2807 ret = super(ImageList, self).create(request, *args, **kwargs)
2808 if (ret.status_code%100 != 200):
2809 raise Exception(ret.data)
2810
2811 return ret
2812
Sapan Bhatiadea39432014-06-13 03:10:36 -04002813
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002814class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002815 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002816 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002817 id_serializer_class = ImageIdSerializer
2818
2819 def get_serializer_class(self):
2820 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2821 if (no_hyperlinks):
2822 return self.id_serializer_class
2823 else:
2824 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002825
2826 def get_queryset(self):
2827 return Image.select_by_user(self.request.user)
2828
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002829 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002830
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002831 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002832
2833
2834
Scott Baker0caeaf02014-06-19 11:12:55 -07002835class NetworkParameterList(generics.ListCreateAPIView):
2836 queryset = NetworkParameter.objects.select_related().all()
2837 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002838 id_serializer_class = NetworkParameterIdSerializer
2839 filter_backends = (filters.DjangoFilterBackend,)
2840 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2841
2842 def get_serializer_class(self):
2843 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2844 if (no_hyperlinks):
2845 return self.id_serializer_class
2846 else:
2847 return self.serializer_class
2848
Scott Baker0caeaf02014-06-19 11:12:55 -07002849 def get_queryset(self):
2850 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002851
Scott Baker0caeaf02014-06-19 11:12:55 -07002852 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002853 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2854 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002855 response = {"error": "validation",
2856 "specific_error": "not serializer.is_valid()",
2857 "reasons": serializer.errors}
2858 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002859 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002860 obj.caller = request.user
2861 if obj.can_update(request.user):
2862 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2863 else:
Scott Baker08898c12014-10-29 23:41:11 -07002864 raise Exception("failed obj.can_update")
2865
2866 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2867 if (ret.status_code%100 != 200):
2868 raise Exception(ret.data)
2869
2870 return ret
2871
Scott Baker0caeaf02014-06-19 11:12:55 -07002872
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002873class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002874 queryset = NetworkParameter.objects.select_related().all()
2875 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002876 id_serializer_class = NetworkParameterIdSerializer
2877
2878 def get_serializer_class(self):
2879 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2880 if (no_hyperlinks):
2881 return self.id_serializer_class
2882 else:
2883 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002884
2885 def get_queryset(self):
2886 return NetworkParameter.select_by_user(self.request.user)
2887
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002888 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002889
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002890 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002891
2892
2893
2894class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002895 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002896 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002897 id_serializer_class = SiteIdSerializer
2898 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08002899 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 -07002900
2901 def get_serializer_class(self):
2902 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2903 if (no_hyperlinks):
2904 return self.id_serializer_class
2905 else:
2906 return self.serializer_class
2907
Scott Baker0caeaf02014-06-19 11:12:55 -07002908 def get_queryset(self):
2909 return Site.select_by_user(self.request.user)
2910
2911 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002912 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2913 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002914 response = {"error": "validation",
2915 "specific_error": "not serializer.is_valid()",
2916 "reasons": serializer.errors}
2917 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002918 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002919 obj.caller = request.user
2920 if obj.can_update(request.user):
2921 return super(SiteList, self).create(request, *args, **kwargs)
2922 else:
Scott Baker08898c12014-10-29 23:41:11 -07002923 raise Exception("failed obj.can_update")
2924
2925 ret = super(SiteList, self).create(request, *args, **kwargs)
2926 if (ret.status_code%100 != 200):
2927 raise Exception(ret.data)
2928
2929 return ret
2930
Sapan Bhatiadea39432014-06-13 03:10:36 -04002931
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002932class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002933 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002934 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002935 id_serializer_class = SiteIdSerializer
2936
2937 def get_serializer_class(self):
2938 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2939 if (no_hyperlinks):
2940 return self.id_serializer_class
2941 else:
2942 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002943
2944 def get_queryset(self):
2945 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002946
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002947 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002948
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002949 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002950
2951
2952
2953class SliceRoleList(generics.ListCreateAPIView):
2954 queryset = SliceRole.objects.select_related().all()
2955 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002956 id_serializer_class = SliceRoleIdSerializer
2957 filter_backends = (filters.DjangoFilterBackend,)
2958 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2959
2960 def get_serializer_class(self):
2961 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2962 if (no_hyperlinks):
2963 return self.id_serializer_class
2964 else:
2965 return self.serializer_class
2966
Scott Baker0caeaf02014-06-19 11:12:55 -07002967 def get_queryset(self):
2968 return SliceRole.select_by_user(self.request.user)
2969
2970 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002971 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2972 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002973 response = {"error": "validation",
2974 "specific_error": "not serializer.is_valid()",
2975 "reasons": serializer.errors}
2976 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002977 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002978 obj.caller = request.user
2979 if obj.can_update(request.user):
2980 return super(SliceRoleList, self).create(request, *args, **kwargs)
2981 else:
Scott Baker08898c12014-10-29 23:41:11 -07002982 raise Exception("failed obj.can_update")
2983
2984 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2985 if (ret.status_code%100 != 200):
2986 raise Exception(ret.data)
2987
2988 return ret
2989
Scott Baker0caeaf02014-06-19 11:12:55 -07002990
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002991class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002992 queryset = SliceRole.objects.select_related().all()
2993 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002994 id_serializer_class = SliceRoleIdSerializer
2995
2996 def get_serializer_class(self):
2997 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2998 if (no_hyperlinks):
2999 return self.id_serializer_class
3000 else:
3001 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003002
3003 def get_queryset(self):
3004 return SliceRole.select_by_user(self.request.user)
3005
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003006 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003007
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003008 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003009
3010
3011
3012class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003013 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003014 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003015 id_serializer_class = TagIdSerializer
3016 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003017 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07003018
3019 def get_serializer_class(self):
3020 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3021 if (no_hyperlinks):
3022 return self.id_serializer_class
3023 else:
3024 return self.serializer_class
3025
Scott Baker0caeaf02014-06-19 11:12:55 -07003026 def get_queryset(self):
3027 return Tag.select_by_user(self.request.user)
3028
3029 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003030 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3031 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003032 response = {"error": "validation",
3033 "specific_error": "not serializer.is_valid()",
3034 "reasons": serializer.errors}
3035 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003036 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003037 obj.caller = request.user
3038 if obj.can_update(request.user):
3039 return super(TagList, self).create(request, *args, **kwargs)
3040 else:
Scott Baker08898c12014-10-29 23:41:11 -07003041 raise Exception("failed obj.can_update")
3042
3043 ret = super(TagList, self).create(request, *args, **kwargs)
3044 if (ret.status_code%100 != 200):
3045 raise Exception(ret.data)
3046
3047 return ret
3048
Sapan Bhatiadea39432014-06-13 03:10:36 -04003049
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003050class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003051 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003052 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003053 id_serializer_class = TagIdSerializer
3054
3055 def get_serializer_class(self):
3056 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3057 if (no_hyperlinks):
3058 return self.id_serializer_class
3059 else:
3060 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003061
3062 def get_queryset(self):
3063 return Tag.select_by_user(self.request.user)
3064
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003065 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003066
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003067 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003068
3069
3070
3071class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003072 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003073 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003074 id_serializer_class = InvoiceIdSerializer
3075 filter_backends = (filters.DjangoFilterBackend,)
3076 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
3077
3078 def get_serializer_class(self):
3079 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3080 if (no_hyperlinks):
3081 return self.id_serializer_class
3082 else:
3083 return self.serializer_class
3084
Scott Baker0caeaf02014-06-19 11:12:55 -07003085 def get_queryset(self):
3086 return Invoice.select_by_user(self.request.user)
3087
3088 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003089 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3090 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003091 response = {"error": "validation",
3092 "specific_error": "not serializer.is_valid()",
3093 "reasons": serializer.errors}
3094 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003095 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003096 obj.caller = request.user
3097 if obj.can_update(request.user):
3098 return super(InvoiceList, self).create(request, *args, **kwargs)
3099 else:
Scott Baker08898c12014-10-29 23:41:11 -07003100 raise Exception("failed obj.can_update")
3101
3102 ret = super(InvoiceList, self).create(request, *args, **kwargs)
3103 if (ret.status_code%100 != 200):
3104 raise Exception(ret.data)
3105
3106 return ret
3107
Sapan Bhatiadea39432014-06-13 03:10:36 -04003108
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003109class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003110 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003111 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003112 id_serializer_class = InvoiceIdSerializer
3113
3114 def get_serializer_class(self):
3115 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3116 if (no_hyperlinks):
3117 return self.id_serializer_class
3118 else:
3119 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003120
3121 def get_queryset(self):
3122 return Invoice.select_by_user(self.request.user)
3123
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003124 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003125
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003126 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003127
3128
3129
Scott Baker0caeaf02014-06-19 11:12:55 -07003130class SlicePrivilegeList(generics.ListCreateAPIView):
3131 queryset = SlicePrivilege.objects.select_related().all()
3132 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003133 id_serializer_class = SlicePrivilegeIdSerializer
3134 filter_backends = (filters.DjangoFilterBackend,)
3135 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
3136
3137 def get_serializer_class(self):
3138 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3139 if (no_hyperlinks):
3140 return self.id_serializer_class
3141 else:
3142 return self.serializer_class
3143
Scott Baker0caeaf02014-06-19 11:12:55 -07003144 def get_queryset(self):
3145 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003146
Scott Baker0caeaf02014-06-19 11:12:55 -07003147 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003148 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3149 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003150 response = {"error": "validation",
3151 "specific_error": "not serializer.is_valid()",
3152 "reasons": serializer.errors}
3153 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003154 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003155 obj.caller = request.user
3156 if obj.can_update(request.user):
3157 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3158 else:
Scott Baker08898c12014-10-29 23:41:11 -07003159 raise Exception("failed obj.can_update")
3160
3161 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3162 if (ret.status_code%100 != 200):
3163 raise Exception(ret.data)
3164
3165 return ret
3166
Scott Baker0caeaf02014-06-19 11:12:55 -07003167
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003168class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003169 queryset = SlicePrivilege.objects.select_related().all()
3170 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003171 id_serializer_class = SlicePrivilegeIdSerializer
3172
3173 def get_serializer_class(self):
3174 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3175 if (no_hyperlinks):
3176 return self.id_serializer_class
3177 else:
3178 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003179
3180 def get_queryset(self):
3181 return SlicePrivilege.select_by_user(self.request.user)
3182
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003183 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3184
3185 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3186
3187
3188
3189class PlanetStackRoleList(generics.ListCreateAPIView):
3190 queryset = PlanetStackRole.objects.select_related().all()
3191 serializer_class = PlanetStackRoleSerializer
3192 id_serializer_class = PlanetStackRoleIdSerializer
3193 filter_backends = (filters.DjangoFilterBackend,)
3194 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3195
3196 def get_serializer_class(self):
3197 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3198 if (no_hyperlinks):
3199 return self.id_serializer_class
3200 else:
3201 return self.serializer_class
3202
3203 def get_queryset(self):
3204 return PlanetStackRole.select_by_user(self.request.user)
3205
3206 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003207 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3208 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003209 response = {"error": "validation",
3210 "specific_error": "not serializer.is_valid()",
3211 "reasons": serializer.errors}
3212 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003213 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003214 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003215 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003216 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003217 else:
Scott Baker08898c12014-10-29 23:41:11 -07003218 raise Exception("failed obj.can_update")
3219
3220 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3221 if (ret.status_code%100 != 200):
3222 raise Exception(ret.data)
3223
3224 return ret
3225
Scott Baker0caeaf02014-06-19 11:12:55 -07003226
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003227class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3228 queryset = PlanetStackRole.objects.select_related().all()
3229 serializer_class = PlanetStackRoleSerializer
3230 id_serializer_class = PlanetStackRoleIdSerializer
3231
3232 def get_serializer_class(self):
3233 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3234 if (no_hyperlinks):
3235 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003236 else:
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003237 return self.serializer_class
3238
3239 def get_queryset(self):
3240 return PlanetStackRole.select_by_user(self.request.user)
3241
3242 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3243
3244 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003245
3246
3247
Scott Baker0caeaf02014-06-19 11:12:55 -07003248class NetworkSliverList(generics.ListCreateAPIView):
3249 queryset = NetworkSliver.objects.select_related().all()
3250 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003251 id_serializer_class = NetworkSliverIdSerializer
3252 filter_backends = (filters.DjangoFilterBackend,)
3253 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
3254
3255 def get_serializer_class(self):
3256 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3257 if (no_hyperlinks):
3258 return self.id_serializer_class
3259 else:
3260 return self.serializer_class
3261
Scott Baker0caeaf02014-06-19 11:12:55 -07003262 def get_queryset(self):
3263 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003264
Scott Baker0caeaf02014-06-19 11:12:55 -07003265 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003266 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3267 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003268 response = {"error": "validation",
3269 "specific_error": "not serializer.is_valid()",
3270 "reasons": serializer.errors}
3271 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003272 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003273 obj.caller = request.user
3274 if obj.can_update(request.user):
3275 return super(NetworkSliverList, self).create(request, *args, **kwargs)
3276 else:
Scott Baker08898c12014-10-29 23:41:11 -07003277 raise Exception("failed obj.can_update")
3278
3279 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3280 if (ret.status_code%100 != 200):
3281 raise Exception(ret.data)
3282
3283 return ret
3284
Scott Baker0caeaf02014-06-19 11:12:55 -07003285
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003286class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003287 queryset = NetworkSliver.objects.select_related().all()
3288 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003289 id_serializer_class = NetworkSliverIdSerializer
3290
3291 def get_serializer_class(self):
3292 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3293 if (no_hyperlinks):
3294 return self.id_serializer_class
3295 else:
3296 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003297
3298 def get_queryset(self):
3299 return NetworkSliver.select_by_user(self.request.user)
3300
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003301 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003302
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003303 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003304
3305
3306
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003307class FlavorList(generics.ListCreateAPIView):
3308 queryset = Flavor.objects.select_related().all()
3309 serializer_class = FlavorSerializer
3310 id_serializer_class = FlavorIdSerializer
3311 filter_backends = (filters.DjangoFilterBackend,)
3312 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
3313
3314 def get_serializer_class(self):
3315 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3316 if (no_hyperlinks):
3317 return self.id_serializer_class
3318 else:
3319 return self.serializer_class
3320
3321 def get_queryset(self):
3322 return Flavor.select_by_user(self.request.user)
3323
3324 def create(self, request, *args, **kwargs):
3325 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3326 if not (serializer.is_valid()):
3327 response = {"error": "validation",
3328 "specific_error": "not serializer.is_valid()",
3329 "reasons": serializer.errors}
3330 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3331 obj = serializer.object
3332 obj.caller = request.user
3333 if obj.can_update(request.user):
3334 return super(FlavorList, self).create(request, *args, **kwargs)
3335 else:
3336 raise Exception("failed obj.can_update")
3337
3338 ret = super(FlavorList, self).create(request, *args, **kwargs)
3339 if (ret.status_code%100 != 200):
3340 raise Exception(ret.data)
3341
3342 return ret
3343
3344
3345class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3346 queryset = Flavor.objects.select_related().all()
3347 serializer_class = FlavorSerializer
3348 id_serializer_class = FlavorIdSerializer
3349
3350 def get_serializer_class(self):
3351 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3352 if (no_hyperlinks):
3353 return self.id_serializer_class
3354 else:
3355 return self.serializer_class
3356
3357 def get_queryset(self):
3358 return Flavor.select_by_user(self.request.user)
3359
3360 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3361
3362 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3363
3364
3365
3366class ControllerSiteList(generics.ListCreateAPIView):
3367 queryset = ControllerSite.objects.select_related().all()
3368 serializer_class = ControllerSiteSerializer
3369 id_serializer_class = ControllerSiteIdSerializer
3370 filter_backends = (filters.DjangoFilterBackend,)
3371 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','controller','tenant_id',)
3372
3373 def get_serializer_class(self):
3374 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3375 if (no_hyperlinks):
3376 return self.id_serializer_class
3377 else:
3378 return self.serializer_class
3379
3380 def get_queryset(self):
3381 return ControllerSite.select_by_user(self.request.user)
3382
3383 def create(self, request, *args, **kwargs):
3384 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3385 if not (serializer.is_valid()):
3386 response = {"error": "validation",
3387 "specific_error": "not serializer.is_valid()",
3388 "reasons": serializer.errors}
3389 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3390 obj = serializer.object
3391 obj.caller = request.user
3392 if obj.can_update(request.user):
3393 return super(ControllerSiteList, self).create(request, *args, **kwargs)
3394 else:
3395 raise Exception("failed obj.can_update")
3396
3397 ret = super(ControllerSiteList, self).create(request, *args, **kwargs)
3398 if (ret.status_code%100 != 200):
3399 raise Exception(ret.data)
3400
3401 return ret
3402
3403
3404class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3405 queryset = ControllerSite.objects.select_related().all()
3406 serializer_class = ControllerSiteSerializer
3407 id_serializer_class = ControllerSiteIdSerializer
3408
3409 def get_serializer_class(self):
3410 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3411 if (no_hyperlinks):
3412 return self.id_serializer_class
3413 else:
3414 return self.serializer_class
3415
3416 def get_queryset(self):
3417 return ControllerSite.select_by_user(self.request.user)
3418
3419 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3420
3421 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3422
3423
3424
Scott Baker0caeaf02014-06-19 11:12:55 -07003425class ProjectList(generics.ListCreateAPIView):
3426 queryset = Project.objects.select_related().all()
3427 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003428 id_serializer_class = ProjectIdSerializer
3429 filter_backends = (filters.DjangoFilterBackend,)
3430 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3431
3432 def get_serializer_class(self):
3433 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3434 if (no_hyperlinks):
3435 return self.id_serializer_class
3436 else:
3437 return self.serializer_class
3438
Scott Baker0caeaf02014-06-19 11:12:55 -07003439 def get_queryset(self):
3440 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003441
Scott Baker0caeaf02014-06-19 11:12:55 -07003442 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003443 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3444 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003445 response = {"error": "validation",
3446 "specific_error": "not serializer.is_valid()",
3447 "reasons": serializer.errors}
3448 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003449 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003450 obj.caller = request.user
3451 if obj.can_update(request.user):
3452 return super(ProjectList, self).create(request, *args, **kwargs)
3453 else:
Scott Baker08898c12014-10-29 23:41:11 -07003454 raise Exception("failed obj.can_update")
3455
3456 ret = super(ProjectList, self).create(request, *args, **kwargs)
3457 if (ret.status_code%100 != 200):
3458 raise Exception(ret.data)
3459
3460 return ret
3461
Scott Baker0caeaf02014-06-19 11:12:55 -07003462
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003463class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003464 queryset = Project.objects.select_related().all()
3465 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003466 id_serializer_class = ProjectIdSerializer
3467
3468 def get_serializer_class(self):
3469 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3470 if (no_hyperlinks):
3471 return self.id_serializer_class
3472 else:
3473 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003474
3475 def get_queryset(self):
3476 return Project.select_by_user(self.request.user)
3477
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003478 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3479
3480 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3481
3482
3483
3484class SliceList(generics.ListCreateAPIView):
3485 queryset = Slice.objects.select_related().all()
3486 serializer_class = SliceSerializer
3487 id_serializer_class = SliceIdSerializer
3488 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003489 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003490
3491 def get_serializer_class(self):
3492 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3493 if (no_hyperlinks):
3494 return self.id_serializer_class
3495 else:
3496 return self.serializer_class
3497
3498 def get_queryset(self):
3499 return Slice.select_by_user(self.request.user)
3500
3501 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003502 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3503 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003504 response = {"error": "validation",
3505 "specific_error": "not serializer.is_valid()",
3506 "reasons": serializer.errors}
3507 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003508 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003509 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003510 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003511 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003512 else:
Scott Baker08898c12014-10-29 23:41:11 -07003513 raise Exception("failed obj.can_update")
3514
3515 ret = super(SliceList, self).create(request, *args, **kwargs)
3516 if (ret.status_code%100 != 200):
3517 raise Exception(ret.data)
3518
3519 return ret
3520
Scott Baker0caeaf02014-06-19 11:12:55 -07003521
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003522class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3523 queryset = Slice.objects.select_related().all()
3524 serializer_class = SliceSerializer
3525 id_serializer_class = SliceIdSerializer
3526
3527 def get_serializer_class(self):
3528 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3529 if (no_hyperlinks):
3530 return self.id_serializer_class
3531 else:
3532 return self.serializer_class
3533
3534 def get_queryset(self):
3535 return Slice.select_by_user(self.request.user)
3536
3537 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3538
3539 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3540
3541
3542
3543class NetworkList(generics.ListCreateAPIView):
3544 queryset = Network.objects.select_related().all()
3545 serializer_class = NetworkSerializer
3546 id_serializer_class = NetworkIdSerializer
3547 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker95bdf0a2015-01-03 12:32:45 -08003548 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003549
3550 def get_serializer_class(self):
3551 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3552 if (no_hyperlinks):
3553 return self.id_serializer_class
3554 else:
3555 return self.serializer_class
3556
3557 def get_queryset(self):
3558 return Network.select_by_user(self.request.user)
3559
3560 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003561 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3562 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003563 response = {"error": "validation",
3564 "specific_error": "not serializer.is_valid()",
3565 "reasons": serializer.errors}
3566 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003567 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003568 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003569 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003570 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003571 else:
Scott Baker08898c12014-10-29 23:41:11 -07003572 raise Exception("failed obj.can_update")
3573
3574 ret = super(NetworkList, self).create(request, *args, **kwargs)
3575 if (ret.status_code%100 != 200):
3576 raise Exception(ret.data)
3577
3578 return ret
3579
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003580
3581class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3582 queryset = Network.objects.select_related().all()
3583 serializer_class = NetworkSerializer
3584 id_serializer_class = NetworkIdSerializer
3585
3586 def get_serializer_class(self):
3587 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3588 if (no_hyperlinks):
3589 return self.id_serializer_class
3590 else:
3591 return self.serializer_class
3592
3593 def get_queryset(self):
3594 return Network.select_by_user(self.request.user)
3595
3596 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3597
3598 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3599
3600
3601
3602class ServiceList(generics.ListCreateAPIView):
3603 queryset = Service.objects.select_related().all()
3604 serializer_class = ServiceSerializer
3605 id_serializer_class = ServiceIdSerializer
3606 filter_backends = (filters.DjangoFilterBackend,)
3607 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3608
3609 def get_serializer_class(self):
3610 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3611 if (no_hyperlinks):
3612 return self.id_serializer_class
3613 else:
3614 return self.serializer_class
3615
3616 def get_queryset(self):
3617 return Service.select_by_user(self.request.user)
3618
3619 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003620 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3621 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003622 response = {"error": "validation",
3623 "specific_error": "not serializer.is_valid()",
3624 "reasons": serializer.errors}
3625 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003626 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003627 obj.caller = request.user
3628 if obj.can_update(request.user):
3629 return super(ServiceList, self).create(request, *args, **kwargs)
3630 else:
Scott Baker08898c12014-10-29 23:41:11 -07003631 raise Exception("failed obj.can_update")
3632
3633 ret = super(ServiceList, self).create(request, *args, **kwargs)
3634 if (ret.status_code%100 != 200):
3635 raise Exception(ret.data)
3636
3637 return ret
3638
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003639
3640class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3641 queryset = Service.objects.select_related().all()
3642 serializer_class = ServiceSerializer
3643 id_serializer_class = ServiceIdSerializer
3644
3645 def get_serializer_class(self):
3646 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3647 if (no_hyperlinks):
3648 return self.id_serializer_class
3649 else:
3650 return self.serializer_class
3651
3652 def get_queryset(self):
3653 return Service.select_by_user(self.request.user)
3654
3655 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3656
3657 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3658
3659
3660
3661class ServiceClassList(generics.ListCreateAPIView):
3662 queryset = ServiceClass.objects.select_related().all()
3663 serializer_class = ServiceClassSerializer
3664 id_serializer_class = ServiceClassIdSerializer
3665 filter_backends = (filters.DjangoFilterBackend,)
3666 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3667
3668 def get_serializer_class(self):
3669 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3670 if (no_hyperlinks):
3671 return self.id_serializer_class
3672 else:
3673 return self.serializer_class
3674
3675 def get_queryset(self):
3676 return ServiceClass.select_by_user(self.request.user)
3677
3678 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003679 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3680 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003681 response = {"error": "validation",
3682 "specific_error": "not serializer.is_valid()",
3683 "reasons": serializer.errors}
3684 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003685 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003686 obj.caller = request.user
3687 if obj.can_update(request.user):
3688 return super(ServiceClassList, self).create(request, *args, **kwargs)
3689 else:
Scott Baker08898c12014-10-29 23:41:11 -07003690 raise Exception("failed obj.can_update")
3691
3692 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3693 if (ret.status_code%100 != 200):
3694 raise Exception(ret.data)
3695
3696 return ret
3697
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003698
3699class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3700 queryset = ServiceClass.objects.select_related().all()
3701 serializer_class = ServiceClassSerializer
3702 id_serializer_class = ServiceClassIdSerializer
3703
3704 def get_serializer_class(self):
3705 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3706 if (no_hyperlinks):
3707 return self.id_serializer_class
3708 else:
3709 return self.serializer_class
3710
3711 def get_queryset(self):
3712 return ServiceClass.select_by_user(self.request.user)
3713
3714 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3715
3716 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3717
3718
3719
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003720class PlanetStackList(generics.ListCreateAPIView):
3721 queryset = PlanetStack.objects.select_related().all()
3722 serializer_class = PlanetStackSerializer
3723 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003724 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003725 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003726
3727 def get_serializer_class(self):
3728 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3729 if (no_hyperlinks):
3730 return self.id_serializer_class
3731 else:
3732 return self.serializer_class
3733
3734 def get_queryset(self):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003735 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003736
3737 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003738 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3739 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003740 response = {"error": "validation",
3741 "specific_error": "not serializer.is_valid()",
3742 "reasons": serializer.errors}
3743 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003744 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003745 obj.caller = request.user
3746 if obj.can_update(request.user):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003747 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003748 else:
Scott Baker08898c12014-10-29 23:41:11 -07003749 raise Exception("failed obj.can_update")
3750
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003751 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003752 if (ret.status_code%100 != 200):
3753 raise Exception(ret.data)
3754
3755 return ret
3756
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003757
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003758class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3759 queryset = PlanetStack.objects.select_related().all()
3760 serializer_class = PlanetStackSerializer
3761 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003762
3763 def get_serializer_class(self):
3764 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3765 if (no_hyperlinks):
3766 return self.id_serializer_class
3767 else:
3768 return self.serializer_class
3769
3770 def get_queryset(self):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003771 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003772
3773 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3774
3775 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3776
3777
3778
3779class ChargeList(generics.ListCreateAPIView):
3780 queryset = Charge.objects.select_related().all()
3781 serializer_class = ChargeSerializer
3782 id_serializer_class = ChargeIdSerializer
3783 filter_backends = (filters.DjangoFilterBackend,)
3784 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3785
3786 def get_serializer_class(self):
3787 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3788 if (no_hyperlinks):
3789 return self.id_serializer_class
3790 else:
3791 return self.serializer_class
3792
3793 def get_queryset(self):
3794 return Charge.select_by_user(self.request.user)
3795
3796 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003797 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3798 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003799 response = {"error": "validation",
3800 "specific_error": "not serializer.is_valid()",
3801 "reasons": serializer.errors}
3802 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003803 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003804 obj.caller = request.user
3805 if obj.can_update(request.user):
3806 return super(ChargeList, self).create(request, *args, **kwargs)
3807 else:
Scott Baker08898c12014-10-29 23:41:11 -07003808 raise Exception("failed obj.can_update")
3809
3810 ret = super(ChargeList, self).create(request, *args, **kwargs)
3811 if (ret.status_code%100 != 200):
3812 raise Exception(ret.data)
3813
3814 return ret
3815
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003816
3817class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3818 queryset = Charge.objects.select_related().all()
3819 serializer_class = ChargeSerializer
3820 id_serializer_class = ChargeIdSerializer
3821
3822 def get_serializer_class(self):
3823 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3824 if (no_hyperlinks):
3825 return self.id_serializer_class
3826 else:
3827 return self.serializer_class
3828
3829 def get_queryset(self):
3830 return Charge.select_by_user(self.request.user)
3831
3832 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3833
3834 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3835
3836
3837
3838class RoleList(generics.ListCreateAPIView):
3839 queryset = Role.objects.select_related().all()
3840 serializer_class = RoleSerializer
3841 id_serializer_class = RoleIdSerializer
3842 filter_backends = (filters.DjangoFilterBackend,)
3843 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3844
3845 def get_serializer_class(self):
3846 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3847 if (no_hyperlinks):
3848 return self.id_serializer_class
3849 else:
3850 return self.serializer_class
3851
3852 def get_queryset(self):
3853 return Role.select_by_user(self.request.user)
3854
3855 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003856 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3857 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003858 response = {"error": "validation",
3859 "specific_error": "not serializer.is_valid()",
3860 "reasons": serializer.errors}
3861 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003862 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003863 obj.caller = request.user
3864 if obj.can_update(request.user):
3865 return super(RoleList, self).create(request, *args, **kwargs)
3866 else:
Scott Baker08898c12014-10-29 23:41:11 -07003867 raise Exception("failed obj.can_update")
3868
3869 ret = super(RoleList, self).create(request, *args, **kwargs)
3870 if (ret.status_code%100 != 200):
3871 raise Exception(ret.data)
3872
3873 return ret
3874
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003875
3876class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3877 queryset = Role.objects.select_related().all()
3878 serializer_class = RoleSerializer
3879 id_serializer_class = RoleIdSerializer
3880
3881 def get_serializer_class(self):
3882 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3883 if (no_hyperlinks):
3884 return self.id_serializer_class
3885 else:
3886 return self.serializer_class
3887
3888 def get_queryset(self):
3889 return Role.select_by_user(self.request.user)
3890
3891 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3892
3893 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3894
3895
3896
3897class UsableObjectList(generics.ListCreateAPIView):
3898 queryset = UsableObject.objects.select_related().all()
3899 serializer_class = UsableObjectSerializer
3900 id_serializer_class = UsableObjectIdSerializer
3901 filter_backends = (filters.DjangoFilterBackend,)
3902 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3903
3904 def get_serializer_class(self):
3905 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3906 if (no_hyperlinks):
3907 return self.id_serializer_class
3908 else:
3909 return self.serializer_class
3910
3911 def get_queryset(self):
3912 return UsableObject.select_by_user(self.request.user)
3913
3914 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003915 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3916 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003917 response = {"error": "validation",
3918 "specific_error": "not serializer.is_valid()",
3919 "reasons": serializer.errors}
3920 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003921 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003922 obj.caller = request.user
3923 if obj.can_update(request.user):
3924 return super(UsableObjectList, self).create(request, *args, **kwargs)
3925 else:
Scott Baker08898c12014-10-29 23:41:11 -07003926 raise Exception("failed obj.can_update")
3927
3928 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3929 if (ret.status_code%100 != 200):
3930 raise Exception(ret.data)
3931
3932 return ret
3933
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003934
3935class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3936 queryset = UsableObject.objects.select_related().all()
3937 serializer_class = UsableObjectSerializer
3938 id_serializer_class = UsableObjectIdSerializer
3939
3940 def get_serializer_class(self):
3941 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3942 if (no_hyperlinks):
3943 return self.id_serializer_class
3944 else:
3945 return self.serializer_class
3946
3947 def get_queryset(self):
3948 return UsableObject.select_by_user(self.request.user)
3949
3950 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3951
3952 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3953
3954
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003955
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003956class SiteRoleList(generics.ListCreateAPIView):
3957 queryset = SiteRole.objects.select_related().all()
3958 serializer_class = SiteRoleSerializer
3959 id_serializer_class = SiteRoleIdSerializer
3960 filter_backends = (filters.DjangoFilterBackend,)
3961 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3962
3963 def get_serializer_class(self):
3964 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3965 if (no_hyperlinks):
3966 return self.id_serializer_class
3967 else:
3968 return self.serializer_class
3969
3970 def get_queryset(self):
3971 return SiteRole.select_by_user(self.request.user)
3972
3973 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003974 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3975 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003976 response = {"error": "validation",
3977 "specific_error": "not serializer.is_valid()",
3978 "reasons": serializer.errors}
3979 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003980 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003981 obj.caller = request.user
3982 if obj.can_update(request.user):
3983 return super(SiteRoleList, self).create(request, *args, **kwargs)
3984 else:
Scott Baker08898c12014-10-29 23:41:11 -07003985 raise Exception("failed obj.can_update")
3986
3987 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3988 if (ret.status_code%100 != 200):
3989 raise Exception(ret.data)
3990
3991 return ret
3992
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003993
3994class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3995 queryset = SiteRole.objects.select_related().all()
3996 serializer_class = SiteRoleSerializer
3997 id_serializer_class = SiteRoleIdSerializer
3998
3999 def get_serializer_class(self):
4000 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4001 if (no_hyperlinks):
4002 return self.id_serializer_class
4003 else:
4004 return self.serializer_class
4005
4006 def get_queryset(self):
4007 return SiteRole.select_by_user(self.request.user)
4008
4009 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4010
4011 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4012
4013
4014
4015class SliceCredentialList(generics.ListCreateAPIView):
4016 queryset = SliceCredential.objects.select_related().all()
4017 serializer_class = SliceCredentialSerializer
4018 id_serializer_class = SliceCredentialIdSerializer
4019 filter_backends = (filters.DjangoFilterBackend,)
4020 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
4021
4022 def get_serializer_class(self):
4023 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4024 if (no_hyperlinks):
4025 return self.id_serializer_class
4026 else:
4027 return self.serializer_class
4028
4029 def get_queryset(self):
4030 return SliceCredential.select_by_user(self.request.user)
4031
4032 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004033 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4034 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004035 response = {"error": "validation",
4036 "specific_error": "not serializer.is_valid()",
4037 "reasons": serializer.errors}
4038 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004039 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004040 obj.caller = request.user
4041 if obj.can_update(request.user):
4042 return super(SliceCredentialList, self).create(request, *args, **kwargs)
4043 else:
Scott Baker08898c12014-10-29 23:41:11 -07004044 raise Exception("failed obj.can_update")
4045
4046 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
4047 if (ret.status_code%100 != 200):
4048 raise Exception(ret.data)
4049
4050 return ret
4051
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004052
4053class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4054 queryset = SliceCredential.objects.select_related().all()
4055 serializer_class = SliceCredentialSerializer
4056 id_serializer_class = SliceCredentialIdSerializer
4057
4058 def get_serializer_class(self):
4059 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4060 if (no_hyperlinks):
4061 return self.id_serializer_class
4062 else:
4063 return self.serializer_class
4064
4065 def get_queryset(self):
4066 return SliceCredential.select_by_user(self.request.user)
4067
4068 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4069
4070 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4071
4072
4073
4074class SliverList(generics.ListCreateAPIView):
4075 queryset = Sliver.objects.select_related().all()
4076 serializer_class = SliverSerializer
4077 id_serializer_class = SliverIdSerializer
4078 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker6c958402015-01-03 12:05:21 -08004079 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004080
4081 def get_serializer_class(self):
4082 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4083 if (no_hyperlinks):
4084 return self.id_serializer_class
4085 else:
4086 return self.serializer_class
4087
4088 def get_queryset(self):
4089 return Sliver.select_by_user(self.request.user)
4090
4091 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004092 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4093 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004094 response = {"error": "validation",
4095 "specific_error": "not serializer.is_valid()",
4096 "reasons": serializer.errors}
4097 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004098 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004099 obj.caller = request.user
4100 if obj.can_update(request.user):
4101 return super(SliverList, self).create(request, *args, **kwargs)
4102 else:
Scott Baker08898c12014-10-29 23:41:11 -07004103 raise Exception("failed obj.can_update")
4104
4105 ret = super(SliverList, self).create(request, *args, **kwargs)
4106 if (ret.status_code%100 != 200):
4107 raise Exception(ret.data)
4108
4109 return ret
4110
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004111
4112class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4113 queryset = Sliver.objects.select_related().all()
4114 serializer_class = SliverSerializer
4115 id_serializer_class = SliverIdSerializer
4116
4117 def get_serializer_class(self):
4118 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4119 if (no_hyperlinks):
4120 return self.id_serializer_class
4121 else:
4122 return self.serializer_class
4123
4124 def get_queryset(self):
4125 return Sliver.select_by_user(self.request.user)
4126
4127 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4128
4129 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4130
4131
4132
4133class NodeList(generics.ListCreateAPIView):
4134 queryset = Node.objects.select_related().all()
4135 serializer_class = NodeSerializer
4136 id_serializer_class = NodeIdSerializer
4137 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004138 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004139
4140 def get_serializer_class(self):
4141 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4142 if (no_hyperlinks):
4143 return self.id_serializer_class
4144 else:
4145 return self.serializer_class
4146
4147 def get_queryset(self):
4148 return Node.select_by_user(self.request.user)
4149
4150 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004151 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4152 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004153 response = {"error": "validation",
4154 "specific_error": "not serializer.is_valid()",
4155 "reasons": serializer.errors}
4156 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004157 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004158 obj.caller = request.user
4159 if obj.can_update(request.user):
4160 return super(NodeList, self).create(request, *args, **kwargs)
4161 else:
Scott Baker08898c12014-10-29 23:41:11 -07004162 raise Exception("failed obj.can_update")
4163
4164 ret = super(NodeList, self).create(request, *args, **kwargs)
4165 if (ret.status_code%100 != 200):
4166 raise Exception(ret.data)
4167
4168 return ret
4169
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004170
4171class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4172 queryset = Node.objects.select_related().all()
4173 serializer_class = NodeSerializer
4174 id_serializer_class = NodeIdSerializer
4175
4176 def get_serializer_class(self):
4177 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4178 if (no_hyperlinks):
4179 return self.id_serializer_class
4180 else:
4181 return self.serializer_class
4182
4183 def get_queryset(self):
4184 return Node.select_by_user(self.request.user)
4185
4186 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4187
4188 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4189
4190
4191
4192class DashboardViewList(generics.ListCreateAPIView):
4193 queryset = DashboardView.objects.select_related().all()
4194 serializer_class = DashboardViewSerializer
4195 id_serializer_class = DashboardViewIdSerializer
4196 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004197 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004198
4199 def get_serializer_class(self):
4200 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4201 if (no_hyperlinks):
4202 return self.id_serializer_class
4203 else:
4204 return self.serializer_class
4205
4206 def get_queryset(self):
4207 return DashboardView.select_by_user(self.request.user)
4208
4209 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004210 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4211 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004212 response = {"error": "validation",
4213 "specific_error": "not serializer.is_valid()",
4214 "reasons": serializer.errors}
4215 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004216 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004217 obj.caller = request.user
4218 if obj.can_update(request.user):
4219 return super(DashboardViewList, self).create(request, *args, **kwargs)
4220 else:
Scott Baker08898c12014-10-29 23:41:11 -07004221 raise Exception("failed obj.can_update")
4222
4223 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
4224 if (ret.status_code%100 != 200):
4225 raise Exception(ret.data)
4226
4227 return ret
4228
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004229
4230class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4231 queryset = DashboardView.objects.select_related().all()
4232 serializer_class = DashboardViewSerializer
4233 id_serializer_class = DashboardViewIdSerializer
4234
4235 def get_serializer_class(self):
4236 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4237 if (no_hyperlinks):
4238 return self.id_serializer_class
4239 else:
4240 return self.serializer_class
4241
4242 def get_queryset(self):
4243 return DashboardView.select_by_user(self.request.user)
4244
4245 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4246
4247 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4248
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004249
Scott Bakerf3816ac2014-11-12 01:13:53 -08004250
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004251class ControllerNetworkList(generics.ListCreateAPIView):
4252 queryset = ControllerNetwork.objects.select_related().all()
4253 serializer_class = ControllerNetworkSerializer
4254 id_serializer_class = ControllerNetworkIdSerializer
4255 filter_backends = (filters.DjangoFilterBackend,)
4256 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
4257
4258 def get_serializer_class(self):
4259 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4260 if (no_hyperlinks):
4261 return self.id_serializer_class
4262 else:
4263 return self.serializer_class
4264
4265 def get_queryset(self):
4266 return ControllerNetwork.select_by_user(self.request.user)
4267
4268 def create(self, request, *args, **kwargs):
4269 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4270 if not (serializer.is_valid()):
4271 response = {"error": "validation",
4272 "specific_error": "not serializer.is_valid()",
4273 "reasons": serializer.errors}
4274 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4275 obj = serializer.object
4276 obj.caller = request.user
4277 if obj.can_update(request.user):
4278 return super(ControllerNetworkList, self).create(request, *args, **kwargs)
4279 else:
4280 raise Exception("failed obj.can_update")
4281
4282 ret = super(ControllerNetworkList, self).create(request, *args, **kwargs)
4283 if (ret.status_code%100 != 200):
4284 raise Exception(ret.data)
4285
4286 return ret
4287
4288
4289class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4290 queryset = ControllerNetwork.objects.select_related().all()
4291 serializer_class = ControllerNetworkSerializer
4292 id_serializer_class = ControllerNetworkIdSerializer
4293
4294 def get_serializer_class(self):
4295 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4296 if (no_hyperlinks):
4297 return self.id_serializer_class
4298 else:
4299 return self.serializer_class
4300
4301 def get_queryset(self):
4302 return ControllerNetwork.select_by_user(self.request.user)
4303
4304 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4305
4306 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4307
4308
4309
Scott Bakerc1d11912014-12-22 09:29:05 -08004310class ImageDeploymentsList(generics.ListCreateAPIView):
4311 queryset = ImageDeployments.objects.select_related().all()
4312 serializer_class = ImageDeploymentsSerializer
4313 id_serializer_class = ImageDeploymentsIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004314 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004315 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker196ffef2014-11-21 11:32:24 -08004316
4317 def get_serializer_class(self):
4318 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4319 if (no_hyperlinks):
4320 return self.id_serializer_class
4321 else:
4322 return self.serializer_class
4323
4324 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08004325 return ImageDeployments.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004326
4327 def create(self, request, *args, **kwargs):
4328 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4329 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004330 response = {"error": "validation",
4331 "specific_error": "not serializer.is_valid()",
4332 "reasons": serializer.errors}
4333 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08004334 obj = serializer.object
4335 obj.caller = request.user
4336 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08004337 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08004338 else:
4339 raise Exception("failed obj.can_update")
4340
Scott Bakerc1d11912014-12-22 09:29:05 -08004341 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08004342 if (ret.status_code%100 != 200):
4343 raise Exception(ret.data)
4344
4345 return ret
4346
4347
Scott Bakerc1d11912014-12-22 09:29:05 -08004348class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4349 queryset = ImageDeployments.objects.select_related().all()
4350 serializer_class = ImageDeploymentsSerializer
4351 id_serializer_class = ImageDeploymentsIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004352
4353 def get_serializer_class(self):
4354 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4355 if (no_hyperlinks):
4356 return self.id_serializer_class
4357 else:
4358 return self.serializer_class
4359
4360 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08004361 return ImageDeployments.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004362
4363 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4364
4365 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4366
Scott Baker196ffef2014-11-21 11:32:24 -08004367
4368
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004369class ControllerUserList(generics.ListCreateAPIView):
4370 queryset = ControllerUser.objects.select_related().all()
4371 serializer_class = ControllerUserSerializer
4372 id_serializer_class = ControllerUserIdSerializer
4373 filter_backends = (filters.DjangoFilterBackend,)
4374 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
4375
4376 def get_serializer_class(self):
4377 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4378 if (no_hyperlinks):
4379 return self.id_serializer_class
4380 else:
4381 return self.serializer_class
4382
4383 def get_queryset(self):
4384 return ControllerUser.select_by_user(self.request.user)
4385
4386 def create(self, request, *args, **kwargs):
4387 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4388 if not (serializer.is_valid()):
4389 response = {"error": "validation",
4390 "specific_error": "not serializer.is_valid()",
4391 "reasons": serializer.errors}
4392 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4393 obj = serializer.object
4394 obj.caller = request.user
4395 if obj.can_update(request.user):
4396 return super(ControllerUserList, self).create(request, *args, **kwargs)
4397 else:
4398 raise Exception("failed obj.can_update")
4399
4400 ret = super(ControllerUserList, self).create(request, *args, **kwargs)
4401 if (ret.status_code%100 != 200):
4402 raise Exception(ret.data)
4403
4404 return ret
4405
4406
4407class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4408 queryset = ControllerUser.objects.select_related().all()
4409 serializer_class = ControllerUserSerializer
4410 id_serializer_class = ControllerUserIdSerializer
4411
4412 def get_serializer_class(self):
4413 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4414 if (no_hyperlinks):
4415 return self.id_serializer_class
4416 else:
4417 return self.serializer_class
4418
4419 def get_queryset(self):
4420 return ControllerUser.select_by_user(self.request.user)
4421
4422 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4423
4424 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4425
4426
4427
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004428class ReservedResourceList(generics.ListCreateAPIView):
4429 queryset = ReservedResource.objects.select_related().all()
4430 serializer_class = ReservedResourceSerializer
4431 id_serializer_class = ReservedResourceIdSerializer
4432 filter_backends = (filters.DjangoFilterBackend,)
4433 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
4434
4435 def get_serializer_class(self):
4436 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4437 if (no_hyperlinks):
4438 return self.id_serializer_class
4439 else:
4440 return self.serializer_class
4441
4442 def get_queryset(self):
4443 return ReservedResource.select_by_user(self.request.user)
4444
4445 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004446 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4447 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004448 response = {"error": "validation",
4449 "specific_error": "not serializer.is_valid()",
4450 "reasons": serializer.errors}
4451 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004452 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004453 obj.caller = request.user
4454 if obj.can_update(request.user):
4455 return super(ReservedResourceList, self).create(request, *args, **kwargs)
4456 else:
Scott Baker08898c12014-10-29 23:41:11 -07004457 raise Exception("failed obj.can_update")
4458
4459 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4460 if (ret.status_code%100 != 200):
4461 raise Exception(ret.data)
4462
4463 return ret
4464
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004465
4466class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4467 queryset = ReservedResource.objects.select_related().all()
4468 serializer_class = ReservedResourceSerializer
4469 id_serializer_class = ReservedResourceIdSerializer
4470
4471 def get_serializer_class(self):
4472 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4473 if (no_hyperlinks):
4474 return self.id_serializer_class
4475 else:
4476 return self.serializer_class
4477
4478 def get_queryset(self):
4479 return ReservedResource.select_by_user(self.request.user)
4480
4481 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4482
4483 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4484
4485
4486
Scott Bakerc1d11912014-12-22 09:29:05 -08004487class PaymentList(generics.ListCreateAPIView):
4488 queryset = Payment.objects.select_related().all()
4489 serializer_class = PaymentSerializer
4490 id_serializer_class = PaymentIdSerializer
4491 filter_backends = (filters.DjangoFilterBackend,)
4492 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
4493
4494 def get_serializer_class(self):
4495 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4496 if (no_hyperlinks):
4497 return self.id_serializer_class
4498 else:
4499 return self.serializer_class
4500
4501 def get_queryset(self):
4502 return Payment.select_by_user(self.request.user)
4503
4504 def create(self, request, *args, **kwargs):
4505 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4506 if not (serializer.is_valid()):
4507 response = {"error": "validation",
4508 "specific_error": "not serializer.is_valid()",
4509 "reasons": serializer.errors}
4510 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4511 obj = serializer.object
4512 obj.caller = request.user
4513 if obj.can_update(request.user):
4514 return super(PaymentList, self).create(request, *args, **kwargs)
4515 else:
4516 raise Exception("failed obj.can_update")
4517
4518 ret = super(PaymentList, self).create(request, *args, **kwargs)
4519 if (ret.status_code%100 != 200):
4520 raise Exception(ret.data)
4521
4522 return ret
4523
4524
4525class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4526 queryset = Payment.objects.select_related().all()
4527 serializer_class = PaymentSerializer
4528 id_serializer_class = PaymentIdSerializer
4529
4530 def get_serializer_class(self):
4531 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4532 if (no_hyperlinks):
4533 return self.id_serializer_class
4534 else:
4535 return self.serializer_class
4536
4537 def get_queryset(self):
4538 return Payment.select_by_user(self.request.user)
4539
4540 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4541
4542 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4543
4544
4545
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004546class NetworkSliceList(generics.ListCreateAPIView):
4547 queryset = NetworkSlice.objects.select_related().all()
4548 serializer_class = NetworkSliceSerializer
4549 id_serializer_class = NetworkSliceIdSerializer
4550 filter_backends = (filters.DjangoFilterBackend,)
4551 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
4552
4553 def get_serializer_class(self):
4554 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4555 if (no_hyperlinks):
4556 return self.id_serializer_class
4557 else:
4558 return self.serializer_class
4559
4560 def get_queryset(self):
4561 return NetworkSlice.select_by_user(self.request.user)
4562
4563 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004564 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4565 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004566 response = {"error": "validation",
4567 "specific_error": "not serializer.is_valid()",
4568 "reasons": serializer.errors}
4569 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004570 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004571 obj.caller = request.user
4572 if obj.can_update(request.user):
4573 return super(NetworkSliceList, self).create(request, *args, **kwargs)
4574 else:
Scott Baker08898c12014-10-29 23:41:11 -07004575 raise Exception("failed obj.can_update")
4576
4577 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4578 if (ret.status_code%100 != 200):
4579 raise Exception(ret.data)
4580
4581 return ret
4582
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004583
4584class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4585 queryset = NetworkSlice.objects.select_related().all()
4586 serializer_class = NetworkSliceSerializer
4587 id_serializer_class = NetworkSliceIdSerializer
4588
4589 def get_serializer_class(self):
4590 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4591 if (no_hyperlinks):
4592 return self.id_serializer_class
4593 else:
4594 return self.serializer_class
4595
4596 def get_queryset(self):
4597 return NetworkSlice.select_by_user(self.request.user)
4598
4599 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4600
4601 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4602
4603
4604
4605class UserDashboardViewList(generics.ListCreateAPIView):
4606 queryset = UserDashboardView.objects.select_related().all()
4607 serializer_class = UserDashboardViewSerializer
4608 id_serializer_class = UserDashboardViewIdSerializer
4609 filter_backends = (filters.DjangoFilterBackend,)
4610 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4611
4612 def get_serializer_class(self):
4613 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4614 if (no_hyperlinks):
4615 return self.id_serializer_class
4616 else:
4617 return self.serializer_class
4618
4619 def get_queryset(self):
4620 return UserDashboardView.select_by_user(self.request.user)
4621
4622 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004623 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4624 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004625 response = {"error": "validation",
4626 "specific_error": "not serializer.is_valid()",
4627 "reasons": serializer.errors}
4628 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004629 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004630 obj.caller = request.user
4631 if obj.can_update(request.user):
4632 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4633 else:
Scott Baker08898c12014-10-29 23:41:11 -07004634 raise Exception("failed obj.can_update")
4635
4636 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4637 if (ret.status_code%100 != 200):
4638 raise Exception(ret.data)
4639
4640 return ret
4641
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004642
4643class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4644 queryset = UserDashboardView.objects.select_related().all()
4645 serializer_class = UserDashboardViewSerializer
4646 id_serializer_class = UserDashboardViewIdSerializer
4647
4648 def get_serializer_class(self):
4649 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4650 if (no_hyperlinks):
4651 return self.id_serializer_class
4652 else:
4653 return self.serializer_class
4654
4655 def get_queryset(self):
4656 return UserDashboardView.select_by_user(self.request.user)
4657
4658 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4659
4660 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4661
4662
4663
Scott Bakerc1d11912014-12-22 09:29:05 -08004664class ControllerList(generics.ListCreateAPIView):
4665 queryset = Controller.objects.select_related().all()
4666 serializer_class = ControllerSerializer
4667 id_serializer_class = ControllerIdSerializer
4668 filter_backends = (filters.DjangoFilterBackend,)
4669 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
4670
4671 def get_serializer_class(self):
4672 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4673 if (no_hyperlinks):
4674 return self.id_serializer_class
4675 else:
4676 return self.serializer_class
4677
4678 def get_queryset(self):
4679 return Controller.select_by_user(self.request.user)
4680
4681 def create(self, request, *args, **kwargs):
4682 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4683 if not (serializer.is_valid()):
4684 response = {"error": "validation",
4685 "specific_error": "not serializer.is_valid()",
4686 "reasons": serializer.errors}
4687 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4688 obj = serializer.object
4689 obj.caller = request.user
4690 if obj.can_update(request.user):
4691 return super(ControllerList, self).create(request, *args, **kwargs)
4692 else:
4693 raise Exception("failed obj.can_update")
4694
4695 ret = super(ControllerList, self).create(request, *args, **kwargs)
4696 if (ret.status_code%100 != 200):
4697 raise Exception(ret.data)
4698
4699 return ret
4700
4701
4702class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4703 queryset = Controller.objects.select_related().all()
4704 serializer_class = ControllerSerializer
4705 id_serializer_class = ControllerIdSerializer
4706
4707 def get_serializer_class(self):
4708 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4709 if (no_hyperlinks):
4710 return self.id_serializer_class
4711 else:
4712 return self.serializer_class
4713
4714 def get_queryset(self):
4715 return Controller.select_by_user(self.request.user)
4716
4717 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4718
4719 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4720
4721
4722
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004723class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4724 queryset = PlanetStackPrivilege.objects.select_related().all()
4725 serializer_class = PlanetStackPrivilegeSerializer
4726 id_serializer_class = PlanetStackPrivilegeIdSerializer
4727 filter_backends = (filters.DjangoFilterBackend,)
4728 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4729
4730 def get_serializer_class(self):
4731 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4732 if (no_hyperlinks):
4733 return self.id_serializer_class
4734 else:
4735 return self.serializer_class
4736
4737 def get_queryset(self):
4738 return PlanetStackPrivilege.select_by_user(self.request.user)
4739
4740 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004741 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4742 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004743 response = {"error": "validation",
4744 "specific_error": "not serializer.is_valid()",
4745 "reasons": serializer.errors}
4746 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004747 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004748 obj.caller = request.user
4749 if obj.can_update(request.user):
4750 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4751 else:
Scott Baker08898c12014-10-29 23:41:11 -07004752 raise Exception("failed obj.can_update")
4753
4754 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4755 if (ret.status_code%100 != 200):
4756 raise Exception(ret.data)
4757
4758 return ret
4759
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004760
4761class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4762 queryset = PlanetStackPrivilege.objects.select_related().all()
4763 serializer_class = PlanetStackPrivilegeSerializer
4764 id_serializer_class = PlanetStackPrivilegeIdSerializer
4765
4766 def get_serializer_class(self):
4767 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4768 if (no_hyperlinks):
4769 return self.id_serializer_class
4770 else:
4771 return self.serializer_class
4772
4773 def get_queryset(self):
4774 return PlanetStackPrivilege.select_by_user(self.request.user)
4775
4776 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4777
4778 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4779
4780
4781
4782class UserList(generics.ListCreateAPIView):
4783 queryset = User.objects.select_related().all()
4784 serializer_class = UserSerializer
4785 id_serializer_class = UserIdSerializer
4786 filter_backends = (filters.DjangoFilterBackend,)
4787 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',)
4788
4789 def get_serializer_class(self):
4790 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4791 if (no_hyperlinks):
4792 return self.id_serializer_class
4793 else:
4794 return self.serializer_class
4795
4796 def get_queryset(self):
4797 return User.select_by_user(self.request.user)
4798
4799 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004800 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4801 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004802 response = {"error": "validation",
4803 "specific_error": "not serializer.is_valid()",
4804 "reasons": serializer.errors}
4805 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004806 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004807 obj.caller = request.user
4808 if obj.can_update(request.user):
4809 return super(UserList, self).create(request, *args, **kwargs)
4810 else:
Scott Baker08898c12014-10-29 23:41:11 -07004811 raise Exception("failed obj.can_update")
4812
4813 ret = super(UserList, self).create(request, *args, **kwargs)
4814 if (ret.status_code%100 != 200):
4815 raise Exception(ret.data)
4816
4817 return ret
4818
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004819
4820class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4821 queryset = User.objects.select_related().all()
4822 serializer_class = UserSerializer
4823 id_serializer_class = UserIdSerializer
4824
4825 def get_serializer_class(self):
4826 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4827 if (no_hyperlinks):
4828 return self.id_serializer_class
4829 else:
4830 return self.serializer_class
4831
4832 def get_queryset(self):
4833 return User.select_by_user(self.request.user)
4834
4835 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4836
4837 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4838
4839
4840
4841class DeploymentList(generics.ListCreateAPIView):
4842 queryset = Deployment.objects.select_related().all()
4843 serializer_class = DeploymentSerializer
4844 id_serializer_class = DeploymentIdSerializer
4845 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004846 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','images','sites','flavors',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004847
4848 def get_serializer_class(self):
4849 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4850 if (no_hyperlinks):
4851 return self.id_serializer_class
4852 else:
4853 return self.serializer_class
4854
4855 def get_queryset(self):
4856 return Deployment.select_by_user(self.request.user)
4857
4858 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004859 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4860 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004861 response = {"error": "validation",
4862 "specific_error": "not serializer.is_valid()",
4863 "reasons": serializer.errors}
4864 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004865 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004866 obj.caller = request.user
4867 if obj.can_update(request.user):
4868 return super(DeploymentList, self).create(request, *args, **kwargs)
4869 else:
Scott Baker08898c12014-10-29 23:41:11 -07004870 raise Exception("failed obj.can_update")
4871
4872 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4873 if (ret.status_code%100 != 200):
4874 raise Exception(ret.data)
4875
4876 return ret
4877
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004878
4879class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4880 queryset = Deployment.objects.select_related().all()
4881 serializer_class = DeploymentSerializer
4882 id_serializer_class = DeploymentIdSerializer
4883
4884 def get_serializer_class(self):
4885 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4886 if (no_hyperlinks):
4887 return self.id_serializer_class
4888 else:
4889 return self.serializer_class
4890
4891 def get_queryset(self):
4892 return Deployment.select_by_user(self.request.user)
4893
4894 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4895
4896 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4897
4898
4899
4900class ReservationList(generics.ListCreateAPIView):
4901 queryset = Reservation.objects.select_related().all()
4902 serializer_class = ReservationSerializer
4903 id_serializer_class = ReservationIdSerializer
4904 filter_backends = (filters.DjangoFilterBackend,)
4905 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4906
4907 def get_serializer_class(self):
4908 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4909 if (no_hyperlinks):
4910 return self.id_serializer_class
4911 else:
4912 return self.serializer_class
4913
4914 def get_queryset(self):
4915 return Reservation.select_by_user(self.request.user)
4916
4917 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004918 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4919 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004920 response = {"error": "validation",
4921 "specific_error": "not serializer.is_valid()",
4922 "reasons": serializer.errors}
4923 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004924 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004925 obj.caller = request.user
4926 if obj.can_update(request.user):
4927 return super(ReservationList, self).create(request, *args, **kwargs)
4928 else:
Scott Baker08898c12014-10-29 23:41:11 -07004929 raise Exception("failed obj.can_update")
4930
4931 ret = super(ReservationList, self).create(request, *args, **kwargs)
4932 if (ret.status_code%100 != 200):
4933 raise Exception(ret.data)
4934
4935 return ret
4936
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004937
4938class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4939 queryset = Reservation.objects.select_related().all()
4940 serializer_class = ReservationSerializer
4941 id_serializer_class = ReservationIdSerializer
4942
4943 def get_serializer_class(self):
4944 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4945 if (no_hyperlinks):
4946 return self.id_serializer_class
4947 else:
4948 return self.serializer_class
4949
4950 def get_queryset(self):
4951 return Reservation.select_by_user(self.request.user)
4952
4953 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4954
4955 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4956
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004957
Scott Bakerf3816ac2014-11-12 01:13:53 -08004958
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004959class SitePrivilegeList(generics.ListCreateAPIView):
4960 queryset = SitePrivilege.objects.select_related().all()
4961 serializer_class = SitePrivilegeSerializer
4962 id_serializer_class = SitePrivilegeIdSerializer
4963 filter_backends = (filters.DjangoFilterBackend,)
4964 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4965
4966 def get_serializer_class(self):
4967 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4968 if (no_hyperlinks):
4969 return self.id_serializer_class
4970 else:
4971 return self.serializer_class
4972
4973 def get_queryset(self):
4974 return SitePrivilege.select_by_user(self.request.user)
4975
4976 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004977 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4978 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004979 response = {"error": "validation",
4980 "specific_error": "not serializer.is_valid()",
4981 "reasons": serializer.errors}
4982 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004983 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004984 obj.caller = request.user
4985 if obj.can_update(request.user):
4986 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4987 else:
Scott Baker08898c12014-10-29 23:41:11 -07004988 raise Exception("failed obj.can_update")
4989
4990 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4991 if (ret.status_code%100 != 200):
4992 raise Exception(ret.data)
4993
4994 return ret
4995
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004996
4997class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4998 queryset = SitePrivilege.objects.select_related().all()
4999 serializer_class = SitePrivilegeSerializer
5000 id_serializer_class = SitePrivilegeIdSerializer
5001
5002 def get_serializer_class(self):
5003 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5004 if (no_hyperlinks):
5005 return self.id_serializer_class
5006 else:
5007 return self.serializer_class
5008
5009 def get_queryset(self):
5010 return SitePrivilege.select_by_user(self.request.user)
5011
5012 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5013
5014 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5015
5016
5017
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005018class ControllerSliceList(generics.ListCreateAPIView):
5019 queryset = ControllerSlice.objects.select_related().all()
5020 serializer_class = ControllerSliceSerializer
5021 id_serializer_class = ControllerSliceIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005022 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005023 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005024
5025 def get_serializer_class(self):
5026 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5027 if (no_hyperlinks):
5028 return self.id_serializer_class
5029 else:
5030 return self.serializer_class
5031
5032 def get_queryset(self):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005033 return ControllerSlice.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005034
5035 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005036 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5037 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005038 response = {"error": "validation",
5039 "specific_error": "not serializer.is_valid()",
5040 "reasons": serializer.errors}
5041 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005042 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005043 obj.caller = request.user
5044 if obj.can_update(request.user):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005045 return super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005046 else:
Scott Baker08898c12014-10-29 23:41:11 -07005047 raise Exception("failed obj.can_update")
5048
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005049 ret = super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005050 if (ret.status_code%100 != 200):
5051 raise Exception(ret.data)
5052
5053 return ret
5054
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005055
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005056class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5057 queryset = ControllerSlice.objects.select_related().all()
5058 serializer_class = ControllerSliceSerializer
5059 id_serializer_class = ControllerSliceIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005060
5061 def get_serializer_class(self):
5062 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5063 if (no_hyperlinks):
5064 return self.id_serializer_class
5065 else:
5066 return self.serializer_class
5067
5068 def get_queryset(self):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005069 return ControllerSlice.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005070
5071 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5072
5073 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5074
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005075
Scott Bakerf3816ac2014-11-12 01:13:53 -08005076
Scott Bakera6a0c772014-12-22 17:35:34 -08005077class ControllerDashboardViewList(generics.ListCreateAPIView):
5078 queryset = ControllerDashboardView.objects.select_related().all()
5079 serializer_class = ControllerDashboardViewSerializer
5080 id_serializer_class = ControllerDashboardViewIdSerializer
5081 filter_backends = (filters.DjangoFilterBackend,)
5082 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
5083
5084 def get_serializer_class(self):
5085 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5086 if (no_hyperlinks):
5087 return self.id_serializer_class
5088 else:
5089 return self.serializer_class
5090
5091 def get_queryset(self):
5092 return ControllerDashboardView.select_by_user(self.request.user)
5093
5094 def create(self, request, *args, **kwargs):
5095 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5096 if not (serializer.is_valid()):
5097 response = {"error": "validation",
5098 "specific_error": "not serializer.is_valid()",
5099 "reasons": serializer.errors}
5100 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5101 obj = serializer.object
5102 obj.caller = request.user
5103 if obj.can_update(request.user):
5104 return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
5105 else:
5106 raise Exception("failed obj.can_update")
5107
5108 ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
5109 if (ret.status_code%100 != 200):
5110 raise Exception(ret.data)
5111
5112 return ret
5113
5114
5115class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5116 queryset = ControllerDashboardView.objects.select_related().all()
5117 serializer_class = ControllerDashboardViewSerializer
5118 id_serializer_class = ControllerDashboardViewIdSerializer
5119
5120 def get_serializer_class(self):
5121 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5122 if (no_hyperlinks):
5123 return self.id_serializer_class
5124 else:
5125 return self.serializer_class
5126
5127 def get_queryset(self):
5128 return ControllerDashboardView.select_by_user(self.request.user)
5129
5130 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5131
5132 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5133
5134
5135
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005136class AccountList(generics.ListCreateAPIView):
5137 queryset = Account.objects.select_related().all()
5138 serializer_class = AccountSerializer
5139 id_serializer_class = AccountIdSerializer
5140 filter_backends = (filters.DjangoFilterBackend,)
5141 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
5142
5143 def get_serializer_class(self):
5144 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5145 if (no_hyperlinks):
5146 return self.id_serializer_class
5147 else:
5148 return self.serializer_class
5149
5150 def get_queryset(self):
5151 return Account.select_by_user(self.request.user)
5152
5153 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005154 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5155 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005156 response = {"error": "validation",
5157 "specific_error": "not serializer.is_valid()",
5158 "reasons": serializer.errors}
5159 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005160 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005161 obj.caller = request.user
5162 if obj.can_update(request.user):
5163 return super(AccountList, self).create(request, *args, **kwargs)
5164 else:
Scott Baker08898c12014-10-29 23:41:11 -07005165 raise Exception("failed obj.can_update")
5166
5167 ret = super(AccountList, self).create(request, *args, **kwargs)
5168 if (ret.status_code%100 != 200):
5169 raise Exception(ret.data)
5170
5171 return ret
5172
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005173
5174class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5175 queryset = Account.objects.select_related().all()
5176 serializer_class = AccountSerializer
5177 id_serializer_class = AccountIdSerializer
5178
5179 def get_serializer_class(self):
5180 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5181 if (no_hyperlinks):
5182 return self.id_serializer_class
5183 else:
5184 return self.serializer_class
5185
5186 def get_queryset(self):
5187 return Account.select_by_user(self.request.user)
5188
5189 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5190
5191 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5192
5193
5194
Scott Bakerc1d11912014-12-22 09:29:05 -08005195class ControllerRoleList(generics.ListCreateAPIView):
5196 queryset = ControllerRole.objects.select_related().all()
5197 serializer_class = ControllerRoleSerializer
5198 id_serializer_class = ControllerRoleIdSerializer
5199 filter_backends = (filters.DjangoFilterBackend,)
5200 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5201
5202 def get_serializer_class(self):
5203 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5204 if (no_hyperlinks):
5205 return self.id_serializer_class
5206 else:
5207 return self.serializer_class
5208
5209 def get_queryset(self):
5210 return ControllerRole.select_by_user(self.request.user)
5211
5212 def create(self, request, *args, **kwargs):
5213 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5214 if not (serializer.is_valid()):
5215 response = {"error": "validation",
5216 "specific_error": "not serializer.is_valid()",
5217 "reasons": serializer.errors}
5218 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5219 obj = serializer.object
5220 obj.caller = request.user
5221 if obj.can_update(request.user):
5222 return super(ControllerRoleList, self).create(request, *args, **kwargs)
5223 else:
5224 raise Exception("failed obj.can_update")
5225
5226 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
5227 if (ret.status_code%100 != 200):
5228 raise Exception(ret.data)
5229
5230 return ret
5231
5232
5233class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5234 queryset = ControllerRole.objects.select_related().all()
5235 serializer_class = ControllerRoleSerializer
5236 id_serializer_class = ControllerRoleIdSerializer
5237
5238 def get_serializer_class(self):
5239 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5240 if (no_hyperlinks):
5241 return self.id_serializer_class
5242 else:
5243 return self.serializer_class
5244
5245 def get_queryset(self):
5246 return ControllerRole.select_by_user(self.request.user)
5247
5248 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5249
5250 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5251
5252
5253
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005254class NetworkParameterTypeList(generics.ListCreateAPIView):
5255 queryset = NetworkParameterType.objects.select_related().all()
5256 serializer_class = NetworkParameterTypeSerializer
5257 id_serializer_class = NetworkParameterTypeIdSerializer
5258 filter_backends = (filters.DjangoFilterBackend,)
5259 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
5260
5261 def get_serializer_class(self):
5262 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5263 if (no_hyperlinks):
5264 return self.id_serializer_class
5265 else:
5266 return self.serializer_class
5267
5268 def get_queryset(self):
5269 return NetworkParameterType.select_by_user(self.request.user)
5270
5271 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005272 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5273 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005274 response = {"error": "validation",
5275 "specific_error": "not serializer.is_valid()",
5276 "reasons": serializer.errors}
5277 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005278 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005279 obj.caller = request.user
5280 if obj.can_update(request.user):
5281 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5282 else:
Scott Baker08898c12014-10-29 23:41:11 -07005283 raise Exception("failed obj.can_update")
5284
5285 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5286 if (ret.status_code%100 != 200):
5287 raise Exception(ret.data)
5288
5289 return ret
5290
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005291
5292class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5293 queryset = NetworkParameterType.objects.select_related().all()
5294 serializer_class = NetworkParameterTypeSerializer
5295 id_serializer_class = NetworkParameterTypeIdSerializer
5296
5297 def get_serializer_class(self):
5298 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5299 if (no_hyperlinks):
5300 return self.id_serializer_class
5301 else:
5302 return self.serializer_class
5303
5304 def get_queryset(self):
5305 return NetworkParameterType.select_by_user(self.request.user)
5306
5307 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5308
5309 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5310
5311
5312
5313class SiteCredentialList(generics.ListCreateAPIView):
5314 queryset = SiteCredential.objects.select_related().all()
5315 serializer_class = SiteCredentialSerializer
5316 id_serializer_class = SiteCredentialIdSerializer
5317 filter_backends = (filters.DjangoFilterBackend,)
5318 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
5319
5320 def get_serializer_class(self):
5321 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5322 if (no_hyperlinks):
5323 return self.id_serializer_class
5324 else:
5325 return self.serializer_class
5326
5327 def get_queryset(self):
5328 return SiteCredential.select_by_user(self.request.user)
5329
5330 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005331 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5332 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005333 response = {"error": "validation",
5334 "specific_error": "not serializer.is_valid()",
5335 "reasons": serializer.errors}
5336 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005337 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005338 obj.caller = request.user
5339 if obj.can_update(request.user):
5340 return super(SiteCredentialList, self).create(request, *args, **kwargs)
5341 else:
Scott Baker08898c12014-10-29 23:41:11 -07005342 raise Exception("failed obj.can_update")
5343
5344 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
5345 if (ret.status_code%100 != 200):
5346 raise Exception(ret.data)
5347
5348 return ret
5349
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005350
5351class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5352 queryset = SiteCredential.objects.select_related().all()
5353 serializer_class = SiteCredentialSerializer
5354 id_serializer_class = SiteCredentialIdSerializer
5355
5356 def get_serializer_class(self):
5357 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5358 if (no_hyperlinks):
5359 return self.id_serializer_class
5360 else:
5361 return self.serializer_class
5362
5363 def get_queryset(self):
5364 return SiteCredential.select_by_user(self.request.user)
5365
5366 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5367
5368 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5369
5370
5371
Scott Bakerc1d11912014-12-22 09:29:05 -08005372class DeploymentPrivilegeList(generics.ListCreateAPIView):
5373 queryset = DeploymentPrivilege.objects.select_related().all()
5374 serializer_class = DeploymentPrivilegeSerializer
5375 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005376 filter_backends = (filters.DjangoFilterBackend,)
5377 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
5378
5379 def get_serializer_class(self):
5380 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5381 if (no_hyperlinks):
5382 return self.id_serializer_class
5383 else:
5384 return self.serializer_class
5385
5386 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005387 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005388
5389 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005390 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5391 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005392 response = {"error": "validation",
5393 "specific_error": "not serializer.is_valid()",
5394 "reasons": serializer.errors}
5395 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005396 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005397 obj.caller = request.user
5398 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08005399 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005400 else:
Scott Baker08898c12014-10-29 23:41:11 -07005401 raise Exception("failed obj.can_update")
5402
Scott Bakerc1d11912014-12-22 09:29:05 -08005403 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005404 if (ret.status_code%100 != 200):
5405 raise Exception(ret.data)
5406
5407 return ret
5408
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005409
Scott Bakerc1d11912014-12-22 09:29:05 -08005410class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5411 queryset = DeploymentPrivilege.objects.select_related().all()
5412 serializer_class = DeploymentPrivilegeSerializer
5413 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005414
5415 def get_serializer_class(self):
5416 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5417 if (no_hyperlinks):
5418 return self.id_serializer_class
5419 else:
5420 return self.serializer_class
5421
5422 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005423 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005424
5425 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5426
5427 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5428
5429
5430
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005431class ControllerSlicePrivilegeList(generics.ListCreateAPIView):
5432 queryset = ControllerSlicePrivilege.objects.select_related().all()
5433 serializer_class = ControllerSlicePrivilegeSerializer
5434 id_serializer_class = ControllerSlicePrivilegeIdSerializer
Scott Bakerc1d11912014-12-22 09:29:05 -08005435 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005436 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Bakerc1d11912014-12-22 09:29:05 -08005437
5438 def get_serializer_class(self):
5439 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5440 if (no_hyperlinks):
5441 return self.id_serializer_class
5442 else:
5443 return self.serializer_class
5444
5445 def get_queryset(self):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005446 return ControllerSlicePrivilege.select_by_user(self.request.user)
Scott Bakerc1d11912014-12-22 09:29:05 -08005447
5448 def create(self, request, *args, **kwargs):
5449 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5450 if not (serializer.is_valid()):
5451 response = {"error": "validation",
5452 "specific_error": "not serializer.is_valid()",
5453 "reasons": serializer.errors}
5454 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5455 obj = serializer.object
5456 obj.caller = request.user
5457 if obj.can_update(request.user):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005458 return super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
Scott Bakerc1d11912014-12-22 09:29:05 -08005459 else:
5460 raise Exception("failed obj.can_update")
5461
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005462 ret = super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
Scott Bakerc1d11912014-12-22 09:29:05 -08005463 if (ret.status_code%100 != 200):
5464 raise Exception(ret.data)
5465
5466 return ret
5467
5468
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005469class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5470 queryset = ControllerSlicePrivilege.objects.select_related().all()
5471 serializer_class = ControllerSlicePrivilegeSerializer
5472 id_serializer_class = ControllerSlicePrivilegeIdSerializer
Scott Bakerc1d11912014-12-22 09:29:05 -08005473
5474 def get_serializer_class(self):
5475 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5476 if (no_hyperlinks):
5477 return self.id_serializer_class
5478 else:
5479 return self.serializer_class
5480
5481 def get_queryset(self):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08005482 return ControllerSlicePrivilege.select_by_user(self.request.user)
5483
5484 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5485
5486 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5487
5488
5489
5490class SiteDeploymentList(generics.ListCreateAPIView):
5491 queryset = SiteDeployment.objects.select_related().all()
5492 serializer_class = SiteDeploymentSerializer
5493 id_serializer_class = SiteDeploymentIdSerializer
5494 filter_backends = (filters.DjangoFilterBackend,)
5495 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
5496
5497 def get_serializer_class(self):
5498 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5499 if (no_hyperlinks):
5500 return self.id_serializer_class
5501 else:
5502 return self.serializer_class
5503
5504 def get_queryset(self):
5505 return SiteDeployment.select_by_user(self.request.user)
5506
5507 def create(self, request, *args, **kwargs):
5508 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5509 if not (serializer.is_valid()):
5510 response = {"error": "validation",
5511 "specific_error": "not serializer.is_valid()",
5512 "reasons": serializer.errors}
5513 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5514 obj = serializer.object
5515 obj.caller = request.user
5516 if obj.can_update(request.user):
5517 return super(SiteDeploymentList, self).create(request, *args, **kwargs)
5518 else:
5519 raise Exception("failed obj.can_update")
5520
5521 ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
5522 if (ret.status_code%100 != 200):
5523 raise Exception(ret.data)
5524
5525 return ret
5526
5527
5528class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5529 queryset = SiteDeployment.objects.select_related().all()
5530 serializer_class = SiteDeploymentSerializer
5531 id_serializer_class = SiteDeploymentIdSerializer
5532
5533 def get_serializer_class(self):
5534 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5535 if (no_hyperlinks):
5536 return self.id_serializer_class
5537 else:
5538 return self.serializer_class
5539
5540 def get_queryset(self):
5541 return SiteDeployment.select_by_user(self.request.user)
Scott Bakerc1d11912014-12-22 09:29:05 -08005542
5543 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5544
5545 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5546
5547
5548
5549class DeploymentRoleList(generics.ListCreateAPIView):
5550 queryset = DeploymentRole.objects.select_related().all()
5551 serializer_class = DeploymentRoleSerializer
5552 id_serializer_class = DeploymentRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005553 filter_backends = (filters.DjangoFilterBackend,)
5554 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5555
5556 def get_serializer_class(self):
5557 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5558 if (no_hyperlinks):
5559 return self.id_serializer_class
5560 else:
5561 return self.serializer_class
5562
5563 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005564 return DeploymentRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005565
5566 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005567 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5568 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005569 response = {"error": "validation",
5570 "specific_error": "not serializer.is_valid()",
5571 "reasons": serializer.errors}
5572 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005573 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005574 obj.caller = request.user
5575 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08005576 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005577 else:
Scott Baker08898c12014-10-29 23:41:11 -07005578 raise Exception("failed obj.can_update")
5579
Scott Bakerc1d11912014-12-22 09:29:05 -08005580 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005581 if (ret.status_code%100 != 200):
5582 raise Exception(ret.data)
5583
5584 return ret
5585
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005586
Scott Bakerc1d11912014-12-22 09:29:05 -08005587class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5588 queryset = DeploymentRole.objects.select_related().all()
5589 serializer_class = DeploymentRoleSerializer
5590 id_serializer_class = DeploymentRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005591
5592 def get_serializer_class(self):
5593 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5594 if (no_hyperlinks):
5595 return self.id_serializer_class
5596 else:
5597 return self.serializer_class
5598
5599 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005600 return DeploymentRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005601
5602 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5603
5604 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5605
5606
5607
5608class UserCredentialList(generics.ListCreateAPIView):
5609 queryset = UserCredential.objects.select_related().all()
5610 serializer_class = UserCredentialSerializer
5611 id_serializer_class = UserCredentialIdSerializer
5612 filter_backends = (filters.DjangoFilterBackend,)
5613 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
5614
5615 def get_serializer_class(self):
5616 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5617 if (no_hyperlinks):
5618 return self.id_serializer_class
5619 else:
5620 return self.serializer_class
5621
5622 def get_queryset(self):
5623 return UserCredential.select_by_user(self.request.user)
5624
5625 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005626 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5627 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005628 response = {"error": "validation",
5629 "specific_error": "not serializer.is_valid()",
5630 "reasons": serializer.errors}
5631 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005632 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005633 obj.caller = request.user
5634 if obj.can_update(request.user):
5635 return super(UserCredentialList, self).create(request, *args, **kwargs)
5636 else:
Scott Baker08898c12014-10-29 23:41:11 -07005637 raise Exception("failed obj.can_update")
5638
5639 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
5640 if (ret.status_code%100 != 200):
5641 raise Exception(ret.data)
5642
5643 return ret
5644
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005645
5646class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5647 queryset = UserCredential.objects.select_related().all()
5648 serializer_class = UserCredentialSerializer
5649 id_serializer_class = UserCredentialIdSerializer
5650
5651 def get_serializer_class(self):
5652 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5653 if (no_hyperlinks):
5654 return self.id_serializer_class
5655 else:
5656 return self.serializer_class
5657
5658 def get_queryset(self):
5659 return UserCredential.select_by_user(self.request.user)
5660
5661 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5662
5663 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5664
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005665
Scott Bakerf3816ac2014-11-12 01:13:53 -08005666
Scott Baker0caeaf02014-06-19 11:12:55 -07005667class SliceTagList(generics.ListCreateAPIView):
5668 queryset = SliceTag.objects.select_related().all()
5669 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005670 id_serializer_class = SliceTagIdSerializer
5671 filter_backends = (filters.DjangoFilterBackend,)
5672 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5673
5674 def get_serializer_class(self):
5675 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5676 if (no_hyperlinks):
5677 return self.id_serializer_class
5678 else:
5679 return self.serializer_class
5680
Scott Baker0caeaf02014-06-19 11:12:55 -07005681 def get_queryset(self):
5682 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005683
Scott Baker0caeaf02014-06-19 11:12:55 -07005684 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005685 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5686 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005687 response = {"error": "validation",
5688 "specific_error": "not serializer.is_valid()",
5689 "reasons": serializer.errors}
5690 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005691 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005692 obj.caller = request.user
5693 if obj.can_update(request.user):
5694 return super(SliceTagList, self).create(request, *args, **kwargs)
5695 else:
Scott Baker08898c12014-10-29 23:41:11 -07005696 raise Exception("failed obj.can_update")
5697
5698 ret = super(SliceTagList, self).create(request, *args, **kwargs)
5699 if (ret.status_code%100 != 200):
5700 raise Exception(ret.data)
5701
5702 return ret
5703
Scott Baker0caeaf02014-06-19 11:12:55 -07005704
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005705class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005706 queryset = SliceTag.objects.select_related().all()
5707 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005708 id_serializer_class = SliceTagIdSerializer
5709
5710 def get_serializer_class(self):
5711 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5712 if (no_hyperlinks):
5713 return self.id_serializer_class
5714 else:
5715 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005716
5717 def get_queryset(self):
5718 return SliceTag.select_by_user(self.request.user)
5719
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005720 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005721
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005722 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005723
5724
5725
Scott Bakera6a0c772014-12-22 17:35:34 -08005726class NetworkTemplateList(generics.ListCreateAPIView):
5727 queryset = NetworkTemplate.objects.select_related().all()
5728 serializer_class = NetworkTemplateSerializer
5729 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005730 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker6c958402015-01-03 12:05:21 -08005731 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07005732
5733 def get_serializer_class(self):
5734 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5735 if (no_hyperlinks):
5736 return self.id_serializer_class
5737 else:
5738 return self.serializer_class
5739
Scott Baker0caeaf02014-06-19 11:12:55 -07005740 def get_queryset(self):
Scott Bakera6a0c772014-12-22 17:35:34 -08005741 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005742
Scott Baker0caeaf02014-06-19 11:12:55 -07005743 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005744 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5745 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005746 response = {"error": "validation",
5747 "specific_error": "not serializer.is_valid()",
5748 "reasons": serializer.errors}
5749 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005750 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005751 obj.caller = request.user
5752 if obj.can_update(request.user):
Scott Bakera6a0c772014-12-22 17:35:34 -08005753 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07005754 else:
Scott Baker08898c12014-10-29 23:41:11 -07005755 raise Exception("failed obj.can_update")
5756
Scott Bakera6a0c772014-12-22 17:35:34 -08005757 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005758 if (ret.status_code%100 != 200):
5759 raise Exception(ret.data)
5760
5761 return ret
5762
Scott Baker0caeaf02014-06-19 11:12:55 -07005763
Scott Bakera6a0c772014-12-22 17:35:34 -08005764class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5765 queryset = NetworkTemplate.objects.select_related().all()
5766 serializer_class = NetworkTemplateSerializer
5767 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005768
5769 def get_serializer_class(self):
5770 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5771 if (no_hyperlinks):
5772 return self.id_serializer_class
5773 else:
5774 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005775
5776 def get_queryset(self):
Scott Bakera6a0c772014-12-22 17:35:34 -08005777 return NetworkTemplate.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07005778
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005779 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005780
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005781 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005782
5783
5784
5785class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005786 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005787 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005788 id_serializer_class = RouterIdSerializer
5789 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08005790 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07005791
5792 def get_serializer_class(self):
5793 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5794 if (no_hyperlinks):
5795 return self.id_serializer_class
5796 else:
5797 return self.serializer_class
5798
Scott Baker0caeaf02014-06-19 11:12:55 -07005799 def get_queryset(self):
5800 return Router.select_by_user(self.request.user)
5801
5802 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005803 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5804 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005805 response = {"error": "validation",
5806 "specific_error": "not serializer.is_valid()",
5807 "reasons": serializer.errors}
5808 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005809 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005810 obj.caller = request.user
5811 if obj.can_update(request.user):
5812 return super(RouterList, self).create(request, *args, **kwargs)
5813 else:
Scott Baker08898c12014-10-29 23:41:11 -07005814 raise Exception("failed obj.can_update")
5815
5816 ret = super(RouterList, self).create(request, *args, **kwargs)
5817 if (ret.status_code%100 != 200):
5818 raise Exception(ret.data)
5819
5820 return ret
5821
Sapan Bhatiadea39432014-06-13 03:10:36 -04005822
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005823class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005824 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005825 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005826 id_serializer_class = RouterIdSerializer
5827
5828 def get_serializer_class(self):
5829 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5830 if (no_hyperlinks):
5831 return self.id_serializer_class
5832 else:
5833 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005834
5835 def get_queryset(self):
5836 return Router.select_by_user(self.request.user)
5837
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005838 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005839
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005840 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005841
5842
5843
Scott Baker0caeaf02014-06-19 11:12:55 -07005844class ServiceResourceList(generics.ListCreateAPIView):
5845 queryset = ServiceResource.objects.select_related().all()
5846 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005847 id_serializer_class = ServiceResourceIdSerializer
5848 filter_backends = (filters.DjangoFilterBackend,)
5849 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5850
5851 def get_serializer_class(self):
5852 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5853 if (no_hyperlinks):
5854 return self.id_serializer_class
5855 else:
5856 return self.serializer_class
5857
Scott Baker0caeaf02014-06-19 11:12:55 -07005858 def get_queryset(self):
5859 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005860
Scott Baker0caeaf02014-06-19 11:12:55 -07005861 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005862 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5863 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005864 response = {"error": "validation",
5865 "specific_error": "not serializer.is_valid()",
5866 "reasons": serializer.errors}
5867 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005868 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005869 obj.caller = request.user
5870 if obj.can_update(request.user):
5871 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5872 else:
Scott Baker08898c12014-10-29 23:41:11 -07005873 raise Exception("failed obj.can_update")
5874
5875 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5876 if (ret.status_code%100 != 200):
5877 raise Exception(ret.data)
5878
5879 return ret
5880
Scott Baker0caeaf02014-06-19 11:12:55 -07005881
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005882class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005883 queryset = ServiceResource.objects.select_related().all()
5884 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005885 id_serializer_class = ServiceResourceIdSerializer
5886
5887 def get_serializer_class(self):
5888 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5889 if (no_hyperlinks):
5890 return self.id_serializer_class
5891 else:
5892 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005893
5894 def get_queryset(self):
5895 return ServiceResource.select_by_user(self.request.user)
5896
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005897 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005898
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005899 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005900
Sapan Bhatiadea39432014-06-13 03:10:36 -04005901
5902