blob: 309f75c06eeb94f077c53d8e9e6100766dfd37ac [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Baker89a7b7c2014-10-07 00:10:17 -07006from rest_framework import status
Scott Baker57c725c2014-11-12 01:13:53 -08007from rest_framework.generics import GenericAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04008from core.models import *
9from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -070010from rest_framework import filters
Scott Bakerd51d0bd2014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Scott Baker20101af2015-02-02 10:41:12 -080012from django.core.exceptions import PermissionDenied
Sapan Bhatiadea39432014-06-13 03:10:36 -040013
Scott Bakerf0480fb2014-12-23 11:12:07 -080014if hasattr(serializers, "ReadOnlyField"):
15 # rest_framework 3.x
16 IdField = serializers.ReadOnlyField
17else:
18 # rest_framework 2.x
19 IdField = serializers.Field
20
Sapan Bhatiadea39432014-06-13 03:10:36 -040021"""
Scott Baker2bcbf372014-10-29 23:41:11 -070022 Schema of the generator object:
23 all: Set of all Model objects
24 all_if(regex): Set of Model objects that match regex
Scott Baker57c725c2014-11-12 01:13:53 -080025
Scott Baker2bcbf372014-10-29 23:41:11 -070026 Model object:
27 plural: English plural of object name
28 camel: CamelCase version of object name
29 refs: list of references to other Model objects
30 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040031
Scott Baker2bcbf372014-10-29 23:41:11 -070032 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040033"""
34
Scott Bakerd51d0bd2014-11-10 16:31:15 -080035def get_REST_patterns():
36 return patterns('',
37 url(r'^plstackapi/$', api_root),
38
39 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
40 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
41
Scott Baker515dc9e2014-12-22 09:29:05 -080042 url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
43 url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
44
Scott Baker191f9b22015-01-12 13:16:39 -080045 url(r'plstackapi/controllersiteprivileges/$', ControllerSitePrivilegeList.as_view(), name='controllersiteprivilege-list'),
46 url(r'plstackapi/controllersiteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSitePrivilegeDetail.as_view(), name ='controllersiteprivilege-detail'),
47
Scott Bakerd51d0bd2014-11-10 16:31:15 -080048 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
49 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
50
51 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
52 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
53
54 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
55 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
56
57 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
58 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
59
60 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
61 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
62
63 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
64 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
65
66 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
67 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
68
69 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
70 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
71
72 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
73 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
74
Scott Baker191f9b22015-01-12 13:16:39 -080075 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
76 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
77
78 url(r'plstackapi/controllersites/$', ControllerSiteList.as_view(), name='controllersite-list'),
79 url(r'plstackapi/controllersites/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDetail.as_view(), name ='controllersite-detail'),
80
Scott Bakerd51d0bd2014-11-10 16:31:15 -080081 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
82 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
83
84 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
85 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
86
87 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
88 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
89
90 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
91 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
92
93 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
94 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
95
Scott Baker191f9b22015-01-12 13:16:39 -080096 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
97 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080098
99 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
100 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
101
102 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
103 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
104
105 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
106 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
107
108 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
109 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
110
111 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
112 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
113
114 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
115 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
116
117 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
118 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
119
120 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
121 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
122
Scott Baker191f9b22015-01-12 13:16:39 -0800123 url(r'plstackapi/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetwork-list'),
124 url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetwork-detail'),
125
Scott Baker515dc9e2014-12-22 09:29:05 -0800126 url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
127 url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800128
Scott Baker191f9b22015-01-12 13:16:39 -0800129 url(r'plstackapi/controllerusers/$', ControllerUserList.as_view(), name='controlleruser-list'),
130 url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controlleruser-detail'),
131
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800132 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
133 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
134
Scott Baker515dc9e2014-12-22 09:29:05 -0800135 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
136 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
137
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800138 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
139 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
140
141 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
142 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
143
Scott Baker515dc9e2014-12-22 09:29:05 -0800144 url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'),
145 url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
146
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800147 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
148 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
149
150 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
151 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
152
153 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
154 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
155
156 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
157 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
158
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800159 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
160 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
161
Scott Baker191f9b22015-01-12 13:16:39 -0800162 url(r'plstackapi/controllerslices/$', ControllerSliceList.as_view(), name='controllerslice-list'),
163 url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslice-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800164
Scott Bakerf2c0c512014-12-22 17:35:34 -0800165 url(r'plstackapi/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'),
166 url(r'plstackapi/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'),
167
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800168 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
169 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
170
Scott Baker515dc9e2014-12-22 09:29:05 -0800171 url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
172 url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
173
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800174 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
175 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
176
177 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
178 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
179
Scott Baker515dc9e2014-12-22 09:29:05 -0800180 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
181 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800182
Scott Baker191f9b22015-01-12 13:16:39 -0800183 url(r'plstackapi/controllersliceprivileges/$', ControllerSlicePrivilegeList.as_view(), name='controllersliceprivilege-list'),
184 url(r'plstackapi/controllersliceprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicePrivilegeDetail.as_view(), name ='controllersliceprivilege-detail'),
185
186 url(r'plstackapi/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployment-list'),
187 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployment-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800188
189 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
190 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800191
192 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
193 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
194
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800195 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
196 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
197
Scott Bakerf2c0c512014-12-22 17:35:34 -0800198 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
199 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800200
201 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
202 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
203
204 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
205 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
206
207 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400208
209@api_view(['GET'])
210def api_root(request, format=None):
211 return Response({
Scott Baker2bcbf372014-10-29 23:41:11 -0700212 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800213 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800214 'controllersiteprivileges': reverse('controllersiteprivilege-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700215 'images': reverse('image-list', request=request, format=format),
216 'networkparameters': reverse('networkparameter-list', request=request, format=format),
217 'sites': reverse('site-list', request=request, format=format),
218 'sliceroles': reverse('slicerole-list', request=request, format=format),
219 'tags': reverse('tag-list', request=request, format=format),
220 'invoices': reverse('invoice-list', request=request, format=format),
221 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
222 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
223 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800224 'flavors': reverse('flavor-list', request=request, format=format),
225 'controllersites': reverse('controllersite-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700226 'projects': reverse('project-list', request=request, format=format),
227 'slices': reverse('slice-list', request=request, format=format),
228 'networks': reverse('network-list', request=request, format=format),
229 'services': reverse('service-list', request=request, format=format),
230 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800231 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700232 'charges': reverse('charge-list', request=request, format=format),
233 'roles': reverse('role-list', request=request, format=format),
234 'usableobjects': reverse('usableobject-list', request=request, format=format),
235 'siteroles': reverse('siterole-list', request=request, format=format),
236 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
237 'slivers': reverse('sliver-list', request=request, format=format),
238 'nodes': reverse('node-list', request=request, format=format),
239 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800240 'controllernetworks': reverse('controllernetwork-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800241 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800242 'controllerusers': reverse('controlleruser-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700243 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800244 'payments': reverse('payment-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700245 'networkslices': reverse('networkslice-list', request=request, format=format),
246 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800247 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700248 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
249 'users': reverse('user-list', request=request, format=format),
250 'deployments': reverse('deployment-list', request=request, format=format),
251 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700252 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800253 'controllerslices': reverse('controllerslice-list', request=request, format=format),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800254 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700255 'accounts': reverse('account-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800256 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700257 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
258 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800259 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800260 'controllersliceprivileges': reverse('controllersliceprivilege-list', request=request, format=format),
261 'sitedeployments': reverse('sitedeployment-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800262 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700263 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700264 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800265 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700266 'routers': reverse('router-list', request=request, format=format),
267 'serviceresources': reverse('serviceresource-list', request=request, format=format),
268
Sapan Bhatiadea39432014-06-13 03:10:36 -0400269 })
270
271# Based on serializers.py
272
Scott Baker515dc9e2014-12-22 09:29:05 -0800273class XOSModelSerializer(serializers.ModelSerializer):
274 def save_object(self, obj, **kwargs):
275
276 """ rest_framework can't deal with ManyToMany relations that have a
277 through table. In plstackapi, most of the through tables we have
278 use defaults or blank fields, so there's no reason why we shouldn't
279 be able to save these objects.
280
281 So, let's strip out these m2m relations, and deal with them ourself.
282 """
283 obj._complex_m2m_data={};
284 if getattr(obj, '_m2m_data', None):
285 for relatedObject in obj._meta.get_all_related_many_to_many_objects():
286 if (relatedObject.field.rel.through._meta.auto_created):
287 # These are non-trough ManyToMany relations and
288 # can be updated just fine
289 continue
290 fieldName = relatedObject.get_accessor_name()
291 if fieldName in obj._m2m_data.keys():
292 obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
293 del obj._m2m_data[fieldName]
294
295 serializers.ModelSerializer.save_object(self, obj, **kwargs);
296
297 for (accessor, stuff) in obj._complex_m2m_data.items():
298 (relatedObject, data) = stuff
299 through = relatedObject.field.rel.through
300 local_fieldName = relatedObject.field.m2m_reverse_field_name()
301 remote_fieldName = relatedObject.field.m2m_field_name()
302
303 # get the current set of existing relations
304 existing = through.objects.filter(**{local_fieldName: obj});
305
306 data_ids = [item.id for item in data]
307 existing_ids = [getattr(item,remote_fieldName).id for item in existing]
308
309 #print "data_ids", data_ids
310 #print "existing_ids", existing_ids
311
312 # remove relations that are in 'existing' but not in 'data'
313 for item in list(existing):
314 if (getattr(item,remote_fieldName).id not in data_ids):
315 print "delete", getattr(item,remote_fieldName)
316 item.delete() #(purge=True)
317
318 # add relations that are in 'data' but not in 'existing'
319 for item in data:
320 if (item.id not in existing_ids):
321 #print "add", item
322 newModel = through(**{local_fieldName: obj, remote_fieldName: item})
323 newModel.save()
324
325
326
Scott Baker0caeaf02014-06-19 11:12:55 -0700327class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800328 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700329
Scott Bakerb744f1c2014-11-21 11:32:24 -0800330 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800331 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800332 def getHumanReadableName(self, obj):
333 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800334 def getValidators(self, obj):
335 try:
336 return obj.getValidators()
337 except:
338 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700339 class Meta:
340 model = ServiceAttribute
Scott Baker84cf39e2015-01-30 15:41:39 -0800341 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700342
Scott Baker515dc9e2014-12-22 09:29:05 -0800343class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800344 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700345
Scott Bakerb744f1c2014-11-21 11:32:24 -0800346 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800347 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800348 def getHumanReadableName(self, obj):
349 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800350 def getValidators(self, obj):
351 try:
352 return obj.getValidators()
353 except:
354 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800355 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700356 model = ServiceAttribute
Scott Baker84cf39e2015-01-30 15:41:39 -0800357 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700358
359
Sapan Bhatiadea39432014-06-13 03:10:36 -0400360
361
Scott Baker515dc9e2014-12-22 09:29:05 -0800362class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800363 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800364
365 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
366 validators = serializers.SerializerMethodField("getValidators")
367 def getHumanReadableName(self, obj):
368 return str(obj)
369 def getValidators(self, obj):
370 try:
371 return obj.getValidators()
372 except:
373 return None
374 class Meta:
375 model = ControllerImages
Scott Baker84cf39e2015-01-30 15:41:39 -0800376 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -0800377
378class ControllerImagesIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800379 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800380
381 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
382 validators = serializers.SerializerMethodField("getValidators")
383 def getHumanReadableName(self, obj):
384 return str(obj)
385 def getValidators(self, obj):
386 try:
387 return obj.getValidators()
388 except:
389 return None
390 class Meta:
391 model = ControllerImages
Scott Baker84cf39e2015-01-30 15:41:39 -0800392 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -0800393
394
395
396
Scott Baker191f9b22015-01-12 13:16:39 -0800397class ControllerSitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
398 id = IdField()
399
400 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
401 validators = serializers.SerializerMethodField("getValidators")
402 def getHumanReadableName(self, obj):
403 return str(obj)
404 def getValidators(self, obj):
405 try:
406 return obj.getValidators()
407 except:
408 return None
409 class Meta:
410 model = ControllerSitePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -0800411 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',)
Scott Baker191f9b22015-01-12 13:16:39 -0800412
413class ControllerSitePrivilegeIdSerializer(XOSModelSerializer):
414 id = IdField()
415
416 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
417 validators = serializers.SerializerMethodField("getValidators")
418 def getHumanReadableName(self, obj):
419 return str(obj)
420 def getValidators(self, obj):
421 try:
422 return obj.getValidators()
423 except:
424 return None
425 class Meta:
426 model = ControllerSitePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -0800427 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',)
Scott Baker191f9b22015-01-12 13:16:39 -0800428
429
430
431
Sapan Bhatiadea39432014-06-13 03:10:36 -0400432class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800433 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700434
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800435
436 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
437
438
Scott Bakerb744f1c2014-11-21 11:32:24 -0800439 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800440 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800441 def getHumanReadableName(self, obj):
442 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800443 def getValidators(self, obj):
444 try:
445 return obj.getValidators()
446 except:
447 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700448 class Meta:
449 model = Image
Scott Baker84cf39e2015-01-30 15:41:39 -0800450 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700451
Scott Baker515dc9e2014-12-22 09:29:05 -0800452class ImageIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800453 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700454
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800455
Scott Baker201f7da2014-12-23 10:56:06 -0800456 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800457
458
Scott Bakerb744f1c2014-11-21 11:32:24 -0800459 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800460 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800461 def getHumanReadableName(self, obj):
462 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800463 def getValidators(self, obj):
464 try:
465 return obj.getValidators()
466 except:
467 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800468 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700469 model = Image
Scott Baker84cf39e2015-01-30 15:41:39 -0800470 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700471
472
Sapan Bhatiadea39432014-06-13 03:10:36 -0400473
474
Scott Baker0caeaf02014-06-19 11:12:55 -0700475class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800476 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700477
Scott Bakerb744f1c2014-11-21 11:32:24 -0800478 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800479 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800480 def getHumanReadableName(self, obj):
481 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800482 def getValidators(self, obj):
483 try:
484 return obj.getValidators()
485 except:
486 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700487 class Meta:
488 model = NetworkParameter
Scott Baker84cf39e2015-01-30 15:41:39 -0800489 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700490
Scott Baker515dc9e2014-12-22 09:29:05 -0800491class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800492 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700493
Scott Bakerb744f1c2014-11-21 11:32:24 -0800494 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800495 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800496 def getHumanReadableName(self, obj):
497 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800498 def getValidators(self, obj):
499 try:
500 return obj.getValidators()
501 except:
502 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800503 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700504 model = NetworkParameter
Scott Baker84cf39e2015-01-30 15:41:39 -0800505 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700506
507
Sapan Bhatiadea39432014-06-13 03:10:36 -0400508
509
510class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800511 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700512
Scott Baker515dc9e2014-12-22 09:29:05 -0800513
514 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
515
516
Scott Bakerb744f1c2014-11-21 11:32:24 -0800517 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800518 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800519 def getHumanReadableName(self, obj):
520 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800521 def getValidators(self, obj):
522 try:
523 return obj.getValidators()
524 except:
525 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700526 class Meta:
527 model = Site
Scott Baker84cf39e2015-01-30 15:41:39 -0800528 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700529
Scott Baker515dc9e2014-12-22 09:29:05 -0800530class SiteIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800531 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700532
Scott Baker515dc9e2014-12-22 09:29:05 -0800533
Scott Baker201f7da2014-12-23 10:56:06 -0800534 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800535
536
Scott Bakerb744f1c2014-11-21 11:32:24 -0800537 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800538 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800539 def getHumanReadableName(self, obj):
540 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800541 def getValidators(self, obj):
542 try:
543 return obj.getValidators()
544 except:
545 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800546 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700547 model = Site
Scott Baker84cf39e2015-01-30 15:41:39 -0800548 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700549
550
Sapan Bhatiadea39432014-06-13 03:10:36 -0400551
552
Scott Baker0caeaf02014-06-19 11:12:55 -0700553class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800554 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700555
Scott Bakerb744f1c2014-11-21 11:32:24 -0800556 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800557 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800558 def getHumanReadableName(self, obj):
559 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800560 def getValidators(self, obj):
561 try:
562 return obj.getValidators()
563 except:
564 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700565 class Meta:
566 model = SliceRole
Scott Baker84cf39e2015-01-30 15:41:39 -0800567 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700568
Scott Baker515dc9e2014-12-22 09:29:05 -0800569class SliceRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800570 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700571
Scott Bakerb744f1c2014-11-21 11:32:24 -0800572 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800573 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800574 def getHumanReadableName(self, obj):
575 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800576 def getValidators(self, obj):
577 try:
578 return obj.getValidators()
579 except:
580 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800581 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700582 model = SliceRole
Scott Baker84cf39e2015-01-30 15:41:39 -0800583 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700584
585
Sapan Bhatiadea39432014-06-13 03:10:36 -0400586
587
588class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800589 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700590
Scott Bakerb744f1c2014-11-21 11:32:24 -0800591 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800592 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800593 def getHumanReadableName(self, obj):
594 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800595 def getValidators(self, obj):
596 try:
597 return obj.getValidators()
598 except:
599 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700600 class Meta:
601 model = Tag
Scott Baker84cf39e2015-01-30 15:41:39 -0800602 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700603
Scott Baker515dc9e2014-12-22 09:29:05 -0800604class TagIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800605 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700606
Scott Bakerb744f1c2014-11-21 11:32:24 -0800607 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800608 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800609 def getHumanReadableName(self, obj):
610 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800611 def getValidators(self, obj):
612 try:
613 return obj.getValidators()
614 except:
615 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800616 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700617 model = Tag
Scott Baker84cf39e2015-01-30 15:41:39 -0800618 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700619
620
Sapan Bhatiadea39432014-06-13 03:10:36 -0400621
622
623class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800624 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700625
Scott Bakerb744f1c2014-11-21 11:32:24 -0800626 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800627 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800628 def getHumanReadableName(self, obj):
629 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800630 def getValidators(self, obj):
631 try:
632 return obj.getValidators()
633 except:
634 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700635 class Meta:
636 model = Invoice
Scott Baker84cf39e2015-01-30 15:41:39 -0800637 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700638
Scott Baker515dc9e2014-12-22 09:29:05 -0800639class InvoiceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800640 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700641
Scott Bakerb744f1c2014-11-21 11:32:24 -0800642 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800643 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800644 def getHumanReadableName(self, obj):
645 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800646 def getValidators(self, obj):
647 try:
648 return obj.getValidators()
649 except:
650 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800651 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700652 model = Invoice
Scott Baker84cf39e2015-01-30 15:41:39 -0800653 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700654
655
Sapan Bhatiadea39432014-06-13 03:10:36 -0400656
657
Scott Baker0caeaf02014-06-19 11:12:55 -0700658class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800659 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700660
Scott Bakerb744f1c2014-11-21 11:32:24 -0800661 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800662 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800663 def getHumanReadableName(self, obj):
664 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800665 def getValidators(self, obj):
666 try:
667 return obj.getValidators()
668 except:
669 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700670 class Meta:
671 model = SlicePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -0800672 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700673
Scott Baker515dc9e2014-12-22 09:29:05 -0800674class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800675 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700676
Scott Bakerb744f1c2014-11-21 11:32:24 -0800677 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800678 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800679 def getHumanReadableName(self, obj):
680 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800681 def getValidators(self, obj):
682 try:
683 return obj.getValidators()
684 except:
685 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800686 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700687 model = SlicePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -0800688 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700689
690
Scott Baker0caeaf02014-06-19 11:12:55 -0700691
692
Scott Baker89a7b7c2014-10-07 00:10:17 -0700693class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800694 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700695
Scott Bakerb744f1c2014-11-21 11:32:24 -0800696 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800697 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800698 def getHumanReadableName(self, obj):
699 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800700 def getValidators(self, obj):
701 try:
702 return obj.getValidators()
703 except:
704 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700705 class Meta:
706 model = PlanetStackRole
Scott Baker84cf39e2015-01-30 15:41:39 -0800707 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700708
Scott Baker515dc9e2014-12-22 09:29:05 -0800709class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800710 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700711
Scott Bakerb744f1c2014-11-21 11:32:24 -0800712 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800713 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800714 def getHumanReadableName(self, obj):
715 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800716 def getValidators(self, obj):
717 try:
718 return obj.getValidators()
719 except:
720 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800721 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700722 model = PlanetStackRole
Scott Baker84cf39e2015-01-30 15:41:39 -0800723 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700724
725
726
727
Scott Baker0caeaf02014-06-19 11:12:55 -0700728class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800729 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700730
Scott Bakerb744f1c2014-11-21 11:32:24 -0800731 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800732 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800733 def getHumanReadableName(self, obj):
734 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800735 def getValidators(self, obj):
736 try:
737 return obj.getValidators()
738 except:
739 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700740 class Meta:
741 model = NetworkSliver
Scott Baker84cf39e2015-01-30 15:41:39 -0800742 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700743
Scott Baker515dc9e2014-12-22 09:29:05 -0800744class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800745 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700746
Scott Bakerb744f1c2014-11-21 11:32:24 -0800747 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800748 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800749 def getHumanReadableName(self, obj):
750 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800751 def getValidators(self, obj):
752 try:
753 return obj.getValidators()
754 except:
755 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800756 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700757 model = NetworkSliver
Scott Baker84cf39e2015-01-30 15:41:39 -0800758 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700759
760
Scott Baker0caeaf02014-06-19 11:12:55 -0700761
762
Scott Baker191f9b22015-01-12 13:16:39 -0800763class FlavorSerializer(serializers.HyperlinkedModelSerializer):
764 id = IdField()
765
766
767 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
768
769
770 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
771 validators = serializers.SerializerMethodField("getValidators")
772 def getHumanReadableName(self, obj):
773 return str(obj)
774 def getValidators(self, obj):
775 try:
776 return obj.getValidators()
777 except:
778 return None
779 class Meta:
780 model = Flavor
Scott Baker84cf39e2015-01-30 15:41:39 -0800781 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',)
Scott Baker191f9b22015-01-12 13:16:39 -0800782
783class FlavorIdSerializer(XOSModelSerializer):
784 id = IdField()
785
786
787 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
788
789
790 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
791 validators = serializers.SerializerMethodField("getValidators")
792 def getHumanReadableName(self, obj):
793 return str(obj)
794 def getValidators(self, obj):
795 try:
796 return obj.getValidators()
797 except:
798 return None
799 class Meta:
800 model = Flavor
Scott Baker84cf39e2015-01-30 15:41:39 -0800801 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',)
Scott Baker191f9b22015-01-12 13:16:39 -0800802
803
804
805
806class ControllerSiteSerializer(serializers.HyperlinkedModelSerializer):
807 id = IdField()
808
809 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
810 validators = serializers.SerializerMethodField("getValidators")
811 def getHumanReadableName(self, obj):
812 return str(obj)
813 def getValidators(self, obj):
814 try:
815 return obj.getValidators()
816 except:
817 return None
818 class Meta:
819 model = ControllerSite
Scott Baker84cf39e2015-01-30 15:41:39 -0800820 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Baker191f9b22015-01-12 13:16:39 -0800821
822class ControllerSiteIdSerializer(XOSModelSerializer):
823 id = IdField()
824
825 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
826 validators = serializers.SerializerMethodField("getValidators")
827 def getHumanReadableName(self, obj):
828 return str(obj)
829 def getValidators(self, obj):
830 try:
831 return obj.getValidators()
832 except:
833 return None
834 class Meta:
835 model = ControllerSite
Scott Baker84cf39e2015-01-30 15:41:39 -0800836 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Baker191f9b22015-01-12 13:16:39 -0800837
838
839
840
Scott Baker89a7b7c2014-10-07 00:10:17 -0700841class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800842 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700843
Scott Bakerb744f1c2014-11-21 11:32:24 -0800844 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800845 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800846 def getHumanReadableName(self, obj):
847 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800848 def getValidators(self, obj):
849 try:
850 return obj.getValidators()
851 except:
852 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700853 class Meta:
854 model = Project
Scott Baker84cf39e2015-01-30 15:41:39 -0800855 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700856
Scott Baker515dc9e2014-12-22 09:29:05 -0800857class ProjectIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800858 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700859
Scott Bakerb744f1c2014-11-21 11:32:24 -0800860 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800861 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800862 def getHumanReadableName(self, obj):
863 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800864 def getValidators(self, obj):
865 try:
866 return obj.getValidators()
867 except:
868 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800869 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700870 model = Project
Scott Baker84cf39e2015-01-30 15:41:39 -0800871 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700872
873
874
875
Sapan Bhatiadea39432014-06-13 03:10:36 -0400876class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800877 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700878
879
880 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
881
882
883
Scott Baker2bcbf372014-10-29 23:41:11 -0700884 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
885
886
Scott Bakerb744f1c2014-11-21 11:32:24 -0800887 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800888 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800889 def getHumanReadableName(self, obj):
890 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800891 def getValidators(self, obj):
892 try:
893 return obj.getValidators()
894 except:
895 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700896 class Meta:
897 model = Slice
Scott Baker84cf39e2015-01-30 15:41:39 -0800898 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700899
Scott Baker515dc9e2014-12-22 09:29:05 -0800900class SliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800901 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700902
903
Scott Baker201f7da2014-12-23 10:56:06 -0800904 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700905
906
907
Scott Baker201f7da2014-12-23 10:56:06 -0800908 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700909
910
Scott Bakerb744f1c2014-11-21 11:32:24 -0800911 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800912 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800913 def getHumanReadableName(self, obj):
914 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800915 def getValidators(self, obj):
916 try:
917 return obj.getValidators()
918 except:
919 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800920 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700921 model = Slice
Scott Baker84cf39e2015-01-30 15:41:39 -0800922 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700923
924
Sapan Bhatiadea39432014-06-13 03:10:36 -0400925
926
927class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800928 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700929
930
Scott Baker515dc9e2014-12-22 09:29:05 -0800931 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700932
933
934
Scott Baker515dc9e2014-12-22 09:29:05 -0800935 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
936
937
938
939 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700940
941
942
943 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
944
945
946
947 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
948
949
Scott Bakerb744f1c2014-11-21 11:32:24 -0800950 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800951 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800952 def getHumanReadableName(self, obj):
953 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800954 def getValidators(self, obj):
955 try:
956 return obj.getValidators()
957 except:
958 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700959 class Meta:
960 model = Network
Scott Baker84cf39e2015-01-30 15:41:39 -0800961 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700962
Scott Baker515dc9e2014-12-22 09:29:05 -0800963class NetworkIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800964 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700965
966
Scott Baker201f7da2014-12-23 10:56:06 -0800967 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700968
969
970
Scott Baker201f7da2014-12-23 10:56:06 -0800971 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700972
973
974
Scott Baker201f7da2014-12-23 10:56:06 -0800975 slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700976
977
978
Scott Baker201f7da2014-12-23 10:56:06 -0800979 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800980
981
982
Scott Baker201f7da2014-12-23 10:56:06 -0800983 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700984
985
Scott Bakerb744f1c2014-11-21 11:32:24 -0800986 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800987 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800988 def getHumanReadableName(self, obj):
989 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800990 def getValidators(self, obj):
991 try:
992 return obj.getValidators()
993 except:
994 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800995 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700996 model = Network
Scott Baker84cf39e2015-01-30 15:41:39 -0800997 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700998
999
Sapan Bhatiadea39432014-06-13 03:10:36 -04001000
1001
1002class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001003 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001004
Scott Bakerb744f1c2014-11-21 11:32:24 -08001005 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001006 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001007 def getHumanReadableName(self, obj):
1008 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001009 def getValidators(self, obj):
1010 try:
1011 return obj.getValidators()
1012 except:
1013 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001014 class Meta:
1015 model = Service
Scott Baker84cf39e2015-01-30 15:41:39 -08001016 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -07001017
Scott Baker515dc9e2014-12-22 09:29:05 -08001018class ServiceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001019 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001020
Scott Bakerb744f1c2014-11-21 11:32:24 -08001021 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001022 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001023 def getHumanReadableName(self, obj):
1024 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001025 def getValidators(self, obj):
1026 try:
1027 return obj.getValidators()
1028 except:
1029 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001030 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001031 model = Service
Scott Baker84cf39e2015-01-30 15:41:39 -08001032 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -07001033
1034
Sapan Bhatiadea39432014-06-13 03:10:36 -04001035
1036
Scott Baker0caeaf02014-06-19 11:12:55 -07001037class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001038 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001039
Scott Bakerb744f1c2014-11-21 11:32:24 -08001040 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001041 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001042 def getHumanReadableName(self, obj):
1043 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001044 def getValidators(self, obj):
1045 try:
1046 return obj.getValidators()
1047 except:
1048 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001049 class Meta:
1050 model = ServiceClass
Scott Baker84cf39e2015-01-30 15:41:39 -08001051 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001052
Scott Baker515dc9e2014-12-22 09:29:05 -08001053class ServiceClassIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001054 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001055
Scott Bakerb744f1c2014-11-21 11:32:24 -08001056 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001057 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001058 def getHumanReadableName(self, obj):
1059 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001060 def getValidators(self, obj):
1061 try:
1062 return obj.getValidators()
1063 except:
1064 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001065 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001066 model = ServiceClass
Scott Baker84cf39e2015-01-30 15:41:39 -08001067 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001068
1069
Sapan Bhatiadea39432014-06-13 03:10:36 -04001070
1071
Scott Baker191f9b22015-01-12 13:16:39 -08001072class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001073 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001074
Scott Bakerb744f1c2014-11-21 11:32:24 -08001075 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001076 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001077 def getHumanReadableName(self, obj):
1078 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001079 def getValidators(self, obj):
1080 try:
1081 return obj.getValidators()
1082 except:
1083 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001084 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08001085 model = PlanetStack
Scott Baker84cf39e2015-01-30 15:41:39 -08001086 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001087
Scott Baker191f9b22015-01-12 13:16:39 -08001088class PlanetStackIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001089 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001090
Scott Bakerb744f1c2014-11-21 11:32:24 -08001091 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001092 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001093 def getHumanReadableName(self, obj):
1094 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001095 def getValidators(self, obj):
1096 try:
1097 return obj.getValidators()
1098 except:
1099 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001100 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08001101 model = PlanetStack
Scott Baker84cf39e2015-01-30 15:41:39 -08001102 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001103
1104
Sapan Bhatiadea39432014-06-13 03:10:36 -04001105
1106
1107class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001108 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001109
Scott Bakerb744f1c2014-11-21 11:32:24 -08001110 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001111 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001112 def getHumanReadableName(self, obj):
1113 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001114 def getValidators(self, obj):
1115 try:
1116 return obj.getValidators()
1117 except:
1118 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001119 class Meta:
1120 model = Charge
Scott Baker84cf39e2015-01-30 15:41:39 -08001121 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -07001122
Scott Baker515dc9e2014-12-22 09:29:05 -08001123class ChargeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001124 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001125
Scott Bakerb744f1c2014-11-21 11:32:24 -08001126 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001127 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001128 def getHumanReadableName(self, obj):
1129 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001130 def getValidators(self, obj):
1131 try:
1132 return obj.getValidators()
1133 except:
1134 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001135 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001136 model = Charge
Scott Baker84cf39e2015-01-30 15:41:39 -08001137 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -07001138
1139
Sapan Bhatiadea39432014-06-13 03:10:36 -04001140
1141
1142class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001143 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001144
Scott Bakerb744f1c2014-11-21 11:32:24 -08001145 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001146 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001147 def getHumanReadableName(self, obj):
1148 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001149 def getValidators(self, obj):
1150 try:
1151 return obj.getValidators()
1152 except:
1153 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001154 class Meta:
1155 model = Role
Scott Baker84cf39e2015-01-30 15:41:39 -08001156 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001157
Scott Baker515dc9e2014-12-22 09:29:05 -08001158class RoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001159 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001160
Scott Bakerb744f1c2014-11-21 11:32:24 -08001161 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001162 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001163 def getHumanReadableName(self, obj):
1164 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001165 def getValidators(self, obj):
1166 try:
1167 return obj.getValidators()
1168 except:
1169 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001170 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001171 model = Role
Scott Baker84cf39e2015-01-30 15:41:39 -08001172 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001173
1174
Sapan Bhatiadea39432014-06-13 03:10:36 -04001175
1176
Scott Baker0caeaf02014-06-19 11:12:55 -07001177class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001178 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001179
Scott Bakerb744f1c2014-11-21 11:32:24 -08001180 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001181 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001182 def getHumanReadableName(self, obj):
1183 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001184 def getValidators(self, obj):
1185 try:
1186 return obj.getValidators()
1187 except:
1188 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001189 class Meta:
1190 model = UsableObject
Scott Baker84cf39e2015-01-30 15:41:39 -08001191 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001192
Scott Baker515dc9e2014-12-22 09:29:05 -08001193class UsableObjectIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001194 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001195
Scott Bakerb744f1c2014-11-21 11:32:24 -08001196 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001197 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001198 def getHumanReadableName(self, obj):
1199 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001200 def getValidators(self, obj):
1201 try:
1202 return obj.getValidators()
1203 except:
1204 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001205 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001206 model = UsableObject
Scott Baker84cf39e2015-01-30 15:41:39 -08001207 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001208
Scott Baker191f9b22015-01-12 13:16:39 -08001209
1210
1211
Scott Baker0caeaf02014-06-19 11:12:55 -07001212class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001213 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001214
Scott Bakerb744f1c2014-11-21 11:32:24 -08001215 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001216 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001217 def getHumanReadableName(self, obj):
1218 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001219 def getValidators(self, obj):
1220 try:
1221 return obj.getValidators()
1222 except:
1223 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001224 class Meta:
1225 model = SiteRole
Scott Baker84cf39e2015-01-30 15:41:39 -08001226 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001227
Scott Baker515dc9e2014-12-22 09:29:05 -08001228class SiteRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001229 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001230
Scott Bakerb744f1c2014-11-21 11:32:24 -08001231 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001232 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001233 def getHumanReadableName(self, obj):
1234 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001235 def getValidators(self, obj):
1236 try:
1237 return obj.getValidators()
1238 except:
1239 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001240 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001241 model = SiteRole
Scott Baker84cf39e2015-01-30 15:41:39 -08001242 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001243
1244
Scott Baker0caeaf02014-06-19 11:12:55 -07001245
1246
Scott Baker89a7b7c2014-10-07 00:10:17 -07001247class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001248 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001249
Scott Bakerb744f1c2014-11-21 11:32:24 -08001250 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001251 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001252 def getHumanReadableName(self, obj):
1253 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001254 def getValidators(self, obj):
1255 try:
1256 return obj.getValidators()
1257 except:
1258 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001259 class Meta:
1260 model = SliceCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08001261 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001262
Scott Baker515dc9e2014-12-22 09:29:05 -08001263class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001264 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001265
Scott Bakerb744f1c2014-11-21 11:32:24 -08001266 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001267 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001268 def getHumanReadableName(self, obj):
1269 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001270 def getValidators(self, obj):
1271 try:
1272 return obj.getValidators()
1273 except:
1274 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001275 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001276 model = SliceCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08001277 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001278
1279
1280
1281
Sapan Bhatiadea39432014-06-13 03:10:36 -04001282class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001283 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001284
1285
1286 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1287
1288
Scott Bakerb744f1c2014-11-21 11:32:24 -08001289 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001290 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001291 def getHumanReadableName(self, obj):
1292 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001293 def getValidators(self, obj):
1294 try:
1295 return obj.getValidators()
1296 except:
1297 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001298 class Meta:
1299 model = Sliver
Scott Baker84cf39e2015-01-30 15:41:39 -08001300 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001301
Scott Baker515dc9e2014-12-22 09:29:05 -08001302class SliverIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001303 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001304
1305
Scott Baker201f7da2014-12-23 10:56:06 -08001306 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -07001307
1308
Scott Bakerb744f1c2014-11-21 11:32:24 -08001309 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001310 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001311 def getHumanReadableName(self, obj):
1312 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001313 def getValidators(self, obj):
1314 try:
1315 return obj.getValidators()
1316 except:
1317 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001318 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001319 model = Sliver
Scott Baker84cf39e2015-01-30 15:41:39 -08001320 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001321
1322
Sapan Bhatiadea39432014-06-13 03:10:36 -04001323
1324
1325class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001326 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001327
Scott Bakerb744f1c2014-11-21 11:32:24 -08001328 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001329 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001330 def getHumanReadableName(self, obj):
1331 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001332 def getValidators(self, obj):
1333 try:
1334 return obj.getValidators()
1335 except:
1336 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001337 class Meta:
1338 model = Node
Scott Baker84cf39e2015-01-30 15:41:39 -08001339 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001340
Scott Baker515dc9e2014-12-22 09:29:05 -08001341class NodeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001342 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001343
Scott Bakerb744f1c2014-11-21 11:32:24 -08001344 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001345 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001346 def getHumanReadableName(self, obj):
1347 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001348 def getValidators(self, obj):
1349 try:
1350 return obj.getValidators()
1351 except:
1352 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001353 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001354 model = Node
Scott Baker84cf39e2015-01-30 15:41:39 -08001355 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001356
1357
Sapan Bhatiadea39432014-06-13 03:10:36 -04001358
1359
Scott Baker0caeaf02014-06-19 11:12:55 -07001360class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001361 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001362
Scott Baker515dc9e2014-12-22 09:29:05 -08001363
1364 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1365
1366
Scott Bakerb744f1c2014-11-21 11:32:24 -08001367 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001368 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001369 def getHumanReadableName(self, obj):
1370 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001371 def getValidators(self, obj):
1372 try:
1373 return obj.getValidators()
1374 except:
1375 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001376 class Meta:
1377 model = DashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001378 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',)
Scott Baker46b58542014-08-11 17:26:12 -07001379
Scott Baker515dc9e2014-12-22 09:29:05 -08001380class DashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001381 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001382
Scott Baker515dc9e2014-12-22 09:29:05 -08001383
Scott Baker201f7da2014-12-23 10:56:06 -08001384 controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001385
1386
Scott Bakerb744f1c2014-11-21 11:32:24 -08001387 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001388 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001389 def getHumanReadableName(self, obj):
1390 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001391 def getValidators(self, obj):
1392 try:
1393 return obj.getValidators()
1394 except:
1395 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001396 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001397 model = DashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001398 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001399
1400
1401
1402
Scott Baker191f9b22015-01-12 13:16:39 -08001403class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer):
1404 id = IdField()
1405
1406 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1407 validators = serializers.SerializerMethodField("getValidators")
1408 def getHumanReadableName(self, obj):
1409 return str(obj)
1410 def getValidators(self, obj):
1411 try:
1412 return obj.getValidators()
1413 except:
1414 return None
1415 class Meta:
1416 model = ControllerNetwork
Scott Baker84cf39e2015-01-30 15:41:39 -08001417 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker191f9b22015-01-12 13:16:39 -08001418
1419class ControllerNetworkIdSerializer(XOSModelSerializer):
1420 id = IdField()
1421
1422 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1423 validators = serializers.SerializerMethodField("getValidators")
1424 def getHumanReadableName(self, obj):
1425 return str(obj)
1426 def getValidators(self, obj):
1427 try:
1428 return obj.getValidators()
1429 except:
1430 return None
1431 class Meta:
1432 model = ControllerNetwork
Scott Baker84cf39e2015-01-30 15:41:39 -08001433 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker191f9b22015-01-12 13:16:39 -08001434
1435
1436
1437
Scott Baker515dc9e2014-12-22 09:29:05 -08001438class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001439 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001440
1441 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001442 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001443 def getHumanReadableName(self, obj):
1444 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001445 def getValidators(self, obj):
1446 try:
1447 return obj.getValidators()
1448 except:
1449 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001450 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001451 model = ImageDeployments
Scott Baker84cf39e2015-01-30 15:41:39 -08001452 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001453
Scott Baker515dc9e2014-12-22 09:29:05 -08001454class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001455 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001456
1457 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001458 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001459 def getHumanReadableName(self, obj):
1460 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001461 def getValidators(self, obj):
1462 try:
1463 return obj.getValidators()
1464 except:
1465 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001466 class Meta:
1467 model = ImageDeployments
Scott Baker84cf39e2015-01-30 15:41:39 -08001468 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001469
1470
Sapan Bhatiadea39432014-06-13 03:10:36 -04001471
1472
Scott Baker191f9b22015-01-12 13:16:39 -08001473class ControllerUserSerializer(serializers.HyperlinkedModelSerializer):
1474 id = IdField()
1475
1476 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1477 validators = serializers.SerializerMethodField("getValidators")
1478 def getHumanReadableName(self, obj):
1479 return str(obj)
1480 def getValidators(self, obj):
1481 try:
1482 return obj.getValidators()
1483 except:
1484 return None
1485 class Meta:
1486 model = ControllerUser
Scott Baker84cf39e2015-01-30 15:41:39 -08001487 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08001488
1489class ControllerUserIdSerializer(XOSModelSerializer):
1490 id = IdField()
1491
1492 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1493 validators = serializers.SerializerMethodField("getValidators")
1494 def getHumanReadableName(self, obj):
1495 return str(obj)
1496 def getValidators(self, obj):
1497 try:
1498 return obj.getValidators()
1499 except:
1500 return None
1501 class Meta:
1502 model = ControllerUser
Scott Baker84cf39e2015-01-30 15:41:39 -08001503 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08001504
1505
1506
1507
Scott Baker0caeaf02014-06-19 11:12:55 -07001508class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001509 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001510
Scott Bakerb744f1c2014-11-21 11:32:24 -08001511 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001512 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001513 def getHumanReadableName(self, obj):
1514 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001515 def getValidators(self, obj):
1516 try:
1517 return obj.getValidators()
1518 except:
1519 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001520 class Meta:
1521 model = ReservedResource
Scott Baker84cf39e2015-01-30 15:41:39 -08001522 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001523
Scott Baker515dc9e2014-12-22 09:29:05 -08001524class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001525 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001526
Scott Bakerb744f1c2014-11-21 11:32:24 -08001527 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001528 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001529 def getHumanReadableName(self, obj):
1530 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001531 def getValidators(self, obj):
1532 try:
1533 return obj.getValidators()
1534 except:
1535 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001536 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001537 model = ReservedResource
Scott Baker84cf39e2015-01-30 15:41:39 -08001538 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker8b533192014-11-17 22:32:19 -08001539
1540
1541
1542
Scott Baker515dc9e2014-12-22 09:29:05 -08001543class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001544 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001545
1546 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1547 validators = serializers.SerializerMethodField("getValidators")
1548 def getHumanReadableName(self, obj):
1549 return str(obj)
1550 def getValidators(self, obj):
1551 try:
1552 return obj.getValidators()
1553 except:
1554 return None
1555 class Meta:
1556 model = Payment
Scott Baker84cf39e2015-01-30 15:41:39 -08001557 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001558
1559class PaymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001560 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001561
1562 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1563 validators = serializers.SerializerMethodField("getValidators")
1564 def getHumanReadableName(self, obj):
1565 return str(obj)
1566 def getValidators(self, obj):
1567 try:
1568 return obj.getValidators()
1569 except:
1570 return None
1571 class Meta:
1572 model = Payment
Scott Baker84cf39e2015-01-30 15:41:39 -08001573 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001574
1575
1576
1577
Scott Baker0caeaf02014-06-19 11:12:55 -07001578class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001579 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001580
Scott Bakerb744f1c2014-11-21 11:32:24 -08001581 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001582 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001583 def getHumanReadableName(self, obj):
1584 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001585 def getValidators(self, obj):
1586 try:
1587 return obj.getValidators()
1588 except:
1589 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001590 class Meta:
1591 model = NetworkSlice
Scott Baker84cf39e2015-01-30 15:41:39 -08001592 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001593
Scott Baker515dc9e2014-12-22 09:29:05 -08001594class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001595 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001596
Scott Bakerb744f1c2014-11-21 11:32:24 -08001597 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001598 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001599 def getHumanReadableName(self, obj):
1600 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001601 def getValidators(self, obj):
1602 try:
1603 return obj.getValidators()
1604 except:
1605 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001606 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001607 model = NetworkSlice
Scott Baker84cf39e2015-01-30 15:41:39 -08001608 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001609
1610
Scott Baker0caeaf02014-06-19 11:12:55 -07001611
1612
1613class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001614 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001615
Scott Bakerb744f1c2014-11-21 11:32:24 -08001616 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001617 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001618 def getHumanReadableName(self, obj):
1619 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001620 def getValidators(self, obj):
1621 try:
1622 return obj.getValidators()
1623 except:
1624 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001625 class Meta:
1626 model = UserDashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001627 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001628
Scott Baker515dc9e2014-12-22 09:29:05 -08001629class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001630 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001631
Scott Bakerb744f1c2014-11-21 11:32:24 -08001632 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001633 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001634 def getHumanReadableName(self, obj):
1635 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001636 def getValidators(self, obj):
1637 try:
1638 return obj.getValidators()
1639 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001640 return None
1641 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001642 model = UserDashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001643 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',)
Scott Baker8b533192014-11-17 22:32:19 -08001644
1645
1646
1647
Scott Baker515dc9e2014-12-22 09:29:05 -08001648class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001649 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001650
Scott Baker515dc9e2014-12-22 09:29:05 -08001651
1652 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1653
1654
Scott Bakerb744f1c2014-11-21 11:32:24 -08001655 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001656 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001657 def getHumanReadableName(self, obj):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001658 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001659 def getValidators(self, obj):
1660 try:
1661 return obj.getValidators()
1662 except:
1663 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001664 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001665 model = Controller
Scott Baker84cf39e2015-01-30 15:41:39 -08001666 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
Scott Baker46b58542014-08-11 17:26:12 -07001667
Scott Baker515dc9e2014-12-22 09:29:05 -08001668class ControllerIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001669 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001670
1671
Scott Baker201f7da2014-12-23 10:56:06 -08001672 dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -07001673
1674
Scott Bakerb744f1c2014-11-21 11:32:24 -08001675 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001676 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001677 def getHumanReadableName(self, obj):
1678 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001679 def getValidators(self, obj):
1680 try:
1681 return obj.getValidators()
1682 except:
1683 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001684 class Meta:
1685 model = Controller
Scott Baker84cf39e2015-01-30 15:41:39 -08001686 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001687
1688
1689
1690
1691class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001692 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001693
1694 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1695 validators = serializers.SerializerMethodField("getValidators")
1696 def getHumanReadableName(self, obj):
1697 return str(obj)
1698 def getValidators(self, obj):
1699 try:
1700 return obj.getValidators()
1701 except:
1702 return None
1703 class Meta:
1704 model = PlanetStackPrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08001705 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001706
1707class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001708 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001709
1710 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1711 validators = serializers.SerializerMethodField("getValidators")
1712 def getHumanReadableName(self, obj):
1713 return str(obj)
1714 def getValidators(self, obj):
1715 try:
1716 return obj.getValidators()
1717 except:
1718 return None
1719 class Meta:
1720 model = PlanetStackPrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08001721 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001722
1723
1724
1725
1726class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001727 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001728
1729 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1730 validators = serializers.SerializerMethodField("getValidators")
1731 def getHumanReadableName(self, obj):
1732 return str(obj)
1733 def getValidators(self, obj):
1734 try:
1735 return obj.getValidators()
1736 except:
1737 return None
1738 class Meta:
1739 model = User
Scott Baker84cf39e2015-01-30 15:41:39 -08001740 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','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001741
1742class UserIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001743 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001744
1745 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1746 validators = serializers.SerializerMethodField("getValidators")
1747 def getHumanReadableName(self, obj):
1748 return str(obj)
1749 def getValidators(self, obj):
1750 try:
1751 return obj.getValidators()
1752 except:
1753 return None
1754 class Meta:
1755 model = User
Scott Baker84cf39e2015-01-30 15:41:39 -08001756 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','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001757
1758
1759
1760
1761class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001762 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001763
1764
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001765 images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1766
1767
1768
Scott Baker515dc9e2014-12-22 09:29:05 -08001769 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1770
1771
Scott Baker191f9b22015-01-12 13:16:39 -08001772
1773 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1774
1775
Scott Baker515dc9e2014-12-22 09:29:05 -08001776 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1777 validators = serializers.SerializerMethodField("getValidators")
1778 def getHumanReadableName(self, obj):
1779 return str(obj)
1780 def getValidators(self, obj):
1781 try:
1782 return obj.getValidators()
1783 except:
1784 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001785 class Meta:
1786 model = Deployment
Scott Baker84cf39e2015-01-30 15:41:39 -08001787 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001788
Scott Baker515dc9e2014-12-22 09:29:05 -08001789class DeploymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001790 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001791
1792
Scott Baker201f7da2014-12-23 10:56:06 -08001793 images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all())
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001794
1795
1796
Scott Baker201f7da2014-12-23 10:56:06 -08001797 sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001798
1799
Scott Baker191f9b22015-01-12 13:16:39 -08001800
1801 flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all())
1802
1803
Tony Mack06c8e472014-11-30 15:53:08 -05001804 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1805 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001806 def getHumanReadableName(self, obj):
1807 return str(obj)
1808 def getValidators(self, obj):
Tony Mack06c8e472014-11-30 15:53:08 -05001809 try:
1810 return obj.getValidators()
1811 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001812 return None
1813 class Meta:
1814 model = Deployment
Scott Baker84cf39e2015-01-30 15:41:39 -08001815 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',)
Tony Mack06c8e472014-11-30 15:53:08 -05001816
1817
Sapan Bhatiadea39432014-06-13 03:10:36 -04001818
1819
1820class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001821 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001822
Scott Bakerb744f1c2014-11-21 11:32:24 -08001823 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001824 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001825 def getHumanReadableName(self, obj):
1826 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001827 def getValidators(self, obj):
1828 try:
1829 return obj.getValidators()
1830 except:
1831 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001832 class Meta:
1833 model = Reservation
Scott Baker84cf39e2015-01-30 15:41:39 -08001834 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001835
Scott Baker515dc9e2014-12-22 09:29:05 -08001836class ReservationIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001837 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001838
Scott Bakerb744f1c2014-11-21 11:32:24 -08001839 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001840 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001841 def getHumanReadableName(self, obj):
1842 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001843 def getValidators(self, obj):
1844 try:
1845 return obj.getValidators()
1846 except:
1847 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001848 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001849 model = Reservation
Scott Baker84cf39e2015-01-30 15:41:39 -08001850 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001851
1852
Scott Baker0caeaf02014-06-19 11:12:55 -07001853
1854
Scott Bakerb744f1c2014-11-21 11:32:24 -08001855class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001856 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001857
1858 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001859 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001860 def getHumanReadableName(self, obj):
1861 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001862 def getValidators(self, obj):
1863 try:
1864 return obj.getValidators()
1865 except:
1866 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001867 class Meta:
1868 model = SitePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08001869 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001870
Scott Baker515dc9e2014-12-22 09:29:05 -08001871class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001872 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001873
1874 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001875 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001876 def getHumanReadableName(self, obj):
1877 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001878 def getValidators(self, obj):
1879 try:
1880 return obj.getValidators()
1881 except:
1882 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001883 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08001884 model = SitePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08001885 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001886
1887
1888
1889
Scott Baker191f9b22015-01-12 13:16:39 -08001890class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001891 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001892
1893 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001894 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001895 def getHumanReadableName(self, obj):
1896 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001897 def getValidators(self, obj):
1898 try:
1899 return obj.getValidators()
1900 except:
1901 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001902 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08001903 model = ControllerSlice
Scott Baker84cf39e2015-01-30 15:41:39 -08001904 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001905
Scott Baker191f9b22015-01-12 13:16:39 -08001906class ControllerSliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001907 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001908
1909 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001910 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001911 def getHumanReadableName(self, obj):
1912 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001913 def getValidators(self, obj):
1914 try:
1915 return obj.getValidators()
1916 except:
1917 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001918 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08001919 model = ControllerSlice
Scott Baker84cf39e2015-01-30 15:41:39 -08001920 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001921
1922
Sapan Bhatiadea39432014-06-13 03:10:36 -04001923
1924
Scott Bakerf2c0c512014-12-22 17:35:34 -08001925class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001926 id = IdField()
Scott Bakerf2c0c512014-12-22 17:35:34 -08001927
1928 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1929 validators = serializers.SerializerMethodField("getValidators")
1930 def getHumanReadableName(self, obj):
1931 return str(obj)
1932 def getValidators(self, obj):
1933 try:
1934 return obj.getValidators()
1935 except:
1936 return None
1937 class Meta:
1938 model = ControllerDashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001939 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakerf2c0c512014-12-22 17:35:34 -08001940
1941class ControllerDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001942 id = IdField()
Scott Bakerf2c0c512014-12-22 17:35:34 -08001943
1944 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1945 validators = serializers.SerializerMethodField("getValidators")
1946 def getHumanReadableName(self, obj):
1947 return str(obj)
1948 def getValidators(self, obj):
1949 try:
1950 return obj.getValidators()
1951 except:
1952 return None
1953 class Meta:
1954 model = ControllerDashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001955 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakerf2c0c512014-12-22 17:35:34 -08001956
1957
1958
1959
Sapan Bhatiadea39432014-06-13 03:10:36 -04001960class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001961 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001962
Scott Bakerb744f1c2014-11-21 11:32:24 -08001963 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001964 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001965 def getHumanReadableName(self, obj):
1966 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001967 def getValidators(self, obj):
1968 try:
1969 return obj.getValidators()
1970 except:
1971 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001972 class Meta:
1973 model = Account
Scott Baker84cf39e2015-01-30 15:41:39 -08001974 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001975
Scott Baker515dc9e2014-12-22 09:29:05 -08001976class AccountIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001977 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001978
Scott Bakerb744f1c2014-11-21 11:32:24 -08001979 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001980 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001981 def getHumanReadableName(self, obj):
1982 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001983 def getValidators(self, obj):
1984 try:
1985 return obj.getValidators()
1986 except:
1987 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001988 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001989 model = Account
Scott Baker84cf39e2015-01-30 15:41:39 -08001990 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001991
1992
Sapan Bhatiadea39432014-06-13 03:10:36 -04001993
1994
Scott Baker515dc9e2014-12-22 09:29:05 -08001995class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001996 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001997
1998 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1999 validators = serializers.SerializerMethodField("getValidators")
2000 def getHumanReadableName(self, obj):
2001 return str(obj)
2002 def getValidators(self, obj):
2003 try:
2004 return obj.getValidators()
2005 except:
2006 return None
2007 class Meta:
2008 model = ControllerRole
Scott Baker84cf39e2015-01-30 15:41:39 -08002009 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002010
2011class ControllerRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002012 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002013
2014 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2015 validators = serializers.SerializerMethodField("getValidators")
2016 def getHumanReadableName(self, obj):
2017 return str(obj)
2018 def getValidators(self, obj):
2019 try:
2020 return obj.getValidators()
2021 except:
2022 return None
2023 class Meta:
2024 model = ControllerRole
Scott Baker84cf39e2015-01-30 15:41:39 -08002025 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002026
2027
2028
2029
Scott Baker0caeaf02014-06-19 11:12:55 -07002030class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002031 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002032
Scott Bakerb744f1c2014-11-21 11:32:24 -08002033 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002034 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002035 def getHumanReadableName(self, obj):
2036 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002037 def getValidators(self, obj):
2038 try:
2039 return obj.getValidators()
2040 except:
2041 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002042 class Meta:
2043 model = NetworkParameterType
Scott Baker84cf39e2015-01-30 15:41:39 -08002044 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07002045
Scott Baker515dc9e2014-12-22 09:29:05 -08002046class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002047 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002048
Scott Bakerb744f1c2014-11-21 11:32:24 -08002049 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002050 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002051 def getHumanReadableName(self, obj):
2052 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002053 def getValidators(self, obj):
2054 try:
2055 return obj.getValidators()
2056 except:
2057 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002058 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002059 model = NetworkParameterType
Scott Baker84cf39e2015-01-30 15:41:39 -08002060 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07002061
2062
Sapan Bhatiadea39432014-06-13 03:10:36 -04002063
2064
Scott Baker89a7b7c2014-10-07 00:10:17 -07002065class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002066 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002067
Scott Bakerb744f1c2014-11-21 11:32:24 -08002068 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002069 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002070 def getHumanReadableName(self, obj):
2071 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002072 def getValidators(self, obj):
2073 try:
2074 return obj.getValidators()
2075 except:
2076 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002077 class Meta:
2078 model = SiteCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08002079 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002080
Scott Baker515dc9e2014-12-22 09:29:05 -08002081class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002082 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002083
Scott Bakerb744f1c2014-11-21 11:32:24 -08002084 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002085 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002086 def getHumanReadableName(self, obj):
2087 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002088 def getValidators(self, obj):
2089 try:
2090 return obj.getValidators()
2091 except:
2092 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002093 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002094 model = SiteCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08002095 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002096
2097
Scott Baker0caeaf02014-06-19 11:12:55 -07002098
2099
Scott Baker515dc9e2014-12-22 09:29:05 -08002100class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002101 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002102
Scott Bakerb744f1c2014-11-21 11:32:24 -08002103 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002104 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002105 def getHumanReadableName(self, obj):
2106 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002107 def getValidators(self, obj):
2108 try:
2109 return obj.getValidators()
2110 except:
2111 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002112 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08002113 model = DeploymentPrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08002114 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002115
Scott Baker515dc9e2014-12-22 09:29:05 -08002116class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002117 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002118
Scott Bakerb744f1c2014-11-21 11:32:24 -08002119 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002120 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002121 def getHumanReadableName(self, obj):
2122 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002123 def getValidators(self, obj):
2124 try:
2125 return obj.getValidators()
2126 except:
2127 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002128 class Meta:
2129 model = DeploymentPrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08002130 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',)
Scott Baker8b533192014-11-17 22:32:19 -08002131
2132
2133
2134
Scott Baker191f9b22015-01-12 13:16:39 -08002135class ControllerSlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002136 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002137
Scott Bakerb744f1c2014-11-21 11:32:24 -08002138 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002139 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002140 def getHumanReadableName(self, obj):
2141 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002142 def getValidators(self, obj):
2143 try:
2144 return obj.getValidators()
2145 except:
2146 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002147 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08002148 model = ControllerSlicePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08002149 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002150
Scott Baker191f9b22015-01-12 13:16:39 -08002151class ControllerSlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002152 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002153
2154 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2155 validators = serializers.SerializerMethodField("getValidators")
2156 def getHumanReadableName(self, obj):
2157 return str(obj)
2158 def getValidators(self, obj):
2159 try:
2160 return obj.getValidators()
2161 except:
2162 return None
2163 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08002164 model = ControllerSlicePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08002165 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08002166
2167
2168
2169
2170class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer):
2171 id = IdField()
2172
2173 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2174 validators = serializers.SerializerMethodField("getValidators")
2175 def getHumanReadableName(self, obj):
2176 return str(obj)
2177 def getValidators(self, obj):
2178 try:
2179 return obj.getValidators()
2180 except:
2181 return None
2182 class Meta:
2183 model = SiteDeployment
Scott Baker84cf39e2015-01-30 15:41:39 -08002184 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker191f9b22015-01-12 13:16:39 -08002185
2186class SiteDeploymentIdSerializer(XOSModelSerializer):
2187 id = IdField()
2188
2189 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2190 validators = serializers.SerializerMethodField("getValidators")
2191 def getHumanReadableName(self, obj):
2192 return str(obj)
2193 def getValidators(self, obj):
2194 try:
2195 return obj.getValidators()
2196 except:
2197 return None
2198 class Meta:
2199 model = SiteDeployment
Scott Baker84cf39e2015-01-30 15:41:39 -08002200 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002201
2202
2203
2204
2205class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002206 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002207
2208 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2209 validators = serializers.SerializerMethodField("getValidators")
2210 def getHumanReadableName(self, obj):
2211 return str(obj)
2212 def getValidators(self, obj):
2213 try:
2214 return obj.getValidators()
2215 except:
2216 return None
2217 class Meta:
2218 model = DeploymentRole
Scott Baker84cf39e2015-01-30 15:41:39 -08002219 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002220
Scott Baker515dc9e2014-12-22 09:29:05 -08002221class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002222 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002223
Scott Bakerb744f1c2014-11-21 11:32:24 -08002224 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002225 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002226 def getHumanReadableName(self, obj):
2227 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002228 def getValidators(self, obj):
2229 try:
2230 return obj.getValidators()
2231 except:
2232 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002233 class Meta:
2234 model = DeploymentRole
Scott Baker84cf39e2015-01-30 15:41:39 -08002235 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002236
2237
Sapan Bhatiadea39432014-06-13 03:10:36 -04002238
2239
Scott Baker89a7b7c2014-10-07 00:10:17 -07002240class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002241 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002242
Scott Bakerb744f1c2014-11-21 11:32:24 -08002243 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002244 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002245 def getHumanReadableName(self, obj):
2246 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002247 def getValidators(self, obj):
2248 try:
2249 return obj.getValidators()
2250 except:
2251 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002252 class Meta:
2253 model = UserCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08002254 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002255
Scott Baker515dc9e2014-12-22 09:29:05 -08002256class UserCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002257 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002258
Scott Bakerb744f1c2014-11-21 11:32:24 -08002259 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002260 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002261 def getHumanReadableName(self, obj):
2262 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002263 def getValidators(self, obj):
2264 try:
2265 return obj.getValidators()
2266 except:
2267 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002268 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002269 model = UserCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08002270 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08002271
2272
2273
2274
Scott Baker0caeaf02014-06-19 11:12:55 -07002275class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002276 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002277
Scott Bakerb744f1c2014-11-21 11:32:24 -08002278 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002279 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002280 def getHumanReadableName(self, obj):
2281 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002282 def getValidators(self, obj):
2283 try:
2284 return obj.getValidators()
2285 except:
2286 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002287 class Meta:
2288 model = SliceTag
Scott Baker84cf39e2015-01-30 15:41:39 -08002289 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002290
Scott Baker515dc9e2014-12-22 09:29:05 -08002291class SliceTagIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002292 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002293
Scott Bakerb744f1c2014-11-21 11:32:24 -08002294 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002295 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002296 def getHumanReadableName(self, obj):
2297 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002298 def getValidators(self, obj):
2299 try:
2300 return obj.getValidators()
2301 except:
2302 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002303 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002304 model = SliceTag
Scott Baker84cf39e2015-01-30 15:41:39 -08002305 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002306
2307
Scott Baker0caeaf02014-06-19 11:12:55 -07002308
2309
Scott Bakerf2c0c512014-12-22 17:35:34 -08002310class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002311 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002312
Scott Bakerb744f1c2014-11-21 11:32:24 -08002313 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002314 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002315 def getHumanReadableName(self, obj):
2316 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002317 def getValidators(self, obj):
2318 try:
2319 return obj.getValidators()
2320 except:
2321 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002322 class Meta:
Scott Bakerf2c0c512014-12-22 17:35:34 -08002323 model = NetworkTemplate
Scott Baker84cf39e2015-01-30 15:41:39 -08002324 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','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 -07002325
Scott Bakerf2c0c512014-12-22 17:35:34 -08002326class NetworkTemplateIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002327 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002328
Scott Bakerb744f1c2014-11-21 11:32:24 -08002329 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002330 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002331 def getHumanReadableName(self, obj):
2332 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002333 def getValidators(self, obj):
2334 try:
2335 return obj.getValidators()
2336 except:
2337 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002338 class Meta:
Scott Bakerf2c0c512014-12-22 17:35:34 -08002339 model = NetworkTemplate
Scott Baker84cf39e2015-01-30 15:41:39 -08002340 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','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 -07002341
2342
Sapan Bhatiadea39432014-06-13 03:10:36 -04002343
2344
2345class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002346 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002347
Scott Baker515dc9e2014-12-22 09:29:05 -08002348
2349 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2350
2351
2352
2353 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2354
2355
Scott Bakerb744f1c2014-11-21 11:32:24 -08002356 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002357 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002358 def getHumanReadableName(self, obj):
2359 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002360 def getValidators(self, obj):
2361 try:
2362 return obj.getValidators()
2363 except:
2364 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002365 class Meta:
2366 model = Router
Scott Baker84cf39e2015-01-30 15:41:39 -08002367 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002368
Scott Baker515dc9e2014-12-22 09:29:05 -08002369class RouterIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002370 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002371
Scott Baker515dc9e2014-12-22 09:29:05 -08002372
Scott Baker201f7da2014-12-23 10:56:06 -08002373 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08002374
2375
2376
Scott Baker201f7da2014-12-23 10:56:06 -08002377 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08002378
2379
Scott Bakerb744f1c2014-11-21 11:32:24 -08002380 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002381 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002382 def getHumanReadableName(self, obj):
2383 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002384 def getValidators(self, obj):
2385 try:
2386 return obj.getValidators()
2387 except:
2388 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002389 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002390 model = Router
Scott Baker84cf39e2015-01-30 15:41:39 -08002391 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002392
2393
Sapan Bhatiadea39432014-06-13 03:10:36 -04002394
2395
Scott Baker0caeaf02014-06-19 11:12:55 -07002396class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002397 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002398
Scott Bakerb744f1c2014-11-21 11:32:24 -08002399 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002400 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002401 def getHumanReadableName(self, obj):
2402 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002403 def getValidators(self, obj):
2404 try:
2405 return obj.getValidators()
2406 except:
2407 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002408 class Meta:
2409 model = ServiceResource
Scott Baker84cf39e2015-01-30 15:41:39 -08002410 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002411
Scott Baker515dc9e2014-12-22 09:29:05 -08002412class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002413 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002414
Scott Bakerb744f1c2014-11-21 11:32:24 -08002415 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002416 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002417 def getHumanReadableName(self, obj):
2418 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002419 def getValidators(self, obj):
2420 try:
2421 return obj.getValidators()
2422 except:
2423 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002424 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002425 model = ServiceResource
Scott Baker84cf39e2015-01-30 15:41:39 -08002426 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002427
2428
Sapan Bhatiadea39432014-06-13 03:10:36 -04002429
2430
2431serializerLookUp = {
2432
Scott Baker0caeaf02014-06-19 11:12:55 -07002433 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002434
Scott Baker515dc9e2014-12-22 09:29:05 -08002435 ControllerImages: ControllerImagesSerializer,
2436
Scott Baker191f9b22015-01-12 13:16:39 -08002437 ControllerSitePrivilege: ControllerSitePrivilegeSerializer,
2438
Sapan Bhatiadea39432014-06-13 03:10:36 -04002439 Image: ImageSerializer,
2440
Scott Baker0caeaf02014-06-19 11:12:55 -07002441 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002442
2443 Site: SiteSerializer,
2444
Scott Baker0caeaf02014-06-19 11:12:55 -07002445 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002446
2447 Tag: TagSerializer,
2448
2449 Invoice: InvoiceSerializer,
2450
Scott Baker0caeaf02014-06-19 11:12:55 -07002451 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002452
Scott Baker89a7b7c2014-10-07 00:10:17 -07002453 PlanetStackRole: PlanetStackRoleSerializer,
2454
Scott Baker0caeaf02014-06-19 11:12:55 -07002455 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002456
Scott Baker191f9b22015-01-12 13:16:39 -08002457 Flavor: FlavorSerializer,
2458
2459 ControllerSite: ControllerSiteSerializer,
2460
Scott Baker89a7b7c2014-10-07 00:10:17 -07002461 Project: ProjectSerializer,
2462
Sapan Bhatiadea39432014-06-13 03:10:36 -04002463 Slice: SliceSerializer,
2464
2465 Network: NetworkSerializer,
2466
2467 Service: ServiceSerializer,
2468
Scott Baker0caeaf02014-06-19 11:12:55 -07002469 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002470
Scott Baker191f9b22015-01-12 13:16:39 -08002471 PlanetStack: PlanetStackSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002472
2473 Charge: ChargeSerializer,
2474
2475 Role: RoleSerializer,
2476
Scott Baker0caeaf02014-06-19 11:12:55 -07002477 UsableObject: UsableObjectSerializer,
2478
2479 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002480
Scott Baker89a7b7c2014-10-07 00:10:17 -07002481 SliceCredential: SliceCredentialSerializer,
2482
Sapan Bhatiadea39432014-06-13 03:10:36 -04002483 Sliver: SliverSerializer,
2484
2485 Node: NodeSerializer,
2486
Scott Baker0caeaf02014-06-19 11:12:55 -07002487 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002488
Scott Baker191f9b22015-01-12 13:16:39 -08002489 ControllerNetwork: ControllerNetworkSerializer,
2490
Scott Baker515dc9e2014-12-22 09:29:05 -08002491 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002492
Scott Baker191f9b22015-01-12 13:16:39 -08002493 ControllerUser: ControllerUserSerializer,
2494
Scott Bakerb744f1c2014-11-21 11:32:24 -08002495 ReservedResource: ReservedResourceSerializer,
Scott Baker8b533192014-11-17 22:32:19 -08002496
Scott Baker515dc9e2014-12-22 09:29:05 -08002497 Payment: PaymentSerializer,
2498
Scott Baker0caeaf02014-06-19 11:12:55 -07002499 NetworkSlice: NetworkSliceSerializer,
2500
2501 UserDashboardView: UserDashboardViewSerializer,
2502
Scott Baker515dc9e2014-12-22 09:29:05 -08002503 Controller: ControllerSerializer,
2504
Scott Baker0caeaf02014-06-19 11:12:55 -07002505 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002506
2507 User: UserSerializer,
2508
2509 Deployment: DeploymentSerializer,
2510
2511 Reservation: ReservationSerializer,
2512
Scott Baker0caeaf02014-06-19 11:12:55 -07002513 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002514
Scott Baker191f9b22015-01-12 13:16:39 -08002515 ControllerSlice: ControllerSliceSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002516
Scott Bakerf2c0c512014-12-22 17:35:34 -08002517 ControllerDashboardView: ControllerDashboardViewSerializer,
2518
Sapan Bhatiadea39432014-06-13 03:10:36 -04002519 Account: AccountSerializer,
2520
Scott Baker515dc9e2014-12-22 09:29:05 -08002521 ControllerRole: ControllerRoleSerializer,
2522
Scott Baker0caeaf02014-06-19 11:12:55 -07002523 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002524
Scott Baker89a7b7c2014-10-07 00:10:17 -07002525 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002526
Scott Baker515dc9e2014-12-22 09:29:05 -08002527 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002528
Scott Baker191f9b22015-01-12 13:16:39 -08002529 ControllerSlicePrivilege: ControllerSlicePrivilegeSerializer,
2530
2531 SiteDeployment: SiteDeploymentSerializer,
Scott Baker515dc9e2014-12-22 09:29:05 -08002532
2533 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002534
Scott Baker89a7b7c2014-10-07 00:10:17 -07002535 UserCredential: UserCredentialSerializer,
2536
Scott Baker0caeaf02014-06-19 11:12:55 -07002537 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002538
Scott Bakerf2c0c512014-12-22 17:35:34 -08002539 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002540
2541 Router: RouterSerializer,
2542
Scott Baker0caeaf02014-06-19 11:12:55 -07002543 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002544
2545 None: None,
2546 }
2547
Scott Baker89a7b7c2014-10-07 00:10:17 -07002548class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2549
2550 # To handle fine-grained field permissions, we have to check can_update
2551 # the object has been updated but before it has been saved.
2552
2553 def update(self, request, *args, **kwargs):
2554 partial = kwargs.pop('partial', False)
2555 self.object = self.get_object_or_none()
2556
2557 serializer = self.get_serializer(self.object, data=request.DATA,
2558 files=request.FILES, partial=partial)
2559
2560 if not serializer.is_valid():
Scott Baker96eb3fd2014-11-25 00:53:25 -08002561 response = {"error": "validation",
2562 "specific_error": "not serializer.is_valid()",
2563 "reasons": serializer.errors}
2564 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002565
2566 try:
2567 self.pre_save(serializer.object)
2568 except ValidationError as err:
2569 # full_clean on model instance may be called in pre_save,
2570 # so we have to handle eventual errors.
Scott Baker96eb3fd2014-11-25 00:53:25 -08002571 response = {"error": "validation",
2572 "specific_error": "ValidationError in pre_save",
2573 "reasons": err.message_dict}
2574 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002575
2576 if serializer.object is not None:
2577 if not serializer.object.can_update(request.user):
2578 return Response(status=status.HTTP_400_BAD_REQUEST)
2579
2580 if self.object is None:
2581 self.object = serializer.save(force_insert=True)
2582 self.post_save(self.object, created=True)
2583 return Response(serializer.data, status=status.HTTP_201_CREATED)
2584
2585 self.object = serializer.save(force_update=True)
2586 self.post_save(self.object, created=False)
2587 return Response(serializer.data, status=status.HTTP_200_OK)
2588
2589 def destroy(self, request, *args, **kwargs):
2590 obj = self.get_object()
2591 if obj.can_update(request.user):
Scott Baker2bcbf372014-10-29 23:41:11 -07002592 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002593 else:
2594 return Response(status=status.HTTP_400_BAD_REQUEST)
2595
2596
Sapan Bhatiadea39432014-06-13 03:10:36 -04002597# Based on core/views/*.py
2598
2599
Scott Baker0caeaf02014-06-19 11:12:55 -07002600class ServiceAttributeList(generics.ListCreateAPIView):
2601 queryset = ServiceAttribute.objects.select_related().all()
2602 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002603 id_serializer_class = ServiceAttributeIdSerializer
2604 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002605 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -07002606
2607 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002608 no_hyperlinks=False
2609 if hasattr(self.request,"QUERY_PARAMS"):
2610 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002611 if (no_hyperlinks):
2612 return self.id_serializer_class
2613 else:
2614 return self.serializer_class
2615
Scott Baker0caeaf02014-06-19 11:12:55 -07002616 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002617 if (not self.request.user.is_authenticated()):
2618 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002619 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002620
Scott Baker0caeaf02014-06-19 11:12:55 -07002621 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002622 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2623 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002624 response = {"error": "validation",
2625 "specific_error": "not serializer.is_valid()",
2626 "reasons": serializer.errors}
2627 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002628 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002629 obj.caller = request.user
2630 if obj.can_update(request.user):
2631 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2632 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002633 raise Exception("failed obj.can_update")
2634
2635 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2636 if (ret.status_code%100 != 200):
2637 raise Exception(ret.data)
2638
2639 return ret
2640
Scott Baker0caeaf02014-06-19 11:12:55 -07002641
Scott Baker89a7b7c2014-10-07 00:10:17 -07002642class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002643 queryset = ServiceAttribute.objects.select_related().all()
2644 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002645 id_serializer_class = ServiceAttributeIdSerializer
2646
2647 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002648 no_hyperlinks=False
2649 if hasattr(self.request,"QUERY_PARAMS"):
2650 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002651 if (no_hyperlinks):
2652 return self.id_serializer_class
2653 else:
2654 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002655
Scott Baker0caeaf02014-06-19 11:12:55 -07002656 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002657 if (not self.request.user.is_authenticated()):
2658 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002659 return ServiceAttribute.select_by_user(self.request.user)
2660
Scott Baker89a7b7c2014-10-07 00:10:17 -07002661 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002662
Scott Baker89a7b7c2014-10-07 00:10:17 -07002663 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002664
2665
2666
Scott Baker515dc9e2014-12-22 09:29:05 -08002667class ControllerImagesList(generics.ListCreateAPIView):
2668 queryset = ControllerImages.objects.select_related().all()
2669 serializer_class = ControllerImagesSerializer
2670 id_serializer_class = ControllerImagesIdSerializer
2671 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002672 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002673
2674 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002675 no_hyperlinks=False
2676 if hasattr(self.request,"QUERY_PARAMS"):
2677 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08002678 if (no_hyperlinks):
2679 return self.id_serializer_class
2680 else:
2681 return self.serializer_class
2682
2683 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002684 if (not self.request.user.is_authenticated()):
2685 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08002686 return ControllerImages.select_by_user(self.request.user)
2687
2688 def create(self, request, *args, **kwargs):
2689 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2690 if not (serializer.is_valid()):
2691 response = {"error": "validation",
2692 "specific_error": "not serializer.is_valid()",
2693 "reasons": serializer.errors}
2694 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2695 obj = serializer.object
2696 obj.caller = request.user
2697 if obj.can_update(request.user):
2698 return super(ControllerImagesList, self).create(request, *args, **kwargs)
2699 else:
2700 raise Exception("failed obj.can_update")
2701
2702 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2703 if (ret.status_code%100 != 200):
2704 raise Exception(ret.data)
2705
2706 return ret
2707
2708
2709class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2710 queryset = ControllerImages.objects.select_related().all()
2711 serializer_class = ControllerImagesSerializer
2712 id_serializer_class = ControllerImagesIdSerializer
2713
2714 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002715 no_hyperlinks=False
2716 if hasattr(self.request,"QUERY_PARAMS"):
2717 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08002718 if (no_hyperlinks):
2719 return self.id_serializer_class
2720 else:
2721 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002722
Scott Baker515dc9e2014-12-22 09:29:05 -08002723 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002724 if (not self.request.user.is_authenticated()):
2725 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08002726 return ControllerImages.select_by_user(self.request.user)
2727
2728 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2729
2730 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2731
2732
2733
Scott Baker191f9b22015-01-12 13:16:39 -08002734class ControllerSitePrivilegeList(generics.ListCreateAPIView):
2735 queryset = ControllerSitePrivilege.objects.select_related().all()
2736 serializer_class = ControllerSitePrivilegeSerializer
2737 id_serializer_class = ControllerSitePrivilegeIdSerializer
2738 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002739 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08002740
2741 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002742 no_hyperlinks=False
2743 if hasattr(self.request,"QUERY_PARAMS"):
2744 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08002745 if (no_hyperlinks):
2746 return self.id_serializer_class
2747 else:
2748 return self.serializer_class
2749
2750 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002751 if (not self.request.user.is_authenticated()):
2752 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08002753 return ControllerSitePrivilege.select_by_user(self.request.user)
2754
2755 def create(self, request, *args, **kwargs):
2756 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2757 if not (serializer.is_valid()):
2758 response = {"error": "validation",
2759 "specific_error": "not serializer.is_valid()",
2760 "reasons": serializer.errors}
2761 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2762 obj = serializer.object
2763 obj.caller = request.user
2764 if obj.can_update(request.user):
2765 return super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
2766 else:
2767 raise Exception("failed obj.can_update")
2768
2769 ret = super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
2770 if (ret.status_code%100 != 200):
2771 raise Exception(ret.data)
2772
2773 return ret
2774
2775
2776class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2777 queryset = ControllerSitePrivilege.objects.select_related().all()
2778 serializer_class = ControllerSitePrivilegeSerializer
2779 id_serializer_class = ControllerSitePrivilegeIdSerializer
2780
2781 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002782 no_hyperlinks=False
2783 if hasattr(self.request,"QUERY_PARAMS"):
2784 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08002785 if (no_hyperlinks):
2786 return self.id_serializer_class
2787 else:
2788 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002789
Scott Baker191f9b22015-01-12 13:16:39 -08002790 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002791 if (not self.request.user.is_authenticated()):
2792 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08002793 return ControllerSitePrivilege.select_by_user(self.request.user)
2794
2795 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2796
2797 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2798
2799
2800
Sapan Bhatiadea39432014-06-13 03:10:36 -04002801class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002802 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002803 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002804 id_serializer_class = ImageIdSerializer
2805 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002806 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002807
2808 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002809 no_hyperlinks=False
2810 if hasattr(self.request,"QUERY_PARAMS"):
2811 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002812 if (no_hyperlinks):
2813 return self.id_serializer_class
2814 else:
2815 return self.serializer_class
2816
Scott Baker0caeaf02014-06-19 11:12:55 -07002817 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002818 if (not self.request.user.is_authenticated()):
2819 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002820 return Image.select_by_user(self.request.user)
2821
2822 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002823 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2824 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002825 response = {"error": "validation",
2826 "specific_error": "not serializer.is_valid()",
2827 "reasons": serializer.errors}
2828 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002829 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002830 obj.caller = request.user
2831 if obj.can_update(request.user):
2832 return super(ImageList, self).create(request, *args, **kwargs)
2833 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002834 raise Exception("failed obj.can_update")
2835
2836 ret = super(ImageList, self).create(request, *args, **kwargs)
2837 if (ret.status_code%100 != 200):
2838 raise Exception(ret.data)
2839
2840 return ret
2841
Sapan Bhatiadea39432014-06-13 03:10:36 -04002842
Scott Baker89a7b7c2014-10-07 00:10:17 -07002843class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002844 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002845 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002846 id_serializer_class = ImageIdSerializer
2847
2848 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002849 no_hyperlinks=False
2850 if hasattr(self.request,"QUERY_PARAMS"):
2851 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002852 if (no_hyperlinks):
2853 return self.id_serializer_class
2854 else:
2855 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002856
Scott Baker0caeaf02014-06-19 11:12:55 -07002857 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002858 if (not self.request.user.is_authenticated()):
2859 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002860 return Image.select_by_user(self.request.user)
2861
Scott Baker89a7b7c2014-10-07 00:10:17 -07002862 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002863
Scott Baker89a7b7c2014-10-07 00:10:17 -07002864 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002865
2866
2867
Scott Baker0caeaf02014-06-19 11:12:55 -07002868class NetworkParameterList(generics.ListCreateAPIView):
2869 queryset = NetworkParameter.objects.select_related().all()
2870 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002871 id_serializer_class = NetworkParameterIdSerializer
2872 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002873 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002874
2875 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002876 no_hyperlinks=False
2877 if hasattr(self.request,"QUERY_PARAMS"):
2878 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002879 if (no_hyperlinks):
2880 return self.id_serializer_class
2881 else:
2882 return self.serializer_class
2883
Scott Baker0caeaf02014-06-19 11:12:55 -07002884 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002885 if (not self.request.user.is_authenticated()):
2886 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002887 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002888
Scott Baker0caeaf02014-06-19 11:12:55 -07002889 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002890 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2891 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002892 response = {"error": "validation",
2893 "specific_error": "not serializer.is_valid()",
2894 "reasons": serializer.errors}
2895 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002896 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002897 obj.caller = request.user
2898 if obj.can_update(request.user):
2899 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2900 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002901 raise Exception("failed obj.can_update")
2902
2903 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2904 if (ret.status_code%100 != 200):
2905 raise Exception(ret.data)
2906
2907 return ret
2908
Scott Baker0caeaf02014-06-19 11:12:55 -07002909
Scott Baker89a7b7c2014-10-07 00:10:17 -07002910class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002911 queryset = NetworkParameter.objects.select_related().all()
2912 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002913 id_serializer_class = NetworkParameterIdSerializer
2914
2915 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002916 no_hyperlinks=False
2917 if hasattr(self.request,"QUERY_PARAMS"):
2918 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002919 if (no_hyperlinks):
2920 return self.id_serializer_class
2921 else:
2922 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002923
Scott Baker0caeaf02014-06-19 11:12:55 -07002924 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002925 if (not self.request.user.is_authenticated()):
2926 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002927 return NetworkParameter.select_by_user(self.request.user)
2928
Scott Baker89a7b7c2014-10-07 00:10:17 -07002929 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002930
Scott Baker89a7b7c2014-10-07 00:10:17 -07002931 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002932
2933
2934
2935class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002936 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002937 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002938 id_serializer_class = SiteIdSerializer
2939 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002940 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002941
2942 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002943 no_hyperlinks=False
2944 if hasattr(self.request,"QUERY_PARAMS"):
2945 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002946 if (no_hyperlinks):
2947 return self.id_serializer_class
2948 else:
2949 return self.serializer_class
2950
Scott Baker0caeaf02014-06-19 11:12:55 -07002951 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002952 if (not self.request.user.is_authenticated()):
2953 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002954 return Site.select_by_user(self.request.user)
2955
2956 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002957 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2958 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002959 response = {"error": "validation",
2960 "specific_error": "not serializer.is_valid()",
2961 "reasons": serializer.errors}
2962 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002963 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002964 obj.caller = request.user
2965 if obj.can_update(request.user):
2966 return super(SiteList, self).create(request, *args, **kwargs)
2967 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002968 raise Exception("failed obj.can_update")
2969
2970 ret = super(SiteList, self).create(request, *args, **kwargs)
2971 if (ret.status_code%100 != 200):
2972 raise Exception(ret.data)
2973
2974 return ret
2975
Sapan Bhatiadea39432014-06-13 03:10:36 -04002976
Scott Baker89a7b7c2014-10-07 00:10:17 -07002977class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002978 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002979 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002980 id_serializer_class = SiteIdSerializer
2981
2982 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002983 no_hyperlinks=False
2984 if hasattr(self.request,"QUERY_PARAMS"):
2985 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002986 if (no_hyperlinks):
2987 return self.id_serializer_class
2988 else:
2989 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002990
Scott Baker0caeaf02014-06-19 11:12:55 -07002991 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002992 if (not self.request.user.is_authenticated()):
2993 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002994 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002995
Scott Baker89a7b7c2014-10-07 00:10:17 -07002996 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002997
Scott Baker89a7b7c2014-10-07 00:10:17 -07002998 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002999
3000
3001
3002class SliceRoleList(generics.ListCreateAPIView):
3003 queryset = SliceRole.objects.select_related().all()
3004 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003005 id_serializer_class = SliceRoleIdSerializer
3006 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003007 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07003008
3009 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003010 no_hyperlinks=False
3011 if hasattr(self.request,"QUERY_PARAMS"):
3012 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003013 if (no_hyperlinks):
3014 return self.id_serializer_class
3015 else:
3016 return self.serializer_class
3017
Scott Baker0caeaf02014-06-19 11:12:55 -07003018 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003019 if (not self.request.user.is_authenticated()):
3020 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003021 return SliceRole.select_by_user(self.request.user)
3022
3023 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003024 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3025 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003026 response = {"error": "validation",
3027 "specific_error": "not serializer.is_valid()",
3028 "reasons": serializer.errors}
3029 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003030 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003031 obj.caller = request.user
3032 if obj.can_update(request.user):
3033 return super(SliceRoleList, self).create(request, *args, **kwargs)
3034 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003035 raise Exception("failed obj.can_update")
3036
3037 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
3038 if (ret.status_code%100 != 200):
3039 raise Exception(ret.data)
3040
3041 return ret
3042
Scott Baker0caeaf02014-06-19 11:12:55 -07003043
Scott Baker89a7b7c2014-10-07 00:10:17 -07003044class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003045 queryset = SliceRole.objects.select_related().all()
3046 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003047 id_serializer_class = SliceRoleIdSerializer
3048
3049 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003050 no_hyperlinks=False
3051 if hasattr(self.request,"QUERY_PARAMS"):
3052 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003053 if (no_hyperlinks):
3054 return self.id_serializer_class
3055 else:
3056 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003057
Scott Baker0caeaf02014-06-19 11:12:55 -07003058 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003059 if (not self.request.user.is_authenticated()):
3060 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003061 return SliceRole.select_by_user(self.request.user)
3062
Scott Baker89a7b7c2014-10-07 00:10:17 -07003063 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003064
Scott Baker89a7b7c2014-10-07 00:10:17 -07003065 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003066
3067
3068
3069class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003070 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003071 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003072 id_serializer_class = TagIdSerializer
3073 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003074 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07003075
3076 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003077 no_hyperlinks=False
3078 if hasattr(self.request,"QUERY_PARAMS"):
3079 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003080 if (no_hyperlinks):
3081 return self.id_serializer_class
3082 else:
3083 return self.serializer_class
3084
Scott Baker0caeaf02014-06-19 11:12:55 -07003085 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003086 if (not self.request.user.is_authenticated()):
3087 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003088 return Tag.select_by_user(self.request.user)
3089
3090 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003091 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3092 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003093 response = {"error": "validation",
3094 "specific_error": "not serializer.is_valid()",
3095 "reasons": serializer.errors}
3096 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003097 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003098 obj.caller = request.user
3099 if obj.can_update(request.user):
3100 return super(TagList, self).create(request, *args, **kwargs)
3101 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003102 raise Exception("failed obj.can_update")
3103
3104 ret = super(TagList, self).create(request, *args, **kwargs)
3105 if (ret.status_code%100 != 200):
3106 raise Exception(ret.data)
3107
3108 return ret
3109
Sapan Bhatiadea39432014-06-13 03:10:36 -04003110
Scott Baker89a7b7c2014-10-07 00:10:17 -07003111class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003112 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003113 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003114 id_serializer_class = TagIdSerializer
3115
3116 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003117 no_hyperlinks=False
3118 if hasattr(self.request,"QUERY_PARAMS"):
3119 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003120 if (no_hyperlinks):
3121 return self.id_serializer_class
3122 else:
3123 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003124
Scott Baker0caeaf02014-06-19 11:12:55 -07003125 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003126 if (not self.request.user.is_authenticated()):
3127 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003128 return Tag.select_by_user(self.request.user)
3129
Scott Baker89a7b7c2014-10-07 00:10:17 -07003130 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003131
Scott Baker89a7b7c2014-10-07 00:10:17 -07003132 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003133
3134
3135
3136class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003137 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003138 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003139 id_serializer_class = InvoiceIdSerializer
3140 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003141 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -07003142
3143 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003144 no_hyperlinks=False
3145 if hasattr(self.request,"QUERY_PARAMS"):
3146 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003147 if (no_hyperlinks):
3148 return self.id_serializer_class
3149 else:
3150 return self.serializer_class
3151
Scott Baker0caeaf02014-06-19 11:12:55 -07003152 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003153 if (not self.request.user.is_authenticated()):
3154 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003155 return Invoice.select_by_user(self.request.user)
3156
3157 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003158 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3159 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003160 response = {"error": "validation",
3161 "specific_error": "not serializer.is_valid()",
3162 "reasons": serializer.errors}
3163 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003164 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003165 obj.caller = request.user
3166 if obj.can_update(request.user):
3167 return super(InvoiceList, self).create(request, *args, **kwargs)
3168 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003169 raise Exception("failed obj.can_update")
3170
3171 ret = super(InvoiceList, self).create(request, *args, **kwargs)
3172 if (ret.status_code%100 != 200):
3173 raise Exception(ret.data)
3174
3175 return ret
3176
Sapan Bhatiadea39432014-06-13 03:10:36 -04003177
Scott Baker89a7b7c2014-10-07 00:10:17 -07003178class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003179 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003180 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003181 id_serializer_class = InvoiceIdSerializer
3182
3183 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003184 no_hyperlinks=False
3185 if hasattr(self.request,"QUERY_PARAMS"):
3186 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003187 if (no_hyperlinks):
3188 return self.id_serializer_class
3189 else:
3190 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003191
Scott Baker0caeaf02014-06-19 11:12:55 -07003192 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003193 if (not self.request.user.is_authenticated()):
3194 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003195 return Invoice.select_by_user(self.request.user)
3196
Scott Baker89a7b7c2014-10-07 00:10:17 -07003197 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003198
Scott Baker89a7b7c2014-10-07 00:10:17 -07003199 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003200
3201
3202
Scott Baker0caeaf02014-06-19 11:12:55 -07003203class SlicePrivilegeList(generics.ListCreateAPIView):
3204 queryset = SlicePrivilege.objects.select_related().all()
3205 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003206 id_serializer_class = SlicePrivilegeIdSerializer
3207 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003208 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -07003209
3210 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003211 no_hyperlinks=False
3212 if hasattr(self.request,"QUERY_PARAMS"):
3213 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003214 if (no_hyperlinks):
3215 return self.id_serializer_class
3216 else:
3217 return self.serializer_class
3218
Scott Baker0caeaf02014-06-19 11:12:55 -07003219 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003220 if (not self.request.user.is_authenticated()):
3221 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003222 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003223
Scott Baker0caeaf02014-06-19 11:12:55 -07003224 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003225 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3226 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003227 response = {"error": "validation",
3228 "specific_error": "not serializer.is_valid()",
3229 "reasons": serializer.errors}
3230 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003231 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003232 obj.caller = request.user
3233 if obj.can_update(request.user):
3234 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3235 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003236 raise Exception("failed obj.can_update")
3237
3238 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3239 if (ret.status_code%100 != 200):
3240 raise Exception(ret.data)
3241
3242 return ret
3243
Scott Baker0caeaf02014-06-19 11:12:55 -07003244
Scott Baker89a7b7c2014-10-07 00:10:17 -07003245class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003246 queryset = SlicePrivilege.objects.select_related().all()
3247 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003248 id_serializer_class = SlicePrivilegeIdSerializer
3249
3250 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003251 no_hyperlinks=False
3252 if hasattr(self.request,"QUERY_PARAMS"):
3253 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003254 if (no_hyperlinks):
3255 return self.id_serializer_class
3256 else:
3257 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003258
Scott Baker0caeaf02014-06-19 11:12:55 -07003259 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003260 if (not self.request.user.is_authenticated()):
3261 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003262 return SlicePrivilege.select_by_user(self.request.user)
3263
Scott Baker89a7b7c2014-10-07 00:10:17 -07003264 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3265
3266 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3267
3268
3269
3270class PlanetStackRoleList(generics.ListCreateAPIView):
3271 queryset = PlanetStackRole.objects.select_related().all()
3272 serializer_class = PlanetStackRoleSerializer
3273 id_serializer_class = PlanetStackRoleIdSerializer
3274 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003275 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003276
3277 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003278 no_hyperlinks=False
3279 if hasattr(self.request,"QUERY_PARAMS"):
3280 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003281 if (no_hyperlinks):
3282 return self.id_serializer_class
3283 else:
3284 return self.serializer_class
3285
3286 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003287 if (not self.request.user.is_authenticated()):
3288 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003289 return PlanetStackRole.select_by_user(self.request.user)
3290
3291 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003292 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3293 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003294 response = {"error": "validation",
3295 "specific_error": "not serializer.is_valid()",
3296 "reasons": serializer.errors}
3297 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003298 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003299 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003300 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003301 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003302 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003303 raise Exception("failed obj.can_update")
3304
3305 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3306 if (ret.status_code%100 != 200):
3307 raise Exception(ret.data)
3308
3309 return ret
3310
Scott Baker0caeaf02014-06-19 11:12:55 -07003311
Scott Baker89a7b7c2014-10-07 00:10:17 -07003312class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3313 queryset = PlanetStackRole.objects.select_related().all()
3314 serializer_class = PlanetStackRoleSerializer
3315 id_serializer_class = PlanetStackRoleIdSerializer
3316
3317 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003318 no_hyperlinks=False
3319 if hasattr(self.request,"QUERY_PARAMS"):
3320 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003321 if (no_hyperlinks):
3322 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003323 else:
Scott Baker89a7b7c2014-10-07 00:10:17 -07003324 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003325
Scott Baker89a7b7c2014-10-07 00:10:17 -07003326 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003327 if (not self.request.user.is_authenticated()):
3328 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003329 return PlanetStackRole.select_by_user(self.request.user)
3330
3331 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3332
3333 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003334
3335
3336
Scott Baker0caeaf02014-06-19 11:12:55 -07003337class NetworkSliverList(generics.ListCreateAPIView):
3338 queryset = NetworkSliver.objects.select_related().all()
3339 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003340 id_serializer_class = NetworkSliverIdSerializer
3341 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003342 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -07003343
3344 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003345 no_hyperlinks=False
3346 if hasattr(self.request,"QUERY_PARAMS"):
3347 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003348 if (no_hyperlinks):
3349 return self.id_serializer_class
3350 else:
3351 return self.serializer_class
3352
Scott Baker0caeaf02014-06-19 11:12:55 -07003353 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003354 if (not self.request.user.is_authenticated()):
3355 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003356 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003357
Scott Baker0caeaf02014-06-19 11:12:55 -07003358 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003359 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3360 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003361 response = {"error": "validation",
3362 "specific_error": "not serializer.is_valid()",
3363 "reasons": serializer.errors}
3364 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003365 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003366 obj.caller = request.user
3367 if obj.can_update(request.user):
3368 return super(NetworkSliverList, self).create(request, *args, **kwargs)
3369 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003370 raise Exception("failed obj.can_update")
3371
3372 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3373 if (ret.status_code%100 != 200):
3374 raise Exception(ret.data)
3375
3376 return ret
3377
Scott Baker0caeaf02014-06-19 11:12:55 -07003378
Scott Baker89a7b7c2014-10-07 00:10:17 -07003379class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003380 queryset = NetworkSliver.objects.select_related().all()
3381 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003382 id_serializer_class = NetworkSliverIdSerializer
3383
3384 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003385 no_hyperlinks=False
3386 if hasattr(self.request,"QUERY_PARAMS"):
3387 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003388 if (no_hyperlinks):
3389 return self.id_serializer_class
3390 else:
3391 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003392
Scott Baker0caeaf02014-06-19 11:12:55 -07003393 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003394 if (not self.request.user.is_authenticated()):
3395 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003396 return NetworkSliver.select_by_user(self.request.user)
3397
Scott Baker89a7b7c2014-10-07 00:10:17 -07003398 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003399
Scott Baker89a7b7c2014-10-07 00:10:17 -07003400 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003401
3402
3403
Scott Baker191f9b22015-01-12 13:16:39 -08003404class FlavorList(generics.ListCreateAPIView):
3405 queryset = Flavor.objects.select_related().all()
3406 serializer_class = FlavorSerializer
3407 id_serializer_class = FlavorIdSerializer
3408 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003409 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',)
Scott Baker191f9b22015-01-12 13:16:39 -08003410
3411 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003412 no_hyperlinks=False
3413 if hasattr(self.request,"QUERY_PARAMS"):
3414 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08003415 if (no_hyperlinks):
3416 return self.id_serializer_class
3417 else:
3418 return self.serializer_class
3419
3420 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003421 if (not self.request.user.is_authenticated()):
3422 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003423 return Flavor.select_by_user(self.request.user)
3424
3425 def create(self, request, *args, **kwargs):
3426 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3427 if not (serializer.is_valid()):
3428 response = {"error": "validation",
3429 "specific_error": "not serializer.is_valid()",
3430 "reasons": serializer.errors}
3431 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3432 obj = serializer.object
3433 obj.caller = request.user
3434 if obj.can_update(request.user):
3435 return super(FlavorList, self).create(request, *args, **kwargs)
3436 else:
3437 raise Exception("failed obj.can_update")
3438
3439 ret = super(FlavorList, self).create(request, *args, **kwargs)
3440 if (ret.status_code%100 != 200):
3441 raise Exception(ret.data)
3442
3443 return ret
3444
3445
3446class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3447 queryset = Flavor.objects.select_related().all()
3448 serializer_class = FlavorSerializer
3449 id_serializer_class = FlavorIdSerializer
3450
3451 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003452 no_hyperlinks=False
3453 if hasattr(self.request,"QUERY_PARAMS"):
3454 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08003455 if (no_hyperlinks):
3456 return self.id_serializer_class
3457 else:
3458 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003459
Scott Baker191f9b22015-01-12 13:16:39 -08003460 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003461 if (not self.request.user.is_authenticated()):
3462 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003463 return Flavor.select_by_user(self.request.user)
3464
3465 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3466
3467 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3468
3469
3470
3471class ControllerSiteList(generics.ListCreateAPIView):
3472 queryset = ControllerSite.objects.select_related().all()
3473 serializer_class = ControllerSiteSerializer
3474 id_serializer_class = ControllerSiteIdSerializer
3475 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003476 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08003477
3478 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003479 no_hyperlinks=False
3480 if hasattr(self.request,"QUERY_PARAMS"):
3481 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08003482 if (no_hyperlinks):
3483 return self.id_serializer_class
3484 else:
3485 return self.serializer_class
3486
3487 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003488 if (not self.request.user.is_authenticated()):
3489 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003490 return ControllerSite.select_by_user(self.request.user)
3491
3492 def create(self, request, *args, **kwargs):
3493 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3494 if not (serializer.is_valid()):
3495 response = {"error": "validation",
3496 "specific_error": "not serializer.is_valid()",
3497 "reasons": serializer.errors}
3498 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3499 obj = serializer.object
3500 obj.caller = request.user
3501 if obj.can_update(request.user):
3502 return super(ControllerSiteList, self).create(request, *args, **kwargs)
3503 else:
3504 raise Exception("failed obj.can_update")
3505
3506 ret = super(ControllerSiteList, self).create(request, *args, **kwargs)
3507 if (ret.status_code%100 != 200):
3508 raise Exception(ret.data)
3509
3510 return ret
3511
3512
3513class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3514 queryset = ControllerSite.objects.select_related().all()
3515 serializer_class = ControllerSiteSerializer
3516 id_serializer_class = ControllerSiteIdSerializer
3517
3518 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003519 no_hyperlinks=False
3520 if hasattr(self.request,"QUERY_PARAMS"):
3521 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08003522 if (no_hyperlinks):
3523 return self.id_serializer_class
3524 else:
3525 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003526
Scott Baker191f9b22015-01-12 13:16:39 -08003527 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003528 if (not self.request.user.is_authenticated()):
3529 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003530 return ControllerSite.select_by_user(self.request.user)
3531
3532 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3533
3534 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3535
3536
3537
Scott Baker0caeaf02014-06-19 11:12:55 -07003538class ProjectList(generics.ListCreateAPIView):
3539 queryset = Project.objects.select_related().all()
3540 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003541 id_serializer_class = ProjectIdSerializer
3542 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003543 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07003544
3545 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003546 no_hyperlinks=False
3547 if hasattr(self.request,"QUERY_PARAMS"):
3548 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003549 if (no_hyperlinks):
3550 return self.id_serializer_class
3551 else:
3552 return self.serializer_class
3553
Scott Baker0caeaf02014-06-19 11:12:55 -07003554 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003555 if (not self.request.user.is_authenticated()):
3556 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003557 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003558
Scott Baker0caeaf02014-06-19 11:12:55 -07003559 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003560 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3561 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003562 response = {"error": "validation",
3563 "specific_error": "not serializer.is_valid()",
3564 "reasons": serializer.errors}
3565 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003566 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003567 obj.caller = request.user
3568 if obj.can_update(request.user):
3569 return super(ProjectList, self).create(request, *args, **kwargs)
3570 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003571 raise Exception("failed obj.can_update")
3572
3573 ret = super(ProjectList, self).create(request, *args, **kwargs)
3574 if (ret.status_code%100 != 200):
3575 raise Exception(ret.data)
3576
3577 return ret
3578
Scott Baker0caeaf02014-06-19 11:12:55 -07003579
Scott Baker89a7b7c2014-10-07 00:10:17 -07003580class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003581 queryset = Project.objects.select_related().all()
3582 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003583 id_serializer_class = ProjectIdSerializer
3584
3585 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003586 no_hyperlinks=False
3587 if hasattr(self.request,"QUERY_PARAMS"):
3588 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003589 if (no_hyperlinks):
3590 return self.id_serializer_class
3591 else:
3592 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003593
Scott Baker0caeaf02014-06-19 11:12:55 -07003594 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003595 if (not self.request.user.is_authenticated()):
3596 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003597 return Project.select_by_user(self.request.user)
3598
Scott Baker89a7b7c2014-10-07 00:10:17 -07003599 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3600
3601 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3602
3603
3604
3605class SliceList(generics.ListCreateAPIView):
3606 queryset = Slice.objects.select_related().all()
3607 serializer_class = SliceSerializer
3608 id_serializer_class = SliceIdSerializer
3609 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003610 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003611
3612 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003613 no_hyperlinks=False
3614 if hasattr(self.request,"QUERY_PARAMS"):
3615 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003616 if (no_hyperlinks):
3617 return self.id_serializer_class
3618 else:
3619 return self.serializer_class
3620
3621 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003622 if (not self.request.user.is_authenticated()):
3623 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003624 return Slice.select_by_user(self.request.user)
3625
3626 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003627 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3628 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003629 response = {"error": "validation",
3630 "specific_error": "not serializer.is_valid()",
3631 "reasons": serializer.errors}
3632 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003633 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003634 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003635 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003636 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003637 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003638 raise Exception("failed obj.can_update")
3639
3640 ret = super(SliceList, self).create(request, *args, **kwargs)
3641 if (ret.status_code%100 != 200):
3642 raise Exception(ret.data)
3643
3644 return ret
3645
Scott Baker0caeaf02014-06-19 11:12:55 -07003646
Scott Baker89a7b7c2014-10-07 00:10:17 -07003647class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3648 queryset = Slice.objects.select_related().all()
3649 serializer_class = SliceSerializer
3650 id_serializer_class = SliceIdSerializer
3651
3652 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003653 no_hyperlinks=False
3654 if hasattr(self.request,"QUERY_PARAMS"):
3655 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003656 if (no_hyperlinks):
3657 return self.id_serializer_class
3658 else:
3659 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003660
Scott Baker89a7b7c2014-10-07 00:10:17 -07003661 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003662 if (not self.request.user.is_authenticated()):
3663 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003664 return Slice.select_by_user(self.request.user)
3665
3666 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3667
3668 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3669
3670
3671
3672class NetworkList(generics.ListCreateAPIView):
3673 queryset = Network.objects.select_related().all()
3674 serializer_class = NetworkSerializer
3675 id_serializer_class = NetworkIdSerializer
3676 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003677 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003678
3679 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003680 no_hyperlinks=False
3681 if hasattr(self.request,"QUERY_PARAMS"):
3682 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003683 if (no_hyperlinks):
3684 return self.id_serializer_class
3685 else:
3686 return self.serializer_class
3687
3688 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003689 if (not self.request.user.is_authenticated()):
3690 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003691 return Network.select_by_user(self.request.user)
3692
3693 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003694 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3695 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003696 response = {"error": "validation",
3697 "specific_error": "not serializer.is_valid()",
3698 "reasons": serializer.errors}
3699 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003700 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003701 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003702 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003703 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003704 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003705 raise Exception("failed obj.can_update")
3706
3707 ret = super(NetworkList, self).create(request, *args, **kwargs)
3708 if (ret.status_code%100 != 200):
3709 raise Exception(ret.data)
3710
3711 return ret
3712
Scott Baker89a7b7c2014-10-07 00:10:17 -07003713
3714class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3715 queryset = Network.objects.select_related().all()
3716 serializer_class = NetworkSerializer
3717 id_serializer_class = NetworkIdSerializer
3718
3719 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003720 no_hyperlinks=False
3721 if hasattr(self.request,"QUERY_PARAMS"):
3722 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003723 if (no_hyperlinks):
3724 return self.id_serializer_class
3725 else:
3726 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003727
Scott Baker89a7b7c2014-10-07 00:10:17 -07003728 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003729 if (not self.request.user.is_authenticated()):
3730 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003731 return Network.select_by_user(self.request.user)
3732
3733 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3734
3735 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3736
3737
3738
3739class ServiceList(generics.ListCreateAPIView):
3740 queryset = Service.objects.select_related().all()
3741 serializer_class = ServiceSerializer
3742 id_serializer_class = ServiceIdSerializer
3743 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003744 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003745
3746 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003747 no_hyperlinks=False
3748 if hasattr(self.request,"QUERY_PARAMS"):
3749 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003750 if (no_hyperlinks):
3751 return self.id_serializer_class
3752 else:
3753 return self.serializer_class
3754
3755 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003756 if (not self.request.user.is_authenticated()):
3757 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003758 return Service.select_by_user(self.request.user)
3759
3760 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003761 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3762 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003763 response = {"error": "validation",
3764 "specific_error": "not serializer.is_valid()",
3765 "reasons": serializer.errors}
3766 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003767 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003768 obj.caller = request.user
3769 if obj.can_update(request.user):
3770 return super(ServiceList, self).create(request, *args, **kwargs)
3771 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003772 raise Exception("failed obj.can_update")
3773
3774 ret = super(ServiceList, self).create(request, *args, **kwargs)
3775 if (ret.status_code%100 != 200):
3776 raise Exception(ret.data)
3777
3778 return ret
3779
Scott Baker89a7b7c2014-10-07 00:10:17 -07003780
3781class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3782 queryset = Service.objects.select_related().all()
3783 serializer_class = ServiceSerializer
3784 id_serializer_class = ServiceIdSerializer
3785
3786 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003787 no_hyperlinks=False
3788 if hasattr(self.request,"QUERY_PARAMS"):
3789 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003790 if (no_hyperlinks):
3791 return self.id_serializer_class
3792 else:
3793 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003794
Scott Baker89a7b7c2014-10-07 00:10:17 -07003795 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003796 if (not self.request.user.is_authenticated()):
3797 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003798 return Service.select_by_user(self.request.user)
3799
3800 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3801
3802 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3803
3804
3805
3806class ServiceClassList(generics.ListCreateAPIView):
3807 queryset = ServiceClass.objects.select_related().all()
3808 serializer_class = ServiceClassSerializer
3809 id_serializer_class = ServiceClassIdSerializer
3810 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003811 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003812
3813 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003814 no_hyperlinks=False
3815 if hasattr(self.request,"QUERY_PARAMS"):
3816 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003817 if (no_hyperlinks):
3818 return self.id_serializer_class
3819 else:
3820 return self.serializer_class
3821
3822 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003823 if (not self.request.user.is_authenticated()):
3824 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003825 return ServiceClass.select_by_user(self.request.user)
3826
3827 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003828 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3829 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003830 response = {"error": "validation",
3831 "specific_error": "not serializer.is_valid()",
3832 "reasons": serializer.errors}
3833 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003834 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003835 obj.caller = request.user
3836 if obj.can_update(request.user):
3837 return super(ServiceClassList, self).create(request, *args, **kwargs)
3838 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003839 raise Exception("failed obj.can_update")
3840
3841 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3842 if (ret.status_code%100 != 200):
3843 raise Exception(ret.data)
3844
3845 return ret
3846
Scott Baker89a7b7c2014-10-07 00:10:17 -07003847
3848class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3849 queryset = ServiceClass.objects.select_related().all()
3850 serializer_class = ServiceClassSerializer
3851 id_serializer_class = ServiceClassIdSerializer
3852
3853 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003854 no_hyperlinks=False
3855 if hasattr(self.request,"QUERY_PARAMS"):
3856 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003857 if (no_hyperlinks):
3858 return self.id_serializer_class
3859 else:
3860 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003861
Scott Baker89a7b7c2014-10-07 00:10:17 -07003862 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003863 if (not self.request.user.is_authenticated()):
3864 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003865 return ServiceClass.select_by_user(self.request.user)
3866
3867 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3868
3869 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3870
3871
3872
Scott Baker191f9b22015-01-12 13:16:39 -08003873class PlanetStackList(generics.ListCreateAPIView):
3874 queryset = PlanetStack.objects.select_related().all()
3875 serializer_class = PlanetStackSerializer
3876 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003877 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003878 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003879
3880 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003881 no_hyperlinks=False
3882 if hasattr(self.request,"QUERY_PARAMS"):
3883 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003884 if (no_hyperlinks):
3885 return self.id_serializer_class
3886 else:
3887 return self.serializer_class
3888
3889 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003890 if (not self.request.user.is_authenticated()):
3891 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003892 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003893
3894 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003895 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3896 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003897 response = {"error": "validation",
3898 "specific_error": "not serializer.is_valid()",
3899 "reasons": serializer.errors}
3900 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003901 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003902 obj.caller = request.user
3903 if obj.can_update(request.user):
Scott Baker191f9b22015-01-12 13:16:39 -08003904 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003905 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003906 raise Exception("failed obj.can_update")
3907
Scott Baker191f9b22015-01-12 13:16:39 -08003908 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07003909 if (ret.status_code%100 != 200):
3910 raise Exception(ret.data)
3911
3912 return ret
3913
Scott Baker89a7b7c2014-10-07 00:10:17 -07003914
Scott Baker191f9b22015-01-12 13:16:39 -08003915class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3916 queryset = PlanetStack.objects.select_related().all()
3917 serializer_class = PlanetStackSerializer
3918 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003919
3920 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003921 no_hyperlinks=False
3922 if hasattr(self.request,"QUERY_PARAMS"):
3923 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003924 if (no_hyperlinks):
3925 return self.id_serializer_class
3926 else:
3927 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003928
Scott Baker89a7b7c2014-10-07 00:10:17 -07003929 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003930 if (not self.request.user.is_authenticated()):
3931 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003932 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003933
3934 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3935
3936 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3937
3938
3939
3940class ChargeList(generics.ListCreateAPIView):
3941 queryset = Charge.objects.select_related().all()
3942 serializer_class = ChargeSerializer
3943 id_serializer_class = ChargeIdSerializer
3944 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003945 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003946
3947 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003948 no_hyperlinks=False
3949 if hasattr(self.request,"QUERY_PARAMS"):
3950 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003951 if (no_hyperlinks):
3952 return self.id_serializer_class
3953 else:
3954 return self.serializer_class
3955
3956 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003957 if (not self.request.user.is_authenticated()):
3958 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003959 return Charge.select_by_user(self.request.user)
3960
3961 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003962 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3963 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003964 response = {"error": "validation",
3965 "specific_error": "not serializer.is_valid()",
3966 "reasons": serializer.errors}
3967 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003968 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003969 obj.caller = request.user
3970 if obj.can_update(request.user):
3971 return super(ChargeList, self).create(request, *args, **kwargs)
3972 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003973 raise Exception("failed obj.can_update")
3974
3975 ret = super(ChargeList, self).create(request, *args, **kwargs)
3976 if (ret.status_code%100 != 200):
3977 raise Exception(ret.data)
3978
3979 return ret
3980
Scott Baker89a7b7c2014-10-07 00:10:17 -07003981
3982class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3983 queryset = Charge.objects.select_related().all()
3984 serializer_class = ChargeSerializer
3985 id_serializer_class = ChargeIdSerializer
3986
3987 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003988 no_hyperlinks=False
3989 if hasattr(self.request,"QUERY_PARAMS"):
3990 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003991 if (no_hyperlinks):
3992 return self.id_serializer_class
3993 else:
3994 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003995
Scott Baker89a7b7c2014-10-07 00:10:17 -07003996 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003997 if (not self.request.user.is_authenticated()):
3998 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003999 return Charge.select_by_user(self.request.user)
4000
4001 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4002
4003 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4004
4005
4006
4007class RoleList(generics.ListCreateAPIView):
4008 queryset = Role.objects.select_related().all()
4009 serializer_class = RoleSerializer
4010 id_serializer_class = RoleIdSerializer
4011 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004012 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004013
4014 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004015 no_hyperlinks=False
4016 if hasattr(self.request,"QUERY_PARAMS"):
4017 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004018 if (no_hyperlinks):
4019 return self.id_serializer_class
4020 else:
4021 return self.serializer_class
4022
4023 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004024 if (not self.request.user.is_authenticated()):
4025 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004026 return Role.select_by_user(self.request.user)
4027
4028 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004029 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4030 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004031 response = {"error": "validation",
4032 "specific_error": "not serializer.is_valid()",
4033 "reasons": serializer.errors}
4034 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004035 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004036 obj.caller = request.user
4037 if obj.can_update(request.user):
4038 return super(RoleList, self).create(request, *args, **kwargs)
4039 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004040 raise Exception("failed obj.can_update")
4041
4042 ret = super(RoleList, self).create(request, *args, **kwargs)
4043 if (ret.status_code%100 != 200):
4044 raise Exception(ret.data)
4045
4046 return ret
4047
Scott Baker89a7b7c2014-10-07 00:10:17 -07004048
4049class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4050 queryset = Role.objects.select_related().all()
4051 serializer_class = RoleSerializer
4052 id_serializer_class = RoleIdSerializer
4053
4054 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004055 no_hyperlinks=False
4056 if hasattr(self.request,"QUERY_PARAMS"):
4057 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004058 if (no_hyperlinks):
4059 return self.id_serializer_class
4060 else:
4061 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004062
Scott Baker89a7b7c2014-10-07 00:10:17 -07004063 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004064 if (not self.request.user.is_authenticated()):
4065 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004066 return Role.select_by_user(self.request.user)
4067
4068 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4069
4070 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4071
4072
4073
4074class UsableObjectList(generics.ListCreateAPIView):
4075 queryset = UsableObject.objects.select_related().all()
4076 serializer_class = UsableObjectSerializer
4077 id_serializer_class = UsableObjectIdSerializer
4078 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004079 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004080
4081 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004082 no_hyperlinks=False
4083 if hasattr(self.request,"QUERY_PARAMS"):
4084 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004085 if (no_hyperlinks):
4086 return self.id_serializer_class
4087 else:
4088 return self.serializer_class
4089
4090 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004091 if (not self.request.user.is_authenticated()):
4092 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004093 return UsableObject.select_by_user(self.request.user)
4094
4095 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004096 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4097 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004098 response = {"error": "validation",
4099 "specific_error": "not serializer.is_valid()",
4100 "reasons": serializer.errors}
4101 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004102 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004103 obj.caller = request.user
4104 if obj.can_update(request.user):
4105 return super(UsableObjectList, self).create(request, *args, **kwargs)
4106 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004107 raise Exception("failed obj.can_update")
4108
4109 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
4110 if (ret.status_code%100 != 200):
4111 raise Exception(ret.data)
4112
4113 return ret
4114
Scott Baker89a7b7c2014-10-07 00:10:17 -07004115
4116class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4117 queryset = UsableObject.objects.select_related().all()
4118 serializer_class = UsableObjectSerializer
4119 id_serializer_class = UsableObjectIdSerializer
4120
4121 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004122 no_hyperlinks=False
4123 if hasattr(self.request,"QUERY_PARAMS"):
4124 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004125 if (no_hyperlinks):
4126 return self.id_serializer_class
4127 else:
4128 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004129
Scott Baker89a7b7c2014-10-07 00:10:17 -07004130 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004131 if (not self.request.user.is_authenticated()):
4132 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004133 return UsableObject.select_by_user(self.request.user)
4134
4135 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4136
4137 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4138
4139
Scott Baker191f9b22015-01-12 13:16:39 -08004140
Scott Baker89a7b7c2014-10-07 00:10:17 -07004141class SiteRoleList(generics.ListCreateAPIView):
4142 queryset = SiteRole.objects.select_related().all()
4143 serializer_class = SiteRoleSerializer
4144 id_serializer_class = SiteRoleIdSerializer
4145 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004146 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004147
4148 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004149 no_hyperlinks=False
4150 if hasattr(self.request,"QUERY_PARAMS"):
4151 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004152 if (no_hyperlinks):
4153 return self.id_serializer_class
4154 else:
4155 return self.serializer_class
4156
4157 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004158 if (not self.request.user.is_authenticated()):
4159 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004160 return SiteRole.select_by_user(self.request.user)
4161
4162 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004163 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4164 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004165 response = {"error": "validation",
4166 "specific_error": "not serializer.is_valid()",
4167 "reasons": serializer.errors}
4168 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004169 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004170 obj.caller = request.user
4171 if obj.can_update(request.user):
4172 return super(SiteRoleList, self).create(request, *args, **kwargs)
4173 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004174 raise Exception("failed obj.can_update")
4175
4176 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
4177 if (ret.status_code%100 != 200):
4178 raise Exception(ret.data)
4179
4180 return ret
4181
Scott Baker89a7b7c2014-10-07 00:10:17 -07004182
4183class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4184 queryset = SiteRole.objects.select_related().all()
4185 serializer_class = SiteRoleSerializer
4186 id_serializer_class = SiteRoleIdSerializer
4187
4188 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004189 no_hyperlinks=False
4190 if hasattr(self.request,"QUERY_PARAMS"):
4191 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004192 if (no_hyperlinks):
4193 return self.id_serializer_class
4194 else:
4195 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004196
Scott Baker89a7b7c2014-10-07 00:10:17 -07004197 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004198 if (not self.request.user.is_authenticated()):
4199 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004200 return SiteRole.select_by_user(self.request.user)
4201
4202 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4203
4204 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4205
4206
4207
4208class SliceCredentialList(generics.ListCreateAPIView):
4209 queryset = SliceCredential.objects.select_related().all()
4210 serializer_class = SliceCredentialSerializer
4211 id_serializer_class = SliceCredentialIdSerializer
4212 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004213 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004214
4215 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004216 no_hyperlinks=False
4217 if hasattr(self.request,"QUERY_PARAMS"):
4218 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004219 if (no_hyperlinks):
4220 return self.id_serializer_class
4221 else:
4222 return self.serializer_class
4223
4224 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004225 if (not self.request.user.is_authenticated()):
4226 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004227 return SliceCredential.select_by_user(self.request.user)
4228
4229 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004230 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4231 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004232 response = {"error": "validation",
4233 "specific_error": "not serializer.is_valid()",
4234 "reasons": serializer.errors}
4235 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004236 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004237 obj.caller = request.user
4238 if obj.can_update(request.user):
4239 return super(SliceCredentialList, self).create(request, *args, **kwargs)
4240 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004241 raise Exception("failed obj.can_update")
4242
4243 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
4244 if (ret.status_code%100 != 200):
4245 raise Exception(ret.data)
4246
4247 return ret
4248
Scott Baker89a7b7c2014-10-07 00:10:17 -07004249
4250class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4251 queryset = SliceCredential.objects.select_related().all()
4252 serializer_class = SliceCredentialSerializer
4253 id_serializer_class = SliceCredentialIdSerializer
4254
4255 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004256 no_hyperlinks=False
4257 if hasattr(self.request,"QUERY_PARAMS"):
4258 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004259 if (no_hyperlinks):
4260 return self.id_serializer_class
4261 else:
4262 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004263
Scott Baker89a7b7c2014-10-07 00:10:17 -07004264 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004265 if (not self.request.user.is_authenticated()):
4266 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004267 return SliceCredential.select_by_user(self.request.user)
4268
4269 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4270
4271 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4272
4273
4274
4275class SliverList(generics.ListCreateAPIView):
4276 queryset = Sliver.objects.select_related().all()
4277 serializer_class = SliverSerializer
4278 id_serializer_class = SliverIdSerializer
4279 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004280 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004281
4282 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004283 no_hyperlinks=False
4284 if hasattr(self.request,"QUERY_PARAMS"):
4285 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004286 if (no_hyperlinks):
4287 return self.id_serializer_class
4288 else:
4289 return self.serializer_class
4290
4291 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004292 if (not self.request.user.is_authenticated()):
4293 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004294 return Sliver.select_by_user(self.request.user)
4295
4296 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004297 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4298 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004299 response = {"error": "validation",
4300 "specific_error": "not serializer.is_valid()",
4301 "reasons": serializer.errors}
4302 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004303 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004304 obj.caller = request.user
4305 if obj.can_update(request.user):
4306 return super(SliverList, self).create(request, *args, **kwargs)
4307 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004308 raise Exception("failed obj.can_update")
4309
4310 ret = super(SliverList, self).create(request, *args, **kwargs)
4311 if (ret.status_code%100 != 200):
4312 raise Exception(ret.data)
4313
4314 return ret
4315
Scott Baker89a7b7c2014-10-07 00:10:17 -07004316
4317class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4318 queryset = Sliver.objects.select_related().all()
4319 serializer_class = SliverSerializer
4320 id_serializer_class = SliverIdSerializer
4321
4322 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004323 no_hyperlinks=False
4324 if hasattr(self.request,"QUERY_PARAMS"):
4325 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004326 if (no_hyperlinks):
4327 return self.id_serializer_class
4328 else:
4329 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004330
Scott Baker89a7b7c2014-10-07 00:10:17 -07004331 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004332 if (not self.request.user.is_authenticated()):
4333 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004334 return Sliver.select_by_user(self.request.user)
4335
4336 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4337
4338 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4339
4340
4341
4342class NodeList(generics.ListCreateAPIView):
4343 queryset = Node.objects.select_related().all()
4344 serializer_class = NodeSerializer
4345 id_serializer_class = NodeIdSerializer
4346 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004347 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004348
4349 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004350 no_hyperlinks=False
4351 if hasattr(self.request,"QUERY_PARAMS"):
4352 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004353 if (no_hyperlinks):
4354 return self.id_serializer_class
4355 else:
4356 return self.serializer_class
4357
4358 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004359 if (not self.request.user.is_authenticated()):
4360 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004361 return Node.select_by_user(self.request.user)
4362
4363 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004364 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4365 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004366 response = {"error": "validation",
4367 "specific_error": "not serializer.is_valid()",
4368 "reasons": serializer.errors}
4369 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004370 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004371 obj.caller = request.user
4372 if obj.can_update(request.user):
4373 return super(NodeList, self).create(request, *args, **kwargs)
4374 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004375 raise Exception("failed obj.can_update")
4376
4377 ret = super(NodeList, self).create(request, *args, **kwargs)
4378 if (ret.status_code%100 != 200):
4379 raise Exception(ret.data)
4380
4381 return ret
4382
Scott Baker89a7b7c2014-10-07 00:10:17 -07004383
4384class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4385 queryset = Node.objects.select_related().all()
4386 serializer_class = NodeSerializer
4387 id_serializer_class = NodeIdSerializer
4388
4389 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004390 no_hyperlinks=False
4391 if hasattr(self.request,"QUERY_PARAMS"):
4392 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004393 if (no_hyperlinks):
4394 return self.id_serializer_class
4395 else:
4396 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004397
Scott Baker89a7b7c2014-10-07 00:10:17 -07004398 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004399 if (not self.request.user.is_authenticated()):
4400 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004401 return Node.select_by_user(self.request.user)
4402
4403 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4404
4405 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4406
4407
4408
4409class DashboardViewList(generics.ListCreateAPIView):
4410 queryset = DashboardView.objects.select_related().all()
4411 serializer_class = DashboardViewSerializer
4412 id_serializer_class = DashboardViewIdSerializer
4413 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004414 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004415
4416 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004417 no_hyperlinks=False
4418 if hasattr(self.request,"QUERY_PARAMS"):
4419 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004420 if (no_hyperlinks):
4421 return self.id_serializer_class
4422 else:
4423 return self.serializer_class
4424
4425 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004426 if (not self.request.user.is_authenticated()):
4427 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004428 return DashboardView.select_by_user(self.request.user)
4429
4430 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004431 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4432 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004433 response = {"error": "validation",
4434 "specific_error": "not serializer.is_valid()",
4435 "reasons": serializer.errors}
4436 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004437 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004438 obj.caller = request.user
4439 if obj.can_update(request.user):
4440 return super(DashboardViewList, self).create(request, *args, **kwargs)
4441 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004442 raise Exception("failed obj.can_update")
4443
4444 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
4445 if (ret.status_code%100 != 200):
4446 raise Exception(ret.data)
4447
4448 return ret
4449
Scott Baker89a7b7c2014-10-07 00:10:17 -07004450
4451class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4452 queryset = DashboardView.objects.select_related().all()
4453 serializer_class = DashboardViewSerializer
4454 id_serializer_class = DashboardViewIdSerializer
4455
4456 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004457 no_hyperlinks=False
4458 if hasattr(self.request,"QUERY_PARAMS"):
4459 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004460 if (no_hyperlinks):
4461 return self.id_serializer_class
4462 else:
4463 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004464
Scott Baker89a7b7c2014-10-07 00:10:17 -07004465 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004466 if (not self.request.user.is_authenticated()):
4467 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004468 return DashboardView.select_by_user(self.request.user)
4469
4470 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4471
4472 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4473
Scott Baker89a7b7c2014-10-07 00:10:17 -07004474
Scott Baker57c725c2014-11-12 01:13:53 -08004475
Scott Baker191f9b22015-01-12 13:16:39 -08004476class ControllerNetworkList(generics.ListCreateAPIView):
4477 queryset = ControllerNetwork.objects.select_related().all()
4478 serializer_class = ControllerNetworkSerializer
4479 id_serializer_class = ControllerNetworkIdSerializer
4480 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004481 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker191f9b22015-01-12 13:16:39 -08004482
4483 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004484 no_hyperlinks=False
4485 if hasattr(self.request,"QUERY_PARAMS"):
4486 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08004487 if (no_hyperlinks):
4488 return self.id_serializer_class
4489 else:
4490 return self.serializer_class
4491
4492 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004493 if (not self.request.user.is_authenticated()):
4494 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08004495 return ControllerNetwork.select_by_user(self.request.user)
4496
4497 def create(self, request, *args, **kwargs):
4498 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4499 if not (serializer.is_valid()):
4500 response = {"error": "validation",
4501 "specific_error": "not serializer.is_valid()",
4502 "reasons": serializer.errors}
4503 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4504 obj = serializer.object
4505 obj.caller = request.user
4506 if obj.can_update(request.user):
4507 return super(ControllerNetworkList, self).create(request, *args, **kwargs)
4508 else:
4509 raise Exception("failed obj.can_update")
4510
4511 ret = super(ControllerNetworkList, self).create(request, *args, **kwargs)
4512 if (ret.status_code%100 != 200):
4513 raise Exception(ret.data)
4514
4515 return ret
4516
4517
4518class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4519 queryset = ControllerNetwork.objects.select_related().all()
4520 serializer_class = ControllerNetworkSerializer
4521 id_serializer_class = ControllerNetworkIdSerializer
4522
4523 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004524 no_hyperlinks=False
4525 if hasattr(self.request,"QUERY_PARAMS"):
4526 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08004527 if (no_hyperlinks):
4528 return self.id_serializer_class
4529 else:
4530 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004531
Scott Baker191f9b22015-01-12 13:16:39 -08004532 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004533 if (not self.request.user.is_authenticated()):
4534 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08004535 return ControllerNetwork.select_by_user(self.request.user)
4536
4537 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4538
4539 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4540
4541
4542
Scott Baker515dc9e2014-12-22 09:29:05 -08004543class ImageDeploymentsList(generics.ListCreateAPIView):
4544 queryset = ImageDeployments.objects.select_related().all()
4545 serializer_class = ImageDeploymentsSerializer
4546 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004547 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004548 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004549
4550 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004551 no_hyperlinks=False
4552 if hasattr(self.request,"QUERY_PARAMS"):
4553 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004554 if (no_hyperlinks):
4555 return self.id_serializer_class
4556 else:
4557 return self.serializer_class
4558
4559 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004560 if (not self.request.user.is_authenticated()):
4561 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004562 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004563
4564 def create(self, request, *args, **kwargs):
4565 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4566 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004567 response = {"error": "validation",
4568 "specific_error": "not serializer.is_valid()",
4569 "reasons": serializer.errors}
4570 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004571 obj = serializer.object
4572 obj.caller = request.user
4573 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08004574 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004575 else:
4576 raise Exception("failed obj.can_update")
4577
Scott Baker515dc9e2014-12-22 09:29:05 -08004578 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004579 if (ret.status_code%100 != 200):
4580 raise Exception(ret.data)
4581
4582 return ret
4583
4584
Scott Baker515dc9e2014-12-22 09:29:05 -08004585class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4586 queryset = ImageDeployments.objects.select_related().all()
4587 serializer_class = ImageDeploymentsSerializer
4588 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004589
4590 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004591 no_hyperlinks=False
4592 if hasattr(self.request,"QUERY_PARAMS"):
4593 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004594 if (no_hyperlinks):
4595 return self.id_serializer_class
4596 else:
4597 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004598
Scott Bakerb744f1c2014-11-21 11:32:24 -08004599 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004600 if (not self.request.user.is_authenticated()):
4601 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004602 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004603
4604 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4605
4606 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4607
Scott Bakerb744f1c2014-11-21 11:32:24 -08004608
4609
Scott Baker191f9b22015-01-12 13:16:39 -08004610class ControllerUserList(generics.ListCreateAPIView):
4611 queryset = ControllerUser.objects.select_related().all()
4612 serializer_class = ControllerUserSerializer
4613 id_serializer_class = ControllerUserIdSerializer
4614 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004615 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08004616
4617 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004618 no_hyperlinks=False
4619 if hasattr(self.request,"QUERY_PARAMS"):
4620 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08004621 if (no_hyperlinks):
4622 return self.id_serializer_class
4623 else:
4624 return self.serializer_class
4625
4626 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004627 if (not self.request.user.is_authenticated()):
4628 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08004629 return ControllerUser.select_by_user(self.request.user)
4630
4631 def create(self, request, *args, **kwargs):
4632 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4633 if not (serializer.is_valid()):
4634 response = {"error": "validation",
4635 "specific_error": "not serializer.is_valid()",
4636 "reasons": serializer.errors}
4637 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4638 obj = serializer.object
4639 obj.caller = request.user
4640 if obj.can_update(request.user):
4641 return super(ControllerUserList, self).create(request, *args, **kwargs)
4642 else:
4643 raise Exception("failed obj.can_update")
4644
4645 ret = super(ControllerUserList, self).create(request, *args, **kwargs)
4646 if (ret.status_code%100 != 200):
4647 raise Exception(ret.data)
4648
4649 return ret
4650
4651
4652class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4653 queryset = ControllerUser.objects.select_related().all()
4654 serializer_class = ControllerUserSerializer
4655 id_serializer_class = ControllerUserIdSerializer
4656
4657 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004658 no_hyperlinks=False
4659 if hasattr(self.request,"QUERY_PARAMS"):
4660 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08004661 if (no_hyperlinks):
4662 return self.id_serializer_class
4663 else:
4664 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004665
Scott Baker191f9b22015-01-12 13:16:39 -08004666 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004667 if (not self.request.user.is_authenticated()):
4668 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08004669 return ControllerUser.select_by_user(self.request.user)
4670
4671 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4672
4673 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4674
4675
4676
Scott Baker89a7b7c2014-10-07 00:10:17 -07004677class ReservedResourceList(generics.ListCreateAPIView):
4678 queryset = ReservedResource.objects.select_related().all()
4679 serializer_class = ReservedResourceSerializer
4680 id_serializer_class = ReservedResourceIdSerializer
4681 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004682 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004683
4684 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004685 no_hyperlinks=False
4686 if hasattr(self.request,"QUERY_PARAMS"):
4687 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004688 if (no_hyperlinks):
4689 return self.id_serializer_class
4690 else:
4691 return self.serializer_class
4692
4693 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004694 if (not self.request.user.is_authenticated()):
4695 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004696 return ReservedResource.select_by_user(self.request.user)
4697
4698 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004699 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4700 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004701 response = {"error": "validation",
4702 "specific_error": "not serializer.is_valid()",
4703 "reasons": serializer.errors}
4704 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004705 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004706 obj.caller = request.user
4707 if obj.can_update(request.user):
4708 return super(ReservedResourceList, self).create(request, *args, **kwargs)
4709 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004710 raise Exception("failed obj.can_update")
4711
4712 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4713 if (ret.status_code%100 != 200):
4714 raise Exception(ret.data)
4715
4716 return ret
4717
Scott Baker89a7b7c2014-10-07 00:10:17 -07004718
4719class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4720 queryset = ReservedResource.objects.select_related().all()
4721 serializer_class = ReservedResourceSerializer
4722 id_serializer_class = ReservedResourceIdSerializer
4723
4724 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004725 no_hyperlinks=False
4726 if hasattr(self.request,"QUERY_PARAMS"):
4727 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004728 if (no_hyperlinks):
4729 return self.id_serializer_class
4730 else:
4731 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004732
Scott Baker89a7b7c2014-10-07 00:10:17 -07004733 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004734 if (not self.request.user.is_authenticated()):
4735 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004736 return ReservedResource.select_by_user(self.request.user)
4737
4738 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4739
4740 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4741
4742
4743
Scott Baker515dc9e2014-12-22 09:29:05 -08004744class PaymentList(generics.ListCreateAPIView):
4745 queryset = Payment.objects.select_related().all()
4746 serializer_class = PaymentSerializer
4747 id_serializer_class = PaymentIdSerializer
4748 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004749 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Baker515dc9e2014-12-22 09:29:05 -08004750
4751 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004752 no_hyperlinks=False
4753 if hasattr(self.request,"QUERY_PARAMS"):
4754 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08004755 if (no_hyperlinks):
4756 return self.id_serializer_class
4757 else:
4758 return self.serializer_class
4759
4760 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004761 if (not self.request.user.is_authenticated()):
4762 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004763 return Payment.select_by_user(self.request.user)
4764
4765 def create(self, request, *args, **kwargs):
4766 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4767 if not (serializer.is_valid()):
4768 response = {"error": "validation",
4769 "specific_error": "not serializer.is_valid()",
4770 "reasons": serializer.errors}
4771 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4772 obj = serializer.object
4773 obj.caller = request.user
4774 if obj.can_update(request.user):
4775 return super(PaymentList, self).create(request, *args, **kwargs)
4776 else:
4777 raise Exception("failed obj.can_update")
4778
4779 ret = super(PaymentList, self).create(request, *args, **kwargs)
4780 if (ret.status_code%100 != 200):
4781 raise Exception(ret.data)
4782
4783 return ret
4784
4785
4786class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4787 queryset = Payment.objects.select_related().all()
4788 serializer_class = PaymentSerializer
4789 id_serializer_class = PaymentIdSerializer
4790
4791 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004792 no_hyperlinks=False
4793 if hasattr(self.request,"QUERY_PARAMS"):
4794 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08004795 if (no_hyperlinks):
4796 return self.id_serializer_class
4797 else:
4798 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004799
Scott Baker515dc9e2014-12-22 09:29:05 -08004800 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004801 if (not self.request.user.is_authenticated()):
4802 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004803 return Payment.select_by_user(self.request.user)
4804
4805 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4806
4807 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4808
4809
4810
Scott Baker89a7b7c2014-10-07 00:10:17 -07004811class NetworkSliceList(generics.ListCreateAPIView):
4812 queryset = NetworkSlice.objects.select_related().all()
4813 serializer_class = NetworkSliceSerializer
4814 id_serializer_class = NetworkSliceIdSerializer
4815 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004816 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004817
4818 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004819 no_hyperlinks=False
4820 if hasattr(self.request,"QUERY_PARAMS"):
4821 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004822 if (no_hyperlinks):
4823 return self.id_serializer_class
4824 else:
4825 return self.serializer_class
4826
4827 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004828 if (not self.request.user.is_authenticated()):
4829 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004830 return NetworkSlice.select_by_user(self.request.user)
4831
4832 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004833 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4834 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004835 response = {"error": "validation",
4836 "specific_error": "not serializer.is_valid()",
4837 "reasons": serializer.errors}
4838 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004839 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004840 obj.caller = request.user
4841 if obj.can_update(request.user):
4842 return super(NetworkSliceList, self).create(request, *args, **kwargs)
4843 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004844 raise Exception("failed obj.can_update")
4845
4846 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4847 if (ret.status_code%100 != 200):
4848 raise Exception(ret.data)
4849
4850 return ret
4851
Scott Baker89a7b7c2014-10-07 00:10:17 -07004852
4853class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4854 queryset = NetworkSlice.objects.select_related().all()
4855 serializer_class = NetworkSliceSerializer
4856 id_serializer_class = NetworkSliceIdSerializer
4857
4858 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004859 no_hyperlinks=False
4860 if hasattr(self.request,"QUERY_PARAMS"):
4861 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004862 if (no_hyperlinks):
4863 return self.id_serializer_class
4864 else:
4865 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004866
Scott Baker89a7b7c2014-10-07 00:10:17 -07004867 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004868 if (not self.request.user.is_authenticated()):
4869 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004870 return NetworkSlice.select_by_user(self.request.user)
4871
4872 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4873
4874 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4875
4876
4877
4878class UserDashboardViewList(generics.ListCreateAPIView):
4879 queryset = UserDashboardView.objects.select_related().all()
4880 serializer_class = UserDashboardViewSerializer
4881 id_serializer_class = UserDashboardViewIdSerializer
4882 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004883 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004884
4885 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004886 no_hyperlinks=False
4887 if hasattr(self.request,"QUERY_PARAMS"):
4888 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004889 if (no_hyperlinks):
4890 return self.id_serializer_class
4891 else:
4892 return self.serializer_class
4893
4894 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004895 if (not self.request.user.is_authenticated()):
4896 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004897 return UserDashboardView.select_by_user(self.request.user)
4898
4899 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004900 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4901 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004902 response = {"error": "validation",
4903 "specific_error": "not serializer.is_valid()",
4904 "reasons": serializer.errors}
4905 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004906 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004907 obj.caller = request.user
4908 if obj.can_update(request.user):
4909 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4910 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004911 raise Exception("failed obj.can_update")
4912
4913 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4914 if (ret.status_code%100 != 200):
4915 raise Exception(ret.data)
4916
4917 return ret
4918
Scott Baker89a7b7c2014-10-07 00:10:17 -07004919
4920class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4921 queryset = UserDashboardView.objects.select_related().all()
4922 serializer_class = UserDashboardViewSerializer
4923 id_serializer_class = UserDashboardViewIdSerializer
4924
4925 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004926 no_hyperlinks=False
4927 if hasattr(self.request,"QUERY_PARAMS"):
4928 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004929 if (no_hyperlinks):
4930 return self.id_serializer_class
4931 else:
4932 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004933
Scott Baker89a7b7c2014-10-07 00:10:17 -07004934 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004935 if (not self.request.user.is_authenticated()):
4936 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004937 return UserDashboardView.select_by_user(self.request.user)
4938
4939 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4940
4941 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4942
4943
4944
Scott Baker515dc9e2014-12-22 09:29:05 -08004945class ControllerList(generics.ListCreateAPIView):
4946 queryset = Controller.objects.select_related().all()
4947 serializer_class = ControllerSerializer
4948 id_serializer_class = ControllerIdSerializer
4949 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004950 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
Scott Baker515dc9e2014-12-22 09:29:05 -08004951
4952 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004953 no_hyperlinks=False
4954 if hasattr(self.request,"QUERY_PARAMS"):
4955 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08004956 if (no_hyperlinks):
4957 return self.id_serializer_class
4958 else:
4959 return self.serializer_class
4960
4961 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004962 if (not self.request.user.is_authenticated()):
4963 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004964 return Controller.select_by_user(self.request.user)
4965
4966 def create(self, request, *args, **kwargs):
4967 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4968 if not (serializer.is_valid()):
4969 response = {"error": "validation",
4970 "specific_error": "not serializer.is_valid()",
4971 "reasons": serializer.errors}
4972 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4973 obj = serializer.object
4974 obj.caller = request.user
4975 if obj.can_update(request.user):
4976 return super(ControllerList, self).create(request, *args, **kwargs)
4977 else:
4978 raise Exception("failed obj.can_update")
4979
4980 ret = super(ControllerList, self).create(request, *args, **kwargs)
4981 if (ret.status_code%100 != 200):
4982 raise Exception(ret.data)
4983
4984 return ret
4985
4986
4987class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4988 queryset = Controller.objects.select_related().all()
4989 serializer_class = ControllerSerializer
4990 id_serializer_class = ControllerIdSerializer
4991
4992 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004993 no_hyperlinks=False
4994 if hasattr(self.request,"QUERY_PARAMS"):
4995 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08004996 if (no_hyperlinks):
4997 return self.id_serializer_class
4998 else:
4999 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005000
Scott Baker515dc9e2014-12-22 09:29:05 -08005001 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005002 if (not self.request.user.is_authenticated()):
5003 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005004 return Controller.select_by_user(self.request.user)
5005
5006 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5007
5008 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5009
5010
5011
Scott Baker89a7b7c2014-10-07 00:10:17 -07005012class PlanetStackPrivilegeList(generics.ListCreateAPIView):
5013 queryset = PlanetStackPrivilege.objects.select_related().all()
5014 serializer_class = PlanetStackPrivilegeSerializer
5015 id_serializer_class = PlanetStackPrivilegeIdSerializer
5016 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005017 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005018
5019 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005020 no_hyperlinks=False
5021 if hasattr(self.request,"QUERY_PARAMS"):
5022 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005023 if (no_hyperlinks):
5024 return self.id_serializer_class
5025 else:
5026 return self.serializer_class
5027
5028 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005029 if (not self.request.user.is_authenticated()):
5030 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005031 return PlanetStackPrivilege.select_by_user(self.request.user)
5032
5033 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005034 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5035 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005036 response = {"error": "validation",
5037 "specific_error": "not serializer.is_valid()",
5038 "reasons": serializer.errors}
5039 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005040 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005041 obj.caller = request.user
5042 if obj.can_update(request.user):
5043 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
5044 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005045 raise Exception("failed obj.can_update")
5046
5047 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
5048 if (ret.status_code%100 != 200):
5049 raise Exception(ret.data)
5050
5051 return ret
5052
Scott Baker89a7b7c2014-10-07 00:10:17 -07005053
5054class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5055 queryset = PlanetStackPrivilege.objects.select_related().all()
5056 serializer_class = PlanetStackPrivilegeSerializer
5057 id_serializer_class = PlanetStackPrivilegeIdSerializer
5058
5059 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005060 no_hyperlinks=False
5061 if hasattr(self.request,"QUERY_PARAMS"):
5062 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005063 if (no_hyperlinks):
5064 return self.id_serializer_class
5065 else:
5066 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005067
Scott Baker89a7b7c2014-10-07 00:10:17 -07005068 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005069 if (not self.request.user.is_authenticated()):
5070 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005071 return PlanetStackPrivilege.select_by_user(self.request.user)
5072
5073 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5074
5075 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5076
5077
5078
5079class UserList(generics.ListCreateAPIView):
5080 queryset = User.objects.select_related().all()
5081 serializer_class = UserSerializer
5082 id_serializer_class = UserIdSerializer
5083 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005084 filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005085
5086 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005087 no_hyperlinks=False
5088 if hasattr(self.request,"QUERY_PARAMS"):
5089 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005090 if (no_hyperlinks):
5091 return self.id_serializer_class
5092 else:
5093 return self.serializer_class
5094
5095 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005096 if (not self.request.user.is_authenticated()):
5097 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005098 return User.select_by_user(self.request.user)
5099
5100 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005101 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5102 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005103 response = {"error": "validation",
5104 "specific_error": "not serializer.is_valid()",
5105 "reasons": serializer.errors}
5106 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005107 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005108 obj.caller = request.user
5109 if obj.can_update(request.user):
5110 return super(UserList, self).create(request, *args, **kwargs)
5111 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005112 raise Exception("failed obj.can_update")
5113
5114 ret = super(UserList, self).create(request, *args, **kwargs)
5115 if (ret.status_code%100 != 200):
5116 raise Exception(ret.data)
5117
5118 return ret
5119
Scott Baker89a7b7c2014-10-07 00:10:17 -07005120
5121class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5122 queryset = User.objects.select_related().all()
5123 serializer_class = UserSerializer
5124 id_serializer_class = UserIdSerializer
5125
5126 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005127 no_hyperlinks=False
5128 if hasattr(self.request,"QUERY_PARAMS"):
5129 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005130 if (no_hyperlinks):
5131 return self.id_serializer_class
5132 else:
5133 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005134
Scott Baker89a7b7c2014-10-07 00:10:17 -07005135 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005136 if (not self.request.user.is_authenticated()):
5137 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005138 return User.select_by_user(self.request.user)
5139
5140 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5141
5142 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5143
5144
5145
5146class DeploymentList(generics.ListCreateAPIView):
5147 queryset = Deployment.objects.select_related().all()
5148 serializer_class = DeploymentSerializer
5149 id_serializer_class = DeploymentIdSerializer
5150 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005151 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005152
5153 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005154 no_hyperlinks=False
5155 if hasattr(self.request,"QUERY_PARAMS"):
5156 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005157 if (no_hyperlinks):
5158 return self.id_serializer_class
5159 else:
5160 return self.serializer_class
5161
5162 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005163 if (not self.request.user.is_authenticated()):
5164 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005165 return Deployment.select_by_user(self.request.user)
5166
5167 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005168 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5169 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005170 response = {"error": "validation",
5171 "specific_error": "not serializer.is_valid()",
5172 "reasons": serializer.errors}
5173 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005174 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005175 obj.caller = request.user
5176 if obj.can_update(request.user):
5177 return super(DeploymentList, self).create(request, *args, **kwargs)
5178 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005179 raise Exception("failed obj.can_update")
5180
5181 ret = super(DeploymentList, self).create(request, *args, **kwargs)
5182 if (ret.status_code%100 != 200):
5183 raise Exception(ret.data)
5184
5185 return ret
5186
Scott Baker89a7b7c2014-10-07 00:10:17 -07005187
5188class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5189 queryset = Deployment.objects.select_related().all()
5190 serializer_class = DeploymentSerializer
5191 id_serializer_class = DeploymentIdSerializer
5192
5193 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005194 no_hyperlinks=False
5195 if hasattr(self.request,"QUERY_PARAMS"):
5196 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005197 if (no_hyperlinks):
5198 return self.id_serializer_class
5199 else:
5200 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005201
Scott Baker89a7b7c2014-10-07 00:10:17 -07005202 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005203 if (not self.request.user.is_authenticated()):
5204 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005205 return Deployment.select_by_user(self.request.user)
5206
5207 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5208
5209 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5210
5211
5212
5213class ReservationList(generics.ListCreateAPIView):
5214 queryset = Reservation.objects.select_related().all()
5215 serializer_class = ReservationSerializer
5216 id_serializer_class = ReservationIdSerializer
5217 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005218 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005219
5220 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005221 no_hyperlinks=False
5222 if hasattr(self.request,"QUERY_PARAMS"):
5223 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005224 if (no_hyperlinks):
5225 return self.id_serializer_class
5226 else:
5227 return self.serializer_class
5228
5229 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005230 if (not self.request.user.is_authenticated()):
5231 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005232 return Reservation.select_by_user(self.request.user)
5233
5234 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005235 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5236 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005237 response = {"error": "validation",
5238 "specific_error": "not serializer.is_valid()",
5239 "reasons": serializer.errors}
5240 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005241 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005242 obj.caller = request.user
5243 if obj.can_update(request.user):
5244 return super(ReservationList, self).create(request, *args, **kwargs)
5245 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005246 raise Exception("failed obj.can_update")
5247
5248 ret = super(ReservationList, self).create(request, *args, **kwargs)
5249 if (ret.status_code%100 != 200):
5250 raise Exception(ret.data)
5251
5252 return ret
5253
Scott Baker89a7b7c2014-10-07 00:10:17 -07005254
5255class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5256 queryset = Reservation.objects.select_related().all()
5257 serializer_class = ReservationSerializer
5258 id_serializer_class = ReservationIdSerializer
5259
5260 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005261 no_hyperlinks=False
5262 if hasattr(self.request,"QUERY_PARAMS"):
5263 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005264 if (no_hyperlinks):
5265 return self.id_serializer_class
5266 else:
5267 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005268
Scott Baker89a7b7c2014-10-07 00:10:17 -07005269 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005270 if (not self.request.user.is_authenticated()):
5271 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005272 return Reservation.select_by_user(self.request.user)
5273
5274 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5275
5276 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5277
Scott Baker89a7b7c2014-10-07 00:10:17 -07005278
Scott Baker57c725c2014-11-12 01:13:53 -08005279
Scott Baker89a7b7c2014-10-07 00:10:17 -07005280class SitePrivilegeList(generics.ListCreateAPIView):
5281 queryset = SitePrivilege.objects.select_related().all()
5282 serializer_class = SitePrivilegeSerializer
5283 id_serializer_class = SitePrivilegeIdSerializer
5284 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005285 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005286
5287 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005288 no_hyperlinks=False
5289 if hasattr(self.request,"QUERY_PARAMS"):
5290 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005291 if (no_hyperlinks):
5292 return self.id_serializer_class
5293 else:
5294 return self.serializer_class
5295
5296 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005297 if (not self.request.user.is_authenticated()):
5298 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005299 return SitePrivilege.select_by_user(self.request.user)
5300
5301 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005302 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5303 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005304 response = {"error": "validation",
5305 "specific_error": "not serializer.is_valid()",
5306 "reasons": serializer.errors}
5307 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005308 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005309 obj.caller = request.user
5310 if obj.can_update(request.user):
5311 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
5312 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005313 raise Exception("failed obj.can_update")
5314
5315 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
5316 if (ret.status_code%100 != 200):
5317 raise Exception(ret.data)
5318
5319 return ret
5320
Scott Baker89a7b7c2014-10-07 00:10:17 -07005321
5322class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5323 queryset = SitePrivilege.objects.select_related().all()
5324 serializer_class = SitePrivilegeSerializer
5325 id_serializer_class = SitePrivilegeIdSerializer
5326
5327 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005328 no_hyperlinks=False
5329 if hasattr(self.request,"QUERY_PARAMS"):
5330 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005331 if (no_hyperlinks):
5332 return self.id_serializer_class
5333 else:
5334 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005335
Scott Baker89a7b7c2014-10-07 00:10:17 -07005336 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005337 if (not self.request.user.is_authenticated()):
5338 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005339 return SitePrivilege.select_by_user(self.request.user)
5340
5341 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5342
5343 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5344
5345
5346
Scott Baker191f9b22015-01-12 13:16:39 -08005347class ControllerSliceList(generics.ListCreateAPIView):
5348 queryset = ControllerSlice.objects.select_related().all()
5349 serializer_class = ControllerSliceSerializer
5350 id_serializer_class = ControllerSliceIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005351 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005352 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005353
5354 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005355 no_hyperlinks=False
5356 if hasattr(self.request,"QUERY_PARAMS"):
5357 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005358 if (no_hyperlinks):
5359 return self.id_serializer_class
5360 else:
5361 return self.serializer_class
5362
5363 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005364 if (not self.request.user.is_authenticated()):
5365 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005366 return ControllerSlice.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005367
5368 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005369 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5370 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005371 response = {"error": "validation",
5372 "specific_error": "not serializer.is_valid()",
5373 "reasons": serializer.errors}
5374 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005375 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005376 obj.caller = request.user
5377 if obj.can_update(request.user):
Scott Baker191f9b22015-01-12 13:16:39 -08005378 return super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005379 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005380 raise Exception("failed obj.can_update")
5381
Scott Baker191f9b22015-01-12 13:16:39 -08005382 ret = super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005383 if (ret.status_code%100 != 200):
5384 raise Exception(ret.data)
5385
5386 return ret
5387
Scott Baker89a7b7c2014-10-07 00:10:17 -07005388
Scott Baker191f9b22015-01-12 13:16:39 -08005389class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5390 queryset = ControllerSlice.objects.select_related().all()
5391 serializer_class = ControllerSliceSerializer
5392 id_serializer_class = ControllerSliceIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005393
5394 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005395 no_hyperlinks=False
5396 if hasattr(self.request,"QUERY_PARAMS"):
5397 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005398 if (no_hyperlinks):
5399 return self.id_serializer_class
5400 else:
5401 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005402
Scott Baker89a7b7c2014-10-07 00:10:17 -07005403 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005404 if (not self.request.user.is_authenticated()):
5405 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005406 return ControllerSlice.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005407
5408 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5409
5410 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5411
Scott Baker89a7b7c2014-10-07 00:10:17 -07005412
Scott Baker57c725c2014-11-12 01:13:53 -08005413
Scott Bakerf2c0c512014-12-22 17:35:34 -08005414class ControllerDashboardViewList(generics.ListCreateAPIView):
5415 queryset = ControllerDashboardView.objects.select_related().all()
5416 serializer_class = ControllerDashboardViewSerializer
5417 id_serializer_class = ControllerDashboardViewIdSerializer
5418 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005419 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakerf2c0c512014-12-22 17:35:34 -08005420
5421 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005422 no_hyperlinks=False
5423 if hasattr(self.request,"QUERY_PARAMS"):
5424 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerf2c0c512014-12-22 17:35:34 -08005425 if (no_hyperlinks):
5426 return self.id_serializer_class
5427 else:
5428 return self.serializer_class
5429
5430 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005431 if (not self.request.user.is_authenticated()):
5432 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Bakerf2c0c512014-12-22 17:35:34 -08005433 return ControllerDashboardView.select_by_user(self.request.user)
5434
5435 def create(self, request, *args, **kwargs):
5436 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5437 if not (serializer.is_valid()):
5438 response = {"error": "validation",
5439 "specific_error": "not serializer.is_valid()",
5440 "reasons": serializer.errors}
5441 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5442 obj = serializer.object
5443 obj.caller = request.user
5444 if obj.can_update(request.user):
5445 return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
5446 else:
5447 raise Exception("failed obj.can_update")
5448
5449 ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
5450 if (ret.status_code%100 != 200):
5451 raise Exception(ret.data)
5452
5453 return ret
5454
5455
5456class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5457 queryset = ControllerDashboardView.objects.select_related().all()
5458 serializer_class = ControllerDashboardViewSerializer
5459 id_serializer_class = ControllerDashboardViewIdSerializer
5460
5461 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005462 no_hyperlinks=False
5463 if hasattr(self.request,"QUERY_PARAMS"):
5464 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerf2c0c512014-12-22 17:35:34 -08005465 if (no_hyperlinks):
5466 return self.id_serializer_class
5467 else:
5468 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005469
Scott Bakerf2c0c512014-12-22 17:35:34 -08005470 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005471 if (not self.request.user.is_authenticated()):
5472 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Bakerf2c0c512014-12-22 17:35:34 -08005473 return ControllerDashboardView.select_by_user(self.request.user)
5474
5475 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5476
5477 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5478
5479
5480
Scott Baker89a7b7c2014-10-07 00:10:17 -07005481class AccountList(generics.ListCreateAPIView):
5482 queryset = Account.objects.select_related().all()
5483 serializer_class = AccountSerializer
5484 id_serializer_class = AccountIdSerializer
5485 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005486 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005487
5488 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005489 no_hyperlinks=False
5490 if hasattr(self.request,"QUERY_PARAMS"):
5491 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005492 if (no_hyperlinks):
5493 return self.id_serializer_class
5494 else:
5495 return self.serializer_class
5496
5497 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005498 if (not self.request.user.is_authenticated()):
5499 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005500 return Account.select_by_user(self.request.user)
5501
5502 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005503 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5504 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005505 response = {"error": "validation",
5506 "specific_error": "not serializer.is_valid()",
5507 "reasons": serializer.errors}
5508 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005509 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005510 obj.caller = request.user
5511 if obj.can_update(request.user):
5512 return super(AccountList, self).create(request, *args, **kwargs)
5513 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005514 raise Exception("failed obj.can_update")
5515
5516 ret = super(AccountList, self).create(request, *args, **kwargs)
5517 if (ret.status_code%100 != 200):
5518 raise Exception(ret.data)
5519
5520 return ret
5521
Scott Baker89a7b7c2014-10-07 00:10:17 -07005522
5523class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5524 queryset = Account.objects.select_related().all()
5525 serializer_class = AccountSerializer
5526 id_serializer_class = AccountIdSerializer
5527
5528 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005529 no_hyperlinks=False
5530 if hasattr(self.request,"QUERY_PARAMS"):
5531 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005532 if (no_hyperlinks):
5533 return self.id_serializer_class
5534 else:
5535 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005536
Scott Baker89a7b7c2014-10-07 00:10:17 -07005537 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005538 if (not self.request.user.is_authenticated()):
5539 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005540 return Account.select_by_user(self.request.user)
5541
5542 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5543
5544 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5545
5546
5547
Scott Baker515dc9e2014-12-22 09:29:05 -08005548class ControllerRoleList(generics.ListCreateAPIView):
5549 queryset = ControllerRole.objects.select_related().all()
5550 serializer_class = ControllerRoleSerializer
5551 id_serializer_class = ControllerRoleIdSerializer
5552 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005553 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08005554
5555 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005556 no_hyperlinks=False
5557 if hasattr(self.request,"QUERY_PARAMS"):
5558 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005559 if (no_hyperlinks):
5560 return self.id_serializer_class
5561 else:
5562 return self.serializer_class
5563
5564 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005565 if (not self.request.user.is_authenticated()):
5566 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005567 return ControllerRole.select_by_user(self.request.user)
5568
5569 def create(self, request, *args, **kwargs):
5570 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5571 if not (serializer.is_valid()):
5572 response = {"error": "validation",
5573 "specific_error": "not serializer.is_valid()",
5574 "reasons": serializer.errors}
5575 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5576 obj = serializer.object
5577 obj.caller = request.user
5578 if obj.can_update(request.user):
5579 return super(ControllerRoleList, self).create(request, *args, **kwargs)
5580 else:
5581 raise Exception("failed obj.can_update")
5582
5583 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
5584 if (ret.status_code%100 != 200):
5585 raise Exception(ret.data)
5586
5587 return ret
5588
5589
5590class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5591 queryset = ControllerRole.objects.select_related().all()
5592 serializer_class = ControllerRoleSerializer
5593 id_serializer_class = ControllerRoleIdSerializer
5594
5595 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005596 no_hyperlinks=False
5597 if hasattr(self.request,"QUERY_PARAMS"):
5598 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005599 if (no_hyperlinks):
5600 return self.id_serializer_class
5601 else:
5602 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005603
Scott Baker515dc9e2014-12-22 09:29:05 -08005604 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005605 if (not self.request.user.is_authenticated()):
5606 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005607 return ControllerRole.select_by_user(self.request.user)
5608
5609 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5610
5611 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5612
5613
5614
Scott Baker89a7b7c2014-10-07 00:10:17 -07005615class NetworkParameterTypeList(generics.ListCreateAPIView):
5616 queryset = NetworkParameterType.objects.select_related().all()
5617 serializer_class = NetworkParameterTypeSerializer
5618 id_serializer_class = NetworkParameterTypeIdSerializer
5619 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005620 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005621
5622 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005623 no_hyperlinks=False
5624 if hasattr(self.request,"QUERY_PARAMS"):
5625 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005626 if (no_hyperlinks):
5627 return self.id_serializer_class
5628 else:
5629 return self.serializer_class
5630
5631 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005632 if (not self.request.user.is_authenticated()):
5633 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005634 return NetworkParameterType.select_by_user(self.request.user)
5635
5636 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005637 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5638 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005639 response = {"error": "validation",
5640 "specific_error": "not serializer.is_valid()",
5641 "reasons": serializer.errors}
5642 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005643 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005644 obj.caller = request.user
5645 if obj.can_update(request.user):
5646 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5647 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005648 raise Exception("failed obj.can_update")
5649
5650 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5651 if (ret.status_code%100 != 200):
5652 raise Exception(ret.data)
5653
5654 return ret
5655
Scott Baker89a7b7c2014-10-07 00:10:17 -07005656
5657class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5658 queryset = NetworkParameterType.objects.select_related().all()
5659 serializer_class = NetworkParameterTypeSerializer
5660 id_serializer_class = NetworkParameterTypeIdSerializer
5661
5662 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005663 no_hyperlinks=False
5664 if hasattr(self.request,"QUERY_PARAMS"):
5665 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005666 if (no_hyperlinks):
5667 return self.id_serializer_class
5668 else:
5669 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005670
Scott Baker89a7b7c2014-10-07 00:10:17 -07005671 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005672 if (not self.request.user.is_authenticated()):
5673 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005674 return NetworkParameterType.select_by_user(self.request.user)
5675
5676 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5677
5678 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5679
5680
5681
5682class SiteCredentialList(generics.ListCreateAPIView):
5683 queryset = SiteCredential.objects.select_related().all()
5684 serializer_class = SiteCredentialSerializer
5685 id_serializer_class = SiteCredentialIdSerializer
5686 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005687 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005688
5689 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005690 no_hyperlinks=False
5691 if hasattr(self.request,"QUERY_PARAMS"):
5692 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005693 if (no_hyperlinks):
5694 return self.id_serializer_class
5695 else:
5696 return self.serializer_class
5697
5698 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005699 if (not self.request.user.is_authenticated()):
5700 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005701 return SiteCredential.select_by_user(self.request.user)
5702
5703 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005704 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5705 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005706 response = {"error": "validation",
5707 "specific_error": "not serializer.is_valid()",
5708 "reasons": serializer.errors}
5709 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005710 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005711 obj.caller = request.user
5712 if obj.can_update(request.user):
5713 return super(SiteCredentialList, self).create(request, *args, **kwargs)
5714 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005715 raise Exception("failed obj.can_update")
5716
5717 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
5718 if (ret.status_code%100 != 200):
5719 raise Exception(ret.data)
5720
5721 return ret
5722
Scott Baker89a7b7c2014-10-07 00:10:17 -07005723
5724class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5725 queryset = SiteCredential.objects.select_related().all()
5726 serializer_class = SiteCredentialSerializer
5727 id_serializer_class = SiteCredentialIdSerializer
5728
5729 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005730 no_hyperlinks=False
5731 if hasattr(self.request,"QUERY_PARAMS"):
5732 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005733 if (no_hyperlinks):
5734 return self.id_serializer_class
5735 else:
5736 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005737
Scott Baker89a7b7c2014-10-07 00:10:17 -07005738 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005739 if (not self.request.user.is_authenticated()):
5740 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005741 return SiteCredential.select_by_user(self.request.user)
5742
5743 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5744
5745 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5746
5747
5748
Scott Baker515dc9e2014-12-22 09:29:05 -08005749class DeploymentPrivilegeList(generics.ListCreateAPIView):
5750 queryset = DeploymentPrivilege.objects.select_related().all()
5751 serializer_class = DeploymentPrivilegeSerializer
5752 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005753 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005754 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005755
5756 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005757 no_hyperlinks=False
5758 if hasattr(self.request,"QUERY_PARAMS"):
5759 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005760 if (no_hyperlinks):
5761 return self.id_serializer_class
5762 else:
5763 return self.serializer_class
5764
5765 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005766 if (not self.request.user.is_authenticated()):
5767 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005768 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005769
5770 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005771 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5772 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005773 response = {"error": "validation",
5774 "specific_error": "not serializer.is_valid()",
5775 "reasons": serializer.errors}
5776 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005777 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005778 obj.caller = request.user
5779 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005780 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005781 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005782 raise Exception("failed obj.can_update")
5783
Scott Baker515dc9e2014-12-22 09:29:05 -08005784 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005785 if (ret.status_code%100 != 200):
5786 raise Exception(ret.data)
5787
5788 return ret
5789
Scott Baker89a7b7c2014-10-07 00:10:17 -07005790
Scott Baker515dc9e2014-12-22 09:29:05 -08005791class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5792 queryset = DeploymentPrivilege.objects.select_related().all()
5793 serializer_class = DeploymentPrivilegeSerializer
5794 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005795
5796 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005797 no_hyperlinks=False
5798 if hasattr(self.request,"QUERY_PARAMS"):
5799 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005800 if (no_hyperlinks):
5801 return self.id_serializer_class
5802 else:
5803 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005804
Scott Baker89a7b7c2014-10-07 00:10:17 -07005805 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005806 if (not self.request.user.is_authenticated()):
5807 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005808 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005809
5810 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5811
5812 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5813
5814
5815
Scott Baker191f9b22015-01-12 13:16:39 -08005816class ControllerSlicePrivilegeList(generics.ListCreateAPIView):
5817 queryset = ControllerSlicePrivilege.objects.select_related().all()
5818 serializer_class = ControllerSlicePrivilegeSerializer
5819 id_serializer_class = ControllerSlicePrivilegeIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005820 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005821 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -08005822
5823 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005824 no_hyperlinks=False
5825 if hasattr(self.request,"QUERY_PARAMS"):
5826 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005827 if (no_hyperlinks):
5828 return self.id_serializer_class
5829 else:
5830 return self.serializer_class
5831
5832 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005833 if (not self.request.user.is_authenticated()):
5834 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005835 return ControllerSlicePrivilege.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005836
5837 def create(self, request, *args, **kwargs):
5838 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5839 if not (serializer.is_valid()):
5840 response = {"error": "validation",
5841 "specific_error": "not serializer.is_valid()",
5842 "reasons": serializer.errors}
5843 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5844 obj = serializer.object
5845 obj.caller = request.user
5846 if obj.can_update(request.user):
Scott Baker191f9b22015-01-12 13:16:39 -08005847 return super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005848 else:
5849 raise Exception("failed obj.can_update")
5850
Scott Baker191f9b22015-01-12 13:16:39 -08005851 ret = super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005852 if (ret.status_code%100 != 200):
5853 raise Exception(ret.data)
5854
5855 return ret
5856
5857
Scott Baker191f9b22015-01-12 13:16:39 -08005858class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5859 queryset = ControllerSlicePrivilege.objects.select_related().all()
5860 serializer_class = ControllerSlicePrivilegeSerializer
5861 id_serializer_class = ControllerSlicePrivilegeIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005862
5863 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005864 no_hyperlinks=False
5865 if hasattr(self.request,"QUERY_PARAMS"):
5866 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005867 if (no_hyperlinks):
5868 return self.id_serializer_class
5869 else:
5870 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005871
Scott Baker515dc9e2014-12-22 09:29:05 -08005872 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005873 if (not self.request.user.is_authenticated()):
5874 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005875 return ControllerSlicePrivilege.select_by_user(self.request.user)
5876
5877 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5878
5879 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5880
5881
5882
5883class SiteDeploymentList(generics.ListCreateAPIView):
5884 queryset = SiteDeployment.objects.select_related().all()
5885 serializer_class = SiteDeploymentSerializer
5886 id_serializer_class = SiteDeploymentIdSerializer
5887 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005888 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker191f9b22015-01-12 13:16:39 -08005889
5890 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005891 no_hyperlinks=False
5892 if hasattr(self.request,"QUERY_PARAMS"):
5893 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08005894 if (no_hyperlinks):
5895 return self.id_serializer_class
5896 else:
5897 return self.serializer_class
5898
5899 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005900 if (not self.request.user.is_authenticated()):
5901 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005902 return SiteDeployment.select_by_user(self.request.user)
5903
5904 def create(self, request, *args, **kwargs):
5905 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5906 if not (serializer.is_valid()):
5907 response = {"error": "validation",
5908 "specific_error": "not serializer.is_valid()",
5909 "reasons": serializer.errors}
5910 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5911 obj = serializer.object
5912 obj.caller = request.user
5913 if obj.can_update(request.user):
5914 return super(SiteDeploymentList, self).create(request, *args, **kwargs)
5915 else:
5916 raise Exception("failed obj.can_update")
5917
5918 ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
5919 if (ret.status_code%100 != 200):
5920 raise Exception(ret.data)
5921
5922 return ret
5923
5924
5925class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5926 queryset = SiteDeployment.objects.select_related().all()
5927 serializer_class = SiteDeploymentSerializer
5928 id_serializer_class = SiteDeploymentIdSerializer
5929
5930 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005931 no_hyperlinks=False
5932 if hasattr(self.request,"QUERY_PARAMS"):
5933 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08005934 if (no_hyperlinks):
5935 return self.id_serializer_class
5936 else:
5937 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005938
Scott Baker191f9b22015-01-12 13:16:39 -08005939 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005940 if (not self.request.user.is_authenticated()):
5941 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005942 return SiteDeployment.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005943
5944 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5945
5946 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5947
5948
5949
5950class DeploymentRoleList(generics.ListCreateAPIView):
5951 queryset = DeploymentRole.objects.select_related().all()
5952 serializer_class = DeploymentRoleSerializer
5953 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005954 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005955 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005956
5957 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005958 no_hyperlinks=False
5959 if hasattr(self.request,"QUERY_PARAMS"):
5960 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005961 if (no_hyperlinks):
5962 return self.id_serializer_class
5963 else:
5964 return self.serializer_class
5965
5966 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005967 if (not self.request.user.is_authenticated()):
5968 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005969 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005970
5971 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005972 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5973 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005974 response = {"error": "validation",
5975 "specific_error": "not serializer.is_valid()",
5976 "reasons": serializer.errors}
5977 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005978 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005979 obj.caller = request.user
5980 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005981 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005982 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005983 raise Exception("failed obj.can_update")
5984
Scott Baker515dc9e2014-12-22 09:29:05 -08005985 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005986 if (ret.status_code%100 != 200):
5987 raise Exception(ret.data)
5988
5989 return ret
5990
Scott Baker89a7b7c2014-10-07 00:10:17 -07005991
Scott Baker515dc9e2014-12-22 09:29:05 -08005992class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5993 queryset = DeploymentRole.objects.select_related().all()
5994 serializer_class = DeploymentRoleSerializer
5995 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005996
5997 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005998 no_hyperlinks=False
5999 if hasattr(self.request,"QUERY_PARAMS"):
6000 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006001 if (no_hyperlinks):
6002 return self.id_serializer_class
6003 else:
6004 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006005
Scott Baker89a7b7c2014-10-07 00:10:17 -07006006 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006007 if (not self.request.user.is_authenticated()):
6008 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08006009 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006010
6011 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
6012
6013 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
6014
6015
6016
6017class UserCredentialList(generics.ListCreateAPIView):
6018 queryset = UserCredential.objects.select_related().all()
6019 serializer_class = UserCredentialSerializer
6020 id_serializer_class = UserCredentialIdSerializer
6021 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006022 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006023
6024 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006025 no_hyperlinks=False
6026 if hasattr(self.request,"QUERY_PARAMS"):
6027 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006028 if (no_hyperlinks):
6029 return self.id_serializer_class
6030 else:
6031 return self.serializer_class
6032
6033 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006034 if (not self.request.user.is_authenticated()):
6035 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07006036 return UserCredential.select_by_user(self.request.user)
6037
6038 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006039 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6040 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006041 response = {"error": "validation",
6042 "specific_error": "not serializer.is_valid()",
6043 "reasons": serializer.errors}
6044 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006045 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07006046 obj.caller = request.user
6047 if obj.can_update(request.user):
6048 return super(UserCredentialList, self).create(request, *args, **kwargs)
6049 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006050 raise Exception("failed obj.can_update")
6051
6052 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
6053 if (ret.status_code%100 != 200):
6054 raise Exception(ret.data)
6055
6056 return ret
6057
Scott Baker89a7b7c2014-10-07 00:10:17 -07006058
6059class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
6060 queryset = UserCredential.objects.select_related().all()
6061 serializer_class = UserCredentialSerializer
6062 id_serializer_class = UserCredentialIdSerializer
6063
6064 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006065 no_hyperlinks=False
6066 if hasattr(self.request,"QUERY_PARAMS"):
6067 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006068 if (no_hyperlinks):
6069 return self.id_serializer_class
6070 else:
6071 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006072
Scott Baker89a7b7c2014-10-07 00:10:17 -07006073 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006074 if (not self.request.user.is_authenticated()):
6075 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07006076 return UserCredential.select_by_user(self.request.user)
6077
6078 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
6079
6080 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
6081
Scott Baker89a7b7c2014-10-07 00:10:17 -07006082
Scott Baker57c725c2014-11-12 01:13:53 -08006083
Scott Baker0caeaf02014-06-19 11:12:55 -07006084class SliceTagList(generics.ListCreateAPIView):
6085 queryset = SliceTag.objects.select_related().all()
6086 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006087 id_serializer_class = SliceTagIdSerializer
6088 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006089 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07006090
6091 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006092 no_hyperlinks=False
6093 if hasattr(self.request,"QUERY_PARAMS"):
6094 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006095 if (no_hyperlinks):
6096 return self.id_serializer_class
6097 else:
6098 return self.serializer_class
6099
Scott Baker0caeaf02014-06-19 11:12:55 -07006100 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006101 if (not self.request.user.is_authenticated()):
6102 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006103 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04006104
Scott Baker0caeaf02014-06-19 11:12:55 -07006105 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006106 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6107 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006108 response = {"error": "validation",
6109 "specific_error": "not serializer.is_valid()",
6110 "reasons": serializer.errors}
6111 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006112 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07006113 obj.caller = request.user
6114 if obj.can_update(request.user):
6115 return super(SliceTagList, self).create(request, *args, **kwargs)
6116 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006117 raise Exception("failed obj.can_update")
6118
6119 ret = super(SliceTagList, self).create(request, *args, **kwargs)
6120 if (ret.status_code%100 != 200):
6121 raise Exception(ret.data)
6122
6123 return ret
6124
Scott Baker0caeaf02014-06-19 11:12:55 -07006125
Scott Baker89a7b7c2014-10-07 00:10:17 -07006126class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006127 queryset = SliceTag.objects.select_related().all()
6128 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006129 id_serializer_class = SliceTagIdSerializer
6130
6131 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006132 no_hyperlinks=False
6133 if hasattr(self.request,"QUERY_PARAMS"):
6134 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006135 if (no_hyperlinks):
6136 return self.id_serializer_class
6137 else:
6138 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006139
Scott Baker0caeaf02014-06-19 11:12:55 -07006140 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006141 if (not self.request.user.is_authenticated()):
6142 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006143 return SliceTag.select_by_user(self.request.user)
6144
Scott Baker89a7b7c2014-10-07 00:10:17 -07006145 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07006146
Scott Baker89a7b7c2014-10-07 00:10:17 -07006147 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04006148
6149
6150
Scott Bakerf2c0c512014-12-22 17:35:34 -08006151class NetworkTemplateList(generics.ListCreateAPIView):
6152 queryset = NetworkTemplate.objects.select_related().all()
6153 serializer_class = NetworkTemplateSerializer
6154 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006155 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006156 filter_fields = ('id','created','updated','enacted','policed','backend_register','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 -07006157
6158 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006159 no_hyperlinks=False
6160 if hasattr(self.request,"QUERY_PARAMS"):
6161 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006162 if (no_hyperlinks):
6163 return self.id_serializer_class
6164 else:
6165 return self.serializer_class
6166
Scott Baker0caeaf02014-06-19 11:12:55 -07006167 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006168 if (not self.request.user.is_authenticated()):
6169 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Bakerf2c0c512014-12-22 17:35:34 -08006170 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04006171
Scott Baker0caeaf02014-06-19 11:12:55 -07006172 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006173 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6174 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006175 response = {"error": "validation",
6176 "specific_error": "not serializer.is_valid()",
6177 "reasons": serializer.errors}
6178 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006179 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07006180 obj.caller = request.user
6181 if obj.can_update(request.user):
Scott Bakerf2c0c512014-12-22 17:35:34 -08006182 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07006183 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006184 raise Exception("failed obj.can_update")
6185
Scott Bakerf2c0c512014-12-22 17:35:34 -08006186 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07006187 if (ret.status_code%100 != 200):
6188 raise Exception(ret.data)
6189
6190 return ret
6191
Scott Baker0caeaf02014-06-19 11:12:55 -07006192
Scott Bakerf2c0c512014-12-22 17:35:34 -08006193class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
6194 queryset = NetworkTemplate.objects.select_related().all()
6195 serializer_class = NetworkTemplateSerializer
6196 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006197
6198 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006199 no_hyperlinks=False
6200 if hasattr(self.request,"QUERY_PARAMS"):
6201 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006202 if (no_hyperlinks):
6203 return self.id_serializer_class
6204 else:
6205 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006206
Scott Baker0caeaf02014-06-19 11:12:55 -07006207 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006208 if (not self.request.user.is_authenticated()):
6209 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Bakerf2c0c512014-12-22 17:35:34 -08006210 return NetworkTemplate.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07006211
Scott Baker89a7b7c2014-10-07 00:10:17 -07006212 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07006213
Scott Baker89a7b7c2014-10-07 00:10:17 -07006214 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04006215
6216
6217
6218class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006219 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04006220 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006221 id_serializer_class = RouterIdSerializer
6222 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006223 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07006224
6225 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006226 no_hyperlinks=False
6227 if hasattr(self.request,"QUERY_PARAMS"):
6228 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006229 if (no_hyperlinks):
6230 return self.id_serializer_class
6231 else:
6232 return self.serializer_class
6233
Scott Baker0caeaf02014-06-19 11:12:55 -07006234 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006235 if (not self.request.user.is_authenticated()):
6236 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006237 return Router.select_by_user(self.request.user)
6238
6239 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006240 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6241 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006242 response = {"error": "validation",
6243 "specific_error": "not serializer.is_valid()",
6244 "reasons": serializer.errors}
6245 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006246 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07006247 obj.caller = request.user
6248 if obj.can_update(request.user):
6249 return super(RouterList, self).create(request, *args, **kwargs)
6250 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006251 raise Exception("failed obj.can_update")
6252
6253 ret = super(RouterList, self).create(request, *args, **kwargs)
6254 if (ret.status_code%100 != 200):
6255 raise Exception(ret.data)
6256
6257 return ret
6258
Sapan Bhatiadea39432014-06-13 03:10:36 -04006259
Scott Baker89a7b7c2014-10-07 00:10:17 -07006260class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006261 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04006262 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006263 id_serializer_class = RouterIdSerializer
6264
6265 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006266 no_hyperlinks=False
6267 if hasattr(self.request,"QUERY_PARAMS"):
6268 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006269 if (no_hyperlinks):
6270 return self.id_serializer_class
6271 else:
6272 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006273
Scott Baker0caeaf02014-06-19 11:12:55 -07006274 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006275 if (not self.request.user.is_authenticated()):
6276 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006277 return Router.select_by_user(self.request.user)
6278
Scott Baker89a7b7c2014-10-07 00:10:17 -07006279 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07006280
Scott Baker89a7b7c2014-10-07 00:10:17 -07006281 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04006282
6283
6284
Scott Baker0caeaf02014-06-19 11:12:55 -07006285class ServiceResourceList(generics.ListCreateAPIView):
6286 queryset = ServiceResource.objects.select_related().all()
6287 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006288 id_serializer_class = ServiceResourceIdSerializer
6289 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006290 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07006291
6292 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006293 no_hyperlinks=False
6294 if hasattr(self.request,"QUERY_PARAMS"):
6295 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006296 if (no_hyperlinks):
6297 return self.id_serializer_class
6298 else:
6299 return self.serializer_class
6300
Scott Baker0caeaf02014-06-19 11:12:55 -07006301 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006302 if (not self.request.user.is_authenticated()):
6303 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006304 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04006305
Scott Baker0caeaf02014-06-19 11:12:55 -07006306 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006307 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6308 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006309 response = {"error": "validation",
6310 "specific_error": "not serializer.is_valid()",
6311 "reasons": serializer.errors}
6312 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006313 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07006314 obj.caller = request.user
6315 if obj.can_update(request.user):
6316 return super(ServiceResourceList, self).create(request, *args, **kwargs)
6317 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006318 raise Exception("failed obj.can_update")
6319
6320 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
6321 if (ret.status_code%100 != 200):
6322 raise Exception(ret.data)
6323
6324 return ret
6325
Scott Baker0caeaf02014-06-19 11:12:55 -07006326
Scott Baker89a7b7c2014-10-07 00:10:17 -07006327class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006328 queryset = ServiceResource.objects.select_related().all()
6329 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006330 id_serializer_class = ServiceResourceIdSerializer
6331
6332 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006333 no_hyperlinks=False
6334 if hasattr(self.request,"QUERY_PARAMS"):
6335 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006336 if (no_hyperlinks):
6337 return self.id_serializer_class
6338 else:
6339 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006340
Scott Baker0caeaf02014-06-19 11:12:55 -07006341 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006342 if (not self.request.user.is_authenticated()):
6343 raise PermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006344 return ServiceResource.select_by_user(self.request.user)
6345
Scott Baker89a7b7c2014-10-07 00:10:17 -07006346 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07006347
Scott Baker89a7b7c2014-10-07 00:10:17 -07006348 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04006349
Sapan Bhatiadea39432014-06-13 03:10:36 -04006350
6351