blob: 33448234d1dabf1886aab6c0950eb82a273b554f [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
Scott Bakerc1d11912014-12-22 09:29:05 -080038 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
39 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
40
Scott Baker55a2e292014-11-10 16:31:15 -080041 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
42 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
43
Scott Bakerc1d11912014-12-22 09:29:05 -080044 url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
45 url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
46
Scott 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
Scott Bakerc1d11912014-12-22 09:29:05 -080071 url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'),
72 url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'),
73
Scott Baker55a2e292014-11-10 16:31:15 -080074 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
75 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
76
Scott Baker55a2e292014-11-10 16:31:15 -080077 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
78 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
79
80 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
81 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
82
83 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
84 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
85
86 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
87 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
88
89 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
90 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
91
Scott Bakerc1d11912014-12-22 09:29:05 -080092 url(r'plstackapi/controllernetworks/$', ControllerNetworksList.as_view(), name='controllernetworks-list'),
93 url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworksDetail.as_view(), name ='controllernetworks-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -080094
95 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
96 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
97
98 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
99 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
100
101 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
102 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
103
Scott Bakerc1d11912014-12-22 09:29:05 -0800104 url(r'plstackapi/controllersitedeploymentses/$', ControllerSiteDeploymentsList.as_view(), name='controllersitedeployments-list'),
105 url(r'plstackapi/controllersitedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDeploymentsDetail.as_view(), name ='controllersitedeployments-detail'),
106
Scott Baker55a2e292014-11-10 16:31:15 -0800107 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 Bakerc1d11912014-12-22 09:29:05 -0800122 url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
123 url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800124
Scott Baker55a2e292014-11-10 16:31:15 -0800125 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
126 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
127
Scott Bakerc1d11912014-12-22 09:29:05 -0800128 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
129 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
130
Scott Baker55a2e292014-11-10 16:31:15 -0800131 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
132 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
133
134 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
135 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
136
Scott Bakerc1d11912014-12-22 09:29:05 -0800137 url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'),
138 url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
139
Scott Baker55a2e292014-11-10 16:31:15 -0800140 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
141 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
142
143 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
144 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
145
146 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
147 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
148
149 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
150 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
151
Scott Baker55a2e292014-11-10 16:31:15 -0800152 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
153 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
154
Scott Baker196ffef2014-11-21 11:32:24 -0800155 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
156 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800157
Scott Bakera6a0c772014-12-22 17:35:34 -0800158 url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'),
159 url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'),
160
Scott Baker55a2e292014-11-10 16:31:15 -0800161 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
162 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
163
Scott Bakerc1d11912014-12-22 09:29:05 -0800164 url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
165 url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
166
Scott Baker55a2e292014-11-10 16:31:15 -0800167 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
168 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
169
170 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
171 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
172
Scott Bakerc1d11912014-12-22 09:29:05 -0800173 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
174 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800175
Scott Bakerc1d11912014-12-22 09:29:05 -0800176 url(r'plstackapi/controllerusers/$', ControllerUsersList.as_view(), name='controllerusers-list'),
177 url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUsersDetail.as_view(), name ='controllerusers-detail'),
178
179 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
180 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800181
182 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
183 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
184
Scott Baker196ffef2014-11-21 11:32:24 -0800185 url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'),
186 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800187
Scott Baker55a2e292014-11-10 16:31:15 -0800188 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
189 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
190
Scott Bakera6a0c772014-12-22 17:35:34 -0800191 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
192 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800193
194 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
195 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
196
197 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
198 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
199
Scott Bakerc1d11912014-12-22 09:29:05 -0800200 url(r'plstackapi/controllerslices/$', ControllerSlicesList.as_view(), name='controllerslices-list'),
201 url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicesDetail.as_view(), name ='controllerslices-detail'),
202
Scott Baker55a2e292014-11-10 16:31:15 -0800203 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400204
205@api_view(['GET'])
206def api_root(request, format=None):
207 return Response({
Scott Bakerc1d11912014-12-22 09:29:05 -0800208 'flavors': reverse('flavor-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700209 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800210 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700211 'images': reverse('image-list', request=request, format=format),
212 'networkparameters': reverse('networkparameter-list', request=request, format=format),
213 'sites': reverse('site-list', request=request, format=format),
214 'sliceroles': reverse('slicerole-list', request=request, format=format),
215 'tags': reverse('tag-list', request=request, format=format),
216 'invoices': reverse('invoice-list', request=request, format=format),
217 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
218 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800219 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700220 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700221 'projects': reverse('project-list', request=request, format=format),
222 'slices': reverse('slice-list', request=request, format=format),
223 'networks': reverse('network-list', request=request, format=format),
224 'services': reverse('service-list', request=request, format=format),
225 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800226 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700227 'charges': reverse('charge-list', request=request, format=format),
228 'roles': reverse('role-list', request=request, format=format),
229 'usableobjects': reverse('usableobject-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800230 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700231 'siteroles': reverse('siterole-list', request=request, format=format),
232 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
233 'slivers': reverse('sliver-list', request=request, format=format),
234 'nodes': reverse('node-list', request=request, format=format),
235 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800236 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700237 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800238 'payments': reverse('payment-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700239 'networkslices': reverse('networkslice-list', request=request, format=format),
240 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800241 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700242 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
243 'users': reverse('user-list', request=request, format=format),
244 'deployments': reverse('deployment-list', request=request, format=format),
245 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700246 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800247 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Bakera6a0c772014-12-22 17:35:34 -0800248 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700249 'accounts': reverse('account-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800250 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700251 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
252 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800253 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
254 'controlleruserses': reverse('controllerusers-list', request=request, format=format),
255 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700256 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800257 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700258 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Bakera6a0c772014-12-22 17:35:34 -0800259 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700260 'routers': reverse('router-list', request=request, format=format),
261 'serviceresources': reverse('serviceresource-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800262 'controllersliceses': reverse('controllerslices-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700263
Sapan Bhatiadea39432014-06-13 03:10:36 -0400264 })
265
266# Based on serializers.py
267
Scott Bakerc1d11912014-12-22 09:29:05 -0800268class XOSModelSerializer(serializers.ModelSerializer):
269 def save_object(self, obj, **kwargs):
270
271 """ rest_framework can't deal with ManyToMany relations that have a
272 through table. In plstackapi, most of the through tables we have
273 use defaults or blank fields, so there's no reason why we shouldn't
274 be able to save these objects.
275
276 So, let's strip out these m2m relations, and deal with them ourself.
277 """
278 obj._complex_m2m_data={};
279 if getattr(obj, '_m2m_data', None):
280 for relatedObject in obj._meta.get_all_related_many_to_many_objects():
281 if (relatedObject.field.rel.through._meta.auto_created):
282 # These are non-trough ManyToMany relations and
283 # can be updated just fine
284 continue
285 fieldName = relatedObject.get_accessor_name()
286 if fieldName in obj._m2m_data.keys():
287 obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
288 del obj._m2m_data[fieldName]
289
290 serializers.ModelSerializer.save_object(self, obj, **kwargs);
291
292 for (accessor, stuff) in obj._complex_m2m_data.items():
293 (relatedObject, data) = stuff
294 through = relatedObject.field.rel.through
295 local_fieldName = relatedObject.field.m2m_reverse_field_name()
296 remote_fieldName = relatedObject.field.m2m_field_name()
297
298 # get the current set of existing relations
299 existing = through.objects.filter(**{local_fieldName: obj});
300
301 data_ids = [item.id for item in data]
302 existing_ids = [getattr(item,remote_fieldName).id for item in existing]
303
304 #print "data_ids", data_ids
305 #print "existing_ids", existing_ids
306
307 # remove relations that are in 'existing' but not in 'data'
308 for item in list(existing):
309 if (getattr(item,remote_fieldName).id not in data_ids):
310 print "delete", getattr(item,remote_fieldName)
311 item.delete() #(purge=True)
312
313 # add relations that are in 'data' but not in 'existing'
314 for item in data:
315 if (item.id not in existing_ids):
316 #print "add", item
317 newModel = through(**{local_fieldName: obj, remote_fieldName: item})
318 newModel.save()
319
320
321
322class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800323 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -0800324
325
326 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
327
328
329 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
330 validators = serializers.SerializerMethodField("getValidators")
331 def getHumanReadableName(self, obj):
332 return str(obj)
333 def getValidators(self, obj):
334 try:
335 return obj.getValidators()
336 except:
337 return None
338 class Meta:
339 model = Flavor
340 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
341
342class FlavorIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800343 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -0800344
345
Scott Bakera3134fe2014-12-23 10:56:06 -0800346 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -0800347
348
349 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
350 validators = serializers.SerializerMethodField("getValidators")
351 def getHumanReadableName(self, obj):
352 return str(obj)
353 def getValidators(self, obj):
354 try:
355 return obj.getValidators()
356 except:
357 return None
358 class Meta:
359 model = Flavor
360 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
361
362
Sapan Bhatiadea39432014-06-13 03:10:36 -0400363
364
Scott Baker0caeaf02014-06-19 11:12:55 -0700365class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800366 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700367
Scott Baker196ffef2014-11-21 11:32:24 -0800368 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800369 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800370 def getHumanReadableName(self, obj):
371 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800372 def getValidators(self, obj):
373 try:
374 return obj.getValidators()
375 except:
376 return None
Scott Baker08898c12014-10-29 23:41:11 -0700377 class Meta:
378 model = ServiceAttribute
Scott Baker351148c2014-11-25 00:53:25 -0800379 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700380
Scott Bakerc1d11912014-12-22 09:29:05 -0800381class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800382 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700383
Scott Baker196ffef2014-11-21 11:32:24 -0800384 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800385 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800386 def getHumanReadableName(self, obj):
387 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800388 def getValidators(self, obj):
389 try:
390 return obj.getValidators()
391 except:
392 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800393 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700394 model = ServiceAttribute
Scott Baker351148c2014-11-25 00:53:25 -0800395 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700396
397
Sapan Bhatiadea39432014-06-13 03:10:36 -0400398
399
Scott Bakerc1d11912014-12-22 09:29:05 -0800400class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800401 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -0800402
403 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
404 validators = serializers.SerializerMethodField("getValidators")
405 def getHumanReadableName(self, obj):
406 return str(obj)
407 def getValidators(self, obj):
408 try:
409 return obj.getValidators()
410 except:
411 return None
412 class Meta:
413 model = ControllerImages
414 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
415
416class ControllerImagesIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800417 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -0800418
419 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
420 validators = serializers.SerializerMethodField("getValidators")
421 def getHumanReadableName(self, obj):
422 return str(obj)
423 def getValidators(self, obj):
424 try:
425 return obj.getValidators()
426 except:
427 return None
428 class Meta:
429 model = ControllerImages
430 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
431
432
433
434
Sapan Bhatiadea39432014-06-13 03:10:36 -0400435class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800436 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700437
Scott Baker93a79a92014-12-22 15:59:33 -0800438
439 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
440
441
Scott Baker196ffef2014-11-21 11:32:24 -0800442 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800443 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800444 def getHumanReadableName(self, obj):
445 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800446 def getValidators(self, obj):
447 try:
448 return obj.getValidators()
449 except:
450 return None
Scott Baker08898c12014-10-29 23:41:11 -0700451 class Meta:
452 model = Image
Scott Baker93a79a92014-12-22 15:59:33 -0800453 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700454
Scott Bakerc1d11912014-12-22 09:29:05 -0800455class ImageIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800456 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700457
Scott Baker93a79a92014-12-22 15:59:33 -0800458
Scott Bakera3134fe2014-12-23 10:56:06 -0800459 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker93a79a92014-12-22 15:59:33 -0800460
461
Scott Baker196ffef2014-11-21 11:32:24 -0800462 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800463 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800464 def getHumanReadableName(self, obj):
465 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800466 def getValidators(self, obj):
467 try:
468 return obj.getValidators()
469 except:
470 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800471 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700472 model = Image
Scott Baker93a79a92014-12-22 15:59:33 -0800473 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700474
475
Sapan Bhatiadea39432014-06-13 03:10:36 -0400476
477
Scott Baker0caeaf02014-06-19 11:12:55 -0700478class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800479 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700480
Scott Baker196ffef2014-11-21 11:32:24 -0800481 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800482 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800483 def getHumanReadableName(self, obj):
484 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800485 def getValidators(self, obj):
486 try:
487 return obj.getValidators()
488 except:
489 return None
Scott Baker08898c12014-10-29 23:41:11 -0700490 class Meta:
491 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800492 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700493
Scott Bakerc1d11912014-12-22 09:29:05 -0800494class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800495 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700496
Scott Baker196ffef2014-11-21 11:32:24 -0800497 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800498 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800499 def getHumanReadableName(self, obj):
500 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800501 def getValidators(self, obj):
502 try:
503 return obj.getValidators()
504 except:
505 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800506 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700507 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800508 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700509
510
Sapan Bhatiadea39432014-06-13 03:10:36 -0400511
512
513class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800514 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700515
Scott Bakerc1d11912014-12-22 09:29:05 -0800516
517 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
518
519
Scott Baker196ffef2014-11-21 11:32:24 -0800520 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800521 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800522 def getHumanReadableName(self, obj):
523 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800524 def getValidators(self, obj):
525 try:
526 return obj.getValidators()
527 except:
528 return None
Scott Baker08898c12014-10-29 23:41:11 -0700529 class Meta:
530 model = Site
Scott Bakerc1d11912014-12-22 09:29:05 -0800531 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 -0700532
Scott Bakerc1d11912014-12-22 09:29:05 -0800533class SiteIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800534 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700535
Scott Bakerc1d11912014-12-22 09:29:05 -0800536
Scott Bakera3134fe2014-12-23 10:56:06 -0800537 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -0800538
539
Scott Baker196ffef2014-11-21 11:32:24 -0800540 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800541 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800542 def getHumanReadableName(self, obj):
543 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800544 def getValidators(self, obj):
545 try:
546 return obj.getValidators()
547 except:
548 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800549 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700550 model = Site
Scott Bakerc1d11912014-12-22 09:29:05 -0800551 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 -0700552
553
Sapan Bhatiadea39432014-06-13 03:10:36 -0400554
555
Scott Baker0caeaf02014-06-19 11:12:55 -0700556class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800557 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700558
Scott Baker196ffef2014-11-21 11:32:24 -0800559 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800560 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800561 def getHumanReadableName(self, obj):
562 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800563 def getValidators(self, obj):
564 try:
565 return obj.getValidators()
566 except:
567 return None
Scott Baker08898c12014-10-29 23:41:11 -0700568 class Meta:
569 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800570 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700571
Scott Bakerc1d11912014-12-22 09:29:05 -0800572class SliceRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800573 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700574
Scott Baker196ffef2014-11-21 11:32:24 -0800575 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800576 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800577 def getHumanReadableName(self, obj):
578 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800579 def getValidators(self, obj):
580 try:
581 return obj.getValidators()
582 except:
583 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800584 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700585 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800586 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700587
588
Sapan Bhatiadea39432014-06-13 03:10:36 -0400589
590
591class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800592 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700593
Scott Baker196ffef2014-11-21 11:32:24 -0800594 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800595 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800596 def getHumanReadableName(self, obj):
597 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800598 def getValidators(self, obj):
599 try:
600 return obj.getValidators()
601 except:
602 return None
Scott Baker08898c12014-10-29 23:41:11 -0700603 class Meta:
604 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800605 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700606
Scott Bakerc1d11912014-12-22 09:29:05 -0800607class TagIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800608 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700609
Scott Baker196ffef2014-11-21 11:32:24 -0800610 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800611 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800612 def getHumanReadableName(self, obj):
613 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800614 def getValidators(self, obj):
615 try:
616 return obj.getValidators()
617 except:
618 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800619 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700620 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800621 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700622
623
Sapan Bhatiadea39432014-06-13 03:10:36 -0400624
625
626class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800627 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700628
Scott Baker196ffef2014-11-21 11:32:24 -0800629 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800630 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800631 def getHumanReadableName(self, obj):
632 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800633 def getValidators(self, obj):
634 try:
635 return obj.getValidators()
636 except:
637 return None
Scott Baker08898c12014-10-29 23:41:11 -0700638 class Meta:
639 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800640 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700641
Scott Bakerc1d11912014-12-22 09:29:05 -0800642class InvoiceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800643 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700644
Scott Baker196ffef2014-11-21 11:32:24 -0800645 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800646 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800647 def getHumanReadableName(self, obj):
648 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800649 def getValidators(self, obj):
650 try:
651 return obj.getValidators()
652 except:
653 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800654 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700655 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800656 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700657
658
Sapan Bhatiadea39432014-06-13 03:10:36 -0400659
660
Scott Baker0caeaf02014-06-19 11:12:55 -0700661class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800662 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700663
Scott Baker196ffef2014-11-21 11:32:24 -0800664 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800665 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800666 def getHumanReadableName(self, obj):
667 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800668 def getValidators(self, obj):
669 try:
670 return obj.getValidators()
671 except:
672 return None
Scott Baker08898c12014-10-29 23:41:11 -0700673 class Meta:
674 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800675 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700676
Scott Bakerc1d11912014-12-22 09:29:05 -0800677class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800678 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700679
Scott Baker196ffef2014-11-21 11:32:24 -0800680 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800681 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800682 def getHumanReadableName(self, obj):
683 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800684 def getValidators(self, obj):
685 try:
686 return obj.getValidators()
687 except:
688 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800689 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700690 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800691 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700692
693
Scott Baker0caeaf02014-06-19 11:12:55 -0700694
695
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700696class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800697 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700698
Scott Baker196ffef2014-11-21 11:32:24 -0800699 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800700 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800701 def getHumanReadableName(self, obj):
702 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800703 def getValidators(self, obj):
704 try:
705 return obj.getValidators()
706 except:
707 return None
Scott Baker08898c12014-10-29 23:41:11 -0700708 class Meta:
709 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800710 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700711
Scott Bakerc1d11912014-12-22 09:29:05 -0800712class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800713 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700714
Scott Baker196ffef2014-11-21 11:32:24 -0800715 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800716 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800717 def getHumanReadableName(self, obj):
718 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800719 def getValidators(self, obj):
720 try:
721 return obj.getValidators()
722 except:
723 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800724 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700725 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800726 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700727
728
729
730
Scott Bakerc1d11912014-12-22 09:29:05 -0800731class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800732 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -0800733
734 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
735 validators = serializers.SerializerMethodField("getValidators")
736 def getHumanReadableName(self, obj):
737 return str(obj)
738 def getValidators(self, obj):
739 try:
740 return obj.getValidators()
741 except:
742 return None
743 class Meta:
744 model = ControllerPrivilege
745 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',)
746
747class ControllerPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800748 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -0800749
750 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
751 validators = serializers.SerializerMethodField("getValidators")
752 def getHumanReadableName(self, obj):
753 return str(obj)
754 def getValidators(self, obj):
755 try:
756 return obj.getValidators()
757 except:
758 return None
759 class Meta:
760 model = ControllerPrivilege
761 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',)
762
763
764
765
Scott Baker0caeaf02014-06-19 11:12:55 -0700766class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800767 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700768
Scott Baker196ffef2014-11-21 11:32:24 -0800769 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800770 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800771 def getHumanReadableName(self, obj):
772 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800773 def getValidators(self, obj):
774 try:
775 return obj.getValidators()
776 except:
777 return None
Scott Baker08898c12014-10-29 23:41:11 -0700778 class Meta:
779 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800780 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700781
Scott Bakerc1d11912014-12-22 09:29:05 -0800782class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800783 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700784
Scott Baker196ffef2014-11-21 11:32:24 -0800785 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800786 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800787 def getHumanReadableName(self, obj):
788 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800789 def getValidators(self, obj):
790 try:
791 return obj.getValidators()
792 except:
793 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800794 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700795 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800796 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700797
798
Scott Baker0caeaf02014-06-19 11:12:55 -0700799
800
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700801class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800802 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700803
Scott Baker196ffef2014-11-21 11:32:24 -0800804 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800805 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800806 def getHumanReadableName(self, obj):
807 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800808 def getValidators(self, obj):
809 try:
810 return obj.getValidators()
811 except:
812 return None
Scott Baker08898c12014-10-29 23:41:11 -0700813 class Meta:
814 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800815 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700816
Scott Bakerc1d11912014-12-22 09:29:05 -0800817class ProjectIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800818 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700819
Scott Baker196ffef2014-11-21 11:32:24 -0800820 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800821 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800822 def getHumanReadableName(self, obj):
823 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800824 def getValidators(self, obj):
825 try:
826 return obj.getValidators()
827 except:
828 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800829 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700830 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800831 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700832
833
834
835
Sapan Bhatiadea39432014-06-13 03:10:36 -0400836class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800837 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700838
839
840 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
841
842
843
Scott Baker08898c12014-10-29 23:41:11 -0700844 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
845
846
Scott Baker196ffef2014-11-21 11:32:24 -0800847 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800848 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800849 def getHumanReadableName(self, obj):
850 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800851 def getValidators(self, obj):
852 try:
853 return obj.getValidators()
854 except:
855 return None
Scott Baker08898c12014-10-29 23:41:11 -0700856 class Meta:
857 model = Slice
Scott Bakerc1d11912014-12-22 09:29:05 -0800858 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700859
Scott Bakerc1d11912014-12-22 09:29:05 -0800860class SliceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800861 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700862
863
Scott Bakera3134fe2014-12-23 10:56:06 -0800864 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700865
866
867
Scott Bakera3134fe2014-12-23 10:56:06 -0800868 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700869
870
Scott Baker196ffef2014-11-21 11:32:24 -0800871 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800872 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800873 def getHumanReadableName(self, obj):
874 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800875 def getValidators(self, obj):
876 try:
877 return obj.getValidators()
878 except:
879 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800880 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700881 model = Slice
Scott Bakerc1d11912014-12-22 09:29:05 -0800882 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700883
884
Sapan Bhatiadea39432014-06-13 03:10:36 -0400885
886
887class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800888 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700889
890
Scott Bakerc1d11912014-12-22 09:29:05 -0800891 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700892
893
894
Scott Bakerc1d11912014-12-22 09:29:05 -0800895 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
896
897
898
899 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700900
901
902
903 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
904
905
906
907 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
908
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 Baker08898c12014-10-29 23:41:11 -0700919 class Meta:
920 model = Network
Scott Bakerc1d11912014-12-22 09:29:05 -0800921 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700922
Scott Bakerc1d11912014-12-22 09:29:05 -0800923class NetworkIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800924 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700925
926
Scott Bakera3134fe2014-12-23 10:56:06 -0800927 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700928
929
930
Scott Bakera3134fe2014-12-23 10:56:06 -0800931 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700932
933
934
Scott Bakera3134fe2014-12-23 10:56:06 -0800935 slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700936
937
938
Scott Bakera3134fe2014-12-23 10:56:06 -0800939 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -0800940
941
942
Scott Bakera3134fe2014-12-23 10:56:06 -0800943 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700944
945
Scott Baker196ffef2014-11-21 11:32:24 -0800946 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800947 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800948 def getHumanReadableName(self, obj):
949 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800950 def getValidators(self, obj):
951 try:
952 return obj.getValidators()
953 except:
954 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800955 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700956 model = Network
Scott Bakerc1d11912014-12-22 09:29:05 -0800957 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700958
959
Sapan Bhatiadea39432014-06-13 03:10:36 -0400960
961
962class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800963 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700964
Scott Baker196ffef2014-11-21 11:32:24 -0800965 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800966 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800967 def getHumanReadableName(self, obj):
968 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800969 def getValidators(self, obj):
970 try:
971 return obj.getValidators()
972 except:
973 return None
Scott Baker08898c12014-10-29 23:41:11 -0700974 class Meta:
975 model = Service
Scott Baker351148c2014-11-25 00:53:25 -0800976 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700977
Scott Bakerc1d11912014-12-22 09:29:05 -0800978class ServiceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800979 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700980
Scott Baker196ffef2014-11-21 11:32:24 -0800981 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800982 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800983 def getHumanReadableName(self, obj):
984 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800985 def getValidators(self, obj):
986 try:
987 return obj.getValidators()
988 except:
989 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800990 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700991 model = Service
Scott Baker351148c2014-11-25 00:53:25 -0800992 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700993
994
Sapan Bhatiadea39432014-06-13 03:10:36 -0400995
996
Scott Baker0caeaf02014-06-19 11:12:55 -0700997class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800998 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700999
Scott Baker196ffef2014-11-21 11:32:24 -08001000 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001001 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001002 def getHumanReadableName(self, obj):
1003 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001004 def getValidators(self, obj):
1005 try:
1006 return obj.getValidators()
1007 except:
1008 return None
Scott Baker08898c12014-10-29 23:41:11 -07001009 class Meta:
1010 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -08001011 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001012
Scott Bakerc1d11912014-12-22 09:29:05 -08001013class ServiceClassIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001014 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001015
Scott Baker196ffef2014-11-21 11:32:24 -08001016 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001017 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001018 def getHumanReadableName(self, obj):
1019 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001020 def getValidators(self, obj):
1021 try:
1022 return obj.getValidators()
1023 except:
1024 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001025 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001026 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -08001027 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001028
1029
Sapan Bhatiadea39432014-06-13 03:10:36 -04001030
1031
Scott Bakerc1d11912014-12-22 09:29:05 -08001032class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001033 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001034
Scott Baker196ffef2014-11-21 11:32:24 -08001035 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001036 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001037 def getHumanReadableName(self, obj):
1038 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001039 def getValidators(self, obj):
1040 try:
1041 return obj.getValidators()
1042 except:
1043 return None
Scott Baker08898c12014-10-29 23:41:11 -07001044 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001045 model = ControllerNetworks
1046 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -07001047
Scott Bakerc1d11912014-12-22 09:29:05 -08001048class ControllerNetworksIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001049 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001050
Scott Baker196ffef2014-11-21 11:32:24 -08001051 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001052 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001053 def getHumanReadableName(self, obj):
1054 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001055 def getValidators(self, obj):
1056 try:
1057 return obj.getValidators()
1058 except:
1059 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001060 class Meta:
1061 model = ControllerNetworks
1062 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -07001063
1064
Sapan Bhatiadea39432014-06-13 03:10:36 -04001065
1066
1067class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001068 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001069
Scott Baker196ffef2014-11-21 11:32:24 -08001070 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001071 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001072 def getHumanReadableName(self, obj):
1073 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001074 def getValidators(self, obj):
1075 try:
1076 return obj.getValidators()
1077 except:
1078 return None
Scott Baker08898c12014-10-29 23:41:11 -07001079 class Meta:
1080 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -08001081 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 -07001082
Scott Bakerc1d11912014-12-22 09:29:05 -08001083class ChargeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001084 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001085
Scott Baker196ffef2014-11-21 11:32:24 -08001086 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001087 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001088 def getHumanReadableName(self, obj):
1089 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001090 def getValidators(self, obj):
1091 try:
1092 return obj.getValidators()
1093 except:
1094 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001095 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001096 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -08001097 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 -07001098
1099
Sapan Bhatiadea39432014-06-13 03:10:36 -04001100
1101
1102class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001103 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001104
Scott Baker196ffef2014-11-21 11:32:24 -08001105 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001106 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001107 def getHumanReadableName(self, obj):
1108 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001109 def getValidators(self, obj):
1110 try:
1111 return obj.getValidators()
1112 except:
1113 return None
Scott Baker08898c12014-10-29 23:41:11 -07001114 class Meta:
1115 model = Role
Scott Baker351148c2014-11-25 00:53:25 -08001116 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001117
Scott Bakerc1d11912014-12-22 09:29:05 -08001118class RoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001119 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001120
Scott Baker196ffef2014-11-21 11:32:24 -08001121 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001122 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001123 def getHumanReadableName(self, obj):
1124 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001125 def getValidators(self, obj):
1126 try:
1127 return obj.getValidators()
1128 except:
1129 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001130 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001131 model = Role
Scott Baker351148c2014-11-25 00:53:25 -08001132 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001133
1134
Sapan Bhatiadea39432014-06-13 03:10:36 -04001135
1136
Scott Baker0caeaf02014-06-19 11:12:55 -07001137class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001138 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001139
Scott Baker196ffef2014-11-21 11:32:24 -08001140 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001141 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001142 def getHumanReadableName(self, obj):
1143 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001144 def getValidators(self, obj):
1145 try:
1146 return obj.getValidators()
1147 except:
1148 return None
Scott Baker08898c12014-10-29 23:41:11 -07001149 class Meta:
1150 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001151 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001152
Scott Bakerc1d11912014-12-22 09:29:05 -08001153class UsableObjectIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001154 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001155
Scott Baker196ffef2014-11-21 11:32:24 -08001156 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001157 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001158 def getHumanReadableName(self, obj):
1159 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001160 def getValidators(self, obj):
1161 try:
1162 return obj.getValidators()
1163 except:
1164 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001165 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001166 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001167 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001168
1169
Sapan Bhatiadea39432014-06-13 03:10:36 -04001170
1171
Scott Bakerc1d11912014-12-22 09:29:05 -08001172class ControllerSiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001173 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001174
1175 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1176 validators = serializers.SerializerMethodField("getValidators")
1177 def getHumanReadableName(self, obj):
1178 return str(obj)
1179 def getValidators(self, obj):
1180 try:
1181 return obj.getValidators()
1182 except:
1183 return None
1184 class Meta:
1185 model = ControllerSiteDeployments
1186 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
1187
1188class ControllerSiteDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001189 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001190
1191 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1192 validators = serializers.SerializerMethodField("getValidators")
1193 def getHumanReadableName(self, obj):
1194 return str(obj)
1195 def getValidators(self, obj):
1196 try:
1197 return obj.getValidators()
1198 except:
1199 return None
1200 class Meta:
1201 model = ControllerSiteDeployments
1202 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
1203
1204
1205
1206
Scott Baker0caeaf02014-06-19 11:12:55 -07001207class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001208 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001209
Scott Baker196ffef2014-11-21 11:32:24 -08001210 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001211 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001212 def getHumanReadableName(self, obj):
1213 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001214 def getValidators(self, obj):
1215 try:
1216 return obj.getValidators()
1217 except:
1218 return None
Scott Baker08898c12014-10-29 23:41:11 -07001219 class Meta:
1220 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001221 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001222
Scott Bakerc1d11912014-12-22 09:29:05 -08001223class SiteRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001224 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001225
Scott Baker196ffef2014-11-21 11:32:24 -08001226 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001227 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001228 def getHumanReadableName(self, obj):
1229 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001230 def getValidators(self, obj):
1231 try:
1232 return obj.getValidators()
1233 except:
1234 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001235 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001236 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001237 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001238
1239
Scott Baker0caeaf02014-06-19 11:12:55 -07001240
1241
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001242class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001243 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001244
Scott Baker196ffef2014-11-21 11:32:24 -08001245 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001246 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001247 def getHumanReadableName(self, obj):
1248 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001249 def getValidators(self, obj):
1250 try:
1251 return obj.getValidators()
1252 except:
1253 return None
Scott Baker08898c12014-10-29 23:41:11 -07001254 class Meta:
1255 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001256 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001257
Scott Bakerc1d11912014-12-22 09:29:05 -08001258class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001259 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001260
Scott Baker196ffef2014-11-21 11:32:24 -08001261 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001262 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001263 def getHumanReadableName(self, obj):
1264 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001265 def getValidators(self, obj):
1266 try:
1267 return obj.getValidators()
1268 except:
1269 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001270 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001271 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001272 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001273
1274
1275
1276
Sapan Bhatiadea39432014-06-13 03:10:36 -04001277class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001278 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001279
1280
1281 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1282
1283
Scott Baker196ffef2014-11-21 11:32:24 -08001284 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001285 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001286 def getHumanReadableName(self, obj):
1287 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001288 def getValidators(self, obj):
1289 try:
1290 return obj.getValidators()
1291 except:
1292 return None
Scott Baker08898c12014-10-29 23:41:11 -07001293 class Meta:
1294 model = Sliver
Scott Baker6c958402015-01-03 12:05:21 -08001295 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 -07001296
Scott Bakerc1d11912014-12-22 09:29:05 -08001297class SliverIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001298 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001299
1300
Scott Bakera3134fe2014-12-23 10:56:06 -08001301 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -07001302
1303
Scott Baker196ffef2014-11-21 11:32:24 -08001304 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001305 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001306 def getHumanReadableName(self, obj):
1307 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001308 def getValidators(self, obj):
1309 try:
1310 return obj.getValidators()
1311 except:
1312 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001313 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001314 model = Sliver
Scott Baker6c958402015-01-03 12:05:21 -08001315 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 -07001316
1317
Sapan Bhatiadea39432014-06-13 03:10:36 -04001318
1319
1320class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001321 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001322
Scott Baker196ffef2014-11-21 11:32:24 -08001323 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001324 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001325 def getHumanReadableName(self, obj):
1326 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001327 def getValidators(self, obj):
1328 try:
1329 return obj.getValidators()
1330 except:
1331 return None
Scott Baker08898c12014-10-29 23:41:11 -07001332 class Meta:
1333 model = Node
Scott Bakerc1d11912014-12-22 09:29:05 -08001334 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001335
Scott Bakerc1d11912014-12-22 09:29:05 -08001336class NodeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001337 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001338
Scott Baker196ffef2014-11-21 11:32:24 -08001339 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001340 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001341 def getHumanReadableName(self, obj):
1342 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001343 def getValidators(self, obj):
1344 try:
1345 return obj.getValidators()
1346 except:
1347 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001348 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001349 model = Node
Scott Bakerc1d11912014-12-22 09:29:05 -08001350 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001351
1352
Sapan Bhatiadea39432014-06-13 03:10:36 -04001353
1354
Scott Baker0caeaf02014-06-19 11:12:55 -07001355class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001356 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001357
Scott Bakerc1d11912014-12-22 09:29:05 -08001358
1359 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1360
1361
Scott Baker196ffef2014-11-21 11:32:24 -08001362 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001363 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001364 def getHumanReadableName(self, obj):
1365 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001366 def getValidators(self, obj):
1367 try:
1368 return obj.getValidators()
1369 except:
1370 return None
Scott Baker08898c12014-10-29 23:41:11 -07001371 class Meta:
1372 model = DashboardView
Scott Bakerc1d11912014-12-22 09:29:05 -08001373 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker46b58542014-08-11 17:26:12 -07001374
Scott Bakerc1d11912014-12-22 09:29:05 -08001375class DashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001376 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001377
Scott Bakerc1d11912014-12-22 09:29:05 -08001378
Scott Bakera3134fe2014-12-23 10:56:06 -08001379 controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08001380
1381
Scott Baker196ffef2014-11-21 11:32:24 -08001382 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001383 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001384 def getHumanReadableName(self, obj):
1385 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001386 def getValidators(self, obj):
1387 try:
1388 return obj.getValidators()
1389 except:
1390 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001391 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001392 model = DashboardView
Scott Bakerc1d11912014-12-22 09:29:05 -08001393 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Baker196ffef2014-11-21 11:32:24 -08001394
1395
1396
1397
Scott Bakerc1d11912014-12-22 09:29:05 -08001398class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001399 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001400
1401 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001402 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001403 def getHumanReadableName(self, obj):
1404 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001405 def getValidators(self, obj):
1406 try:
1407 return obj.getValidators()
1408 except:
1409 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001410 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001411 model = ImageDeployments
1412 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker196ffef2014-11-21 11:32:24 -08001413
Scott Bakerc1d11912014-12-22 09:29:05 -08001414class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001415 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001416
1417 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001418 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001419 def getHumanReadableName(self, obj):
1420 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001421 def getValidators(self, obj):
1422 try:
1423 return obj.getValidators()
1424 except:
1425 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001426 class Meta:
1427 model = ImageDeployments
1428 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001429
1430
Sapan Bhatiadea39432014-06-13 03:10:36 -04001431
1432
Scott Baker0caeaf02014-06-19 11:12:55 -07001433class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001434 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001435
Scott Baker196ffef2014-11-21 11:32:24 -08001436 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001437 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001438 def getHumanReadableName(self, obj):
1439 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001440 def getValidators(self, obj):
1441 try:
1442 return obj.getValidators()
1443 except:
1444 return None
Scott Baker08898c12014-10-29 23:41:11 -07001445 class Meta:
1446 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001447 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001448
Scott Bakerc1d11912014-12-22 09:29:05 -08001449class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001450 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001451
Scott Baker196ffef2014-11-21 11:32:24 -08001452 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001453 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001454 def getHumanReadableName(self, obj):
1455 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001456 def getValidators(self, obj):
1457 try:
1458 return obj.getValidators()
1459 except:
1460 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001461 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001462 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001463 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001464
1465
1466
1467
Scott Bakerc1d11912014-12-22 09:29:05 -08001468class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001469 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001470
1471 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1472 validators = serializers.SerializerMethodField("getValidators")
1473 def getHumanReadableName(self, obj):
1474 return str(obj)
1475 def getValidators(self, obj):
1476 try:
1477 return obj.getValidators()
1478 except:
1479 return None
1480 class Meta:
1481 model = Payment
1482 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1483
1484class PaymentIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001485 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001486
1487 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1488 validators = serializers.SerializerMethodField("getValidators")
1489 def getHumanReadableName(self, obj):
1490 return str(obj)
1491 def getValidators(self, obj):
1492 try:
1493 return obj.getValidators()
1494 except:
1495 return None
1496 class Meta:
1497 model = Payment
1498 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
1499
1500
1501
1502
Scott Baker0caeaf02014-06-19 11:12:55 -07001503class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001504 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001505
Scott Baker196ffef2014-11-21 11:32:24 -08001506 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001507 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001508 def getHumanReadableName(self, obj):
1509 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001510 def getValidators(self, obj):
1511 try:
1512 return obj.getValidators()
1513 except:
1514 return None
Scott Baker08898c12014-10-29 23:41:11 -07001515 class Meta:
1516 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001517 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001518
Scott Bakerc1d11912014-12-22 09:29:05 -08001519class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001520 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001521
Scott Baker196ffef2014-11-21 11:32:24 -08001522 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001523 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001524 def getHumanReadableName(self, obj):
1525 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001526 def getValidators(self, obj):
1527 try:
1528 return obj.getValidators()
1529 except:
1530 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001531 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001532 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001533 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001534
1535
Scott Baker0caeaf02014-06-19 11:12:55 -07001536
1537
1538class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001539 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001540
Scott Baker196ffef2014-11-21 11:32:24 -08001541 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001542 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001543 def getHumanReadableName(self, obj):
1544 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001545 def getValidators(self, obj):
1546 try:
1547 return obj.getValidators()
1548 except:
1549 return None
Scott Baker08898c12014-10-29 23:41:11 -07001550 class Meta:
1551 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001552 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001553
Scott Bakerc1d11912014-12-22 09:29:05 -08001554class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001555 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001556
Scott Baker196ffef2014-11-21 11:32:24 -08001557 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001558 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001559 def getHumanReadableName(self, obj):
1560 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001561 def getValidators(self, obj):
1562 try:
1563 return obj.getValidators()
1564 except:
Scott Bakerc1d11912014-12-22 09:29:05 -08001565 return None
1566 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001567 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001568 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001569
1570
1571
1572
Scott Bakerc1d11912014-12-22 09:29:05 -08001573class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001574 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001575
Scott Bakerc1d11912014-12-22 09:29:05 -08001576
1577 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1578
1579
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 Bakerc1d11912014-12-22 09:29:05 -08001582 def getHumanReadableName(self, obj):
Scott Baker196ffef2014-11-21 11:32:24 -08001583 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:
Scott Bakerc1d11912014-12-22 09:29:05 -08001590 model = Controller
1591 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 -07001592
Scott Bakerc1d11912014-12-22 09:29:05 -08001593class ControllerIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001594 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001595
1596
Scott Bakera3134fe2014-12-23 10:56:06 -08001597 dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -07001598
1599
Scott Baker196ffef2014-11-21 11:32:24 -08001600 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001601 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001602 def getHumanReadableName(self, obj):
1603 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001604 def getValidators(self, obj):
1605 try:
1606 return obj.getValidators()
1607 except:
1608 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001609 class Meta:
1610 model = Controller
1611 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
1612
1613
1614
1615
1616class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001617 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001618
1619 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1620 validators = serializers.SerializerMethodField("getValidators")
1621 def getHumanReadableName(self, obj):
1622 return str(obj)
1623 def getValidators(self, obj):
1624 try:
1625 return obj.getValidators()
1626 except:
1627 return None
1628 class Meta:
1629 model = PlanetStackPrivilege
1630 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1631
1632class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001633 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001634
1635 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1636 validators = serializers.SerializerMethodField("getValidators")
1637 def getHumanReadableName(self, obj):
1638 return str(obj)
1639 def getValidators(self, obj):
1640 try:
1641 return obj.getValidators()
1642 except:
1643 return None
1644 class Meta:
1645 model = PlanetStackPrivilege
1646 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
1647
1648
1649
1650
1651class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001652 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001653
1654 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1655 validators = serializers.SerializerMethodField("getValidators")
1656 def getHumanReadableName(self, obj):
1657 return str(obj)
1658 def getValidators(self, obj):
1659 try:
1660 return obj.getValidators()
1661 except:
1662 return None
1663 class Meta:
1664 model = User
1665 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',)
1666
1667class UserIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001668 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001669
1670 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1671 validators = serializers.SerializerMethodField("getValidators")
1672 def getHumanReadableName(self, obj):
1673 return str(obj)
1674 def getValidators(self, obj):
1675 try:
1676 return obj.getValidators()
1677 except:
1678 return None
1679 class Meta:
1680 model = User
1681 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',)
1682
1683
1684
1685
1686class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001687 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001688
1689
1690 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1691
1692
1693
Scott Baker93a79a92014-12-22 15:59:33 -08001694 images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1695
1696
1697
Scott Bakerc1d11912014-12-22 09:29:05 -08001698 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1699
1700
1701 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1702 validators = serializers.SerializerMethodField("getValidators")
1703 def getHumanReadableName(self, obj):
1704 return str(obj)
1705 def getValidators(self, obj):
1706 try:
1707 return obj.getValidators()
1708 except:
1709 return None
Scott Baker08898c12014-10-29 23:41:11 -07001710 class Meta:
1711 model = Deployment
Scott Baker93a79a92014-12-22 15:59:33 -08001712 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Scott Baker46b58542014-08-11 17:26:12 -07001713
Scott Bakerc1d11912014-12-22 09:29:05 -08001714class DeploymentIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001715 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001716
1717
Scott Bakera3134fe2014-12-23 10:56:06 -08001718 flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08001719
1720
1721
Scott Bakera3134fe2014-12-23 10:56:06 -08001722 images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all())
Scott Baker93a79a92014-12-22 15:59:33 -08001723
1724
1725
Scott Bakera3134fe2014-12-23 10:56:06 -08001726 sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08001727
1728
Tony Mack336e0f92014-11-30 15:53:08 -05001729 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1730 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerc1d11912014-12-22 09:29:05 -08001731 def getHumanReadableName(self, obj):
1732 return str(obj)
1733 def getValidators(self, obj):
Tony Mack336e0f92014-11-30 15:53:08 -05001734 try:
1735 return obj.getValidators()
1736 except:
Scott Bakerc1d11912014-12-22 09:29:05 -08001737 return None
1738 class Meta:
1739 model = Deployment
Scott Baker93a79a92014-12-22 15:59:33 -08001740 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Tony Mack336e0f92014-11-30 15:53:08 -05001741
1742
Sapan Bhatiadea39432014-06-13 03:10:36 -04001743
1744
1745class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001746 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001747
Scott Baker196ffef2014-11-21 11:32:24 -08001748 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001749 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001750 def getHumanReadableName(self, obj):
1751 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001752 def getValidators(self, obj):
1753 try:
1754 return obj.getValidators()
1755 except:
1756 return None
Scott Baker08898c12014-10-29 23:41:11 -07001757 class Meta:
1758 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001759 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001760
Scott Bakerc1d11912014-12-22 09:29:05 -08001761class ReservationIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001762 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001763
Scott Baker196ffef2014-11-21 11:32:24 -08001764 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001765 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001766 def getHumanReadableName(self, obj):
1767 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001768 def getValidators(self, obj):
1769 try:
1770 return obj.getValidators()
1771 except:
1772 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001773 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001774 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001775 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001776
1777
Scott Baker0caeaf02014-06-19 11:12:55 -07001778
1779
Scott Baker196ffef2014-11-21 11:32:24 -08001780class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001781 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001782
1783 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001784 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001785 def getHumanReadableName(self, obj):
1786 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001787 def getValidators(self, obj):
1788 try:
1789 return obj.getValidators()
1790 except:
1791 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001792 class Meta:
1793 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001794 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001795
Scott Bakerc1d11912014-12-22 09:29:05 -08001796class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001797 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001798
1799 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001800 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001801 def getHumanReadableName(self, obj):
1802 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001803 def getValidators(self, obj):
1804 try:
1805 return obj.getValidators()
1806 except:
1807 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001808 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -08001809 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001810 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001811
1812
1813
1814
1815class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001816 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001817
1818 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001819 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001820 def getHumanReadableName(self, obj):
1821 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001822 def getValidators(self, obj):
1823 try:
1824 return obj.getValidators()
1825 except:
1826 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001827 class Meta:
1828 model = PlanetStack
Scott Baker351148c2014-11-25 00:53:25 -08001829 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker196ffef2014-11-21 11:32:24 -08001830
Scott Bakerc1d11912014-12-22 09:29:05 -08001831class PlanetStackIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001832 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001833
1834 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001835 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001836 def getHumanReadableName(self, obj):
1837 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001838 def getValidators(self, obj):
1839 try:
1840 return obj.getValidators()
1841 except:
1842 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001843 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -08001844 model = PlanetStack
Scott Baker351148c2014-11-25 00:53:25 -08001845 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001846
1847
Sapan Bhatiadea39432014-06-13 03:10:36 -04001848
1849
Scott Bakera6a0c772014-12-22 17:35:34 -08001850class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001851 id = IdField()
Scott Bakera6a0c772014-12-22 17:35:34 -08001852
1853 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1854 validators = serializers.SerializerMethodField("getValidators")
1855 def getHumanReadableName(self, obj):
1856 return str(obj)
1857 def getValidators(self, obj):
1858 try:
1859 return obj.getValidators()
1860 except:
1861 return None
1862 class Meta:
1863 model = ControllerDashboardView
1864 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1865
1866class ControllerDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001867 id = IdField()
Scott Bakera6a0c772014-12-22 17:35:34 -08001868
1869 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1870 validators = serializers.SerializerMethodField("getValidators")
1871 def getHumanReadableName(self, obj):
1872 return str(obj)
1873 def getValidators(self, obj):
1874 try:
1875 return obj.getValidators()
1876 except:
1877 return None
1878 class Meta:
1879 model = ControllerDashboardView
1880 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
1881
1882
1883
1884
Sapan Bhatiadea39432014-06-13 03:10:36 -04001885class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001886 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001887
Scott Baker196ffef2014-11-21 11:32:24 -08001888 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001889 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001890 def getHumanReadableName(self, obj):
1891 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001892 def getValidators(self, obj):
1893 try:
1894 return obj.getValidators()
1895 except:
1896 return None
Scott Baker08898c12014-10-29 23:41:11 -07001897 class Meta:
1898 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001899 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001900
Scott Bakerc1d11912014-12-22 09:29:05 -08001901class AccountIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001902 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001903
Scott Baker196ffef2014-11-21 11:32:24 -08001904 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001905 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001906 def getHumanReadableName(self, obj):
1907 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001908 def getValidators(self, obj):
1909 try:
1910 return obj.getValidators()
1911 except:
1912 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001913 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001914 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001915 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001916
1917
Sapan Bhatiadea39432014-06-13 03:10:36 -04001918
1919
Scott Bakerc1d11912014-12-22 09:29:05 -08001920class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001921 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001922
1923 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1924 validators = serializers.SerializerMethodField("getValidators")
1925 def getHumanReadableName(self, obj):
1926 return str(obj)
1927 def getValidators(self, obj):
1928 try:
1929 return obj.getValidators()
1930 except:
1931 return None
1932 class Meta:
1933 model = ControllerRole
1934 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1935
1936class ControllerRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001937 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001938
1939 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1940 validators = serializers.SerializerMethodField("getValidators")
1941 def getHumanReadableName(self, obj):
1942 return str(obj)
1943 def getValidators(self, obj):
1944 try:
1945 return obj.getValidators()
1946 except:
1947 return None
1948 class Meta:
1949 model = ControllerRole
1950 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
1951
1952
1953
1954
Scott Baker0caeaf02014-06-19 11:12:55 -07001955class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001956 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001957
Scott Baker196ffef2014-11-21 11:32:24 -08001958 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001959 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001960 def getHumanReadableName(self, obj):
1961 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001962 def getValidators(self, obj):
1963 try:
1964 return obj.getValidators()
1965 except:
1966 return None
Scott Baker08898c12014-10-29 23:41:11 -07001967 class Meta:
1968 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08001969 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001970
Scott Bakerc1d11912014-12-22 09:29:05 -08001971class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001972 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001973
Scott Baker196ffef2014-11-21 11:32:24 -08001974 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001975 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001976 def getHumanReadableName(self, obj):
1977 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001978 def getValidators(self, obj):
1979 try:
1980 return obj.getValidators()
1981 except:
1982 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001983 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001984 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08001985 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001986
1987
Sapan Bhatiadea39432014-06-13 03:10:36 -04001988
1989
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001990class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001991 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001992
Scott Baker196ffef2014-11-21 11:32:24 -08001993 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001994 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001995 def getHumanReadableName(self, obj):
1996 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001997 def getValidators(self, obj):
1998 try:
1999 return obj.getValidators()
2000 except:
2001 return None
Scott Baker08898c12014-10-29 23:41:11 -07002002 class Meta:
2003 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08002004 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002005
Scott Bakerc1d11912014-12-22 09:29:05 -08002006class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002007 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002008
Scott Baker196ffef2014-11-21 11:32:24 -08002009 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002010 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002011 def getHumanReadableName(self, obj):
2012 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002013 def getValidators(self, obj):
2014 try:
2015 return obj.getValidators()
2016 except:
2017 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002018 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002019 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08002020 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002021
2022
Scott Baker0caeaf02014-06-19 11:12:55 -07002023
2024
Scott Bakerc1d11912014-12-22 09:29:05 -08002025class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002026 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002027
Scott Baker196ffef2014-11-21 11:32:24 -08002028 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002029 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002030 def getHumanReadableName(self, obj):
2031 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002032 def getValidators(self, obj):
2033 try:
2034 return obj.getValidators()
2035 except:
2036 return None
Scott Baker08898c12014-10-29 23:41:11 -07002037 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08002038 model = DeploymentPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08002039 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002040
Scott Bakerc1d11912014-12-22 09:29:05 -08002041class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002042 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002043
Scott Baker196ffef2014-11-21 11:32:24 -08002044 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002045 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002046 def getHumanReadableName(self, obj):
2047 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002048 def getValidators(self, obj):
2049 try:
2050 return obj.getValidators()
2051 except:
2052 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002053 class Meta:
2054 model = DeploymentPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08002055 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker645dc9d2014-11-17 22:32:19 -08002056
2057
2058
2059
Scott Bakerc1d11912014-12-22 09:29:05 -08002060class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002061 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002062
Scott Baker196ffef2014-11-21 11:32:24 -08002063 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002064 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002065 def getHumanReadableName(self, obj):
2066 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002067 def getValidators(self, obj):
2068 try:
2069 return obj.getValidators()
2070 except:
2071 return None
Scott Baker08898c12014-10-29 23:41:11 -07002072 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08002073 model = ControllerUsers
2074 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2075
2076class ControllerUsersIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002077 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08002078
2079 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2080 validators = serializers.SerializerMethodField("getValidators")
2081 def getHumanReadableName(self, obj):
2082 return str(obj)
2083 def getValidators(self, obj):
2084 try:
2085 return obj.getValidators()
2086 except:
2087 return None
2088 class Meta:
2089 model = ControllerUsers
2090 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
2091
2092
2093
2094
2095class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002096 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08002097
2098 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2099 validators = serializers.SerializerMethodField("getValidators")
2100 def getHumanReadableName(self, obj):
2101 return str(obj)
2102 def getValidators(self, obj):
2103 try:
2104 return obj.getValidators()
2105 except:
2106 return None
2107 class Meta:
2108 model = DeploymentRole
Scott Baker351148c2014-11-25 00:53:25 -08002109 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002110
Scott Bakerc1d11912014-12-22 09:29:05 -08002111class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002112 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002113
Scott Baker196ffef2014-11-21 11:32:24 -08002114 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002115 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002116 def getHumanReadableName(self, obj):
2117 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002118 def getValidators(self, obj):
2119 try:
2120 return obj.getValidators()
2121 except:
2122 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002123 class Meta:
2124 model = DeploymentRole
Scott Baker351148c2014-11-25 00:53:25 -08002125 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002126
2127
Sapan Bhatiadea39432014-06-13 03:10:36 -04002128
2129
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002130class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002131 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002132
Scott Baker196ffef2014-11-21 11:32:24 -08002133 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002134 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002135 def getHumanReadableName(self, obj):
2136 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002137 def getValidators(self, obj):
2138 try:
2139 return obj.getValidators()
2140 except:
2141 return None
Scott Baker08898c12014-10-29 23:41:11 -07002142 class Meta:
2143 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08002144 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002145
Scott Bakerc1d11912014-12-22 09:29:05 -08002146class UserCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002147 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002148
Scott Baker196ffef2014-11-21 11:32:24 -08002149 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002150 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002151 def getHumanReadableName(self, obj):
2152 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002153 def getValidators(self, obj):
2154 try:
2155 return obj.getValidators()
2156 except:
2157 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002158 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002159 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08002160 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker196ffef2014-11-21 11:32:24 -08002161
2162
2163
2164
2165class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002166 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08002167
2168 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002169 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002170 def getHumanReadableName(self, obj):
2171 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002172 def getValidators(self, obj):
2173 try:
2174 return obj.getValidators()
2175 except:
2176 return None
Scott Baker196ffef2014-11-21 11:32:24 -08002177 class Meta:
2178 model = SiteDeployments
Scott Bakerc1d11912014-12-22 09:29:05 -08002179 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker196ffef2014-11-21 11:32:24 -08002180
Scott Bakerc1d11912014-12-22 09:29:05 -08002181class SiteDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002182 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08002183
2184 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002185 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002186 def getHumanReadableName(self, obj):
2187 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002188 def getValidators(self, obj):
2189 try:
2190 return obj.getValidators()
2191 except:
2192 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002193 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -08002194 model = SiteDeployments
Scott Bakerc1d11912014-12-22 09:29:05 -08002195 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
2196
2197
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002198
2199
Scott Baker0caeaf02014-06-19 11:12:55 -07002200class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002201 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002202
Scott Baker196ffef2014-11-21 11:32:24 -08002203 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002204 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002205 def getHumanReadableName(self, obj):
2206 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002207 def getValidators(self, obj):
2208 try:
2209 return obj.getValidators()
2210 except:
2211 return None
Scott Baker08898c12014-10-29 23:41:11 -07002212 class Meta:
2213 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08002214 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002215
Scott Bakerc1d11912014-12-22 09:29:05 -08002216class SliceTagIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002217 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002218
Scott Baker196ffef2014-11-21 11:32:24 -08002219 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002220 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002221 def getHumanReadableName(self, obj):
2222 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002223 def getValidators(self, obj):
2224 try:
2225 return obj.getValidators()
2226 except:
2227 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002228 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002229 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08002230 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002231
2232
Scott Baker0caeaf02014-06-19 11:12:55 -07002233
2234
Scott Bakera6a0c772014-12-22 17:35:34 -08002235class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002236 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002237
Scott Baker196ffef2014-11-21 11:32:24 -08002238 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002239 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002240 def getHumanReadableName(self, obj):
2241 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002242 def getValidators(self, obj):
2243 try:
2244 return obj.getValidators()
2245 except:
2246 return None
Scott Baker08898c12014-10-29 23:41:11 -07002247 class Meta:
Scott Bakera6a0c772014-12-22 17:35:34 -08002248 model = NetworkTemplate
Scott Baker6c958402015-01-03 12:05:21 -08002249 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 -07002250
Scott Bakera6a0c772014-12-22 17:35:34 -08002251class NetworkTemplateIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002252 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002253
Scott Baker196ffef2014-11-21 11:32:24 -08002254 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002255 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002256 def getHumanReadableName(self, obj):
2257 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002258 def getValidators(self, obj):
2259 try:
2260 return obj.getValidators()
2261 except:
2262 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002263 class Meta:
Scott Bakera6a0c772014-12-22 17:35:34 -08002264 model = NetworkTemplate
Scott Baker6c958402015-01-03 12:05:21 -08002265 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 -07002266
2267
Sapan Bhatiadea39432014-06-13 03:10:36 -04002268
2269
2270class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002271 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002272
Scott Bakerc1d11912014-12-22 09:29:05 -08002273
2274 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2275
2276
2277
2278 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2279
2280
Scott Baker196ffef2014-11-21 11:32:24 -08002281 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002282 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002283 def getHumanReadableName(self, obj):
2284 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002285 def getValidators(self, obj):
2286 try:
2287 return obj.getValidators()
2288 except:
2289 return None
Scott Baker08898c12014-10-29 23:41:11 -07002290 class Meta:
2291 model = Router
Scott Bakerc1d11912014-12-22 09:29:05 -08002292 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002293
Scott Bakerc1d11912014-12-22 09:29:05 -08002294class RouterIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002295 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002296
Scott Bakerc1d11912014-12-22 09:29:05 -08002297
Scott Bakera3134fe2014-12-23 10:56:06 -08002298 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08002299
2300
2301
Scott Bakera3134fe2014-12-23 10:56:06 -08002302 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08002303
2304
Scott Baker196ffef2014-11-21 11:32:24 -08002305 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002306 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002307 def getHumanReadableName(self, obj):
2308 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002309 def getValidators(self, obj):
2310 try:
2311 return obj.getValidators()
2312 except:
2313 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002314 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002315 model = Router
Scott Bakerc1d11912014-12-22 09:29:05 -08002316 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002317
2318
Sapan Bhatiadea39432014-06-13 03:10:36 -04002319
2320
Scott Baker0caeaf02014-06-19 11:12:55 -07002321class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002322 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002323
Scott Baker196ffef2014-11-21 11:32:24 -08002324 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002325 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002326 def getHumanReadableName(self, obj):
2327 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002328 def getValidators(self, obj):
2329 try:
2330 return obj.getValidators()
2331 except:
2332 return None
Scott Baker08898c12014-10-29 23:41:11 -07002333 class Meta:
2334 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002335 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 -07002336
Scott Bakerc1d11912014-12-22 09:29:05 -08002337class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002338 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002339
Scott Baker196ffef2014-11-21 11:32:24 -08002340 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002341 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002342 def getHumanReadableName(self, obj):
2343 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002344 def getValidators(self, obj):
2345 try:
2346 return obj.getValidators()
2347 except:
2348 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002349 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002350 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002351 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 -07002352
2353
Sapan Bhatiadea39432014-06-13 03:10:36 -04002354
2355
Scott Bakerc1d11912014-12-22 09:29:05 -08002356class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002357 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08002358
2359 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2360 validators = serializers.SerializerMethodField("getValidators")
2361 def getHumanReadableName(self, obj):
2362 return str(obj)
2363 def getValidators(self, obj):
2364 try:
2365 return obj.getValidators()
2366 except:
2367 return None
2368 class Meta:
2369 model = ControllerSlices
2370 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2371
2372class ControllerSlicesIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002373 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08002374
2375 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2376 validators = serializers.SerializerMethodField("getValidators")
2377 def getHumanReadableName(self, obj):
2378 return str(obj)
2379 def getValidators(self, obj):
2380 try:
2381 return obj.getValidators()
2382 except:
2383 return None
2384 class Meta:
2385 model = ControllerSlices
2386 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
2387
2388
2389
2390
Sapan Bhatiadea39432014-06-13 03:10:36 -04002391serializerLookUp = {
2392
Scott Bakerc1d11912014-12-22 09:29:05 -08002393 Flavor: FlavorSerializer,
2394
Scott Baker0caeaf02014-06-19 11:12:55 -07002395 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002396
Scott Bakerc1d11912014-12-22 09:29:05 -08002397 ControllerImages: ControllerImagesSerializer,
2398
Sapan Bhatiadea39432014-06-13 03:10:36 -04002399 Image: ImageSerializer,
2400
Scott Baker0caeaf02014-06-19 11:12:55 -07002401 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002402
2403 Site: SiteSerializer,
2404
Scott Baker0caeaf02014-06-19 11:12:55 -07002405 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002406
2407 Tag: TagSerializer,
2408
2409 Invoice: InvoiceSerializer,
2410
Scott Baker0caeaf02014-06-19 11:12:55 -07002411 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002412
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002413 PlanetStackRole: PlanetStackRoleSerializer,
2414
Scott Bakerc1d11912014-12-22 09:29:05 -08002415 ControllerPrivilege: ControllerPrivilegeSerializer,
2416
Scott Baker0caeaf02014-06-19 11:12:55 -07002417 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002418
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002419 Project: ProjectSerializer,
2420
Sapan Bhatiadea39432014-06-13 03:10:36 -04002421 Slice: SliceSerializer,
2422
2423 Network: NetworkSerializer,
2424
2425 Service: ServiceSerializer,
2426
Scott Baker0caeaf02014-06-19 11:12:55 -07002427 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002428
Scott Bakerc1d11912014-12-22 09:29:05 -08002429 ControllerNetworks: ControllerNetworksSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002430
2431 Charge: ChargeSerializer,
2432
2433 Role: RoleSerializer,
2434
Scott Baker0caeaf02014-06-19 11:12:55 -07002435 UsableObject: UsableObjectSerializer,
2436
Scott Bakerc1d11912014-12-22 09:29:05 -08002437 ControllerSiteDeployments: ControllerSiteDeploymentsSerializer,
2438
Scott Baker0caeaf02014-06-19 11:12:55 -07002439 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002440
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002441 SliceCredential: SliceCredentialSerializer,
2442
Sapan Bhatiadea39432014-06-13 03:10:36 -04002443 Sliver: SliverSerializer,
2444
2445 Node: NodeSerializer,
2446
Scott Baker0caeaf02014-06-19 11:12:55 -07002447 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002448
Scott Bakerc1d11912014-12-22 09:29:05 -08002449 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002450
Scott Baker196ffef2014-11-21 11:32:24 -08002451 ReservedResource: ReservedResourceSerializer,
Scott Baker645dc9d2014-11-17 22:32:19 -08002452
Scott Bakerc1d11912014-12-22 09:29:05 -08002453 Payment: PaymentSerializer,
2454
Scott Baker0caeaf02014-06-19 11:12:55 -07002455 NetworkSlice: NetworkSliceSerializer,
2456
2457 UserDashboardView: UserDashboardViewSerializer,
2458
Scott Bakerc1d11912014-12-22 09:29:05 -08002459 Controller: ControllerSerializer,
2460
Scott Baker0caeaf02014-06-19 11:12:55 -07002461 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002462
2463 User: UserSerializer,
2464
2465 Deployment: DeploymentSerializer,
2466
2467 Reservation: ReservationSerializer,
2468
Scott Baker0caeaf02014-06-19 11:12:55 -07002469 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002470
Scott Baker196ffef2014-11-21 11:32:24 -08002471 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002472
Scott Bakera6a0c772014-12-22 17:35:34 -08002473 ControllerDashboardView: ControllerDashboardViewSerializer,
2474
Sapan Bhatiadea39432014-06-13 03:10:36 -04002475 Account: AccountSerializer,
2476
Scott Bakerc1d11912014-12-22 09:29:05 -08002477 ControllerRole: ControllerRoleSerializer,
2478
Scott Baker0caeaf02014-06-19 11:12:55 -07002479 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002480
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002481 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002482
Scott Bakerc1d11912014-12-22 09:29:05 -08002483 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002484
Scott Bakerc1d11912014-12-22 09:29:05 -08002485 ControllerUsers: ControllerUsersSerializer,
2486
2487 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002488
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002489 UserCredential: UserCredentialSerializer,
2490
Scott Baker196ffef2014-11-21 11:32:24 -08002491 SiteDeployments: SiteDeploymentsSerializer,
2492
Scott Baker0caeaf02014-06-19 11:12:55 -07002493 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002494
Scott Bakera6a0c772014-12-22 17:35:34 -08002495 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002496
2497 Router: RouterSerializer,
2498
Scott Baker0caeaf02014-06-19 11:12:55 -07002499 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002500
Scott Bakerc1d11912014-12-22 09:29:05 -08002501 ControllerSlices: ControllerSlicesSerializer,
2502
Sapan Bhatiadea39432014-06-13 03:10:36 -04002503 None: None,
2504 }
2505
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002506class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2507
2508 # To handle fine-grained field permissions, we have to check can_update
2509 # the object has been updated but before it has been saved.
2510
2511 def update(self, request, *args, **kwargs):
2512 partial = kwargs.pop('partial', False)
2513 self.object = self.get_object_or_none()
2514
2515 serializer = self.get_serializer(self.object, data=request.DATA,
2516 files=request.FILES, partial=partial)
2517
2518 if not serializer.is_valid():
Scott Baker351148c2014-11-25 00:53:25 -08002519 response = {"error": "validation",
2520 "specific_error": "not serializer.is_valid()",
2521 "reasons": serializer.errors}
2522 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002523
2524 try:
2525 self.pre_save(serializer.object)
2526 except ValidationError as err:
2527 # full_clean on model instance may be called in pre_save,
2528 # so we have to handle eventual errors.
Scott Baker351148c2014-11-25 00:53:25 -08002529 response = {"error": "validation",
2530 "specific_error": "ValidationError in pre_save",
2531 "reasons": err.message_dict}
2532 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002533
2534 if serializer.object is not None:
2535 if not serializer.object.can_update(request.user):
2536 return Response(status=status.HTTP_400_BAD_REQUEST)
2537
2538 if self.object is None:
2539 self.object = serializer.save(force_insert=True)
2540 self.post_save(self.object, created=True)
2541 return Response(serializer.data, status=status.HTTP_201_CREATED)
2542
2543 self.object = serializer.save(force_update=True)
2544 self.post_save(self.object, created=False)
2545 return Response(serializer.data, status=status.HTTP_200_OK)
2546
2547 def destroy(self, request, *args, **kwargs):
2548 obj = self.get_object()
2549 if obj.can_update(request.user):
Scott Baker08898c12014-10-29 23:41:11 -07002550 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002551 else:
2552 return Response(status=status.HTTP_400_BAD_REQUEST)
2553
2554
Sapan Bhatiadea39432014-06-13 03:10:36 -04002555# Based on core/views/*.py
2556
2557
Scott Bakerc1d11912014-12-22 09:29:05 -08002558class FlavorList(generics.ListCreateAPIView):
2559 queryset = Flavor.objects.select_related().all()
2560 serializer_class = FlavorSerializer
2561 id_serializer_class = FlavorIdSerializer
2562 filter_backends = (filters.DjangoFilterBackend,)
2563 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',)
2564
2565 def get_serializer_class(self):
2566 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2567 if (no_hyperlinks):
2568 return self.id_serializer_class
2569 else:
2570 return self.serializer_class
2571
2572 def get_queryset(self):
2573 return Flavor.select_by_user(self.request.user)
2574
2575 def create(self, request, *args, **kwargs):
2576 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2577 if not (serializer.is_valid()):
2578 response = {"error": "validation",
2579 "specific_error": "not serializer.is_valid()",
2580 "reasons": serializer.errors}
2581 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2582 obj = serializer.object
2583 obj.caller = request.user
2584 if obj.can_update(request.user):
2585 return super(FlavorList, self).create(request, *args, **kwargs)
2586 else:
2587 raise Exception("failed obj.can_update")
2588
2589 ret = super(FlavorList, self).create(request, *args, **kwargs)
2590 if (ret.status_code%100 != 200):
2591 raise Exception(ret.data)
2592
2593 return ret
2594
2595
2596class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2597 queryset = Flavor.objects.select_related().all()
2598 serializer_class = FlavorSerializer
2599 id_serializer_class = FlavorIdSerializer
2600
2601 def get_serializer_class(self):
2602 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2603 if (no_hyperlinks):
2604 return self.id_serializer_class
2605 else:
2606 return self.serializer_class
2607
2608 def get_queryset(self):
2609 return Flavor.select_by_user(self.request.user)
2610
2611 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2612
2613 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2614
2615
2616
Scott Baker0caeaf02014-06-19 11:12:55 -07002617class ServiceAttributeList(generics.ListCreateAPIView):
2618 queryset = ServiceAttribute.objects.select_related().all()
2619 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002620 id_serializer_class = ServiceAttributeIdSerializer
2621 filter_backends = (filters.DjangoFilterBackend,)
2622 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2623
2624 def get_serializer_class(self):
2625 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2626 if (no_hyperlinks):
2627 return self.id_serializer_class
2628 else:
2629 return self.serializer_class
2630
Scott Baker0caeaf02014-06-19 11:12:55 -07002631 def get_queryset(self):
2632 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002633
Scott Baker0caeaf02014-06-19 11:12:55 -07002634 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002635 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2636 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002637 response = {"error": "validation",
2638 "specific_error": "not serializer.is_valid()",
2639 "reasons": serializer.errors}
2640 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002641 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002642 obj.caller = request.user
2643 if obj.can_update(request.user):
2644 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2645 else:
Scott Baker08898c12014-10-29 23:41:11 -07002646 raise Exception("failed obj.can_update")
2647
2648 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2649 if (ret.status_code%100 != 200):
2650 raise Exception(ret.data)
2651
2652 return ret
2653
Scott Baker0caeaf02014-06-19 11:12:55 -07002654
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002655class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002656 queryset = ServiceAttribute.objects.select_related().all()
2657 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002658 id_serializer_class = ServiceAttributeIdSerializer
2659
2660 def get_serializer_class(self):
2661 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2662 if (no_hyperlinks):
2663 return self.id_serializer_class
2664 else:
2665 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002666
2667 def get_queryset(self):
2668 return ServiceAttribute.select_by_user(self.request.user)
2669
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002670 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002671
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002672 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002673
2674
2675
Scott Bakerc1d11912014-12-22 09:29:05 -08002676class ControllerImagesList(generics.ListCreateAPIView):
2677 queryset = ControllerImages.objects.select_related().all()
2678 serializer_class = ControllerImagesSerializer
2679 id_serializer_class = ControllerImagesIdSerializer
2680 filter_backends = (filters.DjangoFilterBackend,)
2681 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',)
2682
2683 def get_serializer_class(self):
2684 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2685 if (no_hyperlinks):
2686 return self.id_serializer_class
2687 else:
2688 return self.serializer_class
2689
2690 def get_queryset(self):
2691 return ControllerImages.select_by_user(self.request.user)
2692
2693 def create(self, request, *args, **kwargs):
2694 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2695 if not (serializer.is_valid()):
2696 response = {"error": "validation",
2697 "specific_error": "not serializer.is_valid()",
2698 "reasons": serializer.errors}
2699 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2700 obj = serializer.object
2701 obj.caller = request.user
2702 if obj.can_update(request.user):
2703 return super(ControllerImagesList, self).create(request, *args, **kwargs)
2704 else:
2705 raise Exception("failed obj.can_update")
2706
2707 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2708 if (ret.status_code%100 != 200):
2709 raise Exception(ret.data)
2710
2711 return ret
2712
2713
2714class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2715 queryset = ControllerImages.objects.select_related().all()
2716 serializer_class = ControllerImagesSerializer
2717 id_serializer_class = ControllerImagesIdSerializer
2718
2719 def get_serializer_class(self):
2720 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2721 if (no_hyperlinks):
2722 return self.id_serializer_class
2723 else:
2724 return self.serializer_class
2725
2726 def get_queryset(self):
2727 return ControllerImages.select_by_user(self.request.user)
2728
2729 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2730
2731 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2732
2733
2734
Sapan Bhatiadea39432014-06-13 03:10:36 -04002735class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002736 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002737 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002738 id_serializer_class = ImageIdSerializer
2739 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker93a79a92014-12-22 15:59:33 -08002740 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002741
2742 def get_serializer_class(self):
2743 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2744 if (no_hyperlinks):
2745 return self.id_serializer_class
2746 else:
2747 return self.serializer_class
2748
Scott Baker0caeaf02014-06-19 11:12:55 -07002749 def get_queryset(self):
2750 return Image.select_by_user(self.request.user)
2751
2752 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002753 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2754 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002755 response = {"error": "validation",
2756 "specific_error": "not serializer.is_valid()",
2757 "reasons": serializer.errors}
2758 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002759 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002760 obj.caller = request.user
2761 if obj.can_update(request.user):
2762 return super(ImageList, self).create(request, *args, **kwargs)
2763 else:
Scott Baker08898c12014-10-29 23:41:11 -07002764 raise Exception("failed obj.can_update")
2765
2766 ret = super(ImageList, self).create(request, *args, **kwargs)
2767 if (ret.status_code%100 != 200):
2768 raise Exception(ret.data)
2769
2770 return ret
2771
Sapan Bhatiadea39432014-06-13 03:10:36 -04002772
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002773class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002774 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002775 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002776 id_serializer_class = ImageIdSerializer
2777
2778 def get_serializer_class(self):
2779 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2780 if (no_hyperlinks):
2781 return self.id_serializer_class
2782 else:
2783 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002784
2785 def get_queryset(self):
2786 return Image.select_by_user(self.request.user)
2787
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002788 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002789
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002790 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002791
2792
2793
Scott Baker0caeaf02014-06-19 11:12:55 -07002794class NetworkParameterList(generics.ListCreateAPIView):
2795 queryset = NetworkParameter.objects.select_related().all()
2796 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002797 id_serializer_class = NetworkParameterIdSerializer
2798 filter_backends = (filters.DjangoFilterBackend,)
2799 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2800
2801 def get_serializer_class(self):
2802 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2803 if (no_hyperlinks):
2804 return self.id_serializer_class
2805 else:
2806 return self.serializer_class
2807
Scott Baker0caeaf02014-06-19 11:12:55 -07002808 def get_queryset(self):
2809 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002810
Scott Baker0caeaf02014-06-19 11:12:55 -07002811 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002812 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2813 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002814 response = {"error": "validation",
2815 "specific_error": "not serializer.is_valid()",
2816 "reasons": serializer.errors}
2817 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002818 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002819 obj.caller = request.user
2820 if obj.can_update(request.user):
2821 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2822 else:
Scott Baker08898c12014-10-29 23:41:11 -07002823 raise Exception("failed obj.can_update")
2824
2825 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2826 if (ret.status_code%100 != 200):
2827 raise Exception(ret.data)
2828
2829 return ret
2830
Scott Baker0caeaf02014-06-19 11:12:55 -07002831
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002832class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002833 queryset = NetworkParameter.objects.select_related().all()
2834 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002835 id_serializer_class = NetworkParameterIdSerializer
2836
2837 def get_serializer_class(self):
2838 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2839 if (no_hyperlinks):
2840 return self.id_serializer_class
2841 else:
2842 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002843
2844 def get_queryset(self):
2845 return NetworkParameter.select_by_user(self.request.user)
2846
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002847 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002848
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002849 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002850
2851
2852
2853class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002854 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002855 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002856 id_serializer_class = SiteIdSerializer
2857 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08002858 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 -07002859
2860 def get_serializer_class(self):
2861 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2862 if (no_hyperlinks):
2863 return self.id_serializer_class
2864 else:
2865 return self.serializer_class
2866
Scott Baker0caeaf02014-06-19 11:12:55 -07002867 def get_queryset(self):
2868 return Site.select_by_user(self.request.user)
2869
2870 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002871 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2872 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002873 response = {"error": "validation",
2874 "specific_error": "not serializer.is_valid()",
2875 "reasons": serializer.errors}
2876 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002877 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002878 obj.caller = request.user
2879 if obj.can_update(request.user):
2880 return super(SiteList, self).create(request, *args, **kwargs)
2881 else:
Scott Baker08898c12014-10-29 23:41:11 -07002882 raise Exception("failed obj.can_update")
2883
2884 ret = super(SiteList, self).create(request, *args, **kwargs)
2885 if (ret.status_code%100 != 200):
2886 raise Exception(ret.data)
2887
2888 return ret
2889
Sapan Bhatiadea39432014-06-13 03:10:36 -04002890
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002891class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002892 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002893 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002894 id_serializer_class = SiteIdSerializer
2895
2896 def get_serializer_class(self):
2897 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2898 if (no_hyperlinks):
2899 return self.id_serializer_class
2900 else:
2901 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002902
2903 def get_queryset(self):
2904 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002905
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002906 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002907
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002908 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002909
2910
2911
2912class SliceRoleList(generics.ListCreateAPIView):
2913 queryset = SliceRole.objects.select_related().all()
2914 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002915 id_serializer_class = SliceRoleIdSerializer
2916 filter_backends = (filters.DjangoFilterBackend,)
2917 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2918
2919 def get_serializer_class(self):
2920 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2921 if (no_hyperlinks):
2922 return self.id_serializer_class
2923 else:
2924 return self.serializer_class
2925
Scott Baker0caeaf02014-06-19 11:12:55 -07002926 def get_queryset(self):
2927 return SliceRole.select_by_user(self.request.user)
2928
2929 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002930 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2931 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002932 response = {"error": "validation",
2933 "specific_error": "not serializer.is_valid()",
2934 "reasons": serializer.errors}
2935 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002936 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002937 obj.caller = request.user
2938 if obj.can_update(request.user):
2939 return super(SliceRoleList, self).create(request, *args, **kwargs)
2940 else:
Scott Baker08898c12014-10-29 23:41:11 -07002941 raise Exception("failed obj.can_update")
2942
2943 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2944 if (ret.status_code%100 != 200):
2945 raise Exception(ret.data)
2946
2947 return ret
2948
Scott Baker0caeaf02014-06-19 11:12:55 -07002949
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002950class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002951 queryset = SliceRole.objects.select_related().all()
2952 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002953 id_serializer_class = SliceRoleIdSerializer
2954
2955 def get_serializer_class(self):
2956 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2957 if (no_hyperlinks):
2958 return self.id_serializer_class
2959 else:
2960 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002961
2962 def get_queryset(self):
2963 return SliceRole.select_by_user(self.request.user)
2964
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002965 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002966
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002967 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002968
2969
2970
2971class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002972 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002973 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002974 id_serializer_class = TagIdSerializer
2975 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002976 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002977
2978 def get_serializer_class(self):
2979 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2980 if (no_hyperlinks):
2981 return self.id_serializer_class
2982 else:
2983 return self.serializer_class
2984
Scott Baker0caeaf02014-06-19 11:12:55 -07002985 def get_queryset(self):
2986 return Tag.select_by_user(self.request.user)
2987
2988 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002989 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2990 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002991 response = {"error": "validation",
2992 "specific_error": "not serializer.is_valid()",
2993 "reasons": serializer.errors}
2994 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002995 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002996 obj.caller = request.user
2997 if obj.can_update(request.user):
2998 return super(TagList, self).create(request, *args, **kwargs)
2999 else:
Scott Baker08898c12014-10-29 23:41:11 -07003000 raise Exception("failed obj.can_update")
3001
3002 ret = super(TagList, self).create(request, *args, **kwargs)
3003 if (ret.status_code%100 != 200):
3004 raise Exception(ret.data)
3005
3006 return ret
3007
Sapan Bhatiadea39432014-06-13 03:10:36 -04003008
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003009class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003010 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003011 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003012 id_serializer_class = TagIdSerializer
3013
3014 def get_serializer_class(self):
3015 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3016 if (no_hyperlinks):
3017 return self.id_serializer_class
3018 else:
3019 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003020
3021 def get_queryset(self):
3022 return Tag.select_by_user(self.request.user)
3023
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003024 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003025
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003026 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003027
3028
3029
3030class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003031 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003032 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003033 id_serializer_class = InvoiceIdSerializer
3034 filter_backends = (filters.DjangoFilterBackend,)
3035 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
3036
3037 def get_serializer_class(self):
3038 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3039 if (no_hyperlinks):
3040 return self.id_serializer_class
3041 else:
3042 return self.serializer_class
3043
Scott Baker0caeaf02014-06-19 11:12:55 -07003044 def get_queryset(self):
3045 return Invoice.select_by_user(self.request.user)
3046
3047 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003048 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3049 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003050 response = {"error": "validation",
3051 "specific_error": "not serializer.is_valid()",
3052 "reasons": serializer.errors}
3053 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003054 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003055 obj.caller = request.user
3056 if obj.can_update(request.user):
3057 return super(InvoiceList, self).create(request, *args, **kwargs)
3058 else:
Scott Baker08898c12014-10-29 23:41:11 -07003059 raise Exception("failed obj.can_update")
3060
3061 ret = super(InvoiceList, self).create(request, *args, **kwargs)
3062 if (ret.status_code%100 != 200):
3063 raise Exception(ret.data)
3064
3065 return ret
3066
Sapan Bhatiadea39432014-06-13 03:10:36 -04003067
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003068class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003069 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003070 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003071 id_serializer_class = InvoiceIdSerializer
3072
3073 def get_serializer_class(self):
3074 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3075 if (no_hyperlinks):
3076 return self.id_serializer_class
3077 else:
3078 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003079
3080 def get_queryset(self):
3081 return Invoice.select_by_user(self.request.user)
3082
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003083 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003084
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003085 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003086
3087
3088
Scott Baker0caeaf02014-06-19 11:12:55 -07003089class SlicePrivilegeList(generics.ListCreateAPIView):
3090 queryset = SlicePrivilege.objects.select_related().all()
3091 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003092 id_serializer_class = SlicePrivilegeIdSerializer
3093 filter_backends = (filters.DjangoFilterBackend,)
3094 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
3095
3096 def get_serializer_class(self):
3097 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3098 if (no_hyperlinks):
3099 return self.id_serializer_class
3100 else:
3101 return self.serializer_class
3102
Scott Baker0caeaf02014-06-19 11:12:55 -07003103 def get_queryset(self):
3104 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003105
Scott Baker0caeaf02014-06-19 11:12:55 -07003106 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003107 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3108 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003109 response = {"error": "validation",
3110 "specific_error": "not serializer.is_valid()",
3111 "reasons": serializer.errors}
3112 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003113 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003114 obj.caller = request.user
3115 if obj.can_update(request.user):
3116 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3117 else:
Scott Baker08898c12014-10-29 23:41:11 -07003118 raise Exception("failed obj.can_update")
3119
3120 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3121 if (ret.status_code%100 != 200):
3122 raise Exception(ret.data)
3123
3124 return ret
3125
Scott Baker0caeaf02014-06-19 11:12:55 -07003126
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003127class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003128 queryset = SlicePrivilege.objects.select_related().all()
3129 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003130 id_serializer_class = SlicePrivilegeIdSerializer
3131
3132 def get_serializer_class(self):
3133 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3134 if (no_hyperlinks):
3135 return self.id_serializer_class
3136 else:
3137 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003138
3139 def get_queryset(self):
3140 return SlicePrivilege.select_by_user(self.request.user)
3141
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003142 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3143
3144 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3145
3146
3147
3148class PlanetStackRoleList(generics.ListCreateAPIView):
3149 queryset = PlanetStackRole.objects.select_related().all()
3150 serializer_class = PlanetStackRoleSerializer
3151 id_serializer_class = PlanetStackRoleIdSerializer
3152 filter_backends = (filters.DjangoFilterBackend,)
3153 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3154
3155 def get_serializer_class(self):
3156 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3157 if (no_hyperlinks):
3158 return self.id_serializer_class
3159 else:
3160 return self.serializer_class
3161
3162 def get_queryset(self):
3163 return PlanetStackRole.select_by_user(self.request.user)
3164
3165 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003166 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3167 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003168 response = {"error": "validation",
3169 "specific_error": "not serializer.is_valid()",
3170 "reasons": serializer.errors}
3171 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003172 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003173 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003174 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003175 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003176 else:
Scott Baker08898c12014-10-29 23:41:11 -07003177 raise Exception("failed obj.can_update")
3178
3179 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3180 if (ret.status_code%100 != 200):
3181 raise Exception(ret.data)
3182
3183 return ret
3184
Scott Baker0caeaf02014-06-19 11:12:55 -07003185
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003186class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3187 queryset = PlanetStackRole.objects.select_related().all()
3188 serializer_class = PlanetStackRoleSerializer
3189 id_serializer_class = PlanetStackRoleIdSerializer
3190
3191 def get_serializer_class(self):
3192 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3193 if (no_hyperlinks):
3194 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003195 else:
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003196 return self.serializer_class
3197
3198 def get_queryset(self):
3199 return PlanetStackRole.select_by_user(self.request.user)
3200
3201 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3202
3203 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003204
3205
3206
Scott Bakerc1d11912014-12-22 09:29:05 -08003207class ControllerPrivilegeList(generics.ListCreateAPIView):
3208 queryset = ControllerPrivilege.objects.select_related().all()
3209 serializer_class = ControllerPrivilegeSerializer
3210 id_serializer_class = ControllerPrivilegeIdSerializer
3211 filter_backends = (filters.DjangoFilterBackend,)
3212 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','role',)
3213
3214 def get_serializer_class(self):
3215 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3216 if (no_hyperlinks):
3217 return self.id_serializer_class
3218 else:
3219 return self.serializer_class
3220
3221 def get_queryset(self):
3222 return ControllerPrivilege.select_by_user(self.request.user)
3223
3224 def create(self, request, *args, **kwargs):
3225 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3226 if not (serializer.is_valid()):
3227 response = {"error": "validation",
3228 "specific_error": "not serializer.is_valid()",
3229 "reasons": serializer.errors}
3230 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3231 obj = serializer.object
3232 obj.caller = request.user
3233 if obj.can_update(request.user):
3234 return super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
3235 else:
3236 raise Exception("failed obj.can_update")
3237
3238 ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
3239 if (ret.status_code%100 != 200):
3240 raise Exception(ret.data)
3241
3242 return ret
3243
3244
3245class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3246 queryset = ControllerPrivilege.objects.select_related().all()
3247 serializer_class = ControllerPrivilegeSerializer
3248 id_serializer_class = ControllerPrivilegeIdSerializer
3249
3250 def get_serializer_class(self):
3251 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3252 if (no_hyperlinks):
3253 return self.id_serializer_class
3254 else:
3255 return self.serializer_class
3256
3257 def get_queryset(self):
3258 return ControllerPrivilege.select_by_user(self.request.user)
3259
3260 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3261
3262 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3263
3264
3265
Scott Baker0caeaf02014-06-19 11:12:55 -07003266class NetworkSliverList(generics.ListCreateAPIView):
3267 queryset = NetworkSliver.objects.select_related().all()
3268 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003269 id_serializer_class = NetworkSliverIdSerializer
3270 filter_backends = (filters.DjangoFilterBackend,)
3271 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
3272
3273 def get_serializer_class(self):
3274 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3275 if (no_hyperlinks):
3276 return self.id_serializer_class
3277 else:
3278 return self.serializer_class
3279
Scott Baker0caeaf02014-06-19 11:12:55 -07003280 def get_queryset(self):
3281 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003282
Scott Baker0caeaf02014-06-19 11:12:55 -07003283 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003284 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3285 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003286 response = {"error": "validation",
3287 "specific_error": "not serializer.is_valid()",
3288 "reasons": serializer.errors}
3289 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003290 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003291 obj.caller = request.user
3292 if obj.can_update(request.user):
3293 return super(NetworkSliverList, self).create(request, *args, **kwargs)
3294 else:
Scott Baker08898c12014-10-29 23:41:11 -07003295 raise Exception("failed obj.can_update")
3296
3297 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3298 if (ret.status_code%100 != 200):
3299 raise Exception(ret.data)
3300
3301 return ret
3302
Scott Baker0caeaf02014-06-19 11:12:55 -07003303
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003304class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003305 queryset = NetworkSliver.objects.select_related().all()
3306 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003307 id_serializer_class = NetworkSliverIdSerializer
3308
3309 def get_serializer_class(self):
3310 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3311 if (no_hyperlinks):
3312 return self.id_serializer_class
3313 else:
3314 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003315
3316 def get_queryset(self):
3317 return NetworkSliver.select_by_user(self.request.user)
3318
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003319 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003320
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003321 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003322
3323
3324
Scott Baker0caeaf02014-06-19 11:12:55 -07003325class ProjectList(generics.ListCreateAPIView):
3326 queryset = Project.objects.select_related().all()
3327 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003328 id_serializer_class = ProjectIdSerializer
3329 filter_backends = (filters.DjangoFilterBackend,)
3330 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3331
3332 def get_serializer_class(self):
3333 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3334 if (no_hyperlinks):
3335 return self.id_serializer_class
3336 else:
3337 return self.serializer_class
3338
Scott Baker0caeaf02014-06-19 11:12:55 -07003339 def get_queryset(self):
3340 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003341
Scott Baker0caeaf02014-06-19 11:12:55 -07003342 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003343 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3344 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003345 response = {"error": "validation",
3346 "specific_error": "not serializer.is_valid()",
3347 "reasons": serializer.errors}
3348 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003349 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003350 obj.caller = request.user
3351 if obj.can_update(request.user):
3352 return super(ProjectList, self).create(request, *args, **kwargs)
3353 else:
Scott Baker08898c12014-10-29 23:41:11 -07003354 raise Exception("failed obj.can_update")
3355
3356 ret = super(ProjectList, self).create(request, *args, **kwargs)
3357 if (ret.status_code%100 != 200):
3358 raise Exception(ret.data)
3359
3360 return ret
3361
Scott Baker0caeaf02014-06-19 11:12:55 -07003362
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003363class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003364 queryset = Project.objects.select_related().all()
3365 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003366 id_serializer_class = ProjectIdSerializer
3367
3368 def get_serializer_class(self):
3369 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3370 if (no_hyperlinks):
3371 return self.id_serializer_class
3372 else:
3373 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003374
3375 def get_queryset(self):
3376 return Project.select_by_user(self.request.user)
3377
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003378 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3379
3380 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3381
3382
3383
3384class SliceList(generics.ListCreateAPIView):
3385 queryset = Slice.objects.select_related().all()
3386 serializer_class = SliceSerializer
3387 id_serializer_class = SliceIdSerializer
3388 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08003389 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003390
3391 def get_serializer_class(self):
3392 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3393 if (no_hyperlinks):
3394 return self.id_serializer_class
3395 else:
3396 return self.serializer_class
3397
3398 def get_queryset(self):
3399 return Slice.select_by_user(self.request.user)
3400
3401 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003402 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3403 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003404 response = {"error": "validation",
3405 "specific_error": "not serializer.is_valid()",
3406 "reasons": serializer.errors}
3407 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003408 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003409 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003410 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003411 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003412 else:
Scott Baker08898c12014-10-29 23:41:11 -07003413 raise Exception("failed obj.can_update")
3414
3415 ret = super(SliceList, self).create(request, *args, **kwargs)
3416 if (ret.status_code%100 != 200):
3417 raise Exception(ret.data)
3418
3419 return ret
3420
Scott Baker0caeaf02014-06-19 11:12:55 -07003421
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003422class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3423 queryset = Slice.objects.select_related().all()
3424 serializer_class = SliceSerializer
3425 id_serializer_class = SliceIdSerializer
3426
3427 def get_serializer_class(self):
3428 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3429 if (no_hyperlinks):
3430 return self.id_serializer_class
3431 else:
3432 return self.serializer_class
3433
3434 def get_queryset(self):
3435 return Slice.select_by_user(self.request.user)
3436
3437 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3438
3439 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3440
3441
3442
3443class NetworkList(generics.ListCreateAPIView):
3444 queryset = Network.objects.select_related().all()
3445 serializer_class = NetworkSerializer
3446 id_serializer_class = NetworkIdSerializer
3447 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08003448 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003449
3450 def get_serializer_class(self):
3451 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3452 if (no_hyperlinks):
3453 return self.id_serializer_class
3454 else:
3455 return self.serializer_class
3456
3457 def get_queryset(self):
3458 return Network.select_by_user(self.request.user)
3459
3460 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003461 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3462 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003463 response = {"error": "validation",
3464 "specific_error": "not serializer.is_valid()",
3465 "reasons": serializer.errors}
3466 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003467 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003468 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003469 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003470 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003471 else:
Scott Baker08898c12014-10-29 23:41:11 -07003472 raise Exception("failed obj.can_update")
3473
3474 ret = super(NetworkList, self).create(request, *args, **kwargs)
3475 if (ret.status_code%100 != 200):
3476 raise Exception(ret.data)
3477
3478 return ret
3479
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003480
3481class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3482 queryset = Network.objects.select_related().all()
3483 serializer_class = NetworkSerializer
3484 id_serializer_class = NetworkIdSerializer
3485
3486 def get_serializer_class(self):
3487 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3488 if (no_hyperlinks):
3489 return self.id_serializer_class
3490 else:
3491 return self.serializer_class
3492
3493 def get_queryset(self):
3494 return Network.select_by_user(self.request.user)
3495
3496 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3497
3498 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3499
3500
3501
3502class ServiceList(generics.ListCreateAPIView):
3503 queryset = Service.objects.select_related().all()
3504 serializer_class = ServiceSerializer
3505 id_serializer_class = ServiceIdSerializer
3506 filter_backends = (filters.DjangoFilterBackend,)
3507 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3508
3509 def get_serializer_class(self):
3510 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3511 if (no_hyperlinks):
3512 return self.id_serializer_class
3513 else:
3514 return self.serializer_class
3515
3516 def get_queryset(self):
3517 return Service.select_by_user(self.request.user)
3518
3519 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003520 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3521 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003522 response = {"error": "validation",
3523 "specific_error": "not serializer.is_valid()",
3524 "reasons": serializer.errors}
3525 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003526 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003527 obj.caller = request.user
3528 if obj.can_update(request.user):
3529 return super(ServiceList, self).create(request, *args, **kwargs)
3530 else:
Scott Baker08898c12014-10-29 23:41:11 -07003531 raise Exception("failed obj.can_update")
3532
3533 ret = super(ServiceList, self).create(request, *args, **kwargs)
3534 if (ret.status_code%100 != 200):
3535 raise Exception(ret.data)
3536
3537 return ret
3538
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003539
3540class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3541 queryset = Service.objects.select_related().all()
3542 serializer_class = ServiceSerializer
3543 id_serializer_class = ServiceIdSerializer
3544
3545 def get_serializer_class(self):
3546 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3547 if (no_hyperlinks):
3548 return self.id_serializer_class
3549 else:
3550 return self.serializer_class
3551
3552 def get_queryset(self):
3553 return Service.select_by_user(self.request.user)
3554
3555 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3556
3557 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3558
3559
3560
3561class ServiceClassList(generics.ListCreateAPIView):
3562 queryset = ServiceClass.objects.select_related().all()
3563 serializer_class = ServiceClassSerializer
3564 id_serializer_class = ServiceClassIdSerializer
3565 filter_backends = (filters.DjangoFilterBackend,)
3566 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3567
3568 def get_serializer_class(self):
3569 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3570 if (no_hyperlinks):
3571 return self.id_serializer_class
3572 else:
3573 return self.serializer_class
3574
3575 def get_queryset(self):
3576 return ServiceClass.select_by_user(self.request.user)
3577
3578 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003579 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3580 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003581 response = {"error": "validation",
3582 "specific_error": "not serializer.is_valid()",
3583 "reasons": serializer.errors}
3584 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003585 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003586 obj.caller = request.user
3587 if obj.can_update(request.user):
3588 return super(ServiceClassList, self).create(request, *args, **kwargs)
3589 else:
Scott Baker08898c12014-10-29 23:41:11 -07003590 raise Exception("failed obj.can_update")
3591
3592 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3593 if (ret.status_code%100 != 200):
3594 raise Exception(ret.data)
3595
3596 return ret
3597
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003598
3599class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3600 queryset = ServiceClass.objects.select_related().all()
3601 serializer_class = ServiceClassSerializer
3602 id_serializer_class = ServiceClassIdSerializer
3603
3604 def get_serializer_class(self):
3605 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3606 if (no_hyperlinks):
3607 return self.id_serializer_class
3608 else:
3609 return self.serializer_class
3610
3611 def get_queryset(self):
3612 return ServiceClass.select_by_user(self.request.user)
3613
3614 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3615
3616 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3617
3618
3619
Scott Bakerc1d11912014-12-22 09:29:05 -08003620class ControllerNetworksList(generics.ListCreateAPIView):
3621 queryset = ControllerNetworks.objects.select_related().all()
3622 serializer_class = ControllerNetworksSerializer
3623 id_serializer_class = ControllerNetworksIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003624 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08003625 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003626
3627 def get_serializer_class(self):
3628 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3629 if (no_hyperlinks):
3630 return self.id_serializer_class
3631 else:
3632 return self.serializer_class
3633
3634 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08003635 return ControllerNetworks.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003636
3637 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003638 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3639 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003640 response = {"error": "validation",
3641 "specific_error": "not serializer.is_valid()",
3642 "reasons": serializer.errors}
3643 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003644 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003645 obj.caller = request.user
3646 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08003647 return super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003648 else:
Scott Baker08898c12014-10-29 23:41:11 -07003649 raise Exception("failed obj.can_update")
3650
Scott Bakerc1d11912014-12-22 09:29:05 -08003651 ret = super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003652 if (ret.status_code%100 != 200):
3653 raise Exception(ret.data)
3654
3655 return ret
3656
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003657
Scott Bakerc1d11912014-12-22 09:29:05 -08003658class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3659 queryset = ControllerNetworks.objects.select_related().all()
3660 serializer_class = ControllerNetworksSerializer
3661 id_serializer_class = ControllerNetworksIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003662
3663 def get_serializer_class(self):
3664 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3665 if (no_hyperlinks):
3666 return self.id_serializer_class
3667 else:
3668 return self.serializer_class
3669
3670 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08003671 return ControllerNetworks.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003672
3673 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3674
3675 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3676
3677
3678
3679class ChargeList(generics.ListCreateAPIView):
3680 queryset = Charge.objects.select_related().all()
3681 serializer_class = ChargeSerializer
3682 id_serializer_class = ChargeIdSerializer
3683 filter_backends = (filters.DjangoFilterBackend,)
3684 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3685
3686 def get_serializer_class(self):
3687 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3688 if (no_hyperlinks):
3689 return self.id_serializer_class
3690 else:
3691 return self.serializer_class
3692
3693 def get_queryset(self):
3694 return Charge.select_by_user(self.request.user)
3695
3696 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003697 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3698 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003699 response = {"error": "validation",
3700 "specific_error": "not serializer.is_valid()",
3701 "reasons": serializer.errors}
3702 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003703 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003704 obj.caller = request.user
3705 if obj.can_update(request.user):
3706 return super(ChargeList, self).create(request, *args, **kwargs)
3707 else:
Scott Baker08898c12014-10-29 23:41:11 -07003708 raise Exception("failed obj.can_update")
3709
3710 ret = super(ChargeList, self).create(request, *args, **kwargs)
3711 if (ret.status_code%100 != 200):
3712 raise Exception(ret.data)
3713
3714 return ret
3715
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003716
3717class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3718 queryset = Charge.objects.select_related().all()
3719 serializer_class = ChargeSerializer
3720 id_serializer_class = ChargeIdSerializer
3721
3722 def get_serializer_class(self):
3723 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3724 if (no_hyperlinks):
3725 return self.id_serializer_class
3726 else:
3727 return self.serializer_class
3728
3729 def get_queryset(self):
3730 return Charge.select_by_user(self.request.user)
3731
3732 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3733
3734 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3735
3736
3737
3738class RoleList(generics.ListCreateAPIView):
3739 queryset = Role.objects.select_related().all()
3740 serializer_class = RoleSerializer
3741 id_serializer_class = RoleIdSerializer
3742 filter_backends = (filters.DjangoFilterBackend,)
3743 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3744
3745 def get_serializer_class(self):
3746 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3747 if (no_hyperlinks):
3748 return self.id_serializer_class
3749 else:
3750 return self.serializer_class
3751
3752 def get_queryset(self):
3753 return Role.select_by_user(self.request.user)
3754
3755 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003756 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3757 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003758 response = {"error": "validation",
3759 "specific_error": "not serializer.is_valid()",
3760 "reasons": serializer.errors}
3761 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003762 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003763 obj.caller = request.user
3764 if obj.can_update(request.user):
3765 return super(RoleList, self).create(request, *args, **kwargs)
3766 else:
Scott Baker08898c12014-10-29 23:41:11 -07003767 raise Exception("failed obj.can_update")
3768
3769 ret = super(RoleList, self).create(request, *args, **kwargs)
3770 if (ret.status_code%100 != 200):
3771 raise Exception(ret.data)
3772
3773 return ret
3774
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003775
3776class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3777 queryset = Role.objects.select_related().all()
3778 serializer_class = RoleSerializer
3779 id_serializer_class = RoleIdSerializer
3780
3781 def get_serializer_class(self):
3782 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3783 if (no_hyperlinks):
3784 return self.id_serializer_class
3785 else:
3786 return self.serializer_class
3787
3788 def get_queryset(self):
3789 return Role.select_by_user(self.request.user)
3790
3791 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3792
3793 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3794
3795
3796
3797class UsableObjectList(generics.ListCreateAPIView):
3798 queryset = UsableObject.objects.select_related().all()
3799 serializer_class = UsableObjectSerializer
3800 id_serializer_class = UsableObjectIdSerializer
3801 filter_backends = (filters.DjangoFilterBackend,)
3802 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3803
3804 def get_serializer_class(self):
3805 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3806 if (no_hyperlinks):
3807 return self.id_serializer_class
3808 else:
3809 return self.serializer_class
3810
3811 def get_queryset(self):
3812 return UsableObject.select_by_user(self.request.user)
3813
3814 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003815 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3816 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003817 response = {"error": "validation",
3818 "specific_error": "not serializer.is_valid()",
3819 "reasons": serializer.errors}
3820 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003821 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003822 obj.caller = request.user
3823 if obj.can_update(request.user):
3824 return super(UsableObjectList, self).create(request, *args, **kwargs)
3825 else:
Scott Baker08898c12014-10-29 23:41:11 -07003826 raise Exception("failed obj.can_update")
3827
3828 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3829 if (ret.status_code%100 != 200):
3830 raise Exception(ret.data)
3831
3832 return ret
3833
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003834
3835class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3836 queryset = UsableObject.objects.select_related().all()
3837 serializer_class = UsableObjectSerializer
3838 id_serializer_class = UsableObjectIdSerializer
3839
3840 def get_serializer_class(self):
3841 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3842 if (no_hyperlinks):
3843 return self.id_serializer_class
3844 else:
3845 return self.serializer_class
3846
3847 def get_queryset(self):
3848 return UsableObject.select_by_user(self.request.user)
3849
3850 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3851
3852 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3853
3854
3855
Scott Bakerc1d11912014-12-22 09:29:05 -08003856class ControllerSiteDeploymentsList(generics.ListCreateAPIView):
3857 queryset = ControllerSiteDeployments.objects.select_related().all()
3858 serializer_class = ControllerSiteDeploymentsSerializer
3859 id_serializer_class = ControllerSiteDeploymentsIdSerializer
3860 filter_backends = (filters.DjangoFilterBackend,)
3861 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',)
3862
3863 def get_serializer_class(self):
3864 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3865 if (no_hyperlinks):
3866 return self.id_serializer_class
3867 else:
3868 return self.serializer_class
3869
3870 def get_queryset(self):
3871 return ControllerSiteDeployments.select_by_user(self.request.user)
3872
3873 def create(self, request, *args, **kwargs):
3874 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3875 if not (serializer.is_valid()):
3876 response = {"error": "validation",
3877 "specific_error": "not serializer.is_valid()",
3878 "reasons": serializer.errors}
3879 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3880 obj = serializer.object
3881 obj.caller = request.user
3882 if obj.can_update(request.user):
3883 return super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs)
3884 else:
3885 raise Exception("failed obj.can_update")
3886
3887 ret = super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs)
3888 if (ret.status_code%100 != 200):
3889 raise Exception(ret.data)
3890
3891 return ret
3892
3893
3894class ControllerSiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3895 queryset = ControllerSiteDeployments.objects.select_related().all()
3896 serializer_class = ControllerSiteDeploymentsSerializer
3897 id_serializer_class = ControllerSiteDeploymentsIdSerializer
3898
3899 def get_serializer_class(self):
3900 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3901 if (no_hyperlinks):
3902 return self.id_serializer_class
3903 else:
3904 return self.serializer_class
3905
3906 def get_queryset(self):
3907 return ControllerSiteDeployments.select_by_user(self.request.user)
3908
3909 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3910
3911 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3912
3913
3914
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003915class SiteRoleList(generics.ListCreateAPIView):
3916 queryset = SiteRole.objects.select_related().all()
3917 serializer_class = SiteRoleSerializer
3918 id_serializer_class = SiteRoleIdSerializer
3919 filter_backends = (filters.DjangoFilterBackend,)
3920 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3921
3922 def get_serializer_class(self):
3923 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3924 if (no_hyperlinks):
3925 return self.id_serializer_class
3926 else:
3927 return self.serializer_class
3928
3929 def get_queryset(self):
3930 return SiteRole.select_by_user(self.request.user)
3931
3932 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003933 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3934 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003935 response = {"error": "validation",
3936 "specific_error": "not serializer.is_valid()",
3937 "reasons": serializer.errors}
3938 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003939 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003940 obj.caller = request.user
3941 if obj.can_update(request.user):
3942 return super(SiteRoleList, self).create(request, *args, **kwargs)
3943 else:
Scott Baker08898c12014-10-29 23:41:11 -07003944 raise Exception("failed obj.can_update")
3945
3946 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3947 if (ret.status_code%100 != 200):
3948 raise Exception(ret.data)
3949
3950 return ret
3951
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003952
3953class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3954 queryset = SiteRole.objects.select_related().all()
3955 serializer_class = SiteRoleSerializer
3956 id_serializer_class = SiteRoleIdSerializer
3957
3958 def get_serializer_class(self):
3959 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3960 if (no_hyperlinks):
3961 return self.id_serializer_class
3962 else:
3963 return self.serializer_class
3964
3965 def get_queryset(self):
3966 return SiteRole.select_by_user(self.request.user)
3967
3968 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3969
3970 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3971
3972
3973
3974class SliceCredentialList(generics.ListCreateAPIView):
3975 queryset = SliceCredential.objects.select_related().all()
3976 serializer_class = SliceCredentialSerializer
3977 id_serializer_class = SliceCredentialIdSerializer
3978 filter_backends = (filters.DjangoFilterBackend,)
3979 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3980
3981 def get_serializer_class(self):
3982 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3983 if (no_hyperlinks):
3984 return self.id_serializer_class
3985 else:
3986 return self.serializer_class
3987
3988 def get_queryset(self):
3989 return SliceCredential.select_by_user(self.request.user)
3990
3991 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003992 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3993 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003994 response = {"error": "validation",
3995 "specific_error": "not serializer.is_valid()",
3996 "reasons": serializer.errors}
3997 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003998 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003999 obj.caller = request.user
4000 if obj.can_update(request.user):
4001 return super(SliceCredentialList, self).create(request, *args, **kwargs)
4002 else:
Scott Baker08898c12014-10-29 23:41:11 -07004003 raise Exception("failed obj.can_update")
4004
4005 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
4006 if (ret.status_code%100 != 200):
4007 raise Exception(ret.data)
4008
4009 return ret
4010
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004011
4012class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4013 queryset = SliceCredential.objects.select_related().all()
4014 serializer_class = SliceCredentialSerializer
4015 id_serializer_class = SliceCredentialIdSerializer
4016
4017 def get_serializer_class(self):
4018 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4019 if (no_hyperlinks):
4020 return self.id_serializer_class
4021 else:
4022 return self.serializer_class
4023
4024 def get_queryset(self):
4025 return SliceCredential.select_by_user(self.request.user)
4026
4027 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4028
4029 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4030
4031
4032
4033class SliverList(generics.ListCreateAPIView):
4034 queryset = Sliver.objects.select_related().all()
4035 serializer_class = SliverSerializer
4036 id_serializer_class = SliverIdSerializer
4037 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker6c958402015-01-03 12:05:21 -08004038 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 -07004039
4040 def get_serializer_class(self):
4041 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4042 if (no_hyperlinks):
4043 return self.id_serializer_class
4044 else:
4045 return self.serializer_class
4046
4047 def get_queryset(self):
4048 return Sliver.select_by_user(self.request.user)
4049
4050 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004051 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4052 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004053 response = {"error": "validation",
4054 "specific_error": "not serializer.is_valid()",
4055 "reasons": serializer.errors}
4056 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004057 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004058 obj.caller = request.user
4059 if obj.can_update(request.user):
4060 return super(SliverList, self).create(request, *args, **kwargs)
4061 else:
Scott Baker08898c12014-10-29 23:41:11 -07004062 raise Exception("failed obj.can_update")
4063
4064 ret = super(SliverList, self).create(request, *args, **kwargs)
4065 if (ret.status_code%100 != 200):
4066 raise Exception(ret.data)
4067
4068 return ret
4069
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004070
4071class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4072 queryset = Sliver.objects.select_related().all()
4073 serializer_class = SliverSerializer
4074 id_serializer_class = SliverIdSerializer
4075
4076 def get_serializer_class(self):
4077 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4078 if (no_hyperlinks):
4079 return self.id_serializer_class
4080 else:
4081 return self.serializer_class
4082
4083 def get_queryset(self):
4084 return Sliver.select_by_user(self.request.user)
4085
4086 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4087
4088 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4089
4090
4091
4092class NodeList(generics.ListCreateAPIView):
4093 queryset = Node.objects.select_related().all()
4094 serializer_class = NodeSerializer
4095 id_serializer_class = NodeIdSerializer
4096 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004097 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004098
4099 def get_serializer_class(self):
4100 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4101 if (no_hyperlinks):
4102 return self.id_serializer_class
4103 else:
4104 return self.serializer_class
4105
4106 def get_queryset(self):
4107 return Node.select_by_user(self.request.user)
4108
4109 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004110 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4111 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004112 response = {"error": "validation",
4113 "specific_error": "not serializer.is_valid()",
4114 "reasons": serializer.errors}
4115 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004116 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004117 obj.caller = request.user
4118 if obj.can_update(request.user):
4119 return super(NodeList, self).create(request, *args, **kwargs)
4120 else:
Scott Baker08898c12014-10-29 23:41:11 -07004121 raise Exception("failed obj.can_update")
4122
4123 ret = super(NodeList, self).create(request, *args, **kwargs)
4124 if (ret.status_code%100 != 200):
4125 raise Exception(ret.data)
4126
4127 return ret
4128
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004129
4130class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4131 queryset = Node.objects.select_related().all()
4132 serializer_class = NodeSerializer
4133 id_serializer_class = NodeIdSerializer
4134
4135 def get_serializer_class(self):
4136 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4137 if (no_hyperlinks):
4138 return self.id_serializer_class
4139 else:
4140 return self.serializer_class
4141
4142 def get_queryset(self):
4143 return Node.select_by_user(self.request.user)
4144
4145 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4146
4147 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4148
4149
4150
4151class DashboardViewList(generics.ListCreateAPIView):
4152 queryset = DashboardView.objects.select_related().all()
4153 serializer_class = DashboardViewSerializer
4154 id_serializer_class = DashboardViewIdSerializer
4155 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004156 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004157
4158 def get_serializer_class(self):
4159 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4160 if (no_hyperlinks):
4161 return self.id_serializer_class
4162 else:
4163 return self.serializer_class
4164
4165 def get_queryset(self):
4166 return DashboardView.select_by_user(self.request.user)
4167
4168 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004169 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4170 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004171 response = {"error": "validation",
4172 "specific_error": "not serializer.is_valid()",
4173 "reasons": serializer.errors}
4174 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004175 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004176 obj.caller = request.user
4177 if obj.can_update(request.user):
4178 return super(DashboardViewList, self).create(request, *args, **kwargs)
4179 else:
Scott Baker08898c12014-10-29 23:41:11 -07004180 raise Exception("failed obj.can_update")
4181
4182 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
4183 if (ret.status_code%100 != 200):
4184 raise Exception(ret.data)
4185
4186 return ret
4187
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004188
4189class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4190 queryset = DashboardView.objects.select_related().all()
4191 serializer_class = DashboardViewSerializer
4192 id_serializer_class = DashboardViewIdSerializer
4193
4194 def get_serializer_class(self):
4195 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4196 if (no_hyperlinks):
4197 return self.id_serializer_class
4198 else:
4199 return self.serializer_class
4200
4201 def get_queryset(self):
4202 return DashboardView.select_by_user(self.request.user)
4203
4204 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4205
4206 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4207
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004208
Scott Bakerf3816ac2014-11-12 01:13:53 -08004209
Scott Bakerc1d11912014-12-22 09:29:05 -08004210class ImageDeploymentsList(generics.ListCreateAPIView):
4211 queryset = ImageDeployments.objects.select_related().all()
4212 serializer_class = ImageDeploymentsSerializer
4213 id_serializer_class = ImageDeploymentsIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004214 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08004215 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',)
Scott Baker196ffef2014-11-21 11:32:24 -08004216
4217 def get_serializer_class(self):
4218 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4219 if (no_hyperlinks):
4220 return self.id_serializer_class
4221 else:
4222 return self.serializer_class
4223
4224 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08004225 return ImageDeployments.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004226
4227 def create(self, request, *args, **kwargs):
4228 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4229 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004230 response = {"error": "validation",
4231 "specific_error": "not serializer.is_valid()",
4232 "reasons": serializer.errors}
4233 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08004234 obj = serializer.object
4235 obj.caller = request.user
4236 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08004237 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08004238 else:
4239 raise Exception("failed obj.can_update")
4240
Scott Bakerc1d11912014-12-22 09:29:05 -08004241 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08004242 if (ret.status_code%100 != 200):
4243 raise Exception(ret.data)
4244
4245 return ret
4246
4247
Scott Bakerc1d11912014-12-22 09:29:05 -08004248class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4249 queryset = ImageDeployments.objects.select_related().all()
4250 serializer_class = ImageDeploymentsSerializer
4251 id_serializer_class = ImageDeploymentsIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004252
4253 def get_serializer_class(self):
4254 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4255 if (no_hyperlinks):
4256 return self.id_serializer_class
4257 else:
4258 return self.serializer_class
4259
4260 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08004261 return ImageDeployments.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004262
4263 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4264
4265 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4266
Scott Baker196ffef2014-11-21 11:32:24 -08004267
4268
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004269class ReservedResourceList(generics.ListCreateAPIView):
4270 queryset = ReservedResource.objects.select_related().all()
4271 serializer_class = ReservedResourceSerializer
4272 id_serializer_class = ReservedResourceIdSerializer
4273 filter_backends = (filters.DjangoFilterBackend,)
4274 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
4275
4276 def get_serializer_class(self):
4277 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4278 if (no_hyperlinks):
4279 return self.id_serializer_class
4280 else:
4281 return self.serializer_class
4282
4283 def get_queryset(self):
4284 return ReservedResource.select_by_user(self.request.user)
4285
4286 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004287 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4288 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004289 response = {"error": "validation",
4290 "specific_error": "not serializer.is_valid()",
4291 "reasons": serializer.errors}
4292 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004293 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004294 obj.caller = request.user
4295 if obj.can_update(request.user):
4296 return super(ReservedResourceList, self).create(request, *args, **kwargs)
4297 else:
Scott Baker08898c12014-10-29 23:41:11 -07004298 raise Exception("failed obj.can_update")
4299
4300 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4301 if (ret.status_code%100 != 200):
4302 raise Exception(ret.data)
4303
4304 return ret
4305
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004306
4307class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4308 queryset = ReservedResource.objects.select_related().all()
4309 serializer_class = ReservedResourceSerializer
4310 id_serializer_class = ReservedResourceIdSerializer
4311
4312 def get_serializer_class(self):
4313 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4314 if (no_hyperlinks):
4315 return self.id_serializer_class
4316 else:
4317 return self.serializer_class
4318
4319 def get_queryset(self):
4320 return ReservedResource.select_by_user(self.request.user)
4321
4322 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4323
4324 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4325
4326
4327
Scott Bakerc1d11912014-12-22 09:29:05 -08004328class PaymentList(generics.ListCreateAPIView):
4329 queryset = Payment.objects.select_related().all()
4330 serializer_class = PaymentSerializer
4331 id_serializer_class = PaymentIdSerializer
4332 filter_backends = (filters.DjangoFilterBackend,)
4333 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
4334
4335 def get_serializer_class(self):
4336 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4337 if (no_hyperlinks):
4338 return self.id_serializer_class
4339 else:
4340 return self.serializer_class
4341
4342 def get_queryset(self):
4343 return Payment.select_by_user(self.request.user)
4344
4345 def create(self, request, *args, **kwargs):
4346 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4347 if not (serializer.is_valid()):
4348 response = {"error": "validation",
4349 "specific_error": "not serializer.is_valid()",
4350 "reasons": serializer.errors}
4351 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4352 obj = serializer.object
4353 obj.caller = request.user
4354 if obj.can_update(request.user):
4355 return super(PaymentList, self).create(request, *args, **kwargs)
4356 else:
4357 raise Exception("failed obj.can_update")
4358
4359 ret = super(PaymentList, self).create(request, *args, **kwargs)
4360 if (ret.status_code%100 != 200):
4361 raise Exception(ret.data)
4362
4363 return ret
4364
4365
4366class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4367 queryset = Payment.objects.select_related().all()
4368 serializer_class = PaymentSerializer
4369 id_serializer_class = PaymentIdSerializer
4370
4371 def get_serializer_class(self):
4372 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4373 if (no_hyperlinks):
4374 return self.id_serializer_class
4375 else:
4376 return self.serializer_class
4377
4378 def get_queryset(self):
4379 return Payment.select_by_user(self.request.user)
4380
4381 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4382
4383 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4384
4385
4386
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004387class NetworkSliceList(generics.ListCreateAPIView):
4388 queryset = NetworkSlice.objects.select_related().all()
4389 serializer_class = NetworkSliceSerializer
4390 id_serializer_class = NetworkSliceIdSerializer
4391 filter_backends = (filters.DjangoFilterBackend,)
4392 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
4393
4394 def get_serializer_class(self):
4395 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4396 if (no_hyperlinks):
4397 return self.id_serializer_class
4398 else:
4399 return self.serializer_class
4400
4401 def get_queryset(self):
4402 return NetworkSlice.select_by_user(self.request.user)
4403
4404 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004405 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4406 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004407 response = {"error": "validation",
4408 "specific_error": "not serializer.is_valid()",
4409 "reasons": serializer.errors}
4410 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004411 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004412 obj.caller = request.user
4413 if obj.can_update(request.user):
4414 return super(NetworkSliceList, self).create(request, *args, **kwargs)
4415 else:
Scott Baker08898c12014-10-29 23:41:11 -07004416 raise Exception("failed obj.can_update")
4417
4418 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4419 if (ret.status_code%100 != 200):
4420 raise Exception(ret.data)
4421
4422 return ret
4423
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004424
4425class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4426 queryset = NetworkSlice.objects.select_related().all()
4427 serializer_class = NetworkSliceSerializer
4428 id_serializer_class = NetworkSliceIdSerializer
4429
4430 def get_serializer_class(self):
4431 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4432 if (no_hyperlinks):
4433 return self.id_serializer_class
4434 else:
4435 return self.serializer_class
4436
4437 def get_queryset(self):
4438 return NetworkSlice.select_by_user(self.request.user)
4439
4440 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4441
4442 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4443
4444
4445
4446class UserDashboardViewList(generics.ListCreateAPIView):
4447 queryset = UserDashboardView.objects.select_related().all()
4448 serializer_class = UserDashboardViewSerializer
4449 id_serializer_class = UserDashboardViewIdSerializer
4450 filter_backends = (filters.DjangoFilterBackend,)
4451 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4452
4453 def get_serializer_class(self):
4454 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4455 if (no_hyperlinks):
4456 return self.id_serializer_class
4457 else:
4458 return self.serializer_class
4459
4460 def get_queryset(self):
4461 return UserDashboardView.select_by_user(self.request.user)
4462
4463 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004464 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4465 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004466 response = {"error": "validation",
4467 "specific_error": "not serializer.is_valid()",
4468 "reasons": serializer.errors}
4469 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004470 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004471 obj.caller = request.user
4472 if obj.can_update(request.user):
4473 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4474 else:
Scott Baker08898c12014-10-29 23:41:11 -07004475 raise Exception("failed obj.can_update")
4476
4477 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4478 if (ret.status_code%100 != 200):
4479 raise Exception(ret.data)
4480
4481 return ret
4482
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004483
4484class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4485 queryset = UserDashboardView.objects.select_related().all()
4486 serializer_class = UserDashboardViewSerializer
4487 id_serializer_class = UserDashboardViewIdSerializer
4488
4489 def get_serializer_class(self):
4490 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4491 if (no_hyperlinks):
4492 return self.id_serializer_class
4493 else:
4494 return self.serializer_class
4495
4496 def get_queryset(self):
4497 return UserDashboardView.select_by_user(self.request.user)
4498
4499 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4500
4501 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4502
4503
4504
Scott Bakerc1d11912014-12-22 09:29:05 -08004505class ControllerList(generics.ListCreateAPIView):
4506 queryset = Controller.objects.select_related().all()
4507 serializer_class = ControllerSerializer
4508 id_serializer_class = ControllerIdSerializer
4509 filter_backends = (filters.DjangoFilterBackend,)
4510 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
4511
4512 def get_serializer_class(self):
4513 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4514 if (no_hyperlinks):
4515 return self.id_serializer_class
4516 else:
4517 return self.serializer_class
4518
4519 def get_queryset(self):
4520 return Controller.select_by_user(self.request.user)
4521
4522 def create(self, request, *args, **kwargs):
4523 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4524 if not (serializer.is_valid()):
4525 response = {"error": "validation",
4526 "specific_error": "not serializer.is_valid()",
4527 "reasons": serializer.errors}
4528 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4529 obj = serializer.object
4530 obj.caller = request.user
4531 if obj.can_update(request.user):
4532 return super(ControllerList, self).create(request, *args, **kwargs)
4533 else:
4534 raise Exception("failed obj.can_update")
4535
4536 ret = super(ControllerList, self).create(request, *args, **kwargs)
4537 if (ret.status_code%100 != 200):
4538 raise Exception(ret.data)
4539
4540 return ret
4541
4542
4543class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4544 queryset = Controller.objects.select_related().all()
4545 serializer_class = ControllerSerializer
4546 id_serializer_class = ControllerIdSerializer
4547
4548 def get_serializer_class(self):
4549 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4550 if (no_hyperlinks):
4551 return self.id_serializer_class
4552 else:
4553 return self.serializer_class
4554
4555 def get_queryset(self):
4556 return Controller.select_by_user(self.request.user)
4557
4558 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4559
4560 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4561
4562
4563
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004564class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4565 queryset = PlanetStackPrivilege.objects.select_related().all()
4566 serializer_class = PlanetStackPrivilegeSerializer
4567 id_serializer_class = PlanetStackPrivilegeIdSerializer
4568 filter_backends = (filters.DjangoFilterBackend,)
4569 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4570
4571 def get_serializer_class(self):
4572 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4573 if (no_hyperlinks):
4574 return self.id_serializer_class
4575 else:
4576 return self.serializer_class
4577
4578 def get_queryset(self):
4579 return PlanetStackPrivilege.select_by_user(self.request.user)
4580
4581 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004582 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4583 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004584 response = {"error": "validation",
4585 "specific_error": "not serializer.is_valid()",
4586 "reasons": serializer.errors}
4587 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004588 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004589 obj.caller = request.user
4590 if obj.can_update(request.user):
4591 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4592 else:
Scott Baker08898c12014-10-29 23:41:11 -07004593 raise Exception("failed obj.can_update")
4594
4595 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4596 if (ret.status_code%100 != 200):
4597 raise Exception(ret.data)
4598
4599 return ret
4600
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004601
4602class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4603 queryset = PlanetStackPrivilege.objects.select_related().all()
4604 serializer_class = PlanetStackPrivilegeSerializer
4605 id_serializer_class = PlanetStackPrivilegeIdSerializer
4606
4607 def get_serializer_class(self):
4608 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4609 if (no_hyperlinks):
4610 return self.id_serializer_class
4611 else:
4612 return self.serializer_class
4613
4614 def get_queryset(self):
4615 return PlanetStackPrivilege.select_by_user(self.request.user)
4616
4617 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4618
4619 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4620
4621
4622
4623class UserList(generics.ListCreateAPIView):
4624 queryset = User.objects.select_related().all()
4625 serializer_class = UserSerializer
4626 id_serializer_class = UserIdSerializer
4627 filter_backends = (filters.DjangoFilterBackend,)
4628 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',)
4629
4630 def get_serializer_class(self):
4631 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4632 if (no_hyperlinks):
4633 return self.id_serializer_class
4634 else:
4635 return self.serializer_class
4636
4637 def get_queryset(self):
4638 return User.select_by_user(self.request.user)
4639
4640 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004641 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4642 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004643 response = {"error": "validation",
4644 "specific_error": "not serializer.is_valid()",
4645 "reasons": serializer.errors}
4646 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004647 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004648 obj.caller = request.user
4649 if obj.can_update(request.user):
4650 return super(UserList, self).create(request, *args, **kwargs)
4651 else:
Scott Baker08898c12014-10-29 23:41:11 -07004652 raise Exception("failed obj.can_update")
4653
4654 ret = super(UserList, self).create(request, *args, **kwargs)
4655 if (ret.status_code%100 != 200):
4656 raise Exception(ret.data)
4657
4658 return ret
4659
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004660
4661class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4662 queryset = User.objects.select_related().all()
4663 serializer_class = UserSerializer
4664 id_serializer_class = UserIdSerializer
4665
4666 def get_serializer_class(self):
4667 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4668 if (no_hyperlinks):
4669 return self.id_serializer_class
4670 else:
4671 return self.serializer_class
4672
4673 def get_queryset(self):
4674 return User.select_by_user(self.request.user)
4675
4676 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4677
4678 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4679
4680
4681
4682class DeploymentList(generics.ListCreateAPIView):
4683 queryset = Deployment.objects.select_related().all()
4684 serializer_class = DeploymentSerializer
4685 id_serializer_class = DeploymentIdSerializer
4686 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker93a79a92014-12-22 15:59:33 -08004687 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','images','sites',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004688
4689 def get_serializer_class(self):
4690 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4691 if (no_hyperlinks):
4692 return self.id_serializer_class
4693 else:
4694 return self.serializer_class
4695
4696 def get_queryset(self):
4697 return Deployment.select_by_user(self.request.user)
4698
4699 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004700 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4701 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004702 response = {"error": "validation",
4703 "specific_error": "not serializer.is_valid()",
4704 "reasons": serializer.errors}
4705 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004706 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004707 obj.caller = request.user
4708 if obj.can_update(request.user):
4709 return super(DeploymentList, self).create(request, *args, **kwargs)
4710 else:
Scott Baker08898c12014-10-29 23:41:11 -07004711 raise Exception("failed obj.can_update")
4712
4713 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4714 if (ret.status_code%100 != 200):
4715 raise Exception(ret.data)
4716
4717 return ret
4718
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004719
4720class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4721 queryset = Deployment.objects.select_related().all()
4722 serializer_class = DeploymentSerializer
4723 id_serializer_class = DeploymentIdSerializer
4724
4725 def get_serializer_class(self):
4726 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4727 if (no_hyperlinks):
4728 return self.id_serializer_class
4729 else:
4730 return self.serializer_class
4731
4732 def get_queryset(self):
4733 return Deployment.select_by_user(self.request.user)
4734
4735 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4736
4737 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4738
4739
4740
4741class ReservationList(generics.ListCreateAPIView):
4742 queryset = Reservation.objects.select_related().all()
4743 serializer_class = ReservationSerializer
4744 id_serializer_class = ReservationIdSerializer
4745 filter_backends = (filters.DjangoFilterBackend,)
4746 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4747
4748 def get_serializer_class(self):
4749 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4750 if (no_hyperlinks):
4751 return self.id_serializer_class
4752 else:
4753 return self.serializer_class
4754
4755 def get_queryset(self):
4756 return Reservation.select_by_user(self.request.user)
4757
4758 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004759 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4760 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004761 response = {"error": "validation",
4762 "specific_error": "not serializer.is_valid()",
4763 "reasons": serializer.errors}
4764 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004765 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004766 obj.caller = request.user
4767 if obj.can_update(request.user):
4768 return super(ReservationList, self).create(request, *args, **kwargs)
4769 else:
Scott Baker08898c12014-10-29 23:41:11 -07004770 raise Exception("failed obj.can_update")
4771
4772 ret = super(ReservationList, self).create(request, *args, **kwargs)
4773 if (ret.status_code%100 != 200):
4774 raise Exception(ret.data)
4775
4776 return ret
4777
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004778
4779class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4780 queryset = Reservation.objects.select_related().all()
4781 serializer_class = ReservationSerializer
4782 id_serializer_class = ReservationIdSerializer
4783
4784 def get_serializer_class(self):
4785 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4786 if (no_hyperlinks):
4787 return self.id_serializer_class
4788 else:
4789 return self.serializer_class
4790
4791 def get_queryset(self):
4792 return Reservation.select_by_user(self.request.user)
4793
4794 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4795
4796 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4797
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004798
Scott Bakerf3816ac2014-11-12 01:13:53 -08004799
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004800class SitePrivilegeList(generics.ListCreateAPIView):
4801 queryset = SitePrivilege.objects.select_related().all()
4802 serializer_class = SitePrivilegeSerializer
4803 id_serializer_class = SitePrivilegeIdSerializer
4804 filter_backends = (filters.DjangoFilterBackend,)
4805 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4806
4807 def get_serializer_class(self):
4808 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4809 if (no_hyperlinks):
4810 return self.id_serializer_class
4811 else:
4812 return self.serializer_class
4813
4814 def get_queryset(self):
4815 return SitePrivilege.select_by_user(self.request.user)
4816
4817 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004818 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4819 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004820 response = {"error": "validation",
4821 "specific_error": "not serializer.is_valid()",
4822 "reasons": serializer.errors}
4823 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004824 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004825 obj.caller = request.user
4826 if obj.can_update(request.user):
4827 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4828 else:
Scott Baker08898c12014-10-29 23:41:11 -07004829 raise Exception("failed obj.can_update")
4830
4831 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4832 if (ret.status_code%100 != 200):
4833 raise Exception(ret.data)
4834
4835 return ret
4836
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004837
4838class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4839 queryset = SitePrivilege.objects.select_related().all()
4840 serializer_class = SitePrivilegeSerializer
4841 id_serializer_class = SitePrivilegeIdSerializer
4842
4843 def get_serializer_class(self):
4844 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4845 if (no_hyperlinks):
4846 return self.id_serializer_class
4847 else:
4848 return self.serializer_class
4849
4850 def get_queryset(self):
4851 return SitePrivilege.select_by_user(self.request.user)
4852
4853 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4854
4855 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4856
4857
4858
Scott Baker196ffef2014-11-21 11:32:24 -08004859class PlanetStackList(generics.ListCreateAPIView):
4860 queryset = PlanetStack.objects.select_related().all()
4861 serializer_class = PlanetStackSerializer
4862 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004863 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker196ffef2014-11-21 11:32:24 -08004864 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004865
4866 def get_serializer_class(self):
4867 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4868 if (no_hyperlinks):
4869 return self.id_serializer_class
4870 else:
4871 return self.serializer_class
4872
4873 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004874 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004875
4876 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004877 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4878 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004879 response = {"error": "validation",
4880 "specific_error": "not serializer.is_valid()",
4881 "reasons": serializer.errors}
4882 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004883 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004884 obj.caller = request.user
4885 if obj.can_update(request.user):
Scott Baker196ffef2014-11-21 11:32:24 -08004886 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004887 else:
Scott Baker08898c12014-10-29 23:41:11 -07004888 raise Exception("failed obj.can_update")
4889
Scott Baker196ffef2014-11-21 11:32:24 -08004890 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004891 if (ret.status_code%100 != 200):
4892 raise Exception(ret.data)
4893
4894 return ret
4895
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004896
Scott Baker196ffef2014-11-21 11:32:24 -08004897class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4898 queryset = PlanetStack.objects.select_related().all()
4899 serializer_class = PlanetStackSerializer
4900 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004901
4902 def get_serializer_class(self):
4903 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4904 if (no_hyperlinks):
4905 return self.id_serializer_class
4906 else:
4907 return self.serializer_class
4908
4909 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004910 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004911
4912 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4913
4914 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4915
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004916
Scott Bakerf3816ac2014-11-12 01:13:53 -08004917
Scott Bakera6a0c772014-12-22 17:35:34 -08004918class ControllerDashboardViewList(generics.ListCreateAPIView):
4919 queryset = ControllerDashboardView.objects.select_related().all()
4920 serializer_class = ControllerDashboardViewSerializer
4921 id_serializer_class = ControllerDashboardViewIdSerializer
4922 filter_backends = (filters.DjangoFilterBackend,)
4923 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',)
4924
4925 def get_serializer_class(self):
4926 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4927 if (no_hyperlinks):
4928 return self.id_serializer_class
4929 else:
4930 return self.serializer_class
4931
4932 def get_queryset(self):
4933 return ControllerDashboardView.select_by_user(self.request.user)
4934
4935 def create(self, request, *args, **kwargs):
4936 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4937 if not (serializer.is_valid()):
4938 response = {"error": "validation",
4939 "specific_error": "not serializer.is_valid()",
4940 "reasons": serializer.errors}
4941 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4942 obj = serializer.object
4943 obj.caller = request.user
4944 if obj.can_update(request.user):
4945 return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
4946 else:
4947 raise Exception("failed obj.can_update")
4948
4949 ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
4950 if (ret.status_code%100 != 200):
4951 raise Exception(ret.data)
4952
4953 return ret
4954
4955
4956class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4957 queryset = ControllerDashboardView.objects.select_related().all()
4958 serializer_class = ControllerDashboardViewSerializer
4959 id_serializer_class = ControllerDashboardViewIdSerializer
4960
4961 def get_serializer_class(self):
4962 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4963 if (no_hyperlinks):
4964 return self.id_serializer_class
4965 else:
4966 return self.serializer_class
4967
4968 def get_queryset(self):
4969 return ControllerDashboardView.select_by_user(self.request.user)
4970
4971 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4972
4973 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4974
4975
4976
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004977class AccountList(generics.ListCreateAPIView):
4978 queryset = Account.objects.select_related().all()
4979 serializer_class = AccountSerializer
4980 id_serializer_class = AccountIdSerializer
4981 filter_backends = (filters.DjangoFilterBackend,)
4982 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4983
4984 def get_serializer_class(self):
4985 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4986 if (no_hyperlinks):
4987 return self.id_serializer_class
4988 else:
4989 return self.serializer_class
4990
4991 def get_queryset(self):
4992 return Account.select_by_user(self.request.user)
4993
4994 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004995 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4996 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004997 response = {"error": "validation",
4998 "specific_error": "not serializer.is_valid()",
4999 "reasons": serializer.errors}
5000 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005001 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005002 obj.caller = request.user
5003 if obj.can_update(request.user):
5004 return super(AccountList, self).create(request, *args, **kwargs)
5005 else:
Scott Baker08898c12014-10-29 23:41:11 -07005006 raise Exception("failed obj.can_update")
5007
5008 ret = super(AccountList, self).create(request, *args, **kwargs)
5009 if (ret.status_code%100 != 200):
5010 raise Exception(ret.data)
5011
5012 return ret
5013
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005014
5015class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5016 queryset = Account.objects.select_related().all()
5017 serializer_class = AccountSerializer
5018 id_serializer_class = AccountIdSerializer
5019
5020 def get_serializer_class(self):
5021 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5022 if (no_hyperlinks):
5023 return self.id_serializer_class
5024 else:
5025 return self.serializer_class
5026
5027 def get_queryset(self):
5028 return Account.select_by_user(self.request.user)
5029
5030 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5031
5032 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5033
5034
5035
Scott Bakerc1d11912014-12-22 09:29:05 -08005036class ControllerRoleList(generics.ListCreateAPIView):
5037 queryset = ControllerRole.objects.select_related().all()
5038 serializer_class = ControllerRoleSerializer
5039 id_serializer_class = ControllerRoleIdSerializer
5040 filter_backends = (filters.DjangoFilterBackend,)
5041 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5042
5043 def get_serializer_class(self):
5044 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5045 if (no_hyperlinks):
5046 return self.id_serializer_class
5047 else:
5048 return self.serializer_class
5049
5050 def get_queryset(self):
5051 return ControllerRole.select_by_user(self.request.user)
5052
5053 def create(self, request, *args, **kwargs):
5054 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5055 if not (serializer.is_valid()):
5056 response = {"error": "validation",
5057 "specific_error": "not serializer.is_valid()",
5058 "reasons": serializer.errors}
5059 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5060 obj = serializer.object
5061 obj.caller = request.user
5062 if obj.can_update(request.user):
5063 return super(ControllerRoleList, self).create(request, *args, **kwargs)
5064 else:
5065 raise Exception("failed obj.can_update")
5066
5067 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
5068 if (ret.status_code%100 != 200):
5069 raise Exception(ret.data)
5070
5071 return ret
5072
5073
5074class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5075 queryset = ControllerRole.objects.select_related().all()
5076 serializer_class = ControllerRoleSerializer
5077 id_serializer_class = ControllerRoleIdSerializer
5078
5079 def get_serializer_class(self):
5080 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5081 if (no_hyperlinks):
5082 return self.id_serializer_class
5083 else:
5084 return self.serializer_class
5085
5086 def get_queryset(self):
5087 return ControllerRole.select_by_user(self.request.user)
5088
5089 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5090
5091 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5092
5093
5094
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005095class NetworkParameterTypeList(generics.ListCreateAPIView):
5096 queryset = NetworkParameterType.objects.select_related().all()
5097 serializer_class = NetworkParameterTypeSerializer
5098 id_serializer_class = NetworkParameterTypeIdSerializer
5099 filter_backends = (filters.DjangoFilterBackend,)
5100 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
5101
5102 def get_serializer_class(self):
5103 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5104 if (no_hyperlinks):
5105 return self.id_serializer_class
5106 else:
5107 return self.serializer_class
5108
5109 def get_queryset(self):
5110 return NetworkParameterType.select_by_user(self.request.user)
5111
5112 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005113 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5114 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005115 response = {"error": "validation",
5116 "specific_error": "not serializer.is_valid()",
5117 "reasons": serializer.errors}
5118 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005119 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005120 obj.caller = request.user
5121 if obj.can_update(request.user):
5122 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5123 else:
Scott Baker08898c12014-10-29 23:41:11 -07005124 raise Exception("failed obj.can_update")
5125
5126 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5127 if (ret.status_code%100 != 200):
5128 raise Exception(ret.data)
5129
5130 return ret
5131
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005132
5133class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5134 queryset = NetworkParameterType.objects.select_related().all()
5135 serializer_class = NetworkParameterTypeSerializer
5136 id_serializer_class = NetworkParameterTypeIdSerializer
5137
5138 def get_serializer_class(self):
5139 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5140 if (no_hyperlinks):
5141 return self.id_serializer_class
5142 else:
5143 return self.serializer_class
5144
5145 def get_queryset(self):
5146 return NetworkParameterType.select_by_user(self.request.user)
5147
5148 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5149
5150 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5151
5152
5153
5154class SiteCredentialList(generics.ListCreateAPIView):
5155 queryset = SiteCredential.objects.select_related().all()
5156 serializer_class = SiteCredentialSerializer
5157 id_serializer_class = SiteCredentialIdSerializer
5158 filter_backends = (filters.DjangoFilterBackend,)
5159 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
5160
5161 def get_serializer_class(self):
5162 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5163 if (no_hyperlinks):
5164 return self.id_serializer_class
5165 else:
5166 return self.serializer_class
5167
5168 def get_queryset(self):
5169 return SiteCredential.select_by_user(self.request.user)
5170
5171 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005172 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5173 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005174 response = {"error": "validation",
5175 "specific_error": "not serializer.is_valid()",
5176 "reasons": serializer.errors}
5177 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005178 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005179 obj.caller = request.user
5180 if obj.can_update(request.user):
5181 return super(SiteCredentialList, self).create(request, *args, **kwargs)
5182 else:
Scott Baker08898c12014-10-29 23:41:11 -07005183 raise Exception("failed obj.can_update")
5184
5185 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
5186 if (ret.status_code%100 != 200):
5187 raise Exception(ret.data)
5188
5189 return ret
5190
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005191
5192class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5193 queryset = SiteCredential.objects.select_related().all()
5194 serializer_class = SiteCredentialSerializer
5195 id_serializer_class = SiteCredentialIdSerializer
5196
5197 def get_serializer_class(self):
5198 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5199 if (no_hyperlinks):
5200 return self.id_serializer_class
5201 else:
5202 return self.serializer_class
5203
5204 def get_queryset(self):
5205 return SiteCredential.select_by_user(self.request.user)
5206
5207 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5208
5209 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5210
5211
5212
Scott Bakerc1d11912014-12-22 09:29:05 -08005213class DeploymentPrivilegeList(generics.ListCreateAPIView):
5214 queryset = DeploymentPrivilege.objects.select_related().all()
5215 serializer_class = DeploymentPrivilegeSerializer
5216 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005217 filter_backends = (filters.DjangoFilterBackend,)
5218 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
5219
5220 def get_serializer_class(self):
5221 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5222 if (no_hyperlinks):
5223 return self.id_serializer_class
5224 else:
5225 return self.serializer_class
5226
5227 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005228 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005229
5230 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005231 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5232 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005233 response = {"error": "validation",
5234 "specific_error": "not serializer.is_valid()",
5235 "reasons": serializer.errors}
5236 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005237 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005238 obj.caller = request.user
5239 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08005240 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005241 else:
Scott Baker08898c12014-10-29 23:41:11 -07005242 raise Exception("failed obj.can_update")
5243
Scott Bakerc1d11912014-12-22 09:29:05 -08005244 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005245 if (ret.status_code%100 != 200):
5246 raise Exception(ret.data)
5247
5248 return ret
5249
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005250
Scott Bakerc1d11912014-12-22 09:29:05 -08005251class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5252 queryset = DeploymentPrivilege.objects.select_related().all()
5253 serializer_class = DeploymentPrivilegeSerializer
5254 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005255
5256 def get_serializer_class(self):
5257 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5258 if (no_hyperlinks):
5259 return self.id_serializer_class
5260 else:
5261 return self.serializer_class
5262
5263 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005264 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005265
5266 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5267
5268 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5269
5270
5271
Scott Bakerc1d11912014-12-22 09:29:05 -08005272class ControllerUsersList(generics.ListCreateAPIView):
5273 queryset = ControllerUsers.objects.select_related().all()
5274 serializer_class = ControllerUsersSerializer
5275 id_serializer_class = ControllerUsersIdSerializer
5276 filter_backends = (filters.DjangoFilterBackend,)
5277 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',)
5278
5279 def get_serializer_class(self):
5280 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5281 if (no_hyperlinks):
5282 return self.id_serializer_class
5283 else:
5284 return self.serializer_class
5285
5286 def get_queryset(self):
5287 return ControllerUsers.select_by_user(self.request.user)
5288
5289 def create(self, request, *args, **kwargs):
5290 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5291 if not (serializer.is_valid()):
5292 response = {"error": "validation",
5293 "specific_error": "not serializer.is_valid()",
5294 "reasons": serializer.errors}
5295 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5296 obj = serializer.object
5297 obj.caller = request.user
5298 if obj.can_update(request.user):
5299 return super(ControllerUsersList, self).create(request, *args, **kwargs)
5300 else:
5301 raise Exception("failed obj.can_update")
5302
5303 ret = super(ControllerUsersList, self).create(request, *args, **kwargs)
5304 if (ret.status_code%100 != 200):
5305 raise Exception(ret.data)
5306
5307 return ret
5308
5309
5310class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5311 queryset = ControllerUsers.objects.select_related().all()
5312 serializer_class = ControllerUsersSerializer
5313 id_serializer_class = ControllerUsersIdSerializer
5314
5315 def get_serializer_class(self):
5316 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5317 if (no_hyperlinks):
5318 return self.id_serializer_class
5319 else:
5320 return self.serializer_class
5321
5322 def get_queryset(self):
5323 return ControllerUsers.select_by_user(self.request.user)
5324
5325 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5326
5327 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5328
5329
5330
5331class DeploymentRoleList(generics.ListCreateAPIView):
5332 queryset = DeploymentRole.objects.select_related().all()
5333 serializer_class = DeploymentRoleSerializer
5334 id_serializer_class = DeploymentRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005335 filter_backends = (filters.DjangoFilterBackend,)
5336 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5337
5338 def get_serializer_class(self):
5339 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5340 if (no_hyperlinks):
5341 return self.id_serializer_class
5342 else:
5343 return self.serializer_class
5344
5345 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005346 return DeploymentRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005347
5348 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005349 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5350 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005351 response = {"error": "validation",
5352 "specific_error": "not serializer.is_valid()",
5353 "reasons": serializer.errors}
5354 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005355 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005356 obj.caller = request.user
5357 if obj.can_update(request.user):
Scott Bakerc1d11912014-12-22 09:29:05 -08005358 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005359 else:
Scott Baker08898c12014-10-29 23:41:11 -07005360 raise Exception("failed obj.can_update")
5361
Scott Bakerc1d11912014-12-22 09:29:05 -08005362 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005363 if (ret.status_code%100 != 200):
5364 raise Exception(ret.data)
5365
5366 return ret
5367
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005368
Scott Bakerc1d11912014-12-22 09:29:05 -08005369class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5370 queryset = DeploymentRole.objects.select_related().all()
5371 serializer_class = DeploymentRoleSerializer
5372 id_serializer_class = DeploymentRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005373
5374 def get_serializer_class(self):
5375 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5376 if (no_hyperlinks):
5377 return self.id_serializer_class
5378 else:
5379 return self.serializer_class
5380
5381 def get_queryset(self):
Scott Bakerc1d11912014-12-22 09:29:05 -08005382 return DeploymentRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005383
5384 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5385
5386 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5387
5388
5389
5390class UserCredentialList(generics.ListCreateAPIView):
5391 queryset = UserCredential.objects.select_related().all()
5392 serializer_class = UserCredentialSerializer
5393 id_serializer_class = UserCredentialIdSerializer
5394 filter_backends = (filters.DjangoFilterBackend,)
5395 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
5396
5397 def get_serializer_class(self):
5398 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5399 if (no_hyperlinks):
5400 return self.id_serializer_class
5401 else:
5402 return self.serializer_class
5403
5404 def get_queryset(self):
5405 return UserCredential.select_by_user(self.request.user)
5406
5407 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005408 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5409 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005410 response = {"error": "validation",
5411 "specific_error": "not serializer.is_valid()",
5412 "reasons": serializer.errors}
5413 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005414 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005415 obj.caller = request.user
5416 if obj.can_update(request.user):
5417 return super(UserCredentialList, self).create(request, *args, **kwargs)
5418 else:
Scott Baker08898c12014-10-29 23:41:11 -07005419 raise Exception("failed obj.can_update")
5420
5421 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
5422 if (ret.status_code%100 != 200):
5423 raise Exception(ret.data)
5424
5425 return ret
5426
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005427
5428class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5429 queryset = UserCredential.objects.select_related().all()
5430 serializer_class = UserCredentialSerializer
5431 id_serializer_class = UserCredentialIdSerializer
5432
5433 def get_serializer_class(self):
5434 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5435 if (no_hyperlinks):
5436 return self.id_serializer_class
5437 else:
5438 return self.serializer_class
5439
5440 def get_queryset(self):
5441 return UserCredential.select_by_user(self.request.user)
5442
5443 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5444
5445 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5446
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005447
Scott Bakerf3816ac2014-11-12 01:13:53 -08005448
Scott Baker196ffef2014-11-21 11:32:24 -08005449class SiteDeploymentsList(generics.ListCreateAPIView):
5450 queryset = SiteDeployments.objects.select_related().all()
5451 serializer_class = SiteDeploymentsSerializer
5452 id_serializer_class = SiteDeploymentsIdSerializer
5453 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08005454 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker196ffef2014-11-21 11:32:24 -08005455
5456 def get_serializer_class(self):
5457 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5458 if (no_hyperlinks):
5459 return self.id_serializer_class
5460 else:
5461 return self.serializer_class
5462
5463 def get_queryset(self):
5464 return SiteDeployments.select_by_user(self.request.user)
5465
5466 def create(self, request, *args, **kwargs):
5467 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5468 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005469 response = {"error": "validation",
5470 "specific_error": "not serializer.is_valid()",
5471 "reasons": serializer.errors}
5472 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08005473 obj = serializer.object
5474 obj.caller = request.user
5475 if obj.can_update(request.user):
5476 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
5477 else:
5478 raise Exception("failed obj.can_update")
5479
5480 ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
5481 if (ret.status_code%100 != 200):
5482 raise Exception(ret.data)
5483
5484 return ret
5485
5486
5487class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5488 queryset = SiteDeployments.objects.select_related().all()
5489 serializer_class = SiteDeploymentsSerializer
5490 id_serializer_class = SiteDeploymentsIdSerializer
5491
5492 def get_serializer_class(self):
5493 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5494 if (no_hyperlinks):
5495 return self.id_serializer_class
5496 else:
5497 return self.serializer_class
5498
5499 def get_queryset(self):
5500 return SiteDeployments.select_by_user(self.request.user)
5501
5502 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5503
5504 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5505
Scott Bakerc1d11912014-12-22 09:29:05 -08005506
5507
Scott Baker0caeaf02014-06-19 11:12:55 -07005508class SliceTagList(generics.ListCreateAPIView):
5509 queryset = SliceTag.objects.select_related().all()
5510 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005511 id_serializer_class = SliceTagIdSerializer
5512 filter_backends = (filters.DjangoFilterBackend,)
5513 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5514
5515 def get_serializer_class(self):
5516 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5517 if (no_hyperlinks):
5518 return self.id_serializer_class
5519 else:
5520 return self.serializer_class
5521
Scott Baker0caeaf02014-06-19 11:12:55 -07005522 def get_queryset(self):
5523 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005524
Scott Baker0caeaf02014-06-19 11:12:55 -07005525 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005526 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5527 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005528 response = {"error": "validation",
5529 "specific_error": "not serializer.is_valid()",
5530 "reasons": serializer.errors}
5531 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005532 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005533 obj.caller = request.user
5534 if obj.can_update(request.user):
5535 return super(SliceTagList, self).create(request, *args, **kwargs)
5536 else:
Scott Baker08898c12014-10-29 23:41:11 -07005537 raise Exception("failed obj.can_update")
5538
5539 ret = super(SliceTagList, self).create(request, *args, **kwargs)
5540 if (ret.status_code%100 != 200):
5541 raise Exception(ret.data)
5542
5543 return ret
5544
Scott Baker0caeaf02014-06-19 11:12:55 -07005545
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005546class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005547 queryset = SliceTag.objects.select_related().all()
5548 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005549 id_serializer_class = SliceTagIdSerializer
5550
5551 def get_serializer_class(self):
5552 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5553 if (no_hyperlinks):
5554 return self.id_serializer_class
5555 else:
5556 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005557
5558 def get_queryset(self):
5559 return SliceTag.select_by_user(self.request.user)
5560
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005561 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005562
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005563 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005564
5565
5566
Scott Bakera6a0c772014-12-22 17:35:34 -08005567class NetworkTemplateList(generics.ListCreateAPIView):
5568 queryset = NetworkTemplate.objects.select_related().all()
5569 serializer_class = NetworkTemplateSerializer
5570 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005571 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker6c958402015-01-03 12:05:21 -08005572 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 -07005573
5574 def get_serializer_class(self):
5575 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5576 if (no_hyperlinks):
5577 return self.id_serializer_class
5578 else:
5579 return self.serializer_class
5580
Scott Baker0caeaf02014-06-19 11:12:55 -07005581 def get_queryset(self):
Scott Bakera6a0c772014-12-22 17:35:34 -08005582 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005583
Scott Baker0caeaf02014-06-19 11:12:55 -07005584 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005585 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5586 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005587 response = {"error": "validation",
5588 "specific_error": "not serializer.is_valid()",
5589 "reasons": serializer.errors}
5590 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005591 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005592 obj.caller = request.user
5593 if obj.can_update(request.user):
Scott Bakera6a0c772014-12-22 17:35:34 -08005594 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07005595 else:
Scott Baker08898c12014-10-29 23:41:11 -07005596 raise Exception("failed obj.can_update")
5597
Scott Bakera6a0c772014-12-22 17:35:34 -08005598 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07005599 if (ret.status_code%100 != 200):
5600 raise Exception(ret.data)
5601
5602 return ret
5603
Scott Baker0caeaf02014-06-19 11:12:55 -07005604
Scott Bakera6a0c772014-12-22 17:35:34 -08005605class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5606 queryset = NetworkTemplate.objects.select_related().all()
5607 serializer_class = NetworkTemplateSerializer
5608 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005609
5610 def get_serializer_class(self):
5611 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5612 if (no_hyperlinks):
5613 return self.id_serializer_class
5614 else:
5615 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005616
5617 def get_queryset(self):
Scott Bakera6a0c772014-12-22 17:35:34 -08005618 return NetworkTemplate.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07005619
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005620 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005621
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005622 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005623
5624
5625
5626class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005627 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005628 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005629 id_serializer_class = RouterIdSerializer
5630 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerc1d11912014-12-22 09:29:05 -08005631 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07005632
5633 def get_serializer_class(self):
5634 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5635 if (no_hyperlinks):
5636 return self.id_serializer_class
5637 else:
5638 return self.serializer_class
5639
Scott Baker0caeaf02014-06-19 11:12:55 -07005640 def get_queryset(self):
5641 return Router.select_by_user(self.request.user)
5642
5643 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005644 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5645 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005646 response = {"error": "validation",
5647 "specific_error": "not serializer.is_valid()",
5648 "reasons": serializer.errors}
5649 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005650 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005651 obj.caller = request.user
5652 if obj.can_update(request.user):
5653 return super(RouterList, self).create(request, *args, **kwargs)
5654 else:
Scott Baker08898c12014-10-29 23:41:11 -07005655 raise Exception("failed obj.can_update")
5656
5657 ret = super(RouterList, self).create(request, *args, **kwargs)
5658 if (ret.status_code%100 != 200):
5659 raise Exception(ret.data)
5660
5661 return ret
5662
Sapan Bhatiadea39432014-06-13 03:10:36 -04005663
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005664class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005665 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005666 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005667 id_serializer_class = RouterIdSerializer
5668
5669 def get_serializer_class(self):
5670 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5671 if (no_hyperlinks):
5672 return self.id_serializer_class
5673 else:
5674 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005675
5676 def get_queryset(self):
5677 return Router.select_by_user(self.request.user)
5678
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005679 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005680
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005681 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005682
5683
5684
Scott Baker0caeaf02014-06-19 11:12:55 -07005685class ServiceResourceList(generics.ListCreateAPIView):
5686 queryset = ServiceResource.objects.select_related().all()
5687 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005688 id_serializer_class = ServiceResourceIdSerializer
5689 filter_backends = (filters.DjangoFilterBackend,)
5690 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5691
5692 def get_serializer_class(self):
5693 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5694 if (no_hyperlinks):
5695 return self.id_serializer_class
5696 else:
5697 return self.serializer_class
5698
Scott Baker0caeaf02014-06-19 11:12:55 -07005699 def get_queryset(self):
5700 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005701
Scott Baker0caeaf02014-06-19 11:12:55 -07005702 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005703 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5704 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005705 response = {"error": "validation",
5706 "specific_error": "not serializer.is_valid()",
5707 "reasons": serializer.errors}
5708 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005709 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005710 obj.caller = request.user
5711 if obj.can_update(request.user):
5712 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5713 else:
Scott Baker08898c12014-10-29 23:41:11 -07005714 raise Exception("failed obj.can_update")
5715
5716 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5717 if (ret.status_code%100 != 200):
5718 raise Exception(ret.data)
5719
5720 return ret
5721
Scott Baker0caeaf02014-06-19 11:12:55 -07005722
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005723class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005724 queryset = ServiceResource.objects.select_related().all()
5725 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005726 id_serializer_class = ServiceResourceIdSerializer
5727
5728 def get_serializer_class(self):
5729 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5730 if (no_hyperlinks):
5731 return self.id_serializer_class
5732 else:
5733 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005734
5735 def get_queryset(self):
5736 return ServiceResource.select_by_user(self.request.user)
5737
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005738 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005739
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005740 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005741
Sapan Bhatiadea39432014-06-13 03:10:36 -04005742
5743
Scott Bakerc1d11912014-12-22 09:29:05 -08005744class ControllerSlicesList(generics.ListCreateAPIView):
5745 queryset = ControllerSlices.objects.select_related().all()
5746 serializer_class = ControllerSlicesSerializer
5747 id_serializer_class = ControllerSlicesIdSerializer
5748 filter_backends = (filters.DjangoFilterBackend,)
5749 filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',)
5750
5751 def get_serializer_class(self):
5752 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5753 if (no_hyperlinks):
5754 return self.id_serializer_class
5755 else:
5756 return self.serializer_class
5757
5758 def get_queryset(self):
5759 return ControllerSlices.select_by_user(self.request.user)
5760
5761 def create(self, request, *args, **kwargs):
5762 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5763 if not (serializer.is_valid()):
5764 response = {"error": "validation",
5765 "specific_error": "not serializer.is_valid()",
5766 "reasons": serializer.errors}
5767 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5768 obj = serializer.object
5769 obj.caller = request.user
5770 if obj.can_update(request.user):
5771 return super(ControllerSlicesList, self).create(request, *args, **kwargs)
5772 else:
5773 raise Exception("failed obj.can_update")
5774
5775 ret = super(ControllerSlicesList, self).create(request, *args, **kwargs)
5776 if (ret.status_code%100 != 200):
5777 raise Exception(ret.data)
5778
5779 return ret
5780
5781
5782class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5783 queryset = ControllerSlices.objects.select_related().all()
5784 serializer_class = ControllerSlicesSerializer
5785 id_serializer_class = ControllerSlicesIdSerializer
5786
5787 def get_serializer_class(self):
5788 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5789 if (no_hyperlinks):
5790 return self.id_serializer_class
5791 else:
5792 return self.serializer_class
5793
5794 def get_queryset(self):
5795 return ControllerSlices.select_by_user(self.request.user)
5796
5797 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5798
5799 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5800
5801
5802