blob: 13c41d4c4b61fa523f3f67f0e0ecffbdb458546c [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07006from rest_framework import status
Scott Bakerf3816ac2014-11-12 01:13:53 -08007from rest_framework.generics import GenericAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04008from core.models import *
9from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -070010from rest_framework import filters
Scott Baker55a2e292014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Sapan Bhatiadea39432014-06-13 03:10:36 -040012
13"""
Scott Baker08898c12014-10-29 23:41:11 -070014 Schema of the generator object:
15 all: Set of all Model objects
16 all_if(regex): Set of Model objects that match regex
Scott Bakerf3816ac2014-11-12 01:13:53 -080017
Scott Baker08898c12014-10-29 23:41:11 -070018 Model object:
19 plural: English plural of object name
20 camel: CamelCase version of object name
21 refs: list of references to other Model objects
22 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040023
Scott Baker08898c12014-10-29 23:41:11 -070024 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040025"""
26
Scott Baker55a2e292014-11-10 16:31:15 -080027def get_REST_patterns():
28 return patterns('',
29 url(r'^plstackapi/$', api_root),
30
31 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
32 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
33
34 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
35 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
36
37 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
38 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
39
40 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
41 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
42
43 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
44 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
45
46 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
47 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
48
49 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
50 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
51
52 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
53 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
54
55 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
56 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
57
58 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
59 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
60
Tony Mack336e0f92014-11-30 15:53:08 -050061 url(r'plstackapi/controllernetworks/$', ControllerNetworksList.as_view(), name='controllernetworks-list'),
62 url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworksDetail.as_view(), name ='controllernetworks-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -080063
64 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
65 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
66
67 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
68 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
69
70 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
71 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
72
73 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
74 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
75
76 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
77 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
78
79 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
80 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
81
Scott Baker196ffef2014-11-21 11:32:24 -080082 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
83 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -080084
85 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
86 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
87
88 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
89 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
90
91 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
92 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
93
94 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
95 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
96
97 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
98 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
99
100 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
101 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
102
103 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
104 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
105
106 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
107 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
108
Tony Mack336e0f92014-11-30 15:53:08 -0500109 url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
110 url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800111
Scott Baker55a2e292014-11-10 16:31:15 -0800112 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
113 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
114
115 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
116 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
117
118 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
119 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
120
121 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
122 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
123
124 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
125 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
126
127 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
128 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
Tony Mack336e0f92014-11-30 15:53:08 -0500129 url(r'plstackapi/Controller/$', ControllerList.as_view(), name='controller-list'),
130 url(r'plstackapi/Controller/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800131
132 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
133 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
134
Tony Mack336e0f92014-11-30 15:53:08 -0500135 url(r'plstackapi/controllerslices/$', ControllerSlicesList.as_view(), name='controllerslices-list'),
136 url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicesDetail.as_view(), name ='controllerslices-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800137
Scott Baker55a2e292014-11-10 16:31:15 -0800138 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
139 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
140
Scott Baker196ffef2014-11-21 11:32:24 -0800141 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
142 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800143
Tony Mack336e0f92014-11-30 15:53:08 -0500144 url(r'plstackapi/controllerusers/$', ControllerUsersList.as_view(), name='controllerusers-list'),
145 url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUsersDetail.as_view(), name ='controllerusers-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800146
147 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
148 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
149
150 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
151 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
152
153 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
154 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
155
Tony Mack336e0f92014-11-30 15:53:08 -0500156 url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'),
157 url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800158
Tony Mack336e0f92014-11-30 15:53:08 -0500159 url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
160 url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
Scott Baker55a2e292014-11-10 16:31:15 -0800161
162 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
163 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
164
Scott Baker196ffef2014-11-21 11:32:24 -0800165 url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'),
166 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'),
Tony Mack336e0f92014-11-30 15:53:08 -0500167 url(r'plstackapi/controllersites/$', ControllerSitesList.as_view(), name='sitedeployments-list'),
168 url(r'plstackapi/controllersites/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSitesDetail.as_view(), name ='sitedeployments-detail'),
Scott Baker196ffef2014-11-21 11:32:24 -0800169
Scott Baker55a2e292014-11-10 16:31:15 -0800170 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
171 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
172
173 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
174 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
175
176 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
177 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
178
179 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
180 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
181
182 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400183
184@api_view(['GET'])
185def api_root(request, format=None):
186 return Response({
Scott Baker08898c12014-10-29 23:41:11 -0700187 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
188 'images': reverse('image-list', request=request, format=format),
189 'networkparameters': reverse('networkparameter-list', request=request, format=format),
190 'sites': reverse('site-list', request=request, format=format),
191 'sliceroles': reverse('slicerole-list', request=request, format=format),
192 'tags': reverse('tag-list', request=request, format=format),
193 'invoices': reverse('invoice-list', request=request, format=format),
194 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
195 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
196 'networkslivers': reverse('networksliver-list', request=request, format=format),
Tony Mack336e0f92014-11-30 15:53:08 -0500197 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700198 'flavors': reverse('flavor-list', request=request, format=format),
199 'projects': reverse('project-list', request=request, format=format),
200 'slices': reverse('slice-list', request=request, format=format),
201 'networks': reverse('network-list', request=request, format=format),
202 'services': reverse('service-list', request=request, format=format),
203 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800204 'payments': reverse('payment-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700205 'charges': reverse('charge-list', request=request, format=format),
206 'roles': reverse('role-list', request=request, format=format),
207 'usableobjects': reverse('usableobject-list', request=request, format=format),
208 'siteroles': reverse('siterole-list', request=request, format=format),
209 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
210 'slivers': reverse('sliver-list', request=request, format=format),
211 'nodes': reverse('node-list', request=request, format=format),
212 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Tony Mack336e0f92014-11-30 15:53:08 -0500213 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700214 'reservedresources': reverse('reservedresource-list', request=request, format=format),
215 'networkslices': reverse('networkslice-list', request=request, format=format),
216 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
217 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
218 'users': reverse('user-list', request=request, format=format),
219 'deployments': reverse('deployment-list', request=request, format=format),
Tony Mack336e0f92014-11-30 15:53:08 -0500220 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700221 'reservations': reverse('reservation-list', request=request, format=format),
Tony Mack336e0f92014-11-30 15:53:08 -0500222 'controllersliceses': reverse('controllerslices-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700223 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800224 'planetstacks': reverse('planetstack-list', request=request, format=format),
Tony Mack336e0f92014-11-30 15:53:08 -0500225 'controlleruserses': reverse('controllerusers-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700226 'accounts': reverse('account-list', request=request, format=format),
227 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
228 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Tony Mack336e0f92014-11-30 15:53:08 -0500229 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format),
230 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700231 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800232 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Tony Mack336e0f92014-11-30 15:53:08 -0500233 'controllersiteses': reverse('controllersites-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700234 'slicetags': reverse('slicetag-list', request=request, format=format),
235 'networktemplates': reverse('networktemplate-list', request=request, format=format),
236 'routers': reverse('router-list', request=request, format=format),
237 'serviceresources': reverse('serviceresource-list', request=request, format=format),
238
Sapan Bhatiadea39432014-06-13 03:10:36 -0400239 })
240
241# Based on serializers.py
242
243
244
Scott Baker0caeaf02014-06-19 11:12:55 -0700245class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700246 id = serializers.Field()
247
Scott Baker196ffef2014-11-21 11:32:24 -0800248 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800249 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800250 def getHumanReadableName(self, obj):
251 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800252 def getValidators(self, obj):
253 try:
254 return obj.getValidators()
255 except:
256 return None
Scott Baker08898c12014-10-29 23:41:11 -0700257 class Meta:
258 model = ServiceAttribute
Scott Baker351148c2014-11-25 00:53:25 -0800259 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700260
261class ServiceAttributeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700262 id = serializers.Field()
263
Scott Baker196ffef2014-11-21 11:32:24 -0800264 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800265 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800266 def getHumanReadableName(self, obj):
267 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800268 def getValidators(self, obj):
269 try:
270 return obj.getValidators()
271 except:
272 return None
Scott Baker08898c12014-10-29 23:41:11 -0700273 class Meta:
274 model = ServiceAttribute
Scott Baker351148c2014-11-25 00:53:25 -0800275 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700276
277
Sapan Bhatiadea39432014-06-13 03:10:36 -0400278
279
280class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700281 id = serializers.Field()
282
Scott Baker196ffef2014-11-21 11:32:24 -0800283 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800284 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800285 def getHumanReadableName(self, obj):
286 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800287 def getValidators(self, obj):
288 try:
289 return obj.getValidators()
290 except:
291 return None
Scott Baker08898c12014-10-29 23:41:11 -0700292 class Meta:
293 model = Image
Scott Baker351148c2014-11-25 00:53:25 -0800294 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700295
296class ImageIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700297 id = serializers.Field()
298
Scott Baker196ffef2014-11-21 11:32:24 -0800299 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800300 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800301 def getHumanReadableName(self, obj):
302 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800303 def getValidators(self, obj):
304 try:
305 return obj.getValidators()
306 except:
307 return None
Scott Baker08898c12014-10-29 23:41:11 -0700308 class Meta:
309 model = Image
Scott Baker351148c2014-11-25 00:53:25 -0800310 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700311
312
Sapan Bhatiadea39432014-06-13 03:10:36 -0400313
314
Scott Baker0caeaf02014-06-19 11:12:55 -0700315class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700316 id = serializers.Field()
317
Scott Baker196ffef2014-11-21 11:32:24 -0800318 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800319 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800320 def getHumanReadableName(self, obj):
321 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800322 def getValidators(self, obj):
323 try:
324 return obj.getValidators()
325 except:
326 return None
Scott Baker08898c12014-10-29 23:41:11 -0700327 class Meta:
328 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800329 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700330
331class NetworkParameterIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700332 id = serializers.Field()
333
Scott Baker196ffef2014-11-21 11:32:24 -0800334 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800335 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800336 def getHumanReadableName(self, obj):
337 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800338 def getValidators(self, obj):
339 try:
340 return obj.getValidators()
341 except:
342 return None
Scott Baker08898c12014-10-29 23:41:11 -0700343 class Meta:
344 model = NetworkParameter
Scott Baker351148c2014-11-25 00:53:25 -0800345 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700346
347
Sapan Bhatiadea39432014-06-13 03:10:36 -0400348
349
350class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700351 id = serializers.Field()
352
Scott Baker196ffef2014-11-21 11:32:24 -0800353 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800354 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800355 def getHumanReadableName(self, obj):
356 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800357 def getValidators(self, obj):
358 try:
359 return obj.getValidators()
360 except:
361 return None
Scott Baker08898c12014-10-29 23:41:11 -0700362 class Meta:
363 model = Site
Scott Baker351148c2014-11-25 00:53:25 -0800364 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Scott Baker46b58542014-08-11 17:26:12 -0700365
366class SiteIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700367 id = serializers.Field()
368
Scott Baker196ffef2014-11-21 11:32:24 -0800369 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800370 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800371 def getHumanReadableName(self, obj):
372 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800373 def getValidators(self, obj):
374 try:
375 return obj.getValidators()
376 except:
377 return None
Scott Baker08898c12014-10-29 23:41:11 -0700378 class Meta:
379 model = Site
Scott Baker351148c2014-11-25 00:53:25 -0800380 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Scott Baker46b58542014-08-11 17:26:12 -0700381
382
Sapan Bhatiadea39432014-06-13 03:10:36 -0400383
384
Scott Baker0caeaf02014-06-19 11:12:55 -0700385class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700386 id = serializers.Field()
387
Scott Baker196ffef2014-11-21 11:32:24 -0800388 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800389 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800390 def getHumanReadableName(self, obj):
391 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800392 def getValidators(self, obj):
393 try:
394 return obj.getValidators()
395 except:
396 return None
Scott Baker08898c12014-10-29 23:41:11 -0700397 class Meta:
398 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800399 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700400
401class SliceRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700402 id = serializers.Field()
403
Scott Baker196ffef2014-11-21 11:32:24 -0800404 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800405 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800406 def getHumanReadableName(self, obj):
407 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800408 def getValidators(self, obj):
409 try:
410 return obj.getValidators()
411 except:
412 return None
Scott Baker08898c12014-10-29 23:41:11 -0700413 class Meta:
414 model = SliceRole
Scott Baker351148c2014-11-25 00:53:25 -0800415 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700416
417
Sapan Bhatiadea39432014-06-13 03:10:36 -0400418
419
420class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700421 id = serializers.Field()
422
Scott Baker196ffef2014-11-21 11:32:24 -0800423 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800424 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800425 def getHumanReadableName(self, obj):
426 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800427 def getValidators(self, obj):
428 try:
429 return obj.getValidators()
430 except:
431 return None
Scott Baker08898c12014-10-29 23:41:11 -0700432 class Meta:
433 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800434 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700435
436class TagIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700437 id = serializers.Field()
438
Scott Baker196ffef2014-11-21 11:32:24 -0800439 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800440 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800441 def getHumanReadableName(self, obj):
442 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800443 def getValidators(self, obj):
444 try:
445 return obj.getValidators()
446 except:
447 return None
Scott Baker08898c12014-10-29 23:41:11 -0700448 class Meta:
449 model = Tag
Scott Baker351148c2014-11-25 00:53:25 -0800450 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700451
452
Sapan Bhatiadea39432014-06-13 03:10:36 -0400453
454
455class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700456 id = serializers.Field()
457
Scott Baker196ffef2014-11-21 11:32:24 -0800458 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800459 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800460 def getHumanReadableName(self, obj):
461 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800462 def getValidators(self, obj):
463 try:
464 return obj.getValidators()
465 except:
466 return None
Scott Baker08898c12014-10-29 23:41:11 -0700467 class Meta:
468 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800469 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700470
471class InvoiceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700472 id = serializers.Field()
473
Scott Baker196ffef2014-11-21 11:32:24 -0800474 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800475 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800476 def getHumanReadableName(self, obj):
477 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800478 def getValidators(self, obj):
479 try:
480 return obj.getValidators()
481 except:
482 return None
Scott Baker08898c12014-10-29 23:41:11 -0700483 class Meta:
484 model = Invoice
Scott Baker351148c2014-11-25 00:53:25 -0800485 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700486
487
Sapan Bhatiadea39432014-06-13 03:10:36 -0400488
489
Scott Baker0caeaf02014-06-19 11:12:55 -0700490class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700491 id = serializers.Field()
492
Scott Baker196ffef2014-11-21 11:32:24 -0800493 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800494 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800495 def getHumanReadableName(self, obj):
496 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800497 def getValidators(self, obj):
498 try:
499 return obj.getValidators()
500 except:
501 return None
Scott Baker08898c12014-10-29 23:41:11 -0700502 class Meta:
503 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800504 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700505
506class SlicePrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700507 id = serializers.Field()
508
Scott Baker196ffef2014-11-21 11:32:24 -0800509 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800510 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800511 def getHumanReadableName(self, obj):
512 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800513 def getValidators(self, obj):
514 try:
515 return obj.getValidators()
516 except:
517 return None
Scott Baker08898c12014-10-29 23:41:11 -0700518 class Meta:
519 model = SlicePrivilege
Scott Baker351148c2014-11-25 00:53:25 -0800520 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700521
522
Scott Baker0caeaf02014-06-19 11:12:55 -0700523
524
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700525class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700526 id = serializers.Field()
527
Scott Baker196ffef2014-11-21 11:32:24 -0800528 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800529 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800530 def getHumanReadableName(self, obj):
531 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800532 def getValidators(self, obj):
533 try:
534 return obj.getValidators()
535 except:
536 return None
Scott Baker08898c12014-10-29 23:41:11 -0700537 class Meta:
538 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800539 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700540
541class PlanetStackRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700542 id = serializers.Field()
543
Scott Baker196ffef2014-11-21 11:32:24 -0800544 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800545 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800546 def getHumanReadableName(self, obj):
547 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800548 def getValidators(self, obj):
549 try:
550 return obj.getValidators()
551 except:
552 return None
Scott Baker08898c12014-10-29 23:41:11 -0700553 class Meta:
554 model = PlanetStackRole
Scott Baker351148c2014-11-25 00:53:25 -0800555 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700556
557
558
559
Scott Baker0caeaf02014-06-19 11:12:55 -0700560class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700561 id = serializers.Field()
562
Scott Baker196ffef2014-11-21 11:32:24 -0800563 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800564 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800565 def getHumanReadableName(self, obj):
566 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800567 def getValidators(self, obj):
568 try:
569 return obj.getValidators()
570 except:
571 return None
Scott Baker08898c12014-10-29 23:41:11 -0700572 class Meta:
573 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800574 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700575
576class NetworkSliverIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700577 id = serializers.Field()
578
Scott Baker196ffef2014-11-21 11:32:24 -0800579 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800580 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800581 def getHumanReadableName(self, obj):
582 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800583 def getValidators(self, obj):
584 try:
585 return obj.getValidators()
586 except:
587 return None
Scott Baker08898c12014-10-29 23:41:11 -0700588 class Meta:
589 model = NetworkSliver
Scott Baker351148c2014-11-25 00:53:25 -0800590 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700591
592
Scott Baker0caeaf02014-06-19 11:12:55 -0700593
594
Tony Mack336e0f92014-11-30 15:53:08 -0500595class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700596 id = serializers.Field()
597
Scott Baker196ffef2014-11-21 11:32:24 -0800598 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800599 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800600 def getHumanReadableName(self, obj):
601 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800602 def getValidators(self, obj):
603 try:
604 return obj.getValidators()
605 except:
606 return None
Scott Baker08898c12014-10-29 23:41:11 -0700607 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -0500608 model = ControllerNetworks
Scott Baker351148c2014-11-25 00:53:25 -0800609 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700610
Tony Mack336e0f92014-11-30 15:53:08 -0500611class ControllerNetworksIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700612 id = serializers.Field()
613
Scott Baker196ffef2014-11-21 11:32:24 -0800614 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800615 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800616 def getHumanReadableName(self, obj):
617 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800618 def getValidators(self, obj):
619 try:
620 return obj.getValidators()
621 except:
622 return None
Scott Baker08898c12014-10-29 23:41:11 -0700623 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -0500624 model = ControllerNetworks
Scott Baker351148c2014-11-25 00:53:25 -0800625 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700626
627
Sapan Bhatiadea39432014-06-13 03:10:36 -0400628
629
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700630class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700631 id = serializers.Field()
632
Scott Baker196ffef2014-11-21 11:32:24 -0800633 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800634 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800635 def getHumanReadableName(self, obj):
636 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800637 def getValidators(self, obj):
638 try:
639 return obj.getValidators()
640 except:
641 return None
Scott Baker08898c12014-10-29 23:41:11 -0700642 class Meta:
643 model = Flavor
Scott Baker351148c2014-11-25 00:53:25 -0800644 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700645
646class FlavorIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700647 id = serializers.Field()
648
Scott Baker196ffef2014-11-21 11:32:24 -0800649 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800650 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800651 def getHumanReadableName(self, obj):
652 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800653 def getValidators(self, obj):
654 try:
655 return obj.getValidators()
656 except:
657 return None
Scott Baker08898c12014-10-29 23:41:11 -0700658 class Meta:
659 model = Flavor
Scott Baker351148c2014-11-25 00:53:25 -0800660 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700661
662
663
664
665class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700666 id = serializers.Field()
667
Scott Baker196ffef2014-11-21 11:32:24 -0800668 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800669 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800670 def getHumanReadableName(self, obj):
671 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800672 def getValidators(self, obj):
673 try:
674 return obj.getValidators()
675 except:
676 return None
Scott Baker08898c12014-10-29 23:41:11 -0700677 class Meta:
678 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800679 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700680
681class ProjectIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700682 id = serializers.Field()
683
Scott Baker196ffef2014-11-21 11:32:24 -0800684 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800685 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800686 def getHumanReadableName(self, obj):
687 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800688 def getValidators(self, obj):
689 try:
690 return obj.getValidators()
691 except:
692 return None
Scott Baker08898c12014-10-29 23:41:11 -0700693 class Meta:
694 model = Project
Scott Baker351148c2014-11-25 00:53:25 -0800695 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700696
697
698
699
Sapan Bhatiadea39432014-06-13 03:10:36 -0400700class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700701 id = serializers.Field()
702
703
704 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
705
706
707
708 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
709
710
711
712 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
713
714
715
716 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
717
718
Scott Baker196ffef2014-11-21 11:32:24 -0800719 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800720 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800721 def getHumanReadableName(self, obj):
722 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800723 def getValidators(self, obj):
724 try:
725 return obj.getValidators()
726 except:
727 return None
Scott Baker08898c12014-10-29 23:41:11 -0700728 class Meta:
729 model = Slice
Scott Baker351148c2014-11-25 00:53:25 -0800730 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700731
732class SliceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700733 id = serializers.Field()
734
735
736 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
737
738
739
740 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
741
742
743
744 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
745
746
747
748 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
749
750
Scott Baker196ffef2014-11-21 11:32:24 -0800751 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800752 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800753 def getHumanReadableName(self, obj):
754 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800755 def getValidators(self, obj):
756 try:
757 return obj.getValidators()
758 except:
759 return None
Scott Baker08898c12014-10-29 23:41:11 -0700760 class Meta:
761 model = Slice
Scott Baker351148c2014-11-25 00:53:25 -0800762 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700763
764
Sapan Bhatiadea39432014-06-13 03:10:36 -0400765
766
767class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700768 id = serializers.Field()
769
770
771 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
772
773
774
775 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
776
777
778
779 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
780
781
782
783 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
784
785
Scott Baker196ffef2014-11-21 11:32:24 -0800786 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800787 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800788 def getHumanReadableName(self, obj):
789 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800790 def getValidators(self, obj):
791 try:
792 return obj.getValidators()
793 except:
794 return None
Scott Baker08898c12014-10-29 23:41:11 -0700795 class Meta:
796 model = Network
Scott Baker351148c2014-11-25 00:53:25 -0800797 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700798
799class NetworkIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700800 id = serializers.Field()
801
802
803 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
804
805
806
807 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
808
809
810
811 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
812
813
814
815 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
816
817
Scott Baker196ffef2014-11-21 11:32:24 -0800818 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800819 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800820 def getHumanReadableName(self, obj):
821 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800822 def getValidators(self, obj):
823 try:
824 return obj.getValidators()
825 except:
826 return None
Scott Baker08898c12014-10-29 23:41:11 -0700827 class Meta:
828 model = Network
Scott Baker351148c2014-11-25 00:53:25 -0800829 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700830
831
Sapan Bhatiadea39432014-06-13 03:10:36 -0400832
833
834class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700835 id = serializers.Field()
836
Scott Baker196ffef2014-11-21 11:32:24 -0800837 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800838 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800839 def getHumanReadableName(self, obj):
840 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800841 def getValidators(self, obj):
842 try:
843 return obj.getValidators()
844 except:
845 return None
Scott Baker08898c12014-10-29 23:41:11 -0700846 class Meta:
847 model = Service
Scott Baker351148c2014-11-25 00:53:25 -0800848 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700849
850class ServiceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700851 id = serializers.Field()
852
Scott Baker196ffef2014-11-21 11:32:24 -0800853 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800854 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800855 def getHumanReadableName(self, obj):
856 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800857 def getValidators(self, obj):
858 try:
859 return obj.getValidators()
860 except:
861 return None
Scott Baker08898c12014-10-29 23:41:11 -0700862 class Meta:
863 model = Service
Scott Baker351148c2014-11-25 00:53:25 -0800864 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700865
866
Sapan Bhatiadea39432014-06-13 03:10:36 -0400867
868
Scott Baker0caeaf02014-06-19 11:12:55 -0700869class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700870 id = serializers.Field()
871
Scott Baker196ffef2014-11-21 11:32:24 -0800872 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800873 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800874 def getHumanReadableName(self, obj):
875 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800876 def getValidators(self, obj):
877 try:
878 return obj.getValidators()
879 except:
880 return None
Scott Baker08898c12014-10-29 23:41:11 -0700881 class Meta:
882 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -0800883 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700884
885class ServiceClassIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700886 id = serializers.Field()
887
Scott Baker196ffef2014-11-21 11:32:24 -0800888 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800889 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800890 def getHumanReadableName(self, obj):
891 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800892 def getValidators(self, obj):
893 try:
894 return obj.getValidators()
895 except:
896 return None
Scott Baker08898c12014-10-29 23:41:11 -0700897 class Meta:
898 model = ServiceClass
Scott Baker351148c2014-11-25 00:53:25 -0800899 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700900
901
Sapan Bhatiadea39432014-06-13 03:10:36 -0400902
903
Scott Baker196ffef2014-11-21 11:32:24 -0800904class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700905 id = serializers.Field()
906
Scott Baker196ffef2014-11-21 11:32:24 -0800907 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800908 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800909 def getHumanReadableName(self, obj):
910 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800911 def getValidators(self, obj):
912 try:
913 return obj.getValidators()
914 except:
915 return None
Scott Baker08898c12014-10-29 23:41:11 -0700916 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -0800917 model = Payment
Scott Baker351148c2014-11-25 00:53:25 -0800918 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700919
Scott Baker196ffef2014-11-21 11:32:24 -0800920class PaymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700921 id = serializers.Field()
922
Scott Baker196ffef2014-11-21 11:32:24 -0800923 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800924 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800925 def getHumanReadableName(self, obj):
926 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800927 def getValidators(self, obj):
928 try:
929 return obj.getValidators()
930 except:
931 return None
Scott Baker08898c12014-10-29 23:41:11 -0700932 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -0800933 model = Payment
Scott Baker351148c2014-11-25 00:53:25 -0800934 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700935
936
Sapan Bhatiadea39432014-06-13 03:10:36 -0400937
938
939class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700940 id = serializers.Field()
941
Scott Baker196ffef2014-11-21 11:32:24 -0800942 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800943 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800944 def getHumanReadableName(self, obj):
945 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800946 def getValidators(self, obj):
947 try:
948 return obj.getValidators()
949 except:
950 return None
Scott Baker08898c12014-10-29 23:41:11 -0700951 class Meta:
952 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -0800953 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700954
955class ChargeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700956 id = serializers.Field()
957
Scott Baker196ffef2014-11-21 11:32:24 -0800958 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800959 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800960 def getHumanReadableName(self, obj):
961 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800962 def getValidators(self, obj):
963 try:
964 return obj.getValidators()
965 except:
966 return None
Scott Baker08898c12014-10-29 23:41:11 -0700967 class Meta:
968 model = Charge
Scott Baker351148c2014-11-25 00:53:25 -0800969 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700970
971
Sapan Bhatiadea39432014-06-13 03:10:36 -0400972
973
974class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700975 id = serializers.Field()
976
Scott Baker196ffef2014-11-21 11:32:24 -0800977 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800978 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800979 def getHumanReadableName(self, obj):
980 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800981 def getValidators(self, obj):
982 try:
983 return obj.getValidators()
984 except:
985 return None
Scott Baker08898c12014-10-29 23:41:11 -0700986 class Meta:
987 model = Role
Scott Baker351148c2014-11-25 00:53:25 -0800988 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700989
990class RoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700991 id = serializers.Field()
992
Scott Baker196ffef2014-11-21 11:32:24 -0800993 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800994 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800995 def getHumanReadableName(self, obj):
996 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800997 def getValidators(self, obj):
998 try:
999 return obj.getValidators()
1000 except:
1001 return None
Scott Baker08898c12014-10-29 23:41:11 -07001002 class Meta:
1003 model = Role
Scott Baker351148c2014-11-25 00:53:25 -08001004 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001005
1006
Sapan Bhatiadea39432014-06-13 03:10:36 -04001007
1008
Scott Baker0caeaf02014-06-19 11:12:55 -07001009class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001010 id = serializers.Field()
1011
Scott Baker196ffef2014-11-21 11:32:24 -08001012 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001013 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001014 def getHumanReadableName(self, obj):
1015 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001016 def getValidators(self, obj):
1017 try:
1018 return obj.getValidators()
1019 except:
1020 return None
Scott Baker08898c12014-10-29 23:41:11 -07001021 class Meta:
1022 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001023 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001024
1025class UsableObjectIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001026 id = serializers.Field()
1027
Scott Baker196ffef2014-11-21 11:32:24 -08001028 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001029 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001030 def getHumanReadableName(self, obj):
1031 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001032 def getValidators(self, obj):
1033 try:
1034 return obj.getValidators()
1035 except:
1036 return None
Scott Baker08898c12014-10-29 23:41:11 -07001037 class Meta:
1038 model = UsableObject
Scott Baker351148c2014-11-25 00:53:25 -08001039 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001040
1041
Sapan Bhatiadea39432014-06-13 03:10:36 -04001042
1043
Scott Baker0caeaf02014-06-19 11:12:55 -07001044class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001045 id = serializers.Field()
1046
Scott Baker196ffef2014-11-21 11:32:24 -08001047 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001048 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001049 def getHumanReadableName(self, obj):
1050 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001051 def getValidators(self, obj):
1052 try:
1053 return obj.getValidators()
1054 except:
1055 return None
Scott Baker08898c12014-10-29 23:41:11 -07001056 class Meta:
1057 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001058 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001059
1060class SiteRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001061 id = serializers.Field()
1062
Scott Baker196ffef2014-11-21 11:32:24 -08001063 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001064 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001065 def getHumanReadableName(self, obj):
1066 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001067 def getValidators(self, obj):
1068 try:
1069 return obj.getValidators()
1070 except:
1071 return None
Scott Baker08898c12014-10-29 23:41:11 -07001072 class Meta:
1073 model = SiteRole
Scott Baker351148c2014-11-25 00:53:25 -08001074 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001075
1076
Scott Baker0caeaf02014-06-19 11:12:55 -07001077
1078
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001079class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001080 id = serializers.Field()
1081
Scott Baker196ffef2014-11-21 11:32:24 -08001082 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001083 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001084 def getHumanReadableName(self, obj):
1085 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001086 def getValidators(self, obj):
1087 try:
1088 return obj.getValidators()
1089 except:
1090 return None
Scott Baker08898c12014-10-29 23:41:11 -07001091 class Meta:
1092 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001093 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001094
1095class SliceCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001096 id = serializers.Field()
1097
Scott Baker196ffef2014-11-21 11:32:24 -08001098 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001099 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001100 def getHumanReadableName(self, obj):
1101 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001102 def getValidators(self, obj):
1103 try:
1104 return obj.getValidators()
1105 except:
1106 return None
Scott Baker08898c12014-10-29 23:41:11 -07001107 class Meta:
1108 model = SliceCredential
Scott Baker351148c2014-11-25 00:53:25 -08001109 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001110
1111
1112
1113
Sapan Bhatiadea39432014-06-13 03:10:36 -04001114class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001115 id = serializers.Field()
1116
1117
1118 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1119
1120
1121
1122 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1123
1124
Scott Baker196ffef2014-11-21 11:32:24 -08001125 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001126 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001127 def getHumanReadableName(self, obj):
1128 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001129 def getValidators(self, obj):
1130 try:
1131 return obj.getValidators()
1132 except:
1133 return None
Scott Baker08898c12014-10-29 23:41:11 -07001134 class Meta:
1135 model = Sliver
Scott Baker351148c2014-11-25 00:53:25 -08001136 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001137
1138class SliverIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001139 id = serializers.Field()
1140
1141
1142 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1143
1144
1145
1146 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1147
1148
Scott Baker196ffef2014-11-21 11:32:24 -08001149 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001150 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001151 def getHumanReadableName(self, obj):
1152 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001153 def getValidators(self, obj):
1154 try:
1155 return obj.getValidators()
1156 except:
1157 return None
Scott Baker08898c12014-10-29 23:41:11 -07001158 class Meta:
1159 model = Sliver
Scott Baker351148c2014-11-25 00:53:25 -08001160 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001161
1162
Sapan Bhatiadea39432014-06-13 03:10:36 -04001163
1164
1165class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001166 id = serializers.Field()
1167
Scott Baker196ffef2014-11-21 11:32:24 -08001168 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001169 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001170 def getHumanReadableName(self, obj):
1171 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001172 def getValidators(self, obj):
1173 try:
1174 return obj.getValidators()
1175 except:
1176 return None
Scott Baker08898c12014-10-29 23:41:11 -07001177 class Meta:
1178 model = Node
Scott Baker351148c2014-11-25 00:53:25 -08001179 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001180
1181class NodeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001182 id = serializers.Field()
1183
Scott Baker196ffef2014-11-21 11:32:24 -08001184 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001185 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001186 def getHumanReadableName(self, obj):
1187 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001188 def getValidators(self, obj):
1189 try:
1190 return obj.getValidators()
1191 except:
1192 return None
Scott Baker08898c12014-10-29 23:41:11 -07001193 class Meta:
1194 model = Node
Scott Baker351148c2014-11-25 00:53:25 -08001195 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001196
1197
Sapan Bhatiadea39432014-06-13 03:10:36 -04001198
1199
Scott Baker0caeaf02014-06-19 11:12:55 -07001200class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001201 id = serializers.Field()
1202
Scott Baker196ffef2014-11-21 11:32:24 -08001203 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001204 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001205 def getHumanReadableName(self, obj):
1206 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001207 def getValidators(self, obj):
1208 try:
1209 return obj.getValidators()
1210 except:
1211 return None
Scott Baker08898c12014-10-29 23:41:11 -07001212 class Meta:
1213 model = DashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001214 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker46b58542014-08-11 17:26:12 -07001215
1216class DashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001217 id = serializers.Field()
1218
Scott Baker196ffef2014-11-21 11:32:24 -08001219 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001220 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001221 def getHumanReadableName(self, obj):
1222 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001223 def getValidators(self, obj):
1224 try:
1225 return obj.getValidators()
1226 except:
1227 return None
Scott Baker08898c12014-10-29 23:41:11 -07001228 class Meta:
1229 model = DashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001230 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker196ffef2014-11-21 11:32:24 -08001231
1232
1233
1234
Tony Mack336e0f92014-11-30 15:53:08 -05001235class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker196ffef2014-11-21 11:32:24 -08001236 id = serializers.Field()
1237
1238 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001239 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001240 def getHumanReadableName(self, obj):
1241 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001242 def getValidators(self, obj):
1243 try:
1244 return obj.getValidators()
1245 except:
1246 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001247 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001248 model = ControllerImages
Scott Baker351148c2014-11-25 00:53:25 -08001249 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08001250
Tony Mack336e0f92014-11-30 15:53:08 -05001251class ControllerImagesIdSerializer(serializers.ModelSerializer):
Scott Baker196ffef2014-11-21 11:32:24 -08001252 id = serializers.Field()
1253
1254 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001255 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001256 def getHumanReadableName(self, obj):
1257 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001258 def getValidators(self, obj):
1259 try:
1260 return obj.getValidators()
1261 except:
1262 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001263 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001264 model = ControllerImages
Scott Baker351148c2014-11-25 00:53:25 -08001265 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001266
1267
Sapan Bhatiadea39432014-06-13 03:10:36 -04001268
1269
Scott Baker0caeaf02014-06-19 11:12:55 -07001270class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001271 id = serializers.Field()
1272
Scott Baker196ffef2014-11-21 11:32:24 -08001273 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001274 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001275 def getHumanReadableName(self, obj):
1276 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001277 def getValidators(self, obj):
1278 try:
1279 return obj.getValidators()
1280 except:
1281 return None
Scott Baker08898c12014-10-29 23:41:11 -07001282 class Meta:
1283 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001284 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001285
1286class ReservedResourceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001287 id = serializers.Field()
1288
Scott Baker196ffef2014-11-21 11:32:24 -08001289 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001290 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001291 def getHumanReadableName(self, obj):
1292 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001293 def getValidators(self, obj):
1294 try:
1295 return obj.getValidators()
1296 except:
1297 return None
Scott Baker08898c12014-10-29 23:41:11 -07001298 class Meta:
1299 model = ReservedResource
Scott Baker351148c2014-11-25 00:53:25 -08001300 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001301
1302
1303
1304
Scott Baker0caeaf02014-06-19 11:12:55 -07001305class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001306 id = serializers.Field()
1307
Scott Baker196ffef2014-11-21 11:32:24 -08001308 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001309 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001310 def getHumanReadableName(self, obj):
1311 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001312 def getValidators(self, obj):
1313 try:
1314 return obj.getValidators()
1315 except:
1316 return None
Scott Baker08898c12014-10-29 23:41:11 -07001317 class Meta:
1318 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001319 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001320
1321class NetworkSliceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001322 id = serializers.Field()
1323
Scott Baker196ffef2014-11-21 11:32:24 -08001324 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001325 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001326 def getHumanReadableName(self, obj):
1327 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001328 def getValidators(self, obj):
1329 try:
1330 return obj.getValidators()
1331 except:
1332 return None
Scott Baker08898c12014-10-29 23:41:11 -07001333 class Meta:
1334 model = NetworkSlice
Scott Baker351148c2014-11-25 00:53:25 -08001335 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001336
1337
Scott Baker0caeaf02014-06-19 11:12:55 -07001338
1339
1340class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001341 id = serializers.Field()
1342
Scott Baker196ffef2014-11-21 11:32:24 -08001343 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001344 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001345 def getHumanReadableName(self, obj):
1346 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001347 def getValidators(self, obj):
1348 try:
1349 return obj.getValidators()
1350 except:
1351 return None
Scott Baker08898c12014-10-29 23:41:11 -07001352 class Meta:
1353 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001354 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001355
1356class UserDashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001357 id = serializers.Field()
1358
Scott Baker196ffef2014-11-21 11:32:24 -08001359 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001360 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001361 def getHumanReadableName(self, obj):
1362 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001363 def getValidators(self, obj):
1364 try:
1365 return obj.getValidators()
1366 except:
Tony Mack336e0f92014-11-30 15:53:08 -05001367 return None
Scott Baker08898c12014-10-29 23:41:11 -07001368 class Meta:
1369 model = UserDashboardView
Scott Baker351148c2014-11-25 00:53:25 -08001370 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001371
1372
1373
1374
Scott Baker0caeaf02014-06-19 11:12:55 -07001375class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001376 id = serializers.Field()
1377
Scott Baker196ffef2014-11-21 11:32:24 -08001378 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001379 validators = serializers.SerializerMethodField("getValidators")
Tony Mack336e0f92014-11-30 15:53:08 -05001380 def getHumanReadableName(self, obj):
Scott Baker196ffef2014-11-21 11:32:24 -08001381 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001382 def getValidators(self, obj):
1383 try:
1384 return obj.getValidators()
1385 except:
1386 return None
Scott Baker08898c12014-10-29 23:41:11 -07001387 class Meta:
1388 model = PlanetStackPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001389 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001390
1391class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001392 id = serializers.Field()
1393
Scott Baker196ffef2014-11-21 11:32:24 -08001394 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001395 validators = serializers.SerializerMethodField("getValidators")
Tony Mack336e0f92014-11-30 15:53:08 -05001396 def getHumanReadableName(self, obj):
1397 return str(obj)
1398 def getValidators(self, obj):
Scott Baker351148c2014-11-25 00:53:25 -08001399 try:
1400 return obj.getValidators()
1401 except:
Tony Mack336e0f92014-11-30 15:53:08 -05001402 return None
Scott Baker08898c12014-10-29 23:41:11 -07001403 class Meta:
1404 model = PlanetStackPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001405 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001406
1407
Sapan Bhatiadea39432014-06-13 03:10:36 -04001408
1409
1410class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001411 id = serializers.Field()
1412
Scott Baker196ffef2014-11-21 11:32:24 -08001413 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001414 validators = serializers.SerializerMethodField("getValidators")
Tony Mack336e0f92014-11-30 15:53:08 -05001415 def getHumanReadableName(self, obj):
Scott Baker196ffef2014-11-21 11:32:24 -08001416 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001417 def getValidators(self, obj):
1418 try:
1419 return obj.getValidators()
1420 except:
1421 return None
Scott Baker08898c12014-10-29 23:41:11 -07001422 class Meta:
1423 model = User
Scott Baker351148c2014-11-25 00:53:25 -08001424 fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
Scott Baker46b58542014-08-11 17:26:12 -07001425
1426class UserIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001427 id = serializers.Field()
1428
Scott Baker196ffef2014-11-21 11:32:24 -08001429 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001430 validators = serializers.SerializerMethodField("getValidators")
Tony Mack336e0f92014-11-30 15:53:08 -05001431 def getHumanReadableName(self, obj):
1432 return str(obj)
1433 def getValidators(self, obj):
Scott Baker351148c2014-11-25 00:53:25 -08001434 try:
1435 return obj.getValidators()
1436 except:
Tony Mack336e0f92014-11-30 15:53:08 -05001437 return None
Scott Baker08898c12014-10-29 23:41:11 -07001438 class Meta:
1439 model = User
Scott Baker351148c2014-11-25 00:53:25 -08001440 fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
Scott Baker46b58542014-08-11 17:26:12 -07001441
1442
Sapan Bhatiadea39432014-06-13 03:10:36 -04001443
1444
1445class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001446 id = serializers.Field()
1447
1448
1449 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1450
1451
1452
1453 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1454
1455
1456
1457 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1458
1459
1460
1461 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1462
1463
Scott Baker196ffef2014-11-21 11:32:24 -08001464 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001465 validators = serializers.SerializerMethodField("getValidators")
Tony Mack336e0f92014-11-30 15:53:08 -05001466 def getHumanReadableName(self, obj):
Scott Baker196ffef2014-11-21 11:32:24 -08001467 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001468 def getValidators(self, obj):
1469 try:
1470 return obj.getValidators()
1471 except:
1472 return None
Scott Baker08898c12014-10-29 23:41:11 -07001473 class Meta:
1474 model = Deployment
Tony Mack336e0f92014-11-30 15:53:08 -05001475 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','sites','sites','flavors','flavors',)
1476
1477
1478class ControllerSerializer(serializers.HyperlinkedModelSerializer):
1479 id = serializers.Field()
1480 site_deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sitedeployment-detail')
1481 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1482 validators = serializers.SerializerMethodField("getValidators")
1483 def getHumanReadableName(self, obj):
1484 return str(obj)
1485 def getValidators(self, obj):
1486 try:
1487 return obj.getValidators()
1488 except:
1489 return None
1490 class Meta:
1491 model = Controller
1492 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl',)
1493
Scott Baker46b58542014-08-11 17:26:12 -07001494
1495class DeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001496 id = serializers.Field()
1497
1498
1499 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1500
1501
1502
1503 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1504
1505
1506
1507 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1508
1509
1510
1511 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1512
1513
Scott Baker196ffef2014-11-21 11:32:24 -08001514 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001515 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001516 def getHumanReadableName(self, obj):
1517 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001518 def getValidators(self, obj):
1519 try:
1520 return obj.getValidators()
1521 except:
1522 return None
Scott Baker08898c12014-10-29 23:41:11 -07001523 class Meta:
1524 model = Deployment
Scott Baker351148c2014-11-25 00:53:25 -08001525 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001526
1527
Tony Mack336e0f92014-11-30 15:53:08 -05001528class ControllerSerializer(serializers.HyperlinkedModelSerializer):
1529 id = serializers.Field()
1530 site_deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sitedeployment-detail')
1531 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1532 validators = serializers.SerializerMethodField("getValidators")
1533 def getHumanReadableName(self, obj):
1534 return str(obj)
1535 def getValidators(self, obj):
1536 try:
1537 return obj.getValidators()
1538 except:
1539 return None
1540 class Meta:
1541 model = Controller
1542 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','admin_user','admin_password','admin_tenant','auth_url','backend_type')
1543
1544
1545class ControllerIdSerializer(serializers.ModelSerializer):
1546 id = serializers.Field()
1547 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1548 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1549 validators = serializers.SerializerMethodField("getValidators")
1550 def getHumanReadableName(self, obj):
1551 return str(obj)
1552 def getValidators(self, obj):
1553 try:
1554 return obj.getValidators()
1555 except:
1556 return None
1557 class Meta:
1558 model = Controller
1559 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','admin_user','admin_password','admin_tenant','auth_url','backend_type')
Sapan Bhatiadea39432014-06-13 03:10:36 -04001560
1561
1562class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001563 id = serializers.Field()
1564
Scott Baker196ffef2014-11-21 11:32:24 -08001565 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001566 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001567 def getHumanReadableName(self, obj):
1568 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001569 def getValidators(self, obj):
1570 try:
1571 return obj.getValidators()
1572 except:
1573 return None
Scott Baker08898c12014-10-29 23:41:11 -07001574 class Meta:
1575 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001576 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001577
1578class ReservationIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001579 id = serializers.Field()
1580
Scott Baker196ffef2014-11-21 11:32:24 -08001581 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001582 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001583 def getHumanReadableName(self, obj):
1584 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001585 def getValidators(self, obj):
1586 try:
1587 return obj.getValidators()
1588 except:
1589 return None
Scott Baker08898c12014-10-29 23:41:11 -07001590 class Meta:
1591 model = Reservation
Scott Baker351148c2014-11-25 00:53:25 -08001592 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001593
1594
Scott Baker0caeaf02014-06-19 11:12:55 -07001595
1596
Tony Mack336e0f92014-11-30 15:53:08 -05001597class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001598 id = serializers.Field()
1599
Scott Baker196ffef2014-11-21 11:32:24 -08001600 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001601 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001602 def getHumanReadableName(self, obj):
1603 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001604 def getValidators(self, obj):
1605 try:
1606 return obj.getValidators()
1607 except:
1608 return None
Scott Baker08898c12014-10-29 23:41:11 -07001609 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001610 model = ControllerSlices
Scott Baker351148c2014-11-25 00:53:25 -08001611 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001612
Tony Mack336e0f92014-11-30 15:53:08 -05001613class ControllerSlicesIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001614 id = serializers.Field()
1615
Scott Baker196ffef2014-11-21 11:32:24 -08001616 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001617 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001618 def getHumanReadableName(self, obj):
1619 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001620 def getValidators(self, obj):
1621 try:
1622 return obj.getValidators()
1623 except:
1624 return None
Scott Baker08898c12014-10-29 23:41:11 -07001625 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001626 model = ControllerSlices
Scott Baker351148c2014-11-25 00:53:25 -08001627 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08001628
1629
1630
1631
1632class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1633 id = serializers.Field()
1634
1635 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001636 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001637 def getHumanReadableName(self, obj):
1638 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001639 def getValidators(self, obj):
1640 try:
1641 return obj.getValidators()
1642 except:
1643 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001644 class Meta:
1645 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001646 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001647
1648class SitePrivilegeIdSerializer(serializers.ModelSerializer):
1649 id = serializers.Field()
1650
1651 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001652 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001653 def getHumanReadableName(self, obj):
1654 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001655 def getValidators(self, obj):
1656 try:
1657 return obj.getValidators()
1658 except:
1659 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001660 class Meta:
1661 model = SitePrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001662 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001663
1664
1665
1666
1667class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
1668 id = serializers.Field()
1669
1670 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001671 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001672 def getHumanReadableName(self, obj):
1673 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001674 def getValidators(self, obj):
1675 try:
1676 return obj.getValidators()
1677 except:
1678 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001679 class Meta:
1680 model = PlanetStack
Scott Baker351148c2014-11-25 00:53:25 -08001681 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker196ffef2014-11-21 11:32:24 -08001682
1683class PlanetStackIdSerializer(serializers.ModelSerializer):
1684 id = serializers.Field()
1685
1686 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001687 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001688 def getHumanReadableName(self, obj):
1689 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001690 def getValidators(self, obj):
1691 try:
1692 return obj.getValidators()
1693 except:
1694 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001695 class Meta:
1696 model = PlanetStack
Scott Baker351148c2014-11-25 00:53:25 -08001697 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001698
1699
Sapan Bhatiadea39432014-06-13 03:10:36 -04001700
1701
Tony Mack336e0f92014-11-30 15:53:08 -05001702class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001703 id = serializers.Field()
1704
Scott Baker196ffef2014-11-21 11:32:24 -08001705 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001706 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001707 def getHumanReadableName(self, obj):
1708 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001709 def getValidators(self, obj):
1710 try:
1711 return obj.getValidators()
1712 except:
1713 return None
Scott Baker08898c12014-10-29 23:41:11 -07001714 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001715 model = ControllerUsers
Scott Baker351148c2014-11-25 00:53:25 -08001716 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001717
Tony Mack336e0f92014-11-30 15:53:08 -05001718class ControllerUsersIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001719 id = serializers.Field()
1720
Scott Baker196ffef2014-11-21 11:32:24 -08001721 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001722 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001723 def getHumanReadableName(self, obj):
1724 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001725 def getValidators(self, obj):
1726 try:
1727 return obj.getValidators()
1728 except:
1729 return None
Scott Baker08898c12014-10-29 23:41:11 -07001730 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001731 model = ControllerUsers
Scott Baker351148c2014-11-25 00:53:25 -08001732 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001733
1734
Scott Baker0caeaf02014-06-19 11:12:55 -07001735
1736
Sapan Bhatiadea39432014-06-13 03:10:36 -04001737class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001738 id = serializers.Field()
1739
Scott Baker196ffef2014-11-21 11:32:24 -08001740 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001741 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001742 def getHumanReadableName(self, obj):
1743 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001744 def getValidators(self, obj):
1745 try:
1746 return obj.getValidators()
1747 except:
1748 return None
Scott Baker08898c12014-10-29 23:41:11 -07001749 class Meta:
1750 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001751 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001752
1753class AccountIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001754 id = serializers.Field()
1755
Scott Baker196ffef2014-11-21 11:32:24 -08001756 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001757 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001758 def getHumanReadableName(self, obj):
1759 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001760 def getValidators(self, obj):
1761 try:
1762 return obj.getValidators()
1763 except:
1764 return None
Scott Baker08898c12014-10-29 23:41:11 -07001765 class Meta:
1766 model = Account
Scott Baker351148c2014-11-25 00:53:25 -08001767 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001768
1769
Sapan Bhatiadea39432014-06-13 03:10:36 -04001770
1771
Scott Baker0caeaf02014-06-19 11:12:55 -07001772class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001773 id = serializers.Field()
1774
Scott Baker196ffef2014-11-21 11:32:24 -08001775 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001776 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001777 def getHumanReadableName(self, obj):
1778 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001779 def getValidators(self, obj):
1780 try:
1781 return obj.getValidators()
1782 except:
1783 return None
Scott Baker08898c12014-10-29 23:41:11 -07001784 class Meta:
1785 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08001786 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001787
1788class NetworkParameterTypeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001789 id = serializers.Field()
1790
Scott Baker196ffef2014-11-21 11:32:24 -08001791 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001792 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001793 def getHumanReadableName(self, obj):
1794 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001795 def getValidators(self, obj):
1796 try:
1797 return obj.getValidators()
1798 except:
1799 return None
Scott Baker08898c12014-10-29 23:41:11 -07001800 class Meta:
1801 model = NetworkParameterType
Scott Baker351148c2014-11-25 00:53:25 -08001802 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001803
1804
Sapan Bhatiadea39432014-06-13 03:10:36 -04001805
1806
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001807class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001808 id = serializers.Field()
1809
Scott Baker196ffef2014-11-21 11:32:24 -08001810 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001811 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001812 def getHumanReadableName(self, obj):
1813 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001814 def getValidators(self, obj):
1815 try:
1816 return obj.getValidators()
1817 except:
1818 return None
Scott Baker08898c12014-10-29 23:41:11 -07001819 class Meta:
1820 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08001821 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001822
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001823class SiteCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001824 id = serializers.Field()
1825
Scott Baker196ffef2014-11-21 11:32:24 -08001826 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001827 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001828 def getHumanReadableName(self, obj):
1829 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001830 def getValidators(self, obj):
1831 try:
1832 return obj.getValidators()
1833 except:
1834 return None
Scott Baker08898c12014-10-29 23:41:11 -07001835 class Meta:
1836 model = SiteCredential
Scott Baker351148c2014-11-25 00:53:25 -08001837 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001838
1839
Scott Baker0caeaf02014-06-19 11:12:55 -07001840
1841
Tony Mack336e0f92014-11-30 15:53:08 -05001842class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001843 id = serializers.Field()
1844
Scott Baker196ffef2014-11-21 11:32:24 -08001845 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001846 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001847 def getHumanReadableName(self, obj):
1848 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001849 def getValidators(self, obj):
1850 try:
1851 return obj.getValidators()
1852 except:
1853 return None
Scott Baker08898c12014-10-29 23:41:11 -07001854 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001855 model = ControllerPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001856 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001857
Tony Mack336e0f92014-11-30 15:53:08 -05001858class ControllerPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001859 id = serializers.Field()
1860
Scott Baker196ffef2014-11-21 11:32:24 -08001861 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001862 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001863 def getHumanReadableName(self, obj):
1864 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001865 def getValidators(self, obj):
1866 try:
1867 return obj.getValidators()
1868 except:
1869 return None
Scott Baker08898c12014-10-29 23:41:11 -07001870 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001871 model = ControllerPrivilege
Scott Baker351148c2014-11-25 00:53:25 -08001872 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001873
1874
1875
1876
Tony Mack336e0f92014-11-30 15:53:08 -05001877class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001878 id = serializers.Field()
1879
Scott Baker196ffef2014-11-21 11:32:24 -08001880 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001881 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001882 def getHumanReadableName(self, obj):
1883 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001884 def getValidators(self, obj):
1885 try:
1886 return obj.getValidators()
1887 except:
1888 return None
Scott Baker08898c12014-10-29 23:41:11 -07001889 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001890 model = ControllerRole
Scott Baker351148c2014-11-25 00:53:25 -08001891 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001892
Tony Mack336e0f92014-11-30 15:53:08 -05001893class ControllerRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001894 id = serializers.Field()
1895
Scott Baker196ffef2014-11-21 11:32:24 -08001896 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001897 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001898 def getHumanReadableName(self, obj):
1899 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001900 def getValidators(self, obj):
1901 try:
1902 return obj.getValidators()
1903 except:
1904 return None
Scott Baker08898c12014-10-29 23:41:11 -07001905 class Meta:
Tony Mack336e0f92014-11-30 15:53:08 -05001906 model = ControllerRole
Scott Baker351148c2014-11-25 00:53:25 -08001907 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001908
1909
Sapan Bhatiadea39432014-06-13 03:10:36 -04001910
1911
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001912class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001913 id = serializers.Field()
1914
Scott Baker196ffef2014-11-21 11:32:24 -08001915 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001916 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001917 def getHumanReadableName(self, obj):
1918 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001919 def getValidators(self, obj):
1920 try:
1921 return obj.getValidators()
1922 except:
1923 return None
Scott Baker08898c12014-10-29 23:41:11 -07001924 class Meta:
1925 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08001926 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001927
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001928class UserCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001929 id = serializers.Field()
1930
Scott Baker196ffef2014-11-21 11:32:24 -08001931 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001932 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001933 def getHumanReadableName(self, obj):
1934 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001935 def getValidators(self, obj):
1936 try:
1937 return obj.getValidators()
1938 except:
1939 return None
Scott Baker08898c12014-10-29 23:41:11 -07001940 class Meta:
1941 model = UserCredential
Scott Baker351148c2014-11-25 00:53:25 -08001942 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker196ffef2014-11-21 11:32:24 -08001943
1944
1945
1946
1947class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
1948 id = serializers.Field()
1949
1950 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001951 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001952 def getHumanReadableName(self, obj):
1953 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001954 def getValidators(self, obj):
1955 try:
1956 return obj.getValidators()
1957 except:
1958 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001959 class Meta:
1960 model = SiteDeployments
Scott Baker351148c2014-11-25 00:53:25 -08001961 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08001962
1963class SiteDeploymentsIdSerializer(serializers.ModelSerializer):
1964 id = serializers.Field()
1965
1966 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001967 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001968 def getHumanReadableName(self, obj):
1969 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001970 def getValidators(self, obj):
1971 try:
1972 return obj.getValidators()
1973 except:
1974 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001975 class Meta:
1976 model = SiteDeployments
Tony Mack336e0f92014-11-30 15:53:08 -05001977 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment')
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001978
1979
Tony Mack336e0f92014-11-30 15:53:08 -05001980class ControllerSitesSerializer(serializers.HyperlinkedModelSerializer):
1981 id = serializers.Field()
1982
1983 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1984 validators = serializers.SerializerMethodField("getValidators")
1985 def getHumanReadableName(self, obj):
1986 return str(obj)
1987 def getValidators(self, obj):
1988 try:
1989 return obj.getValidators()
1990 except:
1991 return None
1992 class Meta:
1993 model = ControllerSites
1994 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site_deployment','controller','tenant_id',)
1995
1996class ControllerSitesIdSerializer(serializers.ModelSerializer):
1997 id = serializers.Field()
1998
1999 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2000 validators = serializers.SerializerMethodField("getValidators")
2001 def getHumanReadableName(self, obj):
2002 return str(obj)
2003 def getValidators(self, obj):
2004 try:
2005 return obj.getValidators()
2006 except:
2007 return None
2008 class Meta:
2009 model = ControllerSites
2010 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site_deployment','controller','tenant_id',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002011
2012
Scott Baker0caeaf02014-06-19 11:12:55 -07002013class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002014 id = serializers.Field()
2015
Scott Baker196ffef2014-11-21 11:32:24 -08002016 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002017 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002018 def getHumanReadableName(self, obj):
2019 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002020 def getValidators(self, obj):
2021 try:
2022 return obj.getValidators()
2023 except:
2024 return None
Scott Baker08898c12014-10-29 23:41:11 -07002025 class Meta:
2026 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08002027 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002028
2029class SliceTagIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002030 id = serializers.Field()
2031
Scott Baker196ffef2014-11-21 11:32:24 -08002032 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002033 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002034 def getHumanReadableName(self, obj):
2035 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002036 def getValidators(self, obj):
2037 try:
2038 return obj.getValidators()
2039 except:
2040 return None
Scott Baker08898c12014-10-29 23:41:11 -07002041 class Meta:
2042 model = SliceTag
Scott Baker351148c2014-11-25 00:53:25 -08002043 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002044
2045
Scott Baker0caeaf02014-06-19 11:12:55 -07002046
2047
2048class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002049 id = serializers.Field()
2050
Scott Baker196ffef2014-11-21 11:32:24 -08002051 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002052 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002053 def getHumanReadableName(self, obj):
2054 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002055 def getValidators(self, obj):
2056 try:
2057 return obj.getValidators()
2058 except:
2059 return None
Scott Baker08898c12014-10-29 23:41:11 -07002060 class Meta:
2061 model = NetworkTemplate
Scott Baker351148c2014-11-25 00:53:25 -08002062 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07002063
2064class NetworkTemplateIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002065 id = serializers.Field()
2066
Scott Baker196ffef2014-11-21 11:32:24 -08002067 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002068 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002069 def getHumanReadableName(self, obj):
2070 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002071 def getValidators(self, obj):
2072 try:
2073 return obj.getValidators()
2074 except:
2075 return None
Scott Baker08898c12014-10-29 23:41:11 -07002076 class Meta:
2077 model = NetworkTemplate
Scott Baker351148c2014-11-25 00:53:25 -08002078 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07002079
2080
Sapan Bhatiadea39432014-06-13 03:10:36 -04002081
2082
2083class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002084 id = serializers.Field()
2085
Scott Baker196ffef2014-11-21 11:32:24 -08002086 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002087 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002088 def getHumanReadableName(self, obj):
2089 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002090 def getValidators(self, obj):
2091 try:
2092 return obj.getValidators()
2093 except:
2094 return None
Scott Baker08898c12014-10-29 23:41:11 -07002095 class Meta:
2096 model = Router
Scott Baker351148c2014-11-25 00:53:25 -08002097 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07002098
2099class RouterIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002100 id = serializers.Field()
2101
Scott Baker196ffef2014-11-21 11:32:24 -08002102 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002103 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002104 def getHumanReadableName(self, obj):
2105 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002106 def getValidators(self, obj):
2107 try:
2108 return obj.getValidators()
2109 except:
2110 return None
Scott Baker08898c12014-10-29 23:41:11 -07002111 class Meta:
2112 model = Router
Scott Baker351148c2014-11-25 00:53:25 -08002113 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07002114
2115
Sapan Bhatiadea39432014-06-13 03:10:36 -04002116
2117
Scott Baker0caeaf02014-06-19 11:12:55 -07002118class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002119 id = serializers.Field()
2120
Scott Baker196ffef2014-11-21 11:32:24 -08002121 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002122 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002123 def getHumanReadableName(self, obj):
2124 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002125 def getValidators(self, obj):
2126 try:
2127 return obj.getValidators()
2128 except:
2129 return None
Scott Baker08898c12014-10-29 23:41:11 -07002130 class Meta:
2131 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002132 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002133
2134class ServiceResourceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07002135 id = serializers.Field()
2136
Scott Baker196ffef2014-11-21 11:32:24 -08002137 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002138 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002139 def getHumanReadableName(self, obj):
2140 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002141 def getValidators(self, obj):
2142 try:
2143 return obj.getValidators()
2144 except:
2145 return None
Scott Baker08898c12014-10-29 23:41:11 -07002146 class Meta:
2147 model = ServiceResource
Scott Baker351148c2014-11-25 00:53:25 -08002148 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002149
2150
Sapan Bhatiadea39432014-06-13 03:10:36 -04002151
2152
2153serializerLookUp = {
2154
Scott Baker0caeaf02014-06-19 11:12:55 -07002155 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002156
2157 Image: ImageSerializer,
2158
Scott Baker0caeaf02014-06-19 11:12:55 -07002159 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002160
2161 Site: SiteSerializer,
2162
Scott Baker0caeaf02014-06-19 11:12:55 -07002163 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002164
2165 Tag: TagSerializer,
2166
2167 Invoice: InvoiceSerializer,
2168
Scott Baker0caeaf02014-06-19 11:12:55 -07002169 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002170
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002171 PlanetStackRole: PlanetStackRoleSerializer,
2172
Scott Baker0caeaf02014-06-19 11:12:55 -07002173 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002174
Tony Mack336e0f92014-11-30 15:53:08 -05002175 ControllerNetworks: ControllerNetworksSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002176
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002177 Flavor: FlavorSerializer,
2178
2179 Project: ProjectSerializer,
2180
Sapan Bhatiadea39432014-06-13 03:10:36 -04002181 Slice: SliceSerializer,
2182
2183 Network: NetworkSerializer,
2184
2185 Service: ServiceSerializer,
2186
Scott Baker0caeaf02014-06-19 11:12:55 -07002187 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002188
Scott Baker196ffef2014-11-21 11:32:24 -08002189 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002190
2191 Charge: ChargeSerializer,
2192
2193 Role: RoleSerializer,
2194
Scott Baker0caeaf02014-06-19 11:12:55 -07002195 UsableObject: UsableObjectSerializer,
2196
2197 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002198
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002199 SliceCredential: SliceCredentialSerializer,
2200
Sapan Bhatiadea39432014-06-13 03:10:36 -04002201 Sliver: SliverSerializer,
2202
2203 Node: NodeSerializer,
2204
Scott Baker0caeaf02014-06-19 11:12:55 -07002205 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002206
Tony Mack336e0f92014-11-30 15:53:08 -05002207 ControllerImages: ControllerImagesSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002208
Scott Baker196ffef2014-11-21 11:32:24 -08002209 ReservedResource: ReservedResourceSerializer,
Scott Baker645dc9d2014-11-17 22:32:19 -08002210
Scott Baker0caeaf02014-06-19 11:12:55 -07002211 NetworkSlice: NetworkSliceSerializer,
2212
2213 UserDashboardView: UserDashboardViewSerializer,
2214
2215 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002216
2217 User: UserSerializer,
2218
2219 Deployment: DeploymentSerializer,
2220
2221 Reservation: ReservationSerializer,
2222
Tony Mack336e0f92014-11-30 15:53:08 -05002223 ControllerSlices: ControllerSlicesSerializer,
Scott Baker196ffef2014-11-21 11:32:24 -08002224
Scott Baker0caeaf02014-06-19 11:12:55 -07002225 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002226
Scott Baker196ffef2014-11-21 11:32:24 -08002227 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002228
Tony Mack336e0f92014-11-30 15:53:08 -05002229 ControllerUsers: ControllerUsersSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002230
2231 Account: AccountSerializer,
2232
Scott Baker0caeaf02014-06-19 11:12:55 -07002233 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002234
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002235 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002236
Tony Mack336e0f92014-11-30 15:53:08 -05002237 ControllerPrivilege: ControllerPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002238
Tony Mack336e0f92014-11-30 15:53:08 -05002239 ControllerRole: ControllerRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002240
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002241 UserCredential: UserCredentialSerializer,
2242
Scott Baker196ffef2014-11-21 11:32:24 -08002243 SiteDeployments: SiteDeploymentsSerializer,
2244
Scott Baker0caeaf02014-06-19 11:12:55 -07002245 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002246
Scott Baker0caeaf02014-06-19 11:12:55 -07002247 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002248
2249 Router: RouterSerializer,
2250
Scott Baker0caeaf02014-06-19 11:12:55 -07002251 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002252
2253 None: None,
2254 }
2255
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002256class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2257
2258 # To handle fine-grained field permissions, we have to check can_update
2259 # the object has been updated but before it has been saved.
2260
2261 def update(self, request, *args, **kwargs):
2262 partial = kwargs.pop('partial', False)
2263 self.object = self.get_object_or_none()
2264
2265 serializer = self.get_serializer(self.object, data=request.DATA,
2266 files=request.FILES, partial=partial)
2267
2268 if not serializer.is_valid():
Scott Baker351148c2014-11-25 00:53:25 -08002269 response = {"error": "validation",
2270 "specific_error": "not serializer.is_valid()",
2271 "reasons": serializer.errors}
2272 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002273
2274 try:
2275 self.pre_save(serializer.object)
2276 except ValidationError as err:
2277 # full_clean on model instance may be called in pre_save,
2278 # so we have to handle eventual errors.
Scott Baker351148c2014-11-25 00:53:25 -08002279 response = {"error": "validation",
2280 "specific_error": "ValidationError in pre_save",
2281 "reasons": err.message_dict}
2282 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002283
2284 if serializer.object is not None:
2285 if not serializer.object.can_update(request.user):
2286 return Response(status=status.HTTP_400_BAD_REQUEST)
2287
2288 if self.object is None:
2289 self.object = serializer.save(force_insert=True)
2290 self.post_save(self.object, created=True)
2291 return Response(serializer.data, status=status.HTTP_201_CREATED)
2292
2293 self.object = serializer.save(force_update=True)
2294 self.post_save(self.object, created=False)
2295 return Response(serializer.data, status=status.HTTP_200_OK)
2296
2297 def destroy(self, request, *args, **kwargs):
2298 obj = self.get_object()
2299 if obj.can_update(request.user):
Scott Baker08898c12014-10-29 23:41:11 -07002300 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002301 else:
2302 return Response(status=status.HTTP_400_BAD_REQUEST)
2303
2304
Sapan Bhatiadea39432014-06-13 03:10:36 -04002305# Based on core/views/*.py
2306
2307
Scott Baker0caeaf02014-06-19 11:12:55 -07002308class ServiceAttributeList(generics.ListCreateAPIView):
2309 queryset = ServiceAttribute.objects.select_related().all()
2310 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002311 id_serializer_class = ServiceAttributeIdSerializer
2312 filter_backends = (filters.DjangoFilterBackend,)
2313 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
2314
2315 def get_serializer_class(self):
2316 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2317 if (no_hyperlinks):
2318 return self.id_serializer_class
2319 else:
2320 return self.serializer_class
2321
Scott Baker0caeaf02014-06-19 11:12:55 -07002322 def get_queryset(self):
2323 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002324
Scott Baker0caeaf02014-06-19 11:12:55 -07002325 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002326 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2327 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002328 response = {"error": "validation",
2329 "specific_error": "not serializer.is_valid()",
2330 "reasons": serializer.errors}
2331 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002332 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002333 obj.caller = request.user
2334 if obj.can_update(request.user):
2335 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2336 else:
Scott Baker08898c12014-10-29 23:41:11 -07002337 raise Exception("failed obj.can_update")
2338
2339 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2340 if (ret.status_code%100 != 200):
2341 raise Exception(ret.data)
2342
2343 return ret
2344
Scott Baker0caeaf02014-06-19 11:12:55 -07002345
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002346class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002347 queryset = ServiceAttribute.objects.select_related().all()
2348 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002349 id_serializer_class = ServiceAttributeIdSerializer
2350
2351 def get_serializer_class(self):
2352 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2353 if (no_hyperlinks):
2354 return self.id_serializer_class
2355 else:
2356 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002357
2358 def get_queryset(self):
2359 return ServiceAttribute.select_by_user(self.request.user)
2360
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002361 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002362
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002363 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002364
2365
2366
2367class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002368 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002369 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002370 id_serializer_class = ImageIdSerializer
2371 filter_backends = (filters.DjangoFilterBackend,)
2372 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
2373
2374 def get_serializer_class(self):
2375 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2376 if (no_hyperlinks):
2377 return self.id_serializer_class
2378 else:
2379 return self.serializer_class
2380
Scott Baker0caeaf02014-06-19 11:12:55 -07002381 def get_queryset(self):
2382 return Image.select_by_user(self.request.user)
2383
2384 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002385 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2386 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002387 response = {"error": "validation",
2388 "specific_error": "not serializer.is_valid()",
2389 "reasons": serializer.errors}
2390 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002391 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002392 obj.caller = request.user
2393 if obj.can_update(request.user):
2394 return super(ImageList, self).create(request, *args, **kwargs)
2395 else:
Scott Baker08898c12014-10-29 23:41:11 -07002396 raise Exception("failed obj.can_update")
2397
2398 ret = super(ImageList, self).create(request, *args, **kwargs)
2399 if (ret.status_code%100 != 200):
2400 raise Exception(ret.data)
2401
2402 return ret
2403
Sapan Bhatiadea39432014-06-13 03:10:36 -04002404
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002405class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002406 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002407 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002408 id_serializer_class = ImageIdSerializer
2409
2410 def get_serializer_class(self):
2411 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2412 if (no_hyperlinks):
2413 return self.id_serializer_class
2414 else:
2415 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002416
2417 def get_queryset(self):
2418 return Image.select_by_user(self.request.user)
2419
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002420 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002421
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002422 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002423
2424
2425
Scott Baker0caeaf02014-06-19 11:12:55 -07002426class NetworkParameterList(generics.ListCreateAPIView):
2427 queryset = NetworkParameter.objects.select_related().all()
2428 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002429 id_serializer_class = NetworkParameterIdSerializer
2430 filter_backends = (filters.DjangoFilterBackend,)
2431 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
2432
2433 def get_serializer_class(self):
2434 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2435 if (no_hyperlinks):
2436 return self.id_serializer_class
2437 else:
2438 return self.serializer_class
2439
Scott Baker0caeaf02014-06-19 11:12:55 -07002440 def get_queryset(self):
2441 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002442
Scott Baker0caeaf02014-06-19 11:12:55 -07002443 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002444 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2445 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002446 response = {"error": "validation",
2447 "specific_error": "not serializer.is_valid()",
2448 "reasons": serializer.errors}
2449 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002450 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002451 obj.caller = request.user
2452 if obj.can_update(request.user):
2453 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2454 else:
Scott Baker08898c12014-10-29 23:41:11 -07002455 raise Exception("failed obj.can_update")
2456
2457 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2458 if (ret.status_code%100 != 200):
2459 raise Exception(ret.data)
2460
2461 return ret
2462
Scott Baker0caeaf02014-06-19 11:12:55 -07002463
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002464class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002465 queryset = NetworkParameter.objects.select_related().all()
2466 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002467 id_serializer_class = NetworkParameterIdSerializer
2468
2469 def get_serializer_class(self):
2470 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2471 if (no_hyperlinks):
2472 return self.id_serializer_class
2473 else:
2474 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002475
2476 def get_queryset(self):
2477 return NetworkParameter.select_by_user(self.request.user)
2478
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002479 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002480
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002481 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002482
2483
2484
2485class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002486 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002487 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002488 id_serializer_class = SiteIdSerializer
2489 filter_backends = (filters.DjangoFilterBackend,)
2490 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
2491
2492 def get_serializer_class(self):
2493 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2494 if (no_hyperlinks):
2495 return self.id_serializer_class
2496 else:
2497 return self.serializer_class
2498
Scott Baker0caeaf02014-06-19 11:12:55 -07002499 def get_queryset(self):
2500 return Site.select_by_user(self.request.user)
2501
2502 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002503 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2504 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002505 response = {"error": "validation",
2506 "specific_error": "not serializer.is_valid()",
2507 "reasons": serializer.errors}
2508 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002509 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002510 obj.caller = request.user
2511 if obj.can_update(request.user):
2512 return super(SiteList, self).create(request, *args, **kwargs)
2513 else:
Scott Baker08898c12014-10-29 23:41:11 -07002514 raise Exception("failed obj.can_update")
2515
2516 ret = super(SiteList, self).create(request, *args, **kwargs)
2517 if (ret.status_code%100 != 200):
2518 raise Exception(ret.data)
2519
2520 return ret
2521
Sapan Bhatiadea39432014-06-13 03:10:36 -04002522
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002523class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002524 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002525 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002526 id_serializer_class = SiteIdSerializer
2527
2528 def get_serializer_class(self):
2529 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2530 if (no_hyperlinks):
2531 return self.id_serializer_class
2532 else:
2533 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002534
2535 def get_queryset(self):
2536 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002537
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002538 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002539
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002540 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002541
2542
2543
2544class SliceRoleList(generics.ListCreateAPIView):
2545 queryset = SliceRole.objects.select_related().all()
2546 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002547 id_serializer_class = SliceRoleIdSerializer
2548 filter_backends = (filters.DjangoFilterBackend,)
2549 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2550
2551 def get_serializer_class(self):
2552 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2553 if (no_hyperlinks):
2554 return self.id_serializer_class
2555 else:
2556 return self.serializer_class
2557
Scott Baker0caeaf02014-06-19 11:12:55 -07002558 def get_queryset(self):
2559 return SliceRole.select_by_user(self.request.user)
2560
2561 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002562 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2563 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002564 response = {"error": "validation",
2565 "specific_error": "not serializer.is_valid()",
2566 "reasons": serializer.errors}
2567 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002568 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002569 obj.caller = request.user
2570 if obj.can_update(request.user):
2571 return super(SliceRoleList, self).create(request, *args, **kwargs)
2572 else:
Scott Baker08898c12014-10-29 23:41:11 -07002573 raise Exception("failed obj.can_update")
2574
2575 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2576 if (ret.status_code%100 != 200):
2577 raise Exception(ret.data)
2578
2579 return ret
2580
Scott Baker0caeaf02014-06-19 11:12:55 -07002581
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002582class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002583 queryset = SliceRole.objects.select_related().all()
2584 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002585 id_serializer_class = SliceRoleIdSerializer
2586
2587 def get_serializer_class(self):
2588 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2589 if (no_hyperlinks):
2590 return self.id_serializer_class
2591 else:
2592 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002593
2594 def get_queryset(self):
2595 return SliceRole.select_by_user(self.request.user)
2596
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002597 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002598
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002599 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002600
2601
2602
2603class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002604 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002605 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002606 id_serializer_class = TagIdSerializer
2607 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002608 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002609
2610 def get_serializer_class(self):
2611 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2612 if (no_hyperlinks):
2613 return self.id_serializer_class
2614 else:
2615 return self.serializer_class
2616
Scott Baker0caeaf02014-06-19 11:12:55 -07002617 def get_queryset(self):
2618 return Tag.select_by_user(self.request.user)
2619
2620 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002621 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2622 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002623 response = {"error": "validation",
2624 "specific_error": "not serializer.is_valid()",
2625 "reasons": serializer.errors}
2626 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002627 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002628 obj.caller = request.user
2629 if obj.can_update(request.user):
2630 return super(TagList, self).create(request, *args, **kwargs)
2631 else:
Scott Baker08898c12014-10-29 23:41:11 -07002632 raise Exception("failed obj.can_update")
2633
2634 ret = super(TagList, self).create(request, *args, **kwargs)
2635 if (ret.status_code%100 != 200):
2636 raise Exception(ret.data)
2637
2638 return ret
2639
Sapan Bhatiadea39432014-06-13 03:10:36 -04002640
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002641class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002642 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002643 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002644 id_serializer_class = TagIdSerializer
2645
2646 def get_serializer_class(self):
2647 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2648 if (no_hyperlinks):
2649 return self.id_serializer_class
2650 else:
2651 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002652
2653 def get_queryset(self):
2654 return Tag.select_by_user(self.request.user)
2655
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002656 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002657
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002658 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002659
2660
2661
2662class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002663 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002664 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002665 id_serializer_class = InvoiceIdSerializer
2666 filter_backends = (filters.DjangoFilterBackend,)
2667 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
2668
2669 def get_serializer_class(self):
2670 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2671 if (no_hyperlinks):
2672 return self.id_serializer_class
2673 else:
2674 return self.serializer_class
2675
Scott Baker0caeaf02014-06-19 11:12:55 -07002676 def get_queryset(self):
2677 return Invoice.select_by_user(self.request.user)
2678
2679 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002680 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2681 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002682 response = {"error": "validation",
2683 "specific_error": "not serializer.is_valid()",
2684 "reasons": serializer.errors}
2685 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002686 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002687 obj.caller = request.user
2688 if obj.can_update(request.user):
2689 return super(InvoiceList, self).create(request, *args, **kwargs)
2690 else:
Scott Baker08898c12014-10-29 23:41:11 -07002691 raise Exception("failed obj.can_update")
2692
2693 ret = super(InvoiceList, self).create(request, *args, **kwargs)
2694 if (ret.status_code%100 != 200):
2695 raise Exception(ret.data)
2696
2697 return ret
2698
Sapan Bhatiadea39432014-06-13 03:10:36 -04002699
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002700class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002701 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002702 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002703 id_serializer_class = InvoiceIdSerializer
2704
2705 def get_serializer_class(self):
2706 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2707 if (no_hyperlinks):
2708 return self.id_serializer_class
2709 else:
2710 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002711
2712 def get_queryset(self):
2713 return Invoice.select_by_user(self.request.user)
2714
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002715 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002716
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002717 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002718
2719
2720
Scott Baker0caeaf02014-06-19 11:12:55 -07002721class SlicePrivilegeList(generics.ListCreateAPIView):
2722 queryset = SlicePrivilege.objects.select_related().all()
2723 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002724 id_serializer_class = SlicePrivilegeIdSerializer
2725 filter_backends = (filters.DjangoFilterBackend,)
2726 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
2727
2728 def get_serializer_class(self):
2729 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2730 if (no_hyperlinks):
2731 return self.id_serializer_class
2732 else:
2733 return self.serializer_class
2734
Scott Baker0caeaf02014-06-19 11:12:55 -07002735 def get_queryset(self):
2736 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002737
Scott Baker0caeaf02014-06-19 11:12:55 -07002738 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002739 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2740 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002741 response = {"error": "validation",
2742 "specific_error": "not serializer.is_valid()",
2743 "reasons": serializer.errors}
2744 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002745 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002746 obj.caller = request.user
2747 if obj.can_update(request.user):
2748 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
2749 else:
Scott Baker08898c12014-10-29 23:41:11 -07002750 raise Exception("failed obj.can_update")
2751
2752 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
2753 if (ret.status_code%100 != 200):
2754 raise Exception(ret.data)
2755
2756 return ret
2757
Scott Baker0caeaf02014-06-19 11:12:55 -07002758
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002759class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002760 queryset = SlicePrivilege.objects.select_related().all()
2761 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002762 id_serializer_class = SlicePrivilegeIdSerializer
2763
2764 def get_serializer_class(self):
2765 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2766 if (no_hyperlinks):
2767 return self.id_serializer_class
2768 else:
2769 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002770
2771 def get_queryset(self):
2772 return SlicePrivilege.select_by_user(self.request.user)
2773
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002774 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2775
2776 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2777
2778
2779
2780class PlanetStackRoleList(generics.ListCreateAPIView):
2781 queryset = PlanetStackRole.objects.select_related().all()
2782 serializer_class = PlanetStackRoleSerializer
2783 id_serializer_class = PlanetStackRoleIdSerializer
2784 filter_backends = (filters.DjangoFilterBackend,)
2785 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2786
2787 def get_serializer_class(self):
2788 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2789 if (no_hyperlinks):
2790 return self.id_serializer_class
2791 else:
2792 return self.serializer_class
2793
2794 def get_queryset(self):
2795 return PlanetStackRole.select_by_user(self.request.user)
2796
2797 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002798 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2799 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002800 response = {"error": "validation",
2801 "specific_error": "not serializer.is_valid()",
2802 "reasons": serializer.errors}
2803 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002804 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002805 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07002806 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002807 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002808 else:
Scott Baker08898c12014-10-29 23:41:11 -07002809 raise Exception("failed obj.can_update")
2810
2811 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
2812 if (ret.status_code%100 != 200):
2813 raise Exception(ret.data)
2814
2815 return ret
2816
Scott Baker0caeaf02014-06-19 11:12:55 -07002817
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002818class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2819 queryset = PlanetStackRole.objects.select_related().all()
2820 serializer_class = PlanetStackRoleSerializer
2821 id_serializer_class = PlanetStackRoleIdSerializer
2822
2823 def get_serializer_class(self):
2824 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2825 if (no_hyperlinks):
2826 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002827 else:
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002828 return self.serializer_class
2829
2830 def get_queryset(self):
2831 return PlanetStackRole.select_by_user(self.request.user)
2832
2833 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2834
2835 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002836
2837
2838
Scott Baker0caeaf02014-06-19 11:12:55 -07002839class NetworkSliverList(generics.ListCreateAPIView):
2840 queryset = NetworkSliver.objects.select_related().all()
2841 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002842 id_serializer_class = NetworkSliverIdSerializer
2843 filter_backends = (filters.DjangoFilterBackend,)
2844 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
2845
2846 def get_serializer_class(self):
2847 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2848 if (no_hyperlinks):
2849 return self.id_serializer_class
2850 else:
2851 return self.serializer_class
2852
Scott Baker0caeaf02014-06-19 11:12:55 -07002853 def get_queryset(self):
2854 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002855
Scott Baker0caeaf02014-06-19 11:12:55 -07002856 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002857 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2858 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002859 response = {"error": "validation",
2860 "specific_error": "not serializer.is_valid()",
2861 "reasons": serializer.errors}
2862 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002863 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002864 obj.caller = request.user
2865 if obj.can_update(request.user):
2866 return super(NetworkSliverList, self).create(request, *args, **kwargs)
2867 else:
Scott Baker08898c12014-10-29 23:41:11 -07002868 raise Exception("failed obj.can_update")
2869
2870 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
2871 if (ret.status_code%100 != 200):
2872 raise Exception(ret.data)
2873
2874 return ret
2875
Scott Baker0caeaf02014-06-19 11:12:55 -07002876
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002877class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002878 queryset = NetworkSliver.objects.select_related().all()
2879 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002880 id_serializer_class = NetworkSliverIdSerializer
2881
2882 def get_serializer_class(self):
2883 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2884 if (no_hyperlinks):
2885 return self.id_serializer_class
2886 else:
2887 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002888
2889 def get_queryset(self):
2890 return NetworkSliver.select_by_user(self.request.user)
2891
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002892 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002893
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002894 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002895
2896
2897
Tony Mack336e0f92014-11-30 15:53:08 -05002898class ControllerNetworksList(generics.ListCreateAPIView):
2899 queryset = ControllerNetworks.objects.select_related().all()
2900 serializer_class = ControllerNetworksSerializer
2901 id_serializer_class = ControllerNetworksIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002902 filter_backends = (filters.DjangoFilterBackend,)
2903 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
2904
2905 def get_serializer_class(self):
2906 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2907 if (no_hyperlinks):
2908 return self.id_serializer_class
2909 else:
2910 return self.serializer_class
2911
Scott Baker0caeaf02014-06-19 11:12:55 -07002912 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05002913 return ControllerNetworks.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002914
Scott Baker0caeaf02014-06-19 11:12:55 -07002915 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002916 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2917 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002918 response = {"error": "validation",
2919 "specific_error": "not serializer.is_valid()",
2920 "reasons": serializer.errors}
2921 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002922 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002923 obj.caller = request.user
2924 if obj.can_update(request.user):
Tony Mack336e0f92014-11-30 15:53:08 -05002925 return super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002926 else:
Scott Baker08898c12014-10-29 23:41:11 -07002927 raise Exception("failed obj.can_update")
2928
Tony Mack336e0f92014-11-30 15:53:08 -05002929 ret = super(ControllerNetworksList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07002930 if (ret.status_code%100 != 200):
2931 raise Exception(ret.data)
2932
2933 return ret
2934
Scott Baker0caeaf02014-06-19 11:12:55 -07002935
Tony Mack336e0f92014-11-30 15:53:08 -05002936class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2937 queryset = ControllerNetworks.objects.select_related().all()
2938 serializer_class = ControllerNetworksSerializer
2939 id_serializer_class = ControllerNetworksIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002940
2941 def get_serializer_class(self):
2942 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2943 if (no_hyperlinks):
2944 return self.id_serializer_class
2945 else:
2946 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002947
2948 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05002949 return ControllerNetworks.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002950
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002951 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002952
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002953 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002954
2955
2956
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002957class FlavorList(generics.ListCreateAPIView):
2958 queryset = Flavor.objects.select_related().all()
2959 serializer_class = FlavorSerializer
2960 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002961 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002962 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker46b58542014-08-11 17:26:12 -07002963
2964 def get_serializer_class(self):
2965 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2966 if (no_hyperlinks):
2967 return self.id_serializer_class
2968 else:
2969 return self.serializer_class
2970
Scott Baker0caeaf02014-06-19 11:12:55 -07002971 def get_queryset(self):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002972 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002973
2974 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002975 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2976 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08002977 response = {"error": "validation",
2978 "specific_error": "not serializer.is_valid()",
2979 "reasons": serializer.errors}
2980 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08002981 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002982 obj.caller = request.user
2983 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002984 return super(FlavorList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002985 else:
Scott Baker08898c12014-10-29 23:41:11 -07002986 raise Exception("failed obj.can_update")
2987
2988 ret = super(FlavorList, self).create(request, *args, **kwargs)
2989 if (ret.status_code%100 != 200):
2990 raise Exception(ret.data)
2991
2992 return ret
2993
Sapan Bhatiadea39432014-06-13 03:10:36 -04002994
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002995class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2996 queryset = Flavor.objects.select_related().all()
2997 serializer_class = FlavorSerializer
2998 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002999
3000 def get_serializer_class(self):
3001 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3002 if (no_hyperlinks):
3003 return self.id_serializer_class
3004 else:
3005 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003006
3007 def get_queryset(self):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003008 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07003009
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003010 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003011
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003012 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003013
3014
3015
Scott Baker0caeaf02014-06-19 11:12:55 -07003016class ProjectList(generics.ListCreateAPIView):
3017 queryset = Project.objects.select_related().all()
3018 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003019 id_serializer_class = ProjectIdSerializer
3020 filter_backends = (filters.DjangoFilterBackend,)
3021 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3022
3023 def get_serializer_class(self):
3024 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3025 if (no_hyperlinks):
3026 return self.id_serializer_class
3027 else:
3028 return self.serializer_class
3029
Scott Baker0caeaf02014-06-19 11:12:55 -07003030 def get_queryset(self):
3031 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003032
Scott Baker0caeaf02014-06-19 11:12:55 -07003033 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003034 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3035 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003036 response = {"error": "validation",
3037 "specific_error": "not serializer.is_valid()",
3038 "reasons": serializer.errors}
3039 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003040 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003041 obj.caller = request.user
3042 if obj.can_update(request.user):
3043 return super(ProjectList, self).create(request, *args, **kwargs)
3044 else:
Scott Baker08898c12014-10-29 23:41:11 -07003045 raise Exception("failed obj.can_update")
3046
3047 ret = super(ProjectList, self).create(request, *args, **kwargs)
3048 if (ret.status_code%100 != 200):
3049 raise Exception(ret.data)
3050
3051 return ret
3052
Scott Baker0caeaf02014-06-19 11:12:55 -07003053
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003054class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003055 queryset = Project.objects.select_related().all()
3056 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003057 id_serializer_class = ProjectIdSerializer
3058
3059 def get_serializer_class(self):
3060 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3061 if (no_hyperlinks):
3062 return self.id_serializer_class
3063 else:
3064 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003065
3066 def get_queryset(self):
3067 return Project.select_by_user(self.request.user)
3068
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003069 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3070
3071 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3072
3073
3074
3075class SliceList(generics.ListCreateAPIView):
3076 queryset = Slice.objects.select_related().all()
3077 serializer_class = SliceSerializer
3078 id_serializer_class = SliceIdSerializer
3079 filter_backends = (filters.DjangoFilterBackend,)
3080 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
3081
3082 def get_serializer_class(self):
3083 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3084 if (no_hyperlinks):
3085 return self.id_serializer_class
3086 else:
3087 return self.serializer_class
3088
3089 def get_queryset(self):
3090 return Slice.select_by_user(self.request.user)
3091
3092 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003093 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3094 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003095 response = {"error": "validation",
3096 "specific_error": "not serializer.is_valid()",
3097 "reasons": serializer.errors}
3098 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003099 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003100 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003101 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003102 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003103 else:
Scott Baker08898c12014-10-29 23:41:11 -07003104 raise Exception("failed obj.can_update")
3105
3106 ret = super(SliceList, self).create(request, *args, **kwargs)
3107 if (ret.status_code%100 != 200):
3108 raise Exception(ret.data)
3109
3110 return ret
3111
Scott Baker0caeaf02014-06-19 11:12:55 -07003112
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003113class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3114 queryset = Slice.objects.select_related().all()
3115 serializer_class = SliceSerializer
3116 id_serializer_class = SliceIdSerializer
3117
3118 def get_serializer_class(self):
3119 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3120 if (no_hyperlinks):
3121 return self.id_serializer_class
3122 else:
3123 return self.serializer_class
3124
3125 def get_queryset(self):
3126 return Slice.select_by_user(self.request.user)
3127
3128 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3129
3130 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3131
3132
3133
3134class NetworkList(generics.ListCreateAPIView):
3135 queryset = Network.objects.select_related().all()
3136 serializer_class = NetworkSerializer
3137 id_serializer_class = NetworkIdSerializer
3138 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker645dc9d2014-11-17 22:32:19 -08003139 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003140
3141 def get_serializer_class(self):
3142 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3143 if (no_hyperlinks):
3144 return self.id_serializer_class
3145 else:
3146 return self.serializer_class
3147
3148 def get_queryset(self):
3149 return Network.select_by_user(self.request.user)
3150
3151 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003152 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3153 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003154 response = {"error": "validation",
3155 "specific_error": "not serializer.is_valid()",
3156 "reasons": serializer.errors}
3157 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003158 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003159 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003160 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003161 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003162 else:
Scott Baker08898c12014-10-29 23:41:11 -07003163 raise Exception("failed obj.can_update")
3164
3165 ret = super(NetworkList, self).create(request, *args, **kwargs)
3166 if (ret.status_code%100 != 200):
3167 raise Exception(ret.data)
3168
3169 return ret
3170
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003171
3172class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3173 queryset = Network.objects.select_related().all()
3174 serializer_class = NetworkSerializer
3175 id_serializer_class = NetworkIdSerializer
3176
3177 def get_serializer_class(self):
3178 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3179 if (no_hyperlinks):
3180 return self.id_serializer_class
3181 else:
3182 return self.serializer_class
3183
3184 def get_queryset(self):
3185 return Network.select_by_user(self.request.user)
3186
3187 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3188
3189 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3190
3191
3192
3193class ServiceList(generics.ListCreateAPIView):
3194 queryset = Service.objects.select_related().all()
3195 serializer_class = ServiceSerializer
3196 id_serializer_class = ServiceIdSerializer
3197 filter_backends = (filters.DjangoFilterBackend,)
3198 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
3199
3200 def get_serializer_class(self):
3201 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3202 if (no_hyperlinks):
3203 return self.id_serializer_class
3204 else:
3205 return self.serializer_class
3206
3207 def get_queryset(self):
3208 return Service.select_by_user(self.request.user)
3209
3210 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003211 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3212 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003213 response = {"error": "validation",
3214 "specific_error": "not serializer.is_valid()",
3215 "reasons": serializer.errors}
3216 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003217 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003218 obj.caller = request.user
3219 if obj.can_update(request.user):
3220 return super(ServiceList, self).create(request, *args, **kwargs)
3221 else:
Scott Baker08898c12014-10-29 23:41:11 -07003222 raise Exception("failed obj.can_update")
3223
3224 ret = super(ServiceList, self).create(request, *args, **kwargs)
3225 if (ret.status_code%100 != 200):
3226 raise Exception(ret.data)
3227
3228 return ret
3229
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003230
3231class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3232 queryset = Service.objects.select_related().all()
3233 serializer_class = ServiceSerializer
3234 id_serializer_class = ServiceIdSerializer
3235
3236 def get_serializer_class(self):
3237 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3238 if (no_hyperlinks):
3239 return self.id_serializer_class
3240 else:
3241 return self.serializer_class
3242
3243 def get_queryset(self):
3244 return Service.select_by_user(self.request.user)
3245
3246 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3247
3248 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3249
3250
3251
3252class ServiceClassList(generics.ListCreateAPIView):
3253 queryset = ServiceClass.objects.select_related().all()
3254 serializer_class = ServiceClassSerializer
3255 id_serializer_class = ServiceClassIdSerializer
3256 filter_backends = (filters.DjangoFilterBackend,)
3257 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
3258
3259 def get_serializer_class(self):
3260 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3261 if (no_hyperlinks):
3262 return self.id_serializer_class
3263 else:
3264 return self.serializer_class
3265
3266 def get_queryset(self):
3267 return ServiceClass.select_by_user(self.request.user)
3268
3269 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003270 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3271 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003272 response = {"error": "validation",
3273 "specific_error": "not serializer.is_valid()",
3274 "reasons": serializer.errors}
3275 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003276 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003277 obj.caller = request.user
3278 if obj.can_update(request.user):
3279 return super(ServiceClassList, self).create(request, *args, **kwargs)
3280 else:
Scott Baker08898c12014-10-29 23:41:11 -07003281 raise Exception("failed obj.can_update")
3282
3283 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3284 if (ret.status_code%100 != 200):
3285 raise Exception(ret.data)
3286
3287 return ret
3288
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003289
3290class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3291 queryset = ServiceClass.objects.select_related().all()
3292 serializer_class = ServiceClassSerializer
3293 id_serializer_class = ServiceClassIdSerializer
3294
3295 def get_serializer_class(self):
3296 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3297 if (no_hyperlinks):
3298 return self.id_serializer_class
3299 else:
3300 return self.serializer_class
3301
3302 def get_queryset(self):
3303 return ServiceClass.select_by_user(self.request.user)
3304
3305 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3306
3307 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3308
3309
3310
Scott Baker196ffef2014-11-21 11:32:24 -08003311class PaymentList(generics.ListCreateAPIView):
3312 queryset = Payment.objects.select_related().all()
3313 serializer_class = PaymentSerializer
3314 id_serializer_class = PaymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003315 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker196ffef2014-11-21 11:32:24 -08003316 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003317
3318 def get_serializer_class(self):
3319 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3320 if (no_hyperlinks):
3321 return self.id_serializer_class
3322 else:
3323 return self.serializer_class
3324
3325 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08003326 return Payment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003327
3328 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003329 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3330 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003331 response = {"error": "validation",
3332 "specific_error": "not serializer.is_valid()",
3333 "reasons": serializer.errors}
3334 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003335 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003336 obj.caller = request.user
3337 if obj.can_update(request.user):
Scott Baker196ffef2014-11-21 11:32:24 -08003338 return super(PaymentList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003339 else:
Scott Baker08898c12014-10-29 23:41:11 -07003340 raise Exception("failed obj.can_update")
3341
Scott Baker196ffef2014-11-21 11:32:24 -08003342 ret = super(PaymentList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003343 if (ret.status_code%100 != 200):
3344 raise Exception(ret.data)
3345
3346 return ret
3347
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003348
Scott Baker196ffef2014-11-21 11:32:24 -08003349class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3350 queryset = Payment.objects.select_related().all()
3351 serializer_class = PaymentSerializer
3352 id_serializer_class = PaymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003353
3354 def get_serializer_class(self):
3355 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3356 if (no_hyperlinks):
3357 return self.id_serializer_class
3358 else:
3359 return self.serializer_class
3360
3361 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08003362 return Payment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003363
3364 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3365
3366 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3367
3368
3369
3370class ChargeList(generics.ListCreateAPIView):
3371 queryset = Charge.objects.select_related().all()
3372 serializer_class = ChargeSerializer
3373 id_serializer_class = ChargeIdSerializer
3374 filter_backends = (filters.DjangoFilterBackend,)
3375 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3376
3377 def get_serializer_class(self):
3378 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3379 if (no_hyperlinks):
3380 return self.id_serializer_class
3381 else:
3382 return self.serializer_class
3383
3384 def get_queryset(self):
3385 return Charge.select_by_user(self.request.user)
3386
3387 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003388 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3389 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003390 response = {"error": "validation",
3391 "specific_error": "not serializer.is_valid()",
3392 "reasons": serializer.errors}
3393 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003394 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003395 obj.caller = request.user
3396 if obj.can_update(request.user):
3397 return super(ChargeList, self).create(request, *args, **kwargs)
3398 else:
Scott Baker08898c12014-10-29 23:41:11 -07003399 raise Exception("failed obj.can_update")
3400
3401 ret = super(ChargeList, self).create(request, *args, **kwargs)
3402 if (ret.status_code%100 != 200):
3403 raise Exception(ret.data)
3404
3405 return ret
3406
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003407
3408class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3409 queryset = Charge.objects.select_related().all()
3410 serializer_class = ChargeSerializer
3411 id_serializer_class = ChargeIdSerializer
3412
3413 def get_serializer_class(self):
3414 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3415 if (no_hyperlinks):
3416 return self.id_serializer_class
3417 else:
3418 return self.serializer_class
3419
3420 def get_queryset(self):
3421 return Charge.select_by_user(self.request.user)
3422
3423 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3424
3425 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3426
3427
3428
3429class RoleList(generics.ListCreateAPIView):
3430 queryset = Role.objects.select_related().all()
3431 serializer_class = RoleSerializer
3432 id_serializer_class = RoleIdSerializer
3433 filter_backends = (filters.DjangoFilterBackend,)
3434 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3435
3436 def get_serializer_class(self):
3437 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3438 if (no_hyperlinks):
3439 return self.id_serializer_class
3440 else:
3441 return self.serializer_class
3442
3443 def get_queryset(self):
3444 return Role.select_by_user(self.request.user)
3445
3446 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003447 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3448 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003449 response = {"error": "validation",
3450 "specific_error": "not serializer.is_valid()",
3451 "reasons": serializer.errors}
3452 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003453 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003454 obj.caller = request.user
3455 if obj.can_update(request.user):
3456 return super(RoleList, self).create(request, *args, **kwargs)
3457 else:
Scott Baker08898c12014-10-29 23:41:11 -07003458 raise Exception("failed obj.can_update")
3459
3460 ret = super(RoleList, self).create(request, *args, **kwargs)
3461 if (ret.status_code%100 != 200):
3462 raise Exception(ret.data)
3463
3464 return ret
3465
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003466
3467class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3468 queryset = Role.objects.select_related().all()
3469 serializer_class = RoleSerializer
3470 id_serializer_class = RoleIdSerializer
3471
3472 def get_serializer_class(self):
3473 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3474 if (no_hyperlinks):
3475 return self.id_serializer_class
3476 else:
3477 return self.serializer_class
3478
3479 def get_queryset(self):
3480 return Role.select_by_user(self.request.user)
3481
3482 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3483
3484 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3485
3486
3487
3488class UsableObjectList(generics.ListCreateAPIView):
3489 queryset = UsableObject.objects.select_related().all()
3490 serializer_class = UsableObjectSerializer
3491 id_serializer_class = UsableObjectIdSerializer
3492 filter_backends = (filters.DjangoFilterBackend,)
3493 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3494
3495 def get_serializer_class(self):
3496 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3497 if (no_hyperlinks):
3498 return self.id_serializer_class
3499 else:
3500 return self.serializer_class
3501
3502 def get_queryset(self):
3503 return UsableObject.select_by_user(self.request.user)
3504
3505 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003506 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3507 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003508 response = {"error": "validation",
3509 "specific_error": "not serializer.is_valid()",
3510 "reasons": serializer.errors}
3511 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003512 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003513 obj.caller = request.user
3514 if obj.can_update(request.user):
3515 return super(UsableObjectList, self).create(request, *args, **kwargs)
3516 else:
Scott Baker08898c12014-10-29 23:41:11 -07003517 raise Exception("failed obj.can_update")
3518
3519 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3520 if (ret.status_code%100 != 200):
3521 raise Exception(ret.data)
3522
3523 return ret
3524
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003525
3526class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3527 queryset = UsableObject.objects.select_related().all()
3528 serializer_class = UsableObjectSerializer
3529 id_serializer_class = UsableObjectIdSerializer
3530
3531 def get_serializer_class(self):
3532 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3533 if (no_hyperlinks):
3534 return self.id_serializer_class
3535 else:
3536 return self.serializer_class
3537
3538 def get_queryset(self):
3539 return UsableObject.select_by_user(self.request.user)
3540
3541 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3542
3543 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3544
3545
3546
3547class SiteRoleList(generics.ListCreateAPIView):
3548 queryset = SiteRole.objects.select_related().all()
3549 serializer_class = SiteRoleSerializer
3550 id_serializer_class = SiteRoleIdSerializer
3551 filter_backends = (filters.DjangoFilterBackend,)
3552 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3553
3554 def get_serializer_class(self):
3555 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3556 if (no_hyperlinks):
3557 return self.id_serializer_class
3558 else:
3559 return self.serializer_class
3560
3561 def get_queryset(self):
3562 return SiteRole.select_by_user(self.request.user)
3563
3564 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003565 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3566 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003567 response = {"error": "validation",
3568 "specific_error": "not serializer.is_valid()",
3569 "reasons": serializer.errors}
3570 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003571 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003572 obj.caller = request.user
3573 if obj.can_update(request.user):
3574 return super(SiteRoleList, self).create(request, *args, **kwargs)
3575 else:
Scott Baker08898c12014-10-29 23:41:11 -07003576 raise Exception("failed obj.can_update")
3577
3578 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3579 if (ret.status_code%100 != 200):
3580 raise Exception(ret.data)
3581
3582 return ret
3583
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003584
3585class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3586 queryset = SiteRole.objects.select_related().all()
3587 serializer_class = SiteRoleSerializer
3588 id_serializer_class = SiteRoleIdSerializer
3589
3590 def get_serializer_class(self):
3591 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3592 if (no_hyperlinks):
3593 return self.id_serializer_class
3594 else:
3595 return self.serializer_class
3596
3597 def get_queryset(self):
3598 return SiteRole.select_by_user(self.request.user)
3599
3600 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3601
3602 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3603
3604
3605
3606class SliceCredentialList(generics.ListCreateAPIView):
3607 queryset = SliceCredential.objects.select_related().all()
3608 serializer_class = SliceCredentialSerializer
3609 id_serializer_class = SliceCredentialIdSerializer
3610 filter_backends = (filters.DjangoFilterBackend,)
3611 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3612
3613 def get_serializer_class(self):
3614 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3615 if (no_hyperlinks):
3616 return self.id_serializer_class
3617 else:
3618 return self.serializer_class
3619
3620 def get_queryset(self):
3621 return SliceCredential.select_by_user(self.request.user)
3622
3623 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003624 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3625 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003626 response = {"error": "validation",
3627 "specific_error": "not serializer.is_valid()",
3628 "reasons": serializer.errors}
3629 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003630 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003631 obj.caller = request.user
3632 if obj.can_update(request.user):
3633 return super(SliceCredentialList, self).create(request, *args, **kwargs)
3634 else:
Scott Baker08898c12014-10-29 23:41:11 -07003635 raise Exception("failed obj.can_update")
3636
3637 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
3638 if (ret.status_code%100 != 200):
3639 raise Exception(ret.data)
3640
3641 return ret
3642
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003643
3644class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3645 queryset = SliceCredential.objects.select_related().all()
3646 serializer_class = SliceCredentialSerializer
3647 id_serializer_class = SliceCredentialIdSerializer
3648
3649 def get_serializer_class(self):
3650 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3651 if (no_hyperlinks):
3652 return self.id_serializer_class
3653 else:
3654 return self.serializer_class
3655
3656 def get_queryset(self):
3657 return SliceCredential.select_by_user(self.request.user)
3658
3659 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3660
3661 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3662
3663
3664
3665class SliverList(generics.ListCreateAPIView):
3666 queryset = Sliver.objects.select_related().all()
3667 serializer_class = SliverSerializer
3668 id_serializer_class = SliverIdSerializer
3669 filter_backends = (filters.DjangoFilterBackend,)
3670 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
3671
3672 def get_serializer_class(self):
3673 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3674 if (no_hyperlinks):
3675 return self.id_serializer_class
3676 else:
3677 return self.serializer_class
3678
3679 def get_queryset(self):
3680 return Sliver.select_by_user(self.request.user)
3681
3682 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003683 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3684 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003685 response = {"error": "validation",
3686 "specific_error": "not serializer.is_valid()",
3687 "reasons": serializer.errors}
3688 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003689 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003690 obj.caller = request.user
3691 if obj.can_update(request.user):
3692 return super(SliverList, self).create(request, *args, **kwargs)
3693 else:
Scott Baker08898c12014-10-29 23:41:11 -07003694 raise Exception("failed obj.can_update")
3695
3696 ret = super(SliverList, self).create(request, *args, **kwargs)
3697 if (ret.status_code%100 != 200):
3698 raise Exception(ret.data)
3699
3700 return ret
3701
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003702
3703class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3704 queryset = Sliver.objects.select_related().all()
3705 serializer_class = SliverSerializer
3706 id_serializer_class = SliverIdSerializer
3707
3708 def get_serializer_class(self):
3709 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3710 if (no_hyperlinks):
3711 return self.id_serializer_class
3712 else:
3713 return self.serializer_class
3714
3715 def get_queryset(self):
3716 return Sliver.select_by_user(self.request.user)
3717
3718 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3719
3720 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3721
3722
3723
3724class NodeList(generics.ListCreateAPIView):
3725 queryset = Node.objects.select_related().all()
3726 serializer_class = NodeSerializer
3727 id_serializer_class = NodeIdSerializer
3728 filter_backends = (filters.DjangoFilterBackend,)
3729 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
3730
3731 def get_serializer_class(self):
3732 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3733 if (no_hyperlinks):
3734 return self.id_serializer_class
3735 else:
3736 return self.serializer_class
3737
3738 def get_queryset(self):
3739 return Node.select_by_user(self.request.user)
3740
3741 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003742 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3743 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003744 response = {"error": "validation",
3745 "specific_error": "not serializer.is_valid()",
3746 "reasons": serializer.errors}
3747 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003748 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003749 obj.caller = request.user
3750 if obj.can_update(request.user):
3751 return super(NodeList, self).create(request, *args, **kwargs)
3752 else:
Scott Baker08898c12014-10-29 23:41:11 -07003753 raise Exception("failed obj.can_update")
3754
3755 ret = super(NodeList, self).create(request, *args, **kwargs)
3756 if (ret.status_code%100 != 200):
3757 raise Exception(ret.data)
3758
3759 return ret
3760
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003761
3762class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3763 queryset = Node.objects.select_related().all()
3764 serializer_class = NodeSerializer
3765 id_serializer_class = NodeIdSerializer
3766
3767 def get_serializer_class(self):
3768 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3769 if (no_hyperlinks):
3770 return self.id_serializer_class
3771 else:
3772 return self.serializer_class
3773
3774 def get_queryset(self):
3775 return Node.select_by_user(self.request.user)
3776
3777 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3778
3779 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3780
3781
3782
3783class DashboardViewList(generics.ListCreateAPIView):
3784 queryset = DashboardView.objects.select_related().all()
3785 serializer_class = DashboardViewSerializer
3786 id_serializer_class = DashboardViewIdSerializer
3787 filter_backends = (filters.DjangoFilterBackend,)
3788 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
3789
3790 def get_serializer_class(self):
3791 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3792 if (no_hyperlinks):
3793 return self.id_serializer_class
3794 else:
3795 return self.serializer_class
3796
3797 def get_queryset(self):
3798 return DashboardView.select_by_user(self.request.user)
3799
3800 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003801 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3802 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003803 response = {"error": "validation",
3804 "specific_error": "not serializer.is_valid()",
3805 "reasons": serializer.errors}
3806 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003807 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003808 obj.caller = request.user
3809 if obj.can_update(request.user):
3810 return super(DashboardViewList, self).create(request, *args, **kwargs)
3811 else:
Scott Baker08898c12014-10-29 23:41:11 -07003812 raise Exception("failed obj.can_update")
3813
3814 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
3815 if (ret.status_code%100 != 200):
3816 raise Exception(ret.data)
3817
3818 return ret
3819
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003820
3821class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3822 queryset = DashboardView.objects.select_related().all()
3823 serializer_class = DashboardViewSerializer
3824 id_serializer_class = DashboardViewIdSerializer
3825
3826 def get_serializer_class(self):
3827 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3828 if (no_hyperlinks):
3829 return self.id_serializer_class
3830 else:
3831 return self.serializer_class
3832
3833 def get_queryset(self):
3834 return DashboardView.select_by_user(self.request.user)
3835
3836 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3837
3838 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3839
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003840
Scott Bakerf3816ac2014-11-12 01:13:53 -08003841
Tony Mack336e0f92014-11-30 15:53:08 -05003842class ControllerImagesList(generics.ListCreateAPIView):
3843 queryset = ControllerImages.objects.select_related().all()
3844 serializer_class = ControllerImagesSerializer
3845 id_serializer_class = ControllerImagesIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08003846 filter_backends = (filters.DjangoFilterBackend,)
3847 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
3848
3849 def get_serializer_class(self):
3850 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3851 if (no_hyperlinks):
3852 return self.id_serializer_class
3853 else:
3854 return self.serializer_class
3855
3856 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05003857 return ControllerImages.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08003858
3859 def create(self, request, *args, **kwargs):
3860 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3861 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003862 response = {"error": "validation",
3863 "specific_error": "not serializer.is_valid()",
3864 "reasons": serializer.errors}
3865 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08003866 obj = serializer.object
3867 obj.caller = request.user
3868 if obj.can_update(request.user):
Tony Mack336e0f92014-11-30 15:53:08 -05003869 return super(ControllerImagesList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08003870 else:
3871 raise Exception("failed obj.can_update")
3872
Tony Mack336e0f92014-11-30 15:53:08 -05003873 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08003874 if (ret.status_code%100 != 200):
3875 raise Exception(ret.data)
3876
3877 return ret
3878
3879
Tony Mack336e0f92014-11-30 15:53:08 -05003880class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3881 queryset = ControllerImages.objects.select_related().all()
3882 serializer_class = ControllerImagesSerializer
3883 id_serializer_class = ControllerImagesIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08003884
3885 def get_serializer_class(self):
3886 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3887 if (no_hyperlinks):
3888 return self.id_serializer_class
3889 else:
3890 return self.serializer_class
3891
3892 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05003893 return ControllerImages.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08003894
3895 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3896
3897 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3898
Scott Baker196ffef2014-11-21 11:32:24 -08003899
3900
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003901class ReservedResourceList(generics.ListCreateAPIView):
3902 queryset = ReservedResource.objects.select_related().all()
3903 serializer_class = ReservedResourceSerializer
3904 id_serializer_class = ReservedResourceIdSerializer
3905 filter_backends = (filters.DjangoFilterBackend,)
3906 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
3907
3908 def get_serializer_class(self):
3909 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3910 if (no_hyperlinks):
3911 return self.id_serializer_class
3912 else:
3913 return self.serializer_class
3914
3915 def get_queryset(self):
3916 return ReservedResource.select_by_user(self.request.user)
3917
3918 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003919 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3920 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003921 response = {"error": "validation",
3922 "specific_error": "not serializer.is_valid()",
3923 "reasons": serializer.errors}
3924 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003925 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003926 obj.caller = request.user
3927 if obj.can_update(request.user):
3928 return super(ReservedResourceList, self).create(request, *args, **kwargs)
3929 else:
Scott Baker08898c12014-10-29 23:41:11 -07003930 raise Exception("failed obj.can_update")
3931
3932 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
3933 if (ret.status_code%100 != 200):
3934 raise Exception(ret.data)
3935
3936 return ret
3937
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003938
3939class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3940 queryset = ReservedResource.objects.select_related().all()
3941 serializer_class = ReservedResourceSerializer
3942 id_serializer_class = ReservedResourceIdSerializer
3943
3944 def get_serializer_class(self):
3945 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3946 if (no_hyperlinks):
3947 return self.id_serializer_class
3948 else:
3949 return self.serializer_class
3950
3951 def get_queryset(self):
3952 return ReservedResource.select_by_user(self.request.user)
3953
3954 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3955
3956 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3957
3958
3959
3960class NetworkSliceList(generics.ListCreateAPIView):
3961 queryset = NetworkSlice.objects.select_related().all()
3962 serializer_class = NetworkSliceSerializer
3963 id_serializer_class = NetworkSliceIdSerializer
3964 filter_backends = (filters.DjangoFilterBackend,)
3965 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
3966
3967 def get_serializer_class(self):
3968 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3969 if (no_hyperlinks):
3970 return self.id_serializer_class
3971 else:
3972 return self.serializer_class
3973
3974 def get_queryset(self):
3975 return NetworkSlice.select_by_user(self.request.user)
3976
3977 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003978 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3979 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08003980 response = {"error": "validation",
3981 "specific_error": "not serializer.is_valid()",
3982 "reasons": serializer.errors}
3983 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08003984 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003985 obj.caller = request.user
3986 if obj.can_update(request.user):
3987 return super(NetworkSliceList, self).create(request, *args, **kwargs)
3988 else:
Scott Baker08898c12014-10-29 23:41:11 -07003989 raise Exception("failed obj.can_update")
3990
3991 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
3992 if (ret.status_code%100 != 200):
3993 raise Exception(ret.data)
3994
3995 return ret
3996
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003997
3998class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3999 queryset = NetworkSlice.objects.select_related().all()
4000 serializer_class = NetworkSliceSerializer
4001 id_serializer_class = NetworkSliceIdSerializer
4002
4003 def get_serializer_class(self):
4004 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4005 if (no_hyperlinks):
4006 return self.id_serializer_class
4007 else:
4008 return self.serializer_class
4009
4010 def get_queryset(self):
4011 return NetworkSlice.select_by_user(self.request.user)
4012
4013 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4014
4015 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4016
4017
4018
4019class UserDashboardViewList(generics.ListCreateAPIView):
4020 queryset = UserDashboardView.objects.select_related().all()
4021 serializer_class = UserDashboardViewSerializer
4022 id_serializer_class = UserDashboardViewIdSerializer
4023 filter_backends = (filters.DjangoFilterBackend,)
4024 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4025
4026 def get_serializer_class(self):
4027 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4028 if (no_hyperlinks):
4029 return self.id_serializer_class
4030 else:
4031 return self.serializer_class
4032
4033 def get_queryset(self):
4034 return UserDashboardView.select_by_user(self.request.user)
4035
4036 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004037 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4038 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004039 response = {"error": "validation",
4040 "specific_error": "not serializer.is_valid()",
4041 "reasons": serializer.errors}
4042 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004043 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004044 obj.caller = request.user
4045 if obj.can_update(request.user):
4046 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4047 else:
Scott Baker08898c12014-10-29 23:41:11 -07004048 raise Exception("failed obj.can_update")
4049
4050 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4051 if (ret.status_code%100 != 200):
4052 raise Exception(ret.data)
4053
4054 return ret
4055
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004056
4057class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4058 queryset = UserDashboardView.objects.select_related().all()
4059 serializer_class = UserDashboardViewSerializer
4060 id_serializer_class = UserDashboardViewIdSerializer
4061
4062 def get_serializer_class(self):
4063 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4064 if (no_hyperlinks):
4065 return self.id_serializer_class
4066 else:
4067 return self.serializer_class
4068
4069 def get_queryset(self):
4070 return UserDashboardView.select_by_user(self.request.user)
4071
4072 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4073
4074 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4075
4076
4077
4078class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4079 queryset = PlanetStackPrivilege.objects.select_related().all()
4080 serializer_class = PlanetStackPrivilegeSerializer
4081 id_serializer_class = PlanetStackPrivilegeIdSerializer
4082 filter_backends = (filters.DjangoFilterBackend,)
4083 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4084
4085 def get_serializer_class(self):
4086 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4087 if (no_hyperlinks):
4088 return self.id_serializer_class
4089 else:
4090 return self.serializer_class
4091
4092 def get_queryset(self):
4093 return PlanetStackPrivilege.select_by_user(self.request.user)
4094
4095 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004096 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4097 if not (serializer.is_valid()):
Scott Baker351148c2014-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 Bakerf3816ac2014-11-12 01:13:53 -08004102 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004103 obj.caller = request.user
4104 if obj.can_update(request.user):
4105 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4106 else:
Scott Baker08898c12014-10-29 23:41:11 -07004107 raise Exception("failed obj.can_update")
4108
4109 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4110 if (ret.status_code%100 != 200):
4111 raise Exception(ret.data)
4112
4113 return ret
4114
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004115
4116class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4117 queryset = PlanetStackPrivilege.objects.select_related().all()
4118 serializer_class = PlanetStackPrivilegeSerializer
4119 id_serializer_class = PlanetStackPrivilegeIdSerializer
4120
4121 def get_serializer_class(self):
4122 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4123 if (no_hyperlinks):
4124 return self.id_serializer_class
4125 else:
4126 return self.serializer_class
4127
4128 def get_queryset(self):
4129 return PlanetStackPrivilege.select_by_user(self.request.user)
4130
4131 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4132
4133 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4134
4135
4136
4137class UserList(generics.ListCreateAPIView):
4138 queryset = User.objects.select_related().all()
4139 serializer_class = UserSerializer
4140 id_serializer_class = UserIdSerializer
4141 filter_backends = (filters.DjangoFilterBackend,)
4142 filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
4143
4144 def get_serializer_class(self):
4145 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4146 if (no_hyperlinks):
4147 return self.id_serializer_class
4148 else:
4149 return self.serializer_class
4150
4151 def get_queryset(self):
4152 return User.select_by_user(self.request.user)
4153
4154 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004155 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4156 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004157 response = {"error": "validation",
4158 "specific_error": "not serializer.is_valid()",
4159 "reasons": serializer.errors}
4160 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004161 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004162 obj.caller = request.user
4163 if obj.can_update(request.user):
4164 return super(UserList, self).create(request, *args, **kwargs)
4165 else:
Scott Baker08898c12014-10-29 23:41:11 -07004166 raise Exception("failed obj.can_update")
4167
4168 ret = super(UserList, self).create(request, *args, **kwargs)
4169 if (ret.status_code%100 != 200):
4170 raise Exception(ret.data)
4171
4172 return ret
4173
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004174
4175class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4176 queryset = User.objects.select_related().all()
4177 serializer_class = UserSerializer
4178 id_serializer_class = UserIdSerializer
4179
4180 def get_serializer_class(self):
4181 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4182 if (no_hyperlinks):
4183 return self.id_serializer_class
4184 else:
4185 return self.serializer_class
4186
4187 def get_queryset(self):
4188 return User.select_by_user(self.request.user)
4189
4190 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4191
4192 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4193
4194
4195
4196class DeploymentList(generics.ListCreateAPIView):
4197 queryset = Deployment.objects.select_related().all()
4198 serializer_class = DeploymentSerializer
4199 id_serializer_class = DeploymentIdSerializer
4200 filter_backends = (filters.DjangoFilterBackend,)
Tony Mack336e0f92014-11-30 15:53:08 -05004201 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','sites','sites','flavors','flavors',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004202
4203 def get_serializer_class(self):
4204 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4205 if (no_hyperlinks):
4206 return self.id_serializer_class
4207 else:
4208 return self.serializer_class
4209
4210 def get_queryset(self):
4211 return Deployment.select_by_user(self.request.user)
4212
4213 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004214 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4215 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004216 response = {"error": "validation",
4217 "specific_error": "not serializer.is_valid()",
4218 "reasons": serializer.errors}
4219 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004220 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004221 obj.caller = request.user
4222 if obj.can_update(request.user):
4223 return super(DeploymentList, self).create(request, *args, **kwargs)
4224 else:
Scott Baker08898c12014-10-29 23:41:11 -07004225 raise Exception("failed obj.can_update")
4226
4227 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4228 if (ret.status_code%100 != 200):
4229 raise Exception(ret.data)
4230
4231 return ret
4232
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004233
4234class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4235 queryset = Deployment.objects.select_related().all()
4236 serializer_class = DeploymentSerializer
4237 id_serializer_class = DeploymentIdSerializer
4238
4239 def get_serializer_class(self):
4240 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4241 if (no_hyperlinks):
4242 return self.id_serializer_class
4243 else:
4244 return self.serializer_class
4245
4246 def get_queryset(self):
4247 return Deployment.select_by_user(self.request.user)
4248
4249 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4250
4251 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4252
Tony Mack336e0f92014-11-30 15:53:08 -05004253class ControllerList(generics.ListCreateAPIView):
4254 queryset = Controller.objects.select_related().all()
4255 serializer_class = ControllerSerializer
4256 id_serializer_class = ControllerIdSerializer
4257 filter_backends = (filters.DjangoFilterBackend,)
4258 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site_deployment','admin_user','admin_password','admin_tenant','auth_url','backend_type')
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004259
Tony Mack336e0f92014-11-30 15:53:08 -05004260 def get_serializer_class(self):
4261 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4262 if (no_hyperlinks):
4263 return self.id_serializer_class
4264 else:
4265 return self.serializer_class
4266
4267 def get_queryset(self):
4268 return Controller.select_by_user(self.request.user)
4269
4270 def create(self, request, *args, **kwargs):
4271 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4272 if not (serializer.is_valid()):
4273 response = {"error": "validation",
4274 "specific_error": "not serializer.is_valid()",
4275 "reasons": serializer.errors}
4276 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4277 obj = serializer.object
4278 obj.caller = request.user
4279 if obj.can_update(request.user):
4280 return super(ControllerList, self).create(request, *args, **kwargs)
4281 else:
4282 raise Exception("failed obj.can_update")
4283
4284 ret = super(ControllerList, self).create(request, *args, **kwargs)
4285 if (ret.status_code%100 != 200):
4286 raise Exception(ret.data)
4287
4288 return ret
4289
4290class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4291 queryset = Controller.objects.select_related().all()
4292 serializer_class = ControllerSerializer
4293 id_serializer_class = ControllerIdSerializer
4294
4295 def get_serializer_class(self):
4296 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4297 if (no_hyperlinks):
4298 return self.id_serializer_class
4299 else:
4300 return self.serializer_class
4301
4302 def get_queryset(self):
4303 return Controller.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004304
4305class ReservationList(generics.ListCreateAPIView):
4306 queryset = Reservation.objects.select_related().all()
4307 serializer_class = ReservationSerializer
4308 id_serializer_class = ReservationIdSerializer
4309 filter_backends = (filters.DjangoFilterBackend,)
4310 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4311
4312 def get_serializer_class(self):
4313 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4314 if (no_hyperlinks):
4315 return self.id_serializer_class
4316 else:
4317 return self.serializer_class
4318
4319 def get_queryset(self):
4320 return Reservation.select_by_user(self.request.user)
4321
4322 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004323 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4324 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004325 response = {"error": "validation",
4326 "specific_error": "not serializer.is_valid()",
4327 "reasons": serializer.errors}
4328 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004329 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004330 obj.caller = request.user
4331 if obj.can_update(request.user):
4332 return super(ReservationList, self).create(request, *args, **kwargs)
4333 else:
Scott Baker08898c12014-10-29 23:41:11 -07004334 raise Exception("failed obj.can_update")
4335
4336 ret = super(ReservationList, self).create(request, *args, **kwargs)
4337 if (ret.status_code%100 != 200):
4338 raise Exception(ret.data)
4339
4340 return ret
4341
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004342
4343class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4344 queryset = Reservation.objects.select_related().all()
4345 serializer_class = ReservationSerializer
4346 id_serializer_class = ReservationIdSerializer
4347
4348 def get_serializer_class(self):
4349 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4350 if (no_hyperlinks):
4351 return self.id_serializer_class
4352 else:
4353 return self.serializer_class
4354
4355 def get_queryset(self):
4356 return Reservation.select_by_user(self.request.user)
4357
4358 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4359
4360 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4361
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004362
Scott Bakerf3816ac2014-11-12 01:13:53 -08004363
Tony Mack336e0f92014-11-30 15:53:08 -05004364class ControllerSlicesList(generics.ListCreateAPIView):
4365 queryset = ControllerSlices.objects.select_related().all()
4366 serializer_class = ControllerSlicesSerializer
4367 id_serializer_class = ControllerSlicesIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004368 filter_backends = (filters.DjangoFilterBackend,)
4369 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
4370
4371 def get_serializer_class(self):
4372 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4373 if (no_hyperlinks):
4374 return self.id_serializer_class
4375 else:
4376 return self.serializer_class
4377
4378 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05004379 return ControllerSlices.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004380
4381 def create(self, request, *args, **kwargs):
4382 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4383 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004384 response = {"error": "validation",
4385 "specific_error": "not serializer.is_valid()",
4386 "reasons": serializer.errors}
4387 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08004388 obj = serializer.object
4389 obj.caller = request.user
4390 if obj.can_update(request.user):
Tony Mack336e0f92014-11-30 15:53:08 -05004391 return super(ControllerSlicesList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08004392 else:
4393 raise Exception("failed obj.can_update")
4394
Tony Mack336e0f92014-11-30 15:53:08 -05004395 ret = super(ControllerSlicesList, self).create(request, *args, **kwargs)
Scott Baker196ffef2014-11-21 11:32:24 -08004396 if (ret.status_code%100 != 200):
4397 raise Exception(ret.data)
4398
4399 return ret
4400
4401
Tony Mack336e0f92014-11-30 15:53:08 -05004402class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4403 queryset = ControllerSlices.objects.select_related().all()
4404 serializer_class = ControllerSlicesSerializer
4405 id_serializer_class = ControllerSlicesIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004406
4407 def get_serializer_class(self):
4408 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4409 if (no_hyperlinks):
4410 return self.id_serializer_class
4411 else:
4412 return self.serializer_class
4413
4414 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05004415 return ControllerSlices.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004416
4417 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4418
4419 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4420
Scott Baker196ffef2014-11-21 11:32:24 -08004421
4422
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004423class SitePrivilegeList(generics.ListCreateAPIView):
4424 queryset = SitePrivilege.objects.select_related().all()
4425 serializer_class = SitePrivilegeSerializer
4426 id_serializer_class = SitePrivilegeIdSerializer
4427 filter_backends = (filters.DjangoFilterBackend,)
4428 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4429
4430 def get_serializer_class(self):
4431 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4432 if (no_hyperlinks):
4433 return self.id_serializer_class
4434 else:
4435 return self.serializer_class
4436
4437 def get_queryset(self):
4438 return SitePrivilege.select_by_user(self.request.user)
4439
4440 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004441 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4442 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004443 response = {"error": "validation",
4444 "specific_error": "not serializer.is_valid()",
4445 "reasons": serializer.errors}
4446 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004447 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004448 obj.caller = request.user
4449 if obj.can_update(request.user):
4450 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4451 else:
Scott Baker08898c12014-10-29 23:41:11 -07004452 raise Exception("failed obj.can_update")
4453
4454 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4455 if (ret.status_code%100 != 200):
4456 raise Exception(ret.data)
4457
4458 return ret
4459
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004460
4461class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4462 queryset = SitePrivilege.objects.select_related().all()
4463 serializer_class = SitePrivilegeSerializer
4464 id_serializer_class = SitePrivilegeIdSerializer
4465
4466 def get_serializer_class(self):
4467 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4468 if (no_hyperlinks):
4469 return self.id_serializer_class
4470 else:
4471 return self.serializer_class
4472
4473 def get_queryset(self):
4474 return SitePrivilege.select_by_user(self.request.user)
4475
4476 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4477
4478 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4479
4480
4481
Scott Baker196ffef2014-11-21 11:32:24 -08004482class PlanetStackList(generics.ListCreateAPIView):
4483 queryset = PlanetStack.objects.select_related().all()
4484 serializer_class = PlanetStackSerializer
4485 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004486 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker196ffef2014-11-21 11:32:24 -08004487 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004488
4489 def get_serializer_class(self):
4490 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4491 if (no_hyperlinks):
4492 return self.id_serializer_class
4493 else:
4494 return self.serializer_class
4495
4496 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004497 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004498
4499 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004500 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4501 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004502 response = {"error": "validation",
4503 "specific_error": "not serializer.is_valid()",
4504 "reasons": serializer.errors}
4505 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004506 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004507 obj.caller = request.user
4508 if obj.can_update(request.user):
Scott Baker196ffef2014-11-21 11:32:24 -08004509 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004510 else:
Scott Baker08898c12014-10-29 23:41:11 -07004511 raise Exception("failed obj.can_update")
4512
Scott Baker196ffef2014-11-21 11:32:24 -08004513 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004514 if (ret.status_code%100 != 200):
4515 raise Exception(ret.data)
4516
4517 return ret
4518
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004519
Scott Baker196ffef2014-11-21 11:32:24 -08004520class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4521 queryset = PlanetStack.objects.select_related().all()
4522 serializer_class = PlanetStackSerializer
4523 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004524
4525 def get_serializer_class(self):
4526 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4527 if (no_hyperlinks):
4528 return self.id_serializer_class
4529 else:
4530 return self.serializer_class
4531
4532 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004533 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004534
4535 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4536
4537 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4538
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004539
Scott Bakerf3816ac2014-11-12 01:13:53 -08004540
Tony Mack336e0f92014-11-30 15:53:08 -05004541class ControllerUsersList(generics.ListCreateAPIView):
4542 queryset = ControllerUsers.objects.select_related().all()
4543 serializer_class = ControllerUsersSerializer
4544 id_serializer_class = ControllerUsersIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004545 filter_backends = (filters.DjangoFilterBackend,)
4546 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
4547
4548 def get_serializer_class(self):
4549 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4550 if (no_hyperlinks):
4551 return self.id_serializer_class
4552 else:
4553 return self.serializer_class
4554
4555 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05004556 return ControllerUsers.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004557
4558 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004559 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4560 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004561 response = {"error": "validation",
4562 "specific_error": "not serializer.is_valid()",
4563 "reasons": serializer.errors}
4564 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004565 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004566 obj.caller = request.user
4567 if obj.can_update(request.user):
Tony Mack336e0f92014-11-30 15:53:08 -05004568 return super(ControllerUsersList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004569 else:
Scott Baker08898c12014-10-29 23:41:11 -07004570 raise Exception("failed obj.can_update")
4571
Tony Mack336e0f92014-11-30 15:53:08 -05004572 ret = super(ControllerUsersList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004573 if (ret.status_code%100 != 200):
4574 raise Exception(ret.data)
4575
4576 return ret
4577
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004578
Tony Mack336e0f92014-11-30 15:53:08 -05004579class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4580 queryset = ControllerUsers.objects.select_related().all()
4581 serializer_class = ControllerUsersSerializer
4582 id_serializer_class = ControllerUsersIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004583
4584 def get_serializer_class(self):
4585 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4586 if (no_hyperlinks):
4587 return self.id_serializer_class
4588 else:
4589 return self.serializer_class
4590
4591 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05004592 return ControllerUsers.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004593
4594 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4595
4596 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4597
4598
4599
4600class AccountList(generics.ListCreateAPIView):
4601 queryset = Account.objects.select_related().all()
4602 serializer_class = AccountSerializer
4603 id_serializer_class = AccountIdSerializer
4604 filter_backends = (filters.DjangoFilterBackend,)
4605 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4606
4607 def get_serializer_class(self):
4608 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4609 if (no_hyperlinks):
4610 return self.id_serializer_class
4611 else:
4612 return self.serializer_class
4613
4614 def get_queryset(self):
4615 return Account.select_by_user(self.request.user)
4616
4617 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004618 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4619 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004620 response = {"error": "validation",
4621 "specific_error": "not serializer.is_valid()",
4622 "reasons": serializer.errors}
4623 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004624 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004625 obj.caller = request.user
4626 if obj.can_update(request.user):
4627 return super(AccountList, self).create(request, *args, **kwargs)
4628 else:
Scott Baker08898c12014-10-29 23:41:11 -07004629 raise Exception("failed obj.can_update")
4630
4631 ret = super(AccountList, self).create(request, *args, **kwargs)
4632 if (ret.status_code%100 != 200):
4633 raise Exception(ret.data)
4634
4635 return ret
4636
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004637
4638class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4639 queryset = Account.objects.select_related().all()
4640 serializer_class = AccountSerializer
4641 id_serializer_class = AccountIdSerializer
4642
4643 def get_serializer_class(self):
4644 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4645 if (no_hyperlinks):
4646 return self.id_serializer_class
4647 else:
4648 return self.serializer_class
4649
4650 def get_queryset(self):
4651 return Account.select_by_user(self.request.user)
4652
4653 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4654
4655 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4656
4657
4658
4659class NetworkParameterTypeList(generics.ListCreateAPIView):
4660 queryset = NetworkParameterType.objects.select_related().all()
4661 serializer_class = NetworkParameterTypeSerializer
4662 id_serializer_class = NetworkParameterTypeIdSerializer
4663 filter_backends = (filters.DjangoFilterBackend,)
4664 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
4665
4666 def get_serializer_class(self):
4667 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4668 if (no_hyperlinks):
4669 return self.id_serializer_class
4670 else:
4671 return self.serializer_class
4672
4673 def get_queryset(self):
4674 return NetworkParameterType.select_by_user(self.request.user)
4675
4676 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004677 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4678 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004679 response = {"error": "validation",
4680 "specific_error": "not serializer.is_valid()",
4681 "reasons": serializer.errors}
4682 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004683 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004684 obj.caller = request.user
4685 if obj.can_update(request.user):
4686 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4687 else:
Scott Baker08898c12014-10-29 23:41:11 -07004688 raise Exception("failed obj.can_update")
4689
4690 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4691 if (ret.status_code%100 != 200):
4692 raise Exception(ret.data)
4693
4694 return ret
4695
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004696
4697class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4698 queryset = NetworkParameterType.objects.select_related().all()
4699 serializer_class = NetworkParameterTypeSerializer
4700 id_serializer_class = NetworkParameterTypeIdSerializer
4701
4702 def get_serializer_class(self):
4703 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4704 if (no_hyperlinks):
4705 return self.id_serializer_class
4706 else:
4707 return self.serializer_class
4708
4709 def get_queryset(self):
4710 return NetworkParameterType.select_by_user(self.request.user)
4711
4712 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4713
4714 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4715
4716
4717
4718class SiteCredentialList(generics.ListCreateAPIView):
4719 queryset = SiteCredential.objects.select_related().all()
4720 serializer_class = SiteCredentialSerializer
4721 id_serializer_class = SiteCredentialIdSerializer
4722 filter_backends = (filters.DjangoFilterBackend,)
4723 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
4724
4725 def get_serializer_class(self):
4726 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4727 if (no_hyperlinks):
4728 return self.id_serializer_class
4729 else:
4730 return self.serializer_class
4731
4732 def get_queryset(self):
4733 return SiteCredential.select_by_user(self.request.user)
4734
4735 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004736 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4737 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004738 response = {"error": "validation",
4739 "specific_error": "not serializer.is_valid()",
4740 "reasons": serializer.errors}
4741 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004742 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004743 obj.caller = request.user
4744 if obj.can_update(request.user):
4745 return super(SiteCredentialList, self).create(request, *args, **kwargs)
4746 else:
Scott Baker08898c12014-10-29 23:41:11 -07004747 raise Exception("failed obj.can_update")
4748
4749 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
4750 if (ret.status_code%100 != 200):
4751 raise Exception(ret.data)
4752
4753 return ret
4754
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004755
4756class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4757 queryset = SiteCredential.objects.select_related().all()
4758 serializer_class = SiteCredentialSerializer
4759 id_serializer_class = SiteCredentialIdSerializer
4760
4761 def get_serializer_class(self):
4762 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4763 if (no_hyperlinks):
4764 return self.id_serializer_class
4765 else:
4766 return self.serializer_class
4767
4768 def get_queryset(self):
4769 return SiteCredential.select_by_user(self.request.user)
4770
4771 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4772
4773 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4774
4775
4776
Tony Mack336e0f92014-11-30 15:53:08 -05004777class ControllerPrivilegeList(generics.ListCreateAPIView):
4778 queryset = ControllerPrivilege.objects.select_related().all()
4779 serializer_class = ControllerPrivilegeSerializer
4780 id_serializer_class = ControllerPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004781 filter_backends = (filters.DjangoFilterBackend,)
4782 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
4783
4784 def get_serializer_class(self):
4785 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4786 if (no_hyperlinks):
4787 return self.id_serializer_class
4788 else:
4789 return self.serializer_class
4790
4791 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05004792 return ControllerPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004793
4794 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004795 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4796 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004797 response = {"error": "validation",
4798 "specific_error": "not serializer.is_valid()",
4799 "reasons": serializer.errors}
4800 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004801 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004802 obj.caller = request.user
4803 if obj.can_update(request.user):
Tony Mack336e0f92014-11-30 15:53:08 -05004804 return super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004805 else:
Scott Baker08898c12014-10-29 23:41:11 -07004806 raise Exception("failed obj.can_update")
4807
Tony Mack336e0f92014-11-30 15:53:08 -05004808 ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004809 if (ret.status_code%100 != 200):
4810 raise Exception(ret.data)
4811
4812 return ret
4813
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004814
Tony Mack336e0f92014-11-30 15:53:08 -05004815class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4816 queryset = ControllerPrivilege.objects.select_related().all()
4817 serializer_class = ControllerPrivilegeSerializer
4818 id_serializer_class = ControllerPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004819
4820 def get_serializer_class(self):
4821 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4822 if (no_hyperlinks):
4823 return self.id_serializer_class
4824 else:
4825 return self.serializer_class
4826
4827 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05004828 return ControllerPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004829
4830 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4831
4832 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4833
4834
4835
Tony Mack336e0f92014-11-30 15:53:08 -05004836class ControllerRoleList(generics.ListCreateAPIView):
4837 queryset = ControllerRole.objects.select_related().all()
4838 serializer_class = ControllerRoleSerializer
4839 id_serializer_class = ControllerRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004840 filter_backends = (filters.DjangoFilterBackend,)
4841 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
4842
4843 def get_serializer_class(self):
4844 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4845 if (no_hyperlinks):
4846 return self.id_serializer_class
4847 else:
4848 return self.serializer_class
4849
4850 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05004851 return ControllerRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004852
4853 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004854 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4855 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004856 response = {"error": "validation",
4857 "specific_error": "not serializer.is_valid()",
4858 "reasons": serializer.errors}
4859 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004860 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004861 obj.caller = request.user
4862 if obj.can_update(request.user):
Tony Mack336e0f92014-11-30 15:53:08 -05004863 return super(ControllerRoleList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004864 else:
Scott Baker08898c12014-10-29 23:41:11 -07004865 raise Exception("failed obj.can_update")
4866
Tony Mack336e0f92014-11-30 15:53:08 -05004867 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004868 if (ret.status_code%100 != 200):
4869 raise Exception(ret.data)
4870
4871 return ret
4872
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004873
Tony Mack336e0f92014-11-30 15:53:08 -05004874class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4875 queryset = ControllerRole.objects.select_related().all()
4876 serializer_class = ControllerRoleSerializer
4877 id_serializer_class = ControllerRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004878
4879 def get_serializer_class(self):
4880 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4881 if (no_hyperlinks):
4882 return self.id_serializer_class
4883 else:
4884 return self.serializer_class
4885
4886 def get_queryset(self):
Tony Mack336e0f92014-11-30 15:53:08 -05004887 return ControllerRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004888
4889 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4890
4891 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4892
4893
4894
4895class UserCredentialList(generics.ListCreateAPIView):
4896 queryset = UserCredential.objects.select_related().all()
4897 serializer_class = UserCredentialSerializer
4898 id_serializer_class = UserCredentialIdSerializer
4899 filter_backends = (filters.DjangoFilterBackend,)
4900 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
4901
4902 def get_serializer_class(self):
4903 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4904 if (no_hyperlinks):
4905 return self.id_serializer_class
4906 else:
4907 return self.serializer_class
4908
4909 def get_queryset(self):
4910 return UserCredential.select_by_user(self.request.user)
4911
4912 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004913 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4914 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004915 response = {"error": "validation",
4916 "specific_error": "not serializer.is_valid()",
4917 "reasons": serializer.errors}
4918 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08004919 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004920 obj.caller = request.user
4921 if obj.can_update(request.user):
4922 return super(UserCredentialList, self).create(request, *args, **kwargs)
4923 else:
Scott Baker08898c12014-10-29 23:41:11 -07004924 raise Exception("failed obj.can_update")
4925
4926 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
4927 if (ret.status_code%100 != 200):
4928 raise Exception(ret.data)
4929
4930 return ret
4931
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004932
4933class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4934 queryset = UserCredential.objects.select_related().all()
4935 serializer_class = UserCredentialSerializer
4936 id_serializer_class = UserCredentialIdSerializer
4937
4938 def get_serializer_class(self):
4939 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4940 if (no_hyperlinks):
4941 return self.id_serializer_class
4942 else:
4943 return self.serializer_class
4944
4945 def get_queryset(self):
4946 return UserCredential.select_by_user(self.request.user)
4947
4948 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4949
4950 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4951
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004952
Scott Bakerf3816ac2014-11-12 01:13:53 -08004953
Scott Baker196ffef2014-11-21 11:32:24 -08004954class SiteDeploymentsList(generics.ListCreateAPIView):
4955 queryset = SiteDeployments.objects.select_related().all()
4956 serializer_class = SiteDeploymentsSerializer
4957 id_serializer_class = SiteDeploymentsIdSerializer
4958 filter_backends = (filters.DjangoFilterBackend,)
Tony Mack336e0f92014-11-30 15:53:08 -05004959 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment')
Scott Baker196ffef2014-11-21 11:32:24 -08004960
4961 def get_serializer_class(self):
4962 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4963 if (no_hyperlinks):
4964 return self.id_serializer_class
4965 else:
4966 return self.serializer_class
4967
4968 def get_queryset(self):
4969 return SiteDeployments.select_by_user(self.request.user)
4970
4971 def create(self, request, *args, **kwargs):
4972 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4973 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08004974 response = {"error": "validation",
4975 "specific_error": "not serializer.is_valid()",
4976 "reasons": serializer.errors}
4977 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker196ffef2014-11-21 11:32:24 -08004978 obj = serializer.object
4979 obj.caller = request.user
4980 if obj.can_update(request.user):
4981 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
4982 else:
4983 raise Exception("failed obj.can_update")
4984
4985 ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
4986 if (ret.status_code%100 != 200):
4987 raise Exception(ret.data)
4988
4989 return ret
4990
4991
4992class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4993 queryset = SiteDeployments.objects.select_related().all()
4994 serializer_class = SiteDeploymentsSerializer
4995 id_serializer_class = SiteDeploymentsIdSerializer
4996
4997 def get_serializer_class(self):
4998 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4999 if (no_hyperlinks):
5000 return self.id_serializer_class
5001 else:
5002 return self.serializer_class
5003
5004 def get_queryset(self):
5005 return SiteDeployments.select_by_user(self.request.user)
5006
5007 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5008
5009 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5010
Tony Mack336e0f92014-11-30 15:53:08 -05005011class ControllerSitesList(generics.ListCreateAPIView):
5012 queryset = ControllerSites.objects.select_related().all()
5013 serializer_class = ControllerSitesSerializer
5014 id_serializer_class = ControllerSiteIdSerializer
5015 filter_backends = (filters.DjangoFilterBackend,)
5016 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site_deployment','controller','tenant_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08005017
Tony Mack336e0f92014-11-30 15:53:08 -05005018 def get_serializer_class(self):
5019 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5020 if (no_hyperlinks):
5021 return self.id_serializer_class
5022 else:
5023 return self.serializer_class
5024
5025 def get_queryset(self):
5026 return ControllerSites.select_by_user(self.request.user)
5027
5028 def create(self, request, *args, **kwargs):
5029 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5030 if not (serializer.is_valid()):
5031 response = {"error": "validation",
5032 "specific_error": "not serializer.is_valid()",
5033 "reasons": serializer.errors}
5034 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5035 obj = serializer.object
5036 obj.caller = request.user
5037 if obj.can_update(request.user):
5038 return super(ControllerSitesList, self).create(request, *args, **kwargs)
5039 else:
5040 raise Exception("failed obj.can_update")
5041
5042 ret = super(ControllerSitesList, self).create(request, *args, **kwargs)
5043 if (ret.status_code%100 != 200):
5044 raise Exception(ret.data)
5045
5046 return ret
5047
5048class ControllerSitesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5049 queryset = ControllerSites.objects.select_related().all()
5050 serializer_class = ControllerSitesSerializer
5051 id_serializer_class = ControllerSitesIdSerializer
5052
5053 def get_serializer_class(self):
5054 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5055 if (no_hyperlinks):
5056 return self.id_serializer_class
5057 else:
5058 return self.serializer_class
5059
5060 def get_queryset(self):
5061 return ControllerSites.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08005062
Scott Baker0caeaf02014-06-19 11:12:55 -07005063class SliceTagList(generics.ListCreateAPIView):
5064 queryset = SliceTag.objects.select_related().all()
5065 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005066 id_serializer_class = SliceTagIdSerializer
5067 filter_backends = (filters.DjangoFilterBackend,)
5068 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5069
5070 def get_serializer_class(self):
5071 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5072 if (no_hyperlinks):
5073 return self.id_serializer_class
5074 else:
5075 return self.serializer_class
5076
Scott Baker0caeaf02014-06-19 11:12:55 -07005077 def get_queryset(self):
5078 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005079
Scott Baker0caeaf02014-06-19 11:12:55 -07005080 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005081 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5082 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005083 response = {"error": "validation",
5084 "specific_error": "not serializer.is_valid()",
5085 "reasons": serializer.errors}
5086 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005087 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005088 obj.caller = request.user
5089 if obj.can_update(request.user):
5090 return super(SliceTagList, self).create(request, *args, **kwargs)
5091 else:
Scott Baker08898c12014-10-29 23:41:11 -07005092 raise Exception("failed obj.can_update")
5093
5094 ret = super(SliceTagList, self).create(request, *args, **kwargs)
5095 if (ret.status_code%100 != 200):
5096 raise Exception(ret.data)
5097
5098 return ret
5099
Scott Baker0caeaf02014-06-19 11:12:55 -07005100
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005101class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005102 queryset = SliceTag.objects.select_related().all()
5103 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005104 id_serializer_class = SliceTagIdSerializer
5105
5106 def get_serializer_class(self):
5107 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5108 if (no_hyperlinks):
5109 return self.id_serializer_class
5110 else:
5111 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005112
5113 def get_queryset(self):
5114 return SliceTag.select_by_user(self.request.user)
5115
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005116 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005117
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005118 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005119
5120
5121
Scott Baker0caeaf02014-06-19 11:12:55 -07005122class NetworkTemplateList(generics.ListCreateAPIView):
5123 queryset = NetworkTemplate.objects.select_related().all()
5124 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005125 id_serializer_class = NetworkTemplateIdSerializer
5126 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker645dc9d2014-11-17 22:32:19 -08005127 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07005128
5129 def get_serializer_class(self):
5130 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5131 if (no_hyperlinks):
5132 return self.id_serializer_class
5133 else:
5134 return self.serializer_class
5135
Scott Baker0caeaf02014-06-19 11:12:55 -07005136 def get_queryset(self):
5137 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005138
Scott Baker0caeaf02014-06-19 11:12:55 -07005139 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005140 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5141 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005142 response = {"error": "validation",
5143 "specific_error": "not serializer.is_valid()",
5144 "reasons": serializer.errors}
5145 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005146 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005147 obj.caller = request.user
5148 if obj.can_update(request.user):
5149 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
5150 else:
Scott Baker08898c12014-10-29 23:41:11 -07005151 raise Exception("failed obj.can_update")
5152
5153 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
5154 if (ret.status_code%100 != 200):
5155 raise Exception(ret.data)
5156
5157 return ret
5158
Scott Baker0caeaf02014-06-19 11:12:55 -07005159
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005160class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005161 queryset = NetworkTemplate.objects.select_related().all()
5162 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005163 id_serializer_class = NetworkTemplateIdSerializer
5164
5165 def get_serializer_class(self):
5166 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5167 if (no_hyperlinks):
5168 return self.id_serializer_class
5169 else:
5170 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005171
5172 def get_queryset(self):
5173 return NetworkTemplate.select_by_user(self.request.user)
5174
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005175 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005176
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005177 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005178
5179
5180
5181class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005182 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005183 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005184 id_serializer_class = RouterIdSerializer
5185 filter_backends = (filters.DjangoFilterBackend,)
5186 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
5187
5188 def get_serializer_class(self):
5189 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5190 if (no_hyperlinks):
5191 return self.id_serializer_class
5192 else:
5193 return self.serializer_class
5194
Scott Baker0caeaf02014-06-19 11:12:55 -07005195 def get_queryset(self):
5196 return Router.select_by_user(self.request.user)
5197
5198 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005199 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5200 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005201 response = {"error": "validation",
5202 "specific_error": "not serializer.is_valid()",
5203 "reasons": serializer.errors}
5204 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005205 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005206 obj.caller = request.user
5207 if obj.can_update(request.user):
5208 return super(RouterList, self).create(request, *args, **kwargs)
5209 else:
Scott Baker08898c12014-10-29 23:41:11 -07005210 raise Exception("failed obj.can_update")
5211
5212 ret = super(RouterList, self).create(request, *args, **kwargs)
5213 if (ret.status_code%100 != 200):
5214 raise Exception(ret.data)
5215
5216 return ret
5217
Sapan Bhatiadea39432014-06-13 03:10:36 -04005218
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005219class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005220 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005221 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005222 id_serializer_class = RouterIdSerializer
5223
5224 def get_serializer_class(self):
5225 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5226 if (no_hyperlinks):
5227 return self.id_serializer_class
5228 else:
5229 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005230
5231 def get_queryset(self):
5232 return Router.select_by_user(self.request.user)
5233
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005234 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005235
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005236 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005237
5238
5239
Scott Baker0caeaf02014-06-19 11:12:55 -07005240class ServiceResourceList(generics.ListCreateAPIView):
5241 queryset = ServiceResource.objects.select_related().all()
5242 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005243 id_serializer_class = ServiceResourceIdSerializer
5244 filter_backends = (filters.DjangoFilterBackend,)
5245 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5246
5247 def get_serializer_class(self):
5248 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5249 if (no_hyperlinks):
5250 return self.id_serializer_class
5251 else:
5252 return self.serializer_class
5253
Scott Baker0caeaf02014-06-19 11:12:55 -07005254 def get_queryset(self):
5255 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005256
Scott Baker0caeaf02014-06-19 11:12:55 -07005257 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005258 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5259 if not (serializer.is_valid()):
Scott Baker351148c2014-11-25 00:53:25 -08005260 response = {"error": "validation",
5261 "specific_error": "not serializer.is_valid()",
5262 "reasons": serializer.errors}
5263 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerf3816ac2014-11-12 01:13:53 -08005264 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005265 obj.caller = request.user
5266 if obj.can_update(request.user):
5267 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5268 else:
Scott Baker08898c12014-10-29 23:41:11 -07005269 raise Exception("failed obj.can_update")
5270
5271 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5272 if (ret.status_code%100 != 200):
5273 raise Exception(ret.data)
5274
5275 return ret
5276
Scott Baker0caeaf02014-06-19 11:12:55 -07005277
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005278class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005279 queryset = ServiceResource.objects.select_related().all()
5280 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005281 id_serializer_class = ServiceResourceIdSerializer
5282
5283 def get_serializer_class(self):
5284 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5285 if (no_hyperlinks):
5286 return self.id_serializer_class
5287 else:
5288 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005289
5290 def get_queryset(self):
5291 return ServiceResource.select_by_user(self.request.user)
5292
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005293 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005294
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005295 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005296
Sapan Bhatiadea39432014-06-13 03:10:36 -04005297
5298