blob: a85368522373b37a251fb036e9d672bc8ac818a1 [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Baker89a7b7c2014-10-07 00:10:17 -07006from rest_framework import status
Scott Baker57c725c2014-11-12 01:13:53 -08007from rest_framework.generics import GenericAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04008from core.models import *
9from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -070010from rest_framework import filters
Scott Bakerd51d0bd2014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Scott Baker4af864e2015-02-02 13:53:46 -080012from rest_framework.exceptions import PermissionDenied as RestFrameworkPermissionDenied
Scott Baker15af5652015-02-02 14:33:08 -080013from django.core.exceptions import PermissionDenied as DjangoPermissionDenied
Sapan Bhatiadea39432014-06-13 03:10:36 -040014
Scott Bakerf0480fb2014-12-23 11:12:07 -080015if hasattr(serializers, "ReadOnlyField"):
16 # rest_framework 3.x
17 IdField = serializers.ReadOnlyField
18else:
19 # rest_framework 2.x
20 IdField = serializers.Field
21
Sapan Bhatiadea39432014-06-13 03:10:36 -040022"""
Scott Baker2bcbf372014-10-29 23:41:11 -070023 Schema of the generator object:
24 all: Set of all Model objects
25 all_if(regex): Set of Model objects that match regex
Scott Baker57c725c2014-11-12 01:13:53 -080026
Scott Baker2bcbf372014-10-29 23:41:11 -070027 Model object:
28 plural: English plural of object name
29 camel: CamelCase version of object name
30 refs: list of references to other Model objects
31 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040032
Scott Baker2bcbf372014-10-29 23:41:11 -070033 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040034"""
35
Scott Bakerd51d0bd2014-11-10 16:31:15 -080036def get_REST_patterns():
37 return patterns('',
Scott Baker1faefd32015-02-02 15:53:37 -080038 url(r'^xos/$', api_root),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080039
Scott Baker1faefd32015-02-02 15:53:37 -080040 url(r'xos/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
41 url(r'xos/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080042
Scott Baker1faefd32015-02-02 15:53:37 -080043 url(r'xos/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'),
44 url(r'xos/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -080045
Scott Baker1faefd32015-02-02 15:53:37 -080046 url(r'xos/controllersiteprivileges/$', ControllerSitePrivilegeList.as_view(), name='controllersiteprivilege-list'),
47 url(r'xos/controllersiteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSitePrivilegeDetail.as_view(), name ='controllersiteprivilege-detail'),
Scott Baker191f9b22015-01-12 13:16:39 -080048
Scott Baker1faefd32015-02-02 15:53:37 -080049 url(r'xos/images/$', ImageList.as_view(), name='image-list'),
50 url(r'xos/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080051
Scott Baker1faefd32015-02-02 15:53:37 -080052 url(r'xos/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
53 url(r'xos/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080054
Scott Baker1faefd32015-02-02 15:53:37 -080055 url(r'xos/sites/$', SiteList.as_view(), name='site-list'),
56 url(r'xos/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080057
Scott Baker1faefd32015-02-02 15:53:37 -080058 url(r'xos/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
59 url(r'xos/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080060
Scott Baker1faefd32015-02-02 15:53:37 -080061 url(r'xos/tags/$', TagList.as_view(), name='tag-list'),
62 url(r'xos/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080063
Scott Baker1faefd32015-02-02 15:53:37 -080064 url(r'xos/invoices/$', InvoiceList.as_view(), name='invoice-list'),
65 url(r'xos/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080066
Scott Baker1faefd32015-02-02 15:53:37 -080067 url(r'xos/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
68 url(r'xos/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080069
Scott Baker1faefd32015-02-02 15:53:37 -080070 url(r'xos/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
71 url(r'xos/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080072
Scott Baker1faefd32015-02-02 15:53:37 -080073 url(r'xos/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
74 url(r'xos/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080075
Scott Baker1faefd32015-02-02 15:53:37 -080076 url(r'xos/flavors/$', FlavorList.as_view(), name='flavor-list'),
77 url(r'xos/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
Scott Baker191f9b22015-01-12 13:16:39 -080078
Scott Baker1faefd32015-02-02 15:53:37 -080079 url(r'xos/controllersites/$', ControllerSiteList.as_view(), name='controllersite-list'),
80 url(r'xos/controllersites/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDetail.as_view(), name ='controllersite-detail'),
Scott Baker191f9b22015-01-12 13:16:39 -080081
Scott Baker1faefd32015-02-02 15:53:37 -080082 url(r'xos/projects/$', ProjectList.as_view(), name='project-list'),
83 url(r'xos/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080084
Scott Baker1faefd32015-02-02 15:53:37 -080085 url(r'xos/slices/$', SliceList.as_view(), name='slice-list'),
86 url(r'xos/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080087
Scott Baker1faefd32015-02-02 15:53:37 -080088 url(r'xos/networks/$', NetworkList.as_view(), name='network-list'),
89 url(r'xos/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080090
Scott Baker1faefd32015-02-02 15:53:37 -080091 url(r'xos/services/$', ServiceList.as_view(), name='service-list'),
92 url(r'xos/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080093
Scott Baker1faefd32015-02-02 15:53:37 -080094 url(r'xos/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
95 url(r'xos/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080096
Scott Baker1faefd32015-02-02 15:53:37 -080097 url(r'xos/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
98 url(r'xos/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -080099
Scott Baker1faefd32015-02-02 15:53:37 -0800100 url(r'xos/charges/$', ChargeList.as_view(), name='charge-list'),
101 url(r'xos/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800102
Scott Baker1faefd32015-02-02 15:53:37 -0800103 url(r'xos/roles/$', RoleList.as_view(), name='role-list'),
104 url(r'xos/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800105
Scott Baker1faefd32015-02-02 15:53:37 -0800106 url(r'xos/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
107 url(r'xos/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800108
Scott Baker1faefd32015-02-02 15:53:37 -0800109 url(r'xos/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
110 url(r'xos/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800111
Scott Baker1faefd32015-02-02 15:53:37 -0800112 url(r'xos/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
113 url(r'xos/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800114
Scott Baker1faefd32015-02-02 15:53:37 -0800115 url(r'xos/slivers/$', SliverList.as_view(), name='sliver-list'),
116 url(r'xos/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800117
Scott Baker1faefd32015-02-02 15:53:37 -0800118 url(r'xos/nodes/$', NodeList.as_view(), name='node-list'),
119 url(r'xos/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800120
Scott Baker1faefd32015-02-02 15:53:37 -0800121 url(r'xos/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
122 url(r'xos/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800123
Scott Baker1faefd32015-02-02 15:53:37 -0800124 url(r'xos/controllernetworks/$', ControllerNetworkList.as_view(), name='controllernetwork-list'),
125 url(r'xos/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworkDetail.as_view(), name ='controllernetwork-detail'),
Scott Baker191f9b22015-01-12 13:16:39 -0800126
Scott Baker1faefd32015-02-02 15:53:37 -0800127 url(r'xos/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
128 url(r'xos/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
Scott Bakerb744f1c2014-11-21 11:32:24 -0800129
Scott Baker1faefd32015-02-02 15:53:37 -0800130 url(r'xos/controllerusers/$', ControllerUserList.as_view(), name='controlleruser-list'),
131 url(r'xos/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUserDetail.as_view(), name ='controlleruser-detail'),
Scott Baker191f9b22015-01-12 13:16:39 -0800132
Scott Baker1faefd32015-02-02 15:53:37 -0800133 url(r'xos/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
134 url(r'xos/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800135
Scott Baker1faefd32015-02-02 15:53:37 -0800136 url(r'xos/payments/$', PaymentList.as_view(), name='payment-list'),
137 url(r'xos/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800138
Scott Baker1faefd32015-02-02 15:53:37 -0800139 url(r'xos/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
140 url(r'xos/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800141
Scott Baker1faefd32015-02-02 15:53:37 -0800142 url(r'xos/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
143 url(r'xos/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800144
Scott Baker1faefd32015-02-02 15:53:37 -0800145 url(r'xos/controllers/$', ControllerList.as_view(), name='controller-list'),
146 url(r'xos/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800147
Scott Baker1faefd32015-02-02 15:53:37 -0800148 url(r'xos/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
149 url(r'xos/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800150
Scott Baker1faefd32015-02-02 15:53:37 -0800151 url(r'xos/users/$', UserList.as_view(), name='user-list'),
152 url(r'xos/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800153
Scott Baker1faefd32015-02-02 15:53:37 -0800154 url(r'xos/deployments/$', DeploymentList.as_view(), name='deployment-list'),
155 url(r'xos/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800156
Scott Baker1faefd32015-02-02 15:53:37 -0800157 url(r'xos/reservations/$', ReservationList.as_view(), name='reservation-list'),
158 url(r'xos/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800159
Scott Baker1faefd32015-02-02 15:53:37 -0800160 url(r'xos/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
161 url(r'xos/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800162
Scott Baker1faefd32015-02-02 15:53:37 -0800163 url(r'xos/controllerslices/$', ControllerSliceList.as_view(), name='controllerslice-list'),
164 url(r'xos/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSliceDetail.as_view(), name ='controllerslice-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800165
Scott Baker1faefd32015-02-02 15:53:37 -0800166 url(r'xos/controllerdashboardviews/$', ControllerDashboardViewList.as_view(), name='controllerdashboardview-list'),
167 url(r'xos/controllerdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardViewDetail.as_view(), name ='controllerdashboardview-detail'),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800168
Scott Baker1faefd32015-02-02 15:53:37 -0800169 url(r'xos/accounts/$', AccountList.as_view(), name='account-list'),
170 url(r'xos/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800171
Scott Baker1faefd32015-02-02 15:53:37 -0800172 url(r'xos/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'),
173 url(r'xos/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800174
Scott Baker1faefd32015-02-02 15:53:37 -0800175 url(r'xos/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
176 url(r'xos/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800177
Scott Baker1faefd32015-02-02 15:53:37 -0800178 url(r'xos/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
179 url(r'xos/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800180
Scott Baker1faefd32015-02-02 15:53:37 -0800181 url(r'xos/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
182 url(r'xos/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800183
Scott Baker1faefd32015-02-02 15:53:37 -0800184 url(r'xos/controllersliceprivileges/$', ControllerSlicePrivilegeList.as_view(), name='controllersliceprivilege-list'),
185 url(r'xos/controllersliceprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicePrivilegeDetail.as_view(), name ='controllersliceprivilege-detail'),
Scott Baker191f9b22015-01-12 13:16:39 -0800186
Scott Baker1faefd32015-02-02 15:53:37 -0800187 url(r'xos/sitedeployments/$', SiteDeploymentList.as_view(), name='sitedeployment-list'),
188 url(r'xos/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentDetail.as_view(), name ='sitedeployment-detail'),
Scott Baker515dc9e2014-12-22 09:29:05 -0800189
Scott Baker1faefd32015-02-02 15:53:37 -0800190 url(r'xos/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
191 url(r'xos/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800192
Scott Baker1faefd32015-02-02 15:53:37 -0800193 url(r'xos/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
194 url(r'xos/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800195
Scott Baker1faefd32015-02-02 15:53:37 -0800196 url(r'xos/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
197 url(r'xos/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800198
Scott Baker1faefd32015-02-02 15:53:37 -0800199 url(r'xos/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
200 url(r'xos/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800201
Scott Baker1faefd32015-02-02 15:53:37 -0800202 url(r'xos/routers/$', RouterList.as_view(), name='router-list'),
203 url(r'xos/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800204
Scott Baker1faefd32015-02-02 15:53:37 -0800205 url(r'xos/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
206 url(r'xos/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
Scott Bakerd51d0bd2014-11-10 16:31:15 -0800207
208 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400209
210@api_view(['GET'])
211def api_root(request, format=None):
212 return Response({
Scott Baker2bcbf372014-10-29 23:41:11 -0700213 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800214 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800215 'controllersiteprivileges': reverse('controllersiteprivilege-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700216 'images': reverse('image-list', request=request, format=format),
217 'networkparameters': reverse('networkparameter-list', request=request, format=format),
218 'sites': reverse('site-list', request=request, format=format),
219 'sliceroles': reverse('slicerole-list', request=request, format=format),
220 'tags': reverse('tag-list', request=request, format=format),
221 'invoices': reverse('invoice-list', request=request, format=format),
222 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
223 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
224 'networkslivers': reverse('networksliver-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800225 'flavors': reverse('flavor-list', request=request, format=format),
226 'controllersites': reverse('controllersite-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700227 'projects': reverse('project-list', request=request, format=format),
228 'slices': reverse('slice-list', request=request, format=format),
229 'networks': reverse('network-list', request=request, format=format),
230 'services': reverse('service-list', request=request, format=format),
231 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800232 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700233 'charges': reverse('charge-list', request=request, format=format),
234 'roles': reverse('role-list', request=request, format=format),
235 'usableobjects': reverse('usableobject-list', request=request, format=format),
236 'siteroles': reverse('siterole-list', request=request, format=format),
237 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
238 'slivers': reverse('sliver-list', request=request, format=format),
239 'nodes': reverse('node-list', request=request, format=format),
240 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800241 'controllernetworks': reverse('controllernetwork-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800242 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800243 'controllerusers': reverse('controlleruser-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700244 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800245 'payments': reverse('payment-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700246 'networkslices': reverse('networkslice-list', request=request, format=format),
247 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800248 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700249 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
250 'users': reverse('user-list', request=request, format=format),
251 'deployments': reverse('deployment-list', request=request, format=format),
252 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700253 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800254 'controllerslices': reverse('controllerslice-list', request=request, format=format),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800255 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700256 'accounts': reverse('account-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800257 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700258 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
259 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800260 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
Scott Baker191f9b22015-01-12 13:16:39 -0800261 'controllersliceprivileges': reverse('controllersliceprivilege-list', request=request, format=format),
262 'sitedeployments': reverse('sitedeployment-list', request=request, format=format),
Scott Baker515dc9e2014-12-22 09:29:05 -0800263 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700264 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700265 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Bakerf2c0c512014-12-22 17:35:34 -0800266 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker2bcbf372014-10-29 23:41:11 -0700267 'routers': reverse('router-list', request=request, format=format),
268 'serviceresources': reverse('serviceresource-list', request=request, format=format),
269
Sapan Bhatiadea39432014-06-13 03:10:36 -0400270 })
271
272# Based on serializers.py
273
Scott Baker515dc9e2014-12-22 09:29:05 -0800274class XOSModelSerializer(serializers.ModelSerializer):
275 def save_object(self, obj, **kwargs):
276
277 """ rest_framework can't deal with ManyToMany relations that have a
Scott Baker1faefd32015-02-02 15:53:37 -0800278 through table. In xos, most of the through tables we have
Scott Baker515dc9e2014-12-22 09:29:05 -0800279 use defaults or blank fields, so there's no reason why we shouldn't
280 be able to save these objects.
281
282 So, let's strip out these m2m relations, and deal with them ourself.
283 """
284 obj._complex_m2m_data={};
285 if getattr(obj, '_m2m_data', None):
286 for relatedObject in obj._meta.get_all_related_many_to_many_objects():
287 if (relatedObject.field.rel.through._meta.auto_created):
288 # These are non-trough ManyToMany relations and
289 # can be updated just fine
290 continue
291 fieldName = relatedObject.get_accessor_name()
292 if fieldName in obj._m2m_data.keys():
293 obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
294 del obj._m2m_data[fieldName]
295
296 serializers.ModelSerializer.save_object(self, obj, **kwargs);
297
298 for (accessor, stuff) in obj._complex_m2m_data.items():
299 (relatedObject, data) = stuff
300 through = relatedObject.field.rel.through
301 local_fieldName = relatedObject.field.m2m_reverse_field_name()
302 remote_fieldName = relatedObject.field.m2m_field_name()
303
304 # get the current set of existing relations
305 existing = through.objects.filter(**{local_fieldName: obj});
306
307 data_ids = [item.id for item in data]
308 existing_ids = [getattr(item,remote_fieldName).id for item in existing]
309
310 #print "data_ids", data_ids
311 #print "existing_ids", existing_ids
312
313 # remove relations that are in 'existing' but not in 'data'
314 for item in list(existing):
315 if (getattr(item,remote_fieldName).id not in data_ids):
316 print "delete", getattr(item,remote_fieldName)
317 item.delete() #(purge=True)
318
319 # add relations that are in 'data' but not in 'existing'
320 for item in data:
321 if (item.id not in existing_ids):
322 #print "add", item
323 newModel = through(**{local_fieldName: obj, remote_fieldName: item})
324 newModel.save()
325
326
327
Scott Baker0caeaf02014-06-19 11:12:55 -0700328class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800329 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700330
Scott Bakerb744f1c2014-11-21 11:32:24 -0800331 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800332 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800333 def getHumanReadableName(self, obj):
334 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800335 def getValidators(self, obj):
336 try:
337 return obj.getValidators()
338 except:
339 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700340 class Meta:
341 model = ServiceAttribute
Scott Baker84cf39e2015-01-30 15:41:39 -0800342 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700343
Scott Baker515dc9e2014-12-22 09:29:05 -0800344class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800345 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700346
Scott Bakerb744f1c2014-11-21 11:32:24 -0800347 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800348 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800349 def getHumanReadableName(self, obj):
350 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800351 def getValidators(self, obj):
352 try:
353 return obj.getValidators()
354 except:
355 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800356 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700357 model = ServiceAttribute
Scott Baker84cf39e2015-01-30 15:41:39 -0800358 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700359
360
Sapan Bhatiadea39432014-06-13 03:10:36 -0400361
362
Scott Baker515dc9e2014-12-22 09:29:05 -0800363class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800364 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800365
366 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
367 validators = serializers.SerializerMethodField("getValidators")
368 def getHumanReadableName(self, obj):
369 return str(obj)
370 def getValidators(self, obj):
371 try:
372 return obj.getValidators()
373 except:
374 return None
375 class Meta:
376 model = ControllerImages
Scott Baker84cf39e2015-01-30 15:41:39 -0800377 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -0800378
379class ControllerImagesIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800380 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -0800381
382 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
383 validators = serializers.SerializerMethodField("getValidators")
384 def getHumanReadableName(self, obj):
385 return str(obj)
386 def getValidators(self, obj):
387 try:
388 return obj.getValidators()
389 except:
390 return None
391 class Meta:
392 model = ControllerImages
Scott Baker84cf39e2015-01-30 15:41:39 -0800393 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -0800394
395
396
397
Scott Baker191f9b22015-01-12 13:16:39 -0800398class ControllerSitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
399 id = IdField()
400
401 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
402 validators = serializers.SerializerMethodField("getValidators")
403 def getHumanReadableName(self, obj):
404 return str(obj)
405 def getValidators(self, obj):
406 try:
407 return obj.getValidators()
408 except:
409 return None
410 class Meta:
411 model = ControllerSitePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -0800412 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',)
Scott Baker191f9b22015-01-12 13:16:39 -0800413
414class ControllerSitePrivilegeIdSerializer(XOSModelSerializer):
415 id = IdField()
416
417 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
418 validators = serializers.SerializerMethodField("getValidators")
419 def getHumanReadableName(self, obj):
420 return str(obj)
421 def getValidators(self, obj):
422 try:
423 return obj.getValidators()
424 except:
425 return None
426 class Meta:
427 model = ControllerSitePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -0800428 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',)
Scott Baker191f9b22015-01-12 13:16:39 -0800429
430
431
432
Sapan Bhatiadea39432014-06-13 03:10:36 -0400433class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800434 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700435
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800436
437 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
438
439
Scott Bakerb744f1c2014-11-21 11:32:24 -0800440 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800441 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800442 def getHumanReadableName(self, obj):
443 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800444 def getValidators(self, obj):
445 try:
446 return obj.getValidators()
447 except:
448 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700449 class Meta:
450 model = Image
Scott Baker84cf39e2015-01-30 15:41:39 -0800451 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700452
Scott Baker515dc9e2014-12-22 09:29:05 -0800453class ImageIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800454 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700455
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800456
Scott Baker201f7da2014-12-23 10:56:06 -0800457 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Bakerbf4ef6d2014-12-22 15:59:33 -0800458
459
Scott Bakerb744f1c2014-11-21 11:32:24 -0800460 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800461 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800462 def getHumanReadableName(self, obj):
463 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800464 def getValidators(self, obj):
465 try:
466 return obj.getValidators()
467 except:
468 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800469 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700470 model = Image
Scott Baker84cf39e2015-01-30 15:41:39 -0800471 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700472
473
Sapan Bhatiadea39432014-06-13 03:10:36 -0400474
475
Scott Baker0caeaf02014-06-19 11:12:55 -0700476class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800477 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700478
Scott Bakerb744f1c2014-11-21 11:32:24 -0800479 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800480 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800481 def getHumanReadableName(self, obj):
482 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800483 def getValidators(self, obj):
484 try:
485 return obj.getValidators()
486 except:
487 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700488 class Meta:
489 model = NetworkParameter
Scott Baker84cf39e2015-01-30 15:41:39 -0800490 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700491
Scott Baker515dc9e2014-12-22 09:29:05 -0800492class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800493 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700494
Scott Bakerb744f1c2014-11-21 11:32:24 -0800495 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800496 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800497 def getHumanReadableName(self, obj):
498 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800499 def getValidators(self, obj):
500 try:
501 return obj.getValidators()
502 except:
503 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800504 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700505 model = NetworkParameter
Scott Baker84cf39e2015-01-30 15:41:39 -0800506 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700507
508
Sapan Bhatiadea39432014-06-13 03:10:36 -0400509
510
511class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800512 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700513
Scott Baker515dc9e2014-12-22 09:29:05 -0800514
515 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
516
517
Scott Bakerb744f1c2014-11-21 11:32:24 -0800518 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800519 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800520 def getHumanReadableName(self, obj):
521 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800522 def getValidators(self, obj):
523 try:
524 return obj.getValidators()
525 except:
526 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700527 class Meta:
528 model = Site
Scott Baker84cf39e2015-01-30 15:41:39 -0800529 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700530
Scott Baker515dc9e2014-12-22 09:29:05 -0800531class SiteIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800532 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700533
Scott Baker515dc9e2014-12-22 09:29:05 -0800534
Scott Baker201f7da2014-12-23 10:56:06 -0800535 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800536
537
Scott Bakerb744f1c2014-11-21 11:32:24 -0800538 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800539 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800540 def getHumanReadableName(self, obj):
541 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800542 def getValidators(self, obj):
543 try:
544 return obj.getValidators()
545 except:
546 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800547 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700548 model = Site
Scott Baker84cf39e2015-01-30 15:41:39 -0800549 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -0700550
551
Sapan Bhatiadea39432014-06-13 03:10:36 -0400552
553
Scott Baker0caeaf02014-06-19 11:12:55 -0700554class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800555 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700556
Scott Bakerb744f1c2014-11-21 11:32:24 -0800557 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800558 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800559 def getHumanReadableName(self, obj):
560 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800561 def getValidators(self, obj):
562 try:
563 return obj.getValidators()
564 except:
565 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700566 class Meta:
567 model = SliceRole
Scott Baker84cf39e2015-01-30 15:41:39 -0800568 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700569
Scott Baker515dc9e2014-12-22 09:29:05 -0800570class SliceRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800571 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700572
Scott Bakerb744f1c2014-11-21 11:32:24 -0800573 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800574 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800575 def getHumanReadableName(self, obj):
576 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800577 def getValidators(self, obj):
578 try:
579 return obj.getValidators()
580 except:
581 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800582 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700583 model = SliceRole
Scott Baker84cf39e2015-01-30 15:41:39 -0800584 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700585
586
Sapan Bhatiadea39432014-06-13 03:10:36 -0400587
588
589class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800590 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700591
Scott Bakerb744f1c2014-11-21 11:32:24 -0800592 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800593 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800594 def getHumanReadableName(self, obj):
595 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800596 def getValidators(self, obj):
597 try:
598 return obj.getValidators()
599 except:
600 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700601 class Meta:
602 model = Tag
Scott Baker84cf39e2015-01-30 15:41:39 -0800603 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700604
Scott Baker515dc9e2014-12-22 09:29:05 -0800605class TagIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800606 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700607
Scott Bakerb744f1c2014-11-21 11:32:24 -0800608 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800609 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800610 def getHumanReadableName(self, obj):
611 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800612 def getValidators(self, obj):
613 try:
614 return obj.getValidators()
615 except:
616 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800617 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700618 model = Tag
Scott Baker84cf39e2015-01-30 15:41:39 -0800619 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700620
621
Sapan Bhatiadea39432014-06-13 03:10:36 -0400622
623
624class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800625 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700626
Scott Bakerb744f1c2014-11-21 11:32:24 -0800627 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800628 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800629 def getHumanReadableName(self, obj):
630 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800631 def getValidators(self, obj):
632 try:
633 return obj.getValidators()
634 except:
635 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700636 class Meta:
637 model = Invoice
Scott Baker84cf39e2015-01-30 15:41:39 -0800638 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700639
Scott Baker515dc9e2014-12-22 09:29:05 -0800640class InvoiceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800641 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700642
Scott Bakerb744f1c2014-11-21 11:32:24 -0800643 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800644 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800645 def getHumanReadableName(self, obj):
646 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800647 def getValidators(self, obj):
648 try:
649 return obj.getValidators()
650 except:
651 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800652 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700653 model = Invoice
Scott Baker84cf39e2015-01-30 15:41:39 -0800654 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700655
656
Sapan Bhatiadea39432014-06-13 03:10:36 -0400657
658
Scott Baker0caeaf02014-06-19 11:12:55 -0700659class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800660 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700661
Scott Bakerb744f1c2014-11-21 11:32:24 -0800662 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800663 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800664 def getHumanReadableName(self, obj):
665 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800666 def getValidators(self, obj):
667 try:
668 return obj.getValidators()
669 except:
670 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700671 class Meta:
672 model = SlicePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -0800673 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700674
Scott Baker515dc9e2014-12-22 09:29:05 -0800675class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800676 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700677
Scott Bakerb744f1c2014-11-21 11:32:24 -0800678 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800679 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800680 def getHumanReadableName(self, obj):
681 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800682 def getValidators(self, obj):
683 try:
684 return obj.getValidators()
685 except:
686 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800687 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700688 model = SlicePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -0800689 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700690
691
Scott Baker0caeaf02014-06-19 11:12:55 -0700692
693
Scott Baker89a7b7c2014-10-07 00:10:17 -0700694class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800695 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700696
Scott Bakerb744f1c2014-11-21 11:32:24 -0800697 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800698 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800699 def getHumanReadableName(self, obj):
700 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800701 def getValidators(self, obj):
702 try:
703 return obj.getValidators()
704 except:
705 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700706 class Meta:
707 model = PlanetStackRole
Scott Baker84cf39e2015-01-30 15:41:39 -0800708 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700709
Scott Baker515dc9e2014-12-22 09:29:05 -0800710class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800711 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700712
Scott Bakerb744f1c2014-11-21 11:32:24 -0800713 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800714 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800715 def getHumanReadableName(self, obj):
716 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800717 def getValidators(self, obj):
718 try:
719 return obj.getValidators()
720 except:
721 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800722 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700723 model = PlanetStackRole
Scott Baker84cf39e2015-01-30 15:41:39 -0800724 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700725
726
727
728
Scott Baker0caeaf02014-06-19 11:12:55 -0700729class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800730 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700731
Scott Bakerb744f1c2014-11-21 11:32:24 -0800732 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800733 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800734 def getHumanReadableName(self, obj):
735 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800736 def getValidators(self, obj):
737 try:
738 return obj.getValidators()
739 except:
740 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700741 class Meta:
742 model = NetworkSliver
Scott Baker84cf39e2015-01-30 15:41:39 -0800743 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700744
Scott Baker515dc9e2014-12-22 09:29:05 -0800745class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800746 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700747
Scott Bakerb744f1c2014-11-21 11:32:24 -0800748 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800749 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800750 def getHumanReadableName(self, obj):
751 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800752 def getValidators(self, obj):
753 try:
754 return obj.getValidators()
755 except:
756 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800757 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700758 model = NetworkSliver
Scott Baker84cf39e2015-01-30 15:41:39 -0800759 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700760
761
Scott Baker0caeaf02014-06-19 11:12:55 -0700762
763
Scott Baker191f9b22015-01-12 13:16:39 -0800764class FlavorSerializer(serializers.HyperlinkedModelSerializer):
765 id = IdField()
766
767
768 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
769
770
771 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
772 validators = serializers.SerializerMethodField("getValidators")
773 def getHumanReadableName(self, obj):
774 return str(obj)
775 def getValidators(self, obj):
776 try:
777 return obj.getValidators()
778 except:
779 return None
780 class Meta:
781 model = Flavor
Scott Baker84cf39e2015-01-30 15:41:39 -0800782 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',)
Scott Baker191f9b22015-01-12 13:16:39 -0800783
784class FlavorIdSerializer(XOSModelSerializer):
785 id = IdField()
786
787
788 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
789
790
791 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
792 validators = serializers.SerializerMethodField("getValidators")
793 def getHumanReadableName(self, obj):
794 return str(obj)
795 def getValidators(self, obj):
796 try:
797 return obj.getValidators()
798 except:
799 return None
800 class Meta:
801 model = Flavor
Scott Baker84cf39e2015-01-30 15:41:39 -0800802 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',)
Scott Baker191f9b22015-01-12 13:16:39 -0800803
804
805
806
807class ControllerSiteSerializer(serializers.HyperlinkedModelSerializer):
808 id = IdField()
809
810 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
811 validators = serializers.SerializerMethodField("getValidators")
812 def getHumanReadableName(self, obj):
813 return str(obj)
814 def getValidators(self, obj):
815 try:
816 return obj.getValidators()
817 except:
818 return None
819 class Meta:
820 model = ControllerSite
Scott Baker84cf39e2015-01-30 15:41:39 -0800821 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Baker191f9b22015-01-12 13:16:39 -0800822
823class ControllerSiteIdSerializer(XOSModelSerializer):
824 id = IdField()
825
826 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
827 validators = serializers.SerializerMethodField("getValidators")
828 def getHumanReadableName(self, obj):
829 return str(obj)
830 def getValidators(self, obj):
831 try:
832 return obj.getValidators()
833 except:
834 return None
835 class Meta:
836 model = ControllerSite
Scott Baker84cf39e2015-01-30 15:41:39 -0800837 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Baker191f9b22015-01-12 13:16:39 -0800838
839
840
841
Scott Baker89a7b7c2014-10-07 00:10:17 -0700842class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800843 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700844
Scott Bakerb744f1c2014-11-21 11:32:24 -0800845 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800846 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800847 def getHumanReadableName(self, obj):
848 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800849 def getValidators(self, obj):
850 try:
851 return obj.getValidators()
852 except:
853 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700854 class Meta:
855 model = Project
Scott Baker84cf39e2015-01-30 15:41:39 -0800856 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700857
Scott Baker515dc9e2014-12-22 09:29:05 -0800858class ProjectIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800859 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700860
Scott Bakerb744f1c2014-11-21 11:32:24 -0800861 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800862 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800863 def getHumanReadableName(self, obj):
864 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800865 def getValidators(self, obj):
866 try:
867 return obj.getValidators()
868 except:
869 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800870 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700871 model = Project
Scott Baker84cf39e2015-01-30 15:41:39 -0800872 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -0700873
874
875
876
Sapan Bhatiadea39432014-06-13 03:10:36 -0400877class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800878 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700879
880
881 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
882
883
884
Scott Baker2bcbf372014-10-29 23:41:11 -0700885 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
886
887
Scott Bakerb744f1c2014-11-21 11:32:24 -0800888 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800889 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800890 def getHumanReadableName(self, obj):
891 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800892 def getValidators(self, obj):
893 try:
894 return obj.getValidators()
895 except:
896 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700897 class Meta:
898 model = Slice
Scott Baker84cf39e2015-01-30 15:41:39 -0800899 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700900
Scott Baker515dc9e2014-12-22 09:29:05 -0800901class SliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800902 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700903
904
Scott Baker201f7da2014-12-23 10:56:06 -0800905 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700906
907
908
Scott Baker201f7da2014-12-23 10:56:06 -0800909 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700910
911
Scott Bakerb744f1c2014-11-21 11:32:24 -0800912 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800913 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800914 def getHumanReadableName(self, obj):
915 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800916 def getValidators(self, obj):
917 try:
918 return obj.getValidators()
919 except:
920 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800921 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700922 model = Slice
Scott Baker84cf39e2015-01-30 15:41:39 -0800923 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700924
925
Sapan Bhatiadea39432014-06-13 03:10:36 -0400926
927
928class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800929 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700930
931
Scott Baker515dc9e2014-12-22 09:29:05 -0800932 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700933
934
935
Scott Baker515dc9e2014-12-22 09:29:05 -0800936 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
937
938
939
940 slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail')
Scott Baker2bcbf372014-10-29 23:41:11 -0700941
942
943
944 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
945
946
947
948 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
949
950
Scott Bakerb744f1c2014-11-21 11:32:24 -0800951 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800952 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800953 def getHumanReadableName(self, obj):
954 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800955 def getValidators(self, obj):
956 try:
957 return obj.getValidators()
958 except:
959 return None
Scott Baker2bcbf372014-10-29 23:41:11 -0700960 class Meta:
961 model = Network
Scott Baker84cf39e2015-01-30 15:41:39 -0800962 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700963
Scott Baker515dc9e2014-12-22 09:29:05 -0800964class NetworkIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -0800965 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -0700966
967
Scott Baker201f7da2014-12-23 10:56:06 -0800968 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700969
970
971
Scott Baker201f7da2014-12-23 10:56:06 -0800972 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700973
974
975
Scott Baker201f7da2014-12-23 10:56:06 -0800976 slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700977
978
979
Scott Baker201f7da2014-12-23 10:56:06 -0800980 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -0800981
982
983
Scott Baker201f7da2014-12-23 10:56:06 -0800984 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -0700985
986
Scott Bakerb744f1c2014-11-21 11:32:24 -0800987 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -0800988 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -0800989 def getHumanReadableName(self, obj):
990 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -0800991 def getValidators(self, obj):
992 try:
993 return obj.getValidators()
994 except:
995 return None
Scott Baker515dc9e2014-12-22 09:29:05 -0800996 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -0700997 model = Network
Scott Baker84cf39e2015-01-30 15:41:39 -0800998 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700999
1000
Sapan Bhatiadea39432014-06-13 03:10:36 -04001001
1002
1003class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001004 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001005
Scott Bakerb744f1c2014-11-21 11:32:24 -08001006 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001007 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001008 def getHumanReadableName(self, obj):
1009 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001010 def getValidators(self, obj):
1011 try:
1012 return obj.getValidators()
1013 except:
1014 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001015 class Meta:
1016 model = Service
Scott Baker84cf39e2015-01-30 15:41:39 -08001017 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -07001018
Scott Baker515dc9e2014-12-22 09:29:05 -08001019class ServiceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001020 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001021
Scott Bakerb744f1c2014-11-21 11:32:24 -08001022 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001023 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001024 def getHumanReadableName(self, obj):
1025 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001026 def getValidators(self, obj):
1027 try:
1028 return obj.getValidators()
1029 except:
1030 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001031 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001032 model = Service
Scott Baker84cf39e2015-01-30 15:41:39 -08001033 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -07001034
1035
Sapan Bhatiadea39432014-06-13 03:10:36 -04001036
1037
Scott Baker0caeaf02014-06-19 11:12:55 -07001038class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001039 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001040
Scott Bakerb744f1c2014-11-21 11:32:24 -08001041 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001042 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001043 def getHumanReadableName(self, obj):
1044 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001045 def getValidators(self, obj):
1046 try:
1047 return obj.getValidators()
1048 except:
1049 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001050 class Meta:
1051 model = ServiceClass
Scott Baker84cf39e2015-01-30 15:41:39 -08001052 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001053
Scott Baker515dc9e2014-12-22 09:29:05 -08001054class ServiceClassIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001055 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001056
Scott Bakerb744f1c2014-11-21 11:32:24 -08001057 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001058 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001059 def getHumanReadableName(self, obj):
1060 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001061 def getValidators(self, obj):
1062 try:
1063 return obj.getValidators()
1064 except:
1065 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001066 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001067 model = ServiceClass
Scott Baker84cf39e2015-01-30 15:41:39 -08001068 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -07001069
1070
Sapan Bhatiadea39432014-06-13 03:10:36 -04001071
1072
Scott Baker191f9b22015-01-12 13:16:39 -08001073class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001074 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001075
Scott Bakerb744f1c2014-11-21 11:32:24 -08001076 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001077 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001078 def getHumanReadableName(self, obj):
1079 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001080 def getValidators(self, obj):
1081 try:
1082 return obj.getValidators()
1083 except:
1084 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001085 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08001086 model = PlanetStack
Scott Baker84cf39e2015-01-30 15:41:39 -08001087 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001088
Scott Baker191f9b22015-01-12 13:16:39 -08001089class PlanetStackIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001090 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001091
Scott Bakerb744f1c2014-11-21 11:32:24 -08001092 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001093 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001094 def getHumanReadableName(self, obj):
1095 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001096 def getValidators(self, obj):
1097 try:
1098 return obj.getValidators()
1099 except:
1100 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001101 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08001102 model = PlanetStack
Scott Baker84cf39e2015-01-30 15:41:39 -08001103 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001104
1105
Sapan Bhatiadea39432014-06-13 03:10:36 -04001106
1107
1108class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001109 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001110
Scott Bakerb744f1c2014-11-21 11:32:24 -08001111 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001112 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001113 def getHumanReadableName(self, obj):
1114 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001115 def getValidators(self, obj):
1116 try:
1117 return obj.getValidators()
1118 except:
1119 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001120 class Meta:
1121 model = Charge
Scott Baker84cf39e2015-01-30 15:41:39 -08001122 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -07001123
Scott Baker515dc9e2014-12-22 09:29:05 -08001124class ChargeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001125 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001126
Scott Bakerb744f1c2014-11-21 11:32:24 -08001127 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001128 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001129 def getHumanReadableName(self, obj):
1130 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001131 def getValidators(self, obj):
1132 try:
1133 return obj.getValidators()
1134 except:
1135 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001136 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001137 model = Charge
Scott Baker84cf39e2015-01-30 15:41:39 -08001138 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -07001139
1140
Sapan Bhatiadea39432014-06-13 03:10:36 -04001141
1142
1143class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001144 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001145
Scott Bakerb744f1c2014-11-21 11:32:24 -08001146 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001147 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001148 def getHumanReadableName(self, obj):
1149 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001150 def getValidators(self, obj):
1151 try:
1152 return obj.getValidators()
1153 except:
1154 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001155 class Meta:
1156 model = Role
Scott Baker84cf39e2015-01-30 15:41:39 -08001157 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001158
Scott Baker515dc9e2014-12-22 09:29:05 -08001159class RoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001160 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001161
Scott Bakerb744f1c2014-11-21 11:32:24 -08001162 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001163 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001164 def getHumanReadableName(self, obj):
1165 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001166 def getValidators(self, obj):
1167 try:
1168 return obj.getValidators()
1169 except:
1170 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001171 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001172 model = Role
Scott Baker84cf39e2015-01-30 15:41:39 -08001173 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -07001174
1175
Sapan Bhatiadea39432014-06-13 03:10:36 -04001176
1177
Scott Baker0caeaf02014-06-19 11:12:55 -07001178class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001179 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001180
Scott Bakerb744f1c2014-11-21 11:32:24 -08001181 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001182 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001183 def getHumanReadableName(self, obj):
1184 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001185 def getValidators(self, obj):
1186 try:
1187 return obj.getValidators()
1188 except:
1189 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001190 class Meta:
1191 model = UsableObject
Scott Baker84cf39e2015-01-30 15:41:39 -08001192 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001193
Scott Baker515dc9e2014-12-22 09:29:05 -08001194class UsableObjectIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001195 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001196
Scott Bakerb744f1c2014-11-21 11:32:24 -08001197 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001198 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001199 def getHumanReadableName(self, obj):
1200 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001201 def getValidators(self, obj):
1202 try:
1203 return obj.getValidators()
1204 except:
1205 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001206 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001207 model = UsableObject
Scott Baker84cf39e2015-01-30 15:41:39 -08001208 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07001209
Scott Baker191f9b22015-01-12 13:16:39 -08001210
1211
1212
Scott Baker0caeaf02014-06-19 11:12:55 -07001213class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001214 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001215
Scott Bakerb744f1c2014-11-21 11:32:24 -08001216 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001217 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001218 def getHumanReadableName(self, obj):
1219 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001220 def getValidators(self, obj):
1221 try:
1222 return obj.getValidators()
1223 except:
1224 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001225 class Meta:
1226 model = SiteRole
Scott Baker84cf39e2015-01-30 15:41:39 -08001227 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001228
Scott Baker515dc9e2014-12-22 09:29:05 -08001229class SiteRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001230 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001231
Scott Bakerb744f1c2014-11-21 11:32:24 -08001232 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001233 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001234 def getHumanReadableName(self, obj):
1235 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001236 def getValidators(self, obj):
1237 try:
1238 return obj.getValidators()
1239 except:
1240 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001241 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001242 model = SiteRole
Scott Baker84cf39e2015-01-30 15:41:39 -08001243 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001244
1245
Scott Baker0caeaf02014-06-19 11:12:55 -07001246
1247
Scott Baker89a7b7c2014-10-07 00:10:17 -07001248class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001249 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001250
Scott Bakerb744f1c2014-11-21 11:32:24 -08001251 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001252 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001253 def getHumanReadableName(self, obj):
1254 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001255 def getValidators(self, obj):
1256 try:
1257 return obj.getValidators()
1258 except:
1259 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001260 class Meta:
1261 model = SliceCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08001262 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001263
Scott Baker515dc9e2014-12-22 09:29:05 -08001264class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001265 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001266
Scott Bakerb744f1c2014-11-21 11:32:24 -08001267 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001268 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001269 def getHumanReadableName(self, obj):
1270 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001271 def getValidators(self, obj):
1272 try:
1273 return obj.getValidators()
1274 except:
1275 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001276 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001277 model = SliceCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08001278 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07001279
1280
1281
1282
Sapan Bhatiadea39432014-06-13 03:10:36 -04001283class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001284 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001285
1286
1287 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1288
1289
Scott Bakerb744f1c2014-11-21 11:32:24 -08001290 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001291 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001292 def getHumanReadableName(self, obj):
1293 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001294 def getValidators(self, obj):
1295 try:
1296 return obj.getValidators()
1297 except:
1298 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001299 class Meta:
1300 model = Sliver
Scott Baker84cf39e2015-01-30 15:41:39 -08001301 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001302
Scott Baker515dc9e2014-12-22 09:29:05 -08001303class SliverIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001304 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001305
1306
Scott Baker201f7da2014-12-23 10:56:06 -08001307 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -07001308
1309
Scott Bakerb744f1c2014-11-21 11:32:24 -08001310 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001311 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001312 def getHumanReadableName(self, obj):
1313 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001314 def getValidators(self, obj):
1315 try:
1316 return obj.getValidators()
1317 except:
1318 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001319 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001320 model = Sliver
Scott Baker84cf39e2015-01-30 15:41:39 -08001321 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07001322
1323
Sapan Bhatiadea39432014-06-13 03:10:36 -04001324
1325
1326class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001327 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001328
Scott Bakerb744f1c2014-11-21 11:32:24 -08001329 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001330 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001331 def getHumanReadableName(self, obj):
1332 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001333 def getValidators(self, obj):
1334 try:
1335 return obj.getValidators()
1336 except:
1337 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001338 class Meta:
1339 model = Node
Scott Baker84cf39e2015-01-30 15:41:39 -08001340 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001341
Scott Baker515dc9e2014-12-22 09:29:05 -08001342class NodeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001343 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001344
Scott Bakerb744f1c2014-11-21 11:32:24 -08001345 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001346 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001347 def getHumanReadableName(self, obj):
1348 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001349 def getValidators(self, obj):
1350 try:
1351 return obj.getValidators()
1352 except:
1353 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001354 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001355 model = Node
Scott Baker84cf39e2015-01-30 15:41:39 -08001356 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001357
1358
Sapan Bhatiadea39432014-06-13 03:10:36 -04001359
1360
Scott Baker0caeaf02014-06-19 11:12:55 -07001361class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001362 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001363
Scott Baker515dc9e2014-12-22 09:29:05 -08001364
1365 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1366
1367
Scott Bakerb744f1c2014-11-21 11:32:24 -08001368 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001369 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001370 def getHumanReadableName(self, obj):
1371 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001372 def getValidators(self, obj):
1373 try:
1374 return obj.getValidators()
1375 except:
1376 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001377 class Meta:
1378 model = DashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001379 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',)
Scott Baker46b58542014-08-11 17:26:12 -07001380
Scott Baker515dc9e2014-12-22 09:29:05 -08001381class DashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001382 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001383
Scott Baker515dc9e2014-12-22 09:29:05 -08001384
Scott Baker201f7da2014-12-23 10:56:06 -08001385 controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001386
1387
Scott Bakerb744f1c2014-11-21 11:32:24 -08001388 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001389 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001390 def getHumanReadableName(self, obj):
1391 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001392 def getValidators(self, obj):
1393 try:
1394 return obj.getValidators()
1395 except:
1396 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001397 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001398 model = DashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001399 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001400
1401
1402
1403
Scott Baker191f9b22015-01-12 13:16:39 -08001404class ControllerNetworkSerializer(serializers.HyperlinkedModelSerializer):
1405 id = IdField()
1406
1407 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1408 validators = serializers.SerializerMethodField("getValidators")
1409 def getHumanReadableName(self, obj):
1410 return str(obj)
1411 def getValidators(self, obj):
1412 try:
1413 return obj.getValidators()
1414 except:
1415 return None
1416 class Meta:
1417 model = ControllerNetwork
Scott Baker84cf39e2015-01-30 15:41:39 -08001418 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker191f9b22015-01-12 13:16:39 -08001419
1420class ControllerNetworkIdSerializer(XOSModelSerializer):
1421 id = IdField()
1422
1423 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1424 validators = serializers.SerializerMethodField("getValidators")
1425 def getHumanReadableName(self, obj):
1426 return str(obj)
1427 def getValidators(self, obj):
1428 try:
1429 return obj.getValidators()
1430 except:
1431 return None
1432 class Meta:
1433 model = ControllerNetwork
Scott Baker84cf39e2015-01-30 15:41:39 -08001434 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker191f9b22015-01-12 13:16:39 -08001435
1436
1437
1438
Scott Baker515dc9e2014-12-22 09:29:05 -08001439class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001440 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001441
1442 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001443 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001444 def getHumanReadableName(self, obj):
1445 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001446 def getValidators(self, obj):
1447 try:
1448 return obj.getValidators()
1449 except:
1450 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001451 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001452 model = ImageDeployments
Scott Baker84cf39e2015-01-30 15:41:39 -08001453 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001454
Scott Baker515dc9e2014-12-22 09:29:05 -08001455class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001456 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001457
1458 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001459 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001460 def getHumanReadableName(self, obj):
1461 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001462 def getValidators(self, obj):
1463 try:
1464 return obj.getValidators()
1465 except:
1466 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001467 class Meta:
1468 model = ImageDeployments
Scott Baker84cf39e2015-01-30 15:41:39 -08001469 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -07001470
1471
Sapan Bhatiadea39432014-06-13 03:10:36 -04001472
1473
Scott Baker191f9b22015-01-12 13:16:39 -08001474class ControllerUserSerializer(serializers.HyperlinkedModelSerializer):
1475 id = IdField()
1476
1477 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1478 validators = serializers.SerializerMethodField("getValidators")
1479 def getHumanReadableName(self, obj):
1480 return str(obj)
1481 def getValidators(self, obj):
1482 try:
1483 return obj.getValidators()
1484 except:
1485 return None
1486 class Meta:
1487 model = ControllerUser
Scott Baker84cf39e2015-01-30 15:41:39 -08001488 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08001489
1490class ControllerUserIdSerializer(XOSModelSerializer):
1491 id = IdField()
1492
1493 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1494 validators = serializers.SerializerMethodField("getValidators")
1495 def getHumanReadableName(self, obj):
1496 return str(obj)
1497 def getValidators(self, obj):
1498 try:
1499 return obj.getValidators()
1500 except:
1501 return None
1502 class Meta:
1503 model = ControllerUser
Scott Baker84cf39e2015-01-30 15:41:39 -08001504 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08001505
1506
1507
1508
Scott Baker0caeaf02014-06-19 11:12:55 -07001509class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001510 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001511
Scott Bakerb744f1c2014-11-21 11:32:24 -08001512 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001513 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001514 def getHumanReadableName(self, obj):
1515 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001516 def getValidators(self, obj):
1517 try:
1518 return obj.getValidators()
1519 except:
1520 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001521 class Meta:
1522 model = ReservedResource
Scott Baker84cf39e2015-01-30 15:41:39 -08001523 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -07001524
Scott Baker515dc9e2014-12-22 09:29:05 -08001525class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001526 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001527
Scott Bakerb744f1c2014-11-21 11:32:24 -08001528 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001529 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001530 def getHumanReadableName(self, obj):
1531 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001532 def getValidators(self, obj):
1533 try:
1534 return obj.getValidators()
1535 except:
1536 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001537 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001538 model = ReservedResource
Scott Baker84cf39e2015-01-30 15:41:39 -08001539 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker8b533192014-11-17 22:32:19 -08001540
1541
1542
1543
Scott Baker515dc9e2014-12-22 09:29:05 -08001544class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001545 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001546
1547 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1548 validators = serializers.SerializerMethodField("getValidators")
1549 def getHumanReadableName(self, obj):
1550 return str(obj)
1551 def getValidators(self, obj):
1552 try:
1553 return obj.getValidators()
1554 except:
1555 return None
1556 class Meta:
1557 model = Payment
Scott Baker84cf39e2015-01-30 15:41:39 -08001558 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001559
1560class PaymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001561 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001562
1563 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1564 validators = serializers.SerializerMethodField("getValidators")
1565 def getHumanReadableName(self, obj):
1566 return str(obj)
1567 def getValidators(self, obj):
1568 try:
1569 return obj.getValidators()
1570 except:
1571 return None
1572 class Meta:
1573 model = Payment
Scott Baker84cf39e2015-01-30 15:41:39 -08001574 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001575
1576
1577
1578
Scott Baker0caeaf02014-06-19 11:12:55 -07001579class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001580 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001581
Scott Bakerb744f1c2014-11-21 11:32:24 -08001582 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001583 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001584 def getHumanReadableName(self, obj):
1585 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001586 def getValidators(self, obj):
1587 try:
1588 return obj.getValidators()
1589 except:
1590 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001591 class Meta:
1592 model = NetworkSlice
Scott Baker84cf39e2015-01-30 15:41:39 -08001593 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001594
Scott Baker515dc9e2014-12-22 09:29:05 -08001595class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001596 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001597
Scott Bakerb744f1c2014-11-21 11:32:24 -08001598 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001599 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001600 def getHumanReadableName(self, obj):
1601 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001602 def getValidators(self, obj):
1603 try:
1604 return obj.getValidators()
1605 except:
1606 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001607 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001608 model = NetworkSlice
Scott Baker84cf39e2015-01-30 15:41:39 -08001609 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001610
1611
Scott Baker0caeaf02014-06-19 11:12:55 -07001612
1613
1614class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001615 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001616
Scott Bakerb744f1c2014-11-21 11:32:24 -08001617 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001618 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001619 def getHumanReadableName(self, obj):
1620 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001621 def getValidators(self, obj):
1622 try:
1623 return obj.getValidators()
1624 except:
1625 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001626 class Meta:
1627 model = UserDashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001628 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001629
Scott Baker515dc9e2014-12-22 09:29:05 -08001630class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001631 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001632
Scott Bakerb744f1c2014-11-21 11:32:24 -08001633 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001634 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001635 def getHumanReadableName(self, obj):
1636 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001637 def getValidators(self, obj):
1638 try:
1639 return obj.getValidators()
1640 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001641 return None
1642 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001643 model = UserDashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001644 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',)
Scott Baker8b533192014-11-17 22:32:19 -08001645
1646
1647
1648
Scott Baker515dc9e2014-12-22 09:29:05 -08001649class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001650 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001651
Scott Baker515dc9e2014-12-22 09:29:05 -08001652
1653 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1654
1655
Scott Bakerb744f1c2014-11-21 11:32:24 -08001656 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001657 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001658 def getHumanReadableName(self, obj):
Scott Bakerb744f1c2014-11-21 11:32:24 -08001659 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001660 def getValidators(self, obj):
1661 try:
1662 return obj.getValidators()
1663 except:
1664 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001665 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08001666 model = Controller
Scott Baker84cf39e2015-01-30 15:41:39 -08001667 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
Scott Baker46b58542014-08-11 17:26:12 -07001668
Scott Baker515dc9e2014-12-22 09:29:05 -08001669class ControllerIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001670 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001671
1672
Scott Baker201f7da2014-12-23 10:56:06 -08001673 dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all())
Scott Baker2bcbf372014-10-29 23:41:11 -07001674
1675
Scott Bakerb744f1c2014-11-21 11:32:24 -08001676 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001677 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001678 def getHumanReadableName(self, obj):
1679 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001680 def getValidators(self, obj):
1681 try:
1682 return obj.getValidators()
1683 except:
1684 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001685 class Meta:
1686 model = Controller
Scott Baker84cf39e2015-01-30 15:41:39 -08001687 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001688
1689
1690
1691
1692class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001693 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001694
1695 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1696 validators = serializers.SerializerMethodField("getValidators")
1697 def getHumanReadableName(self, obj):
1698 return str(obj)
1699 def getValidators(self, obj):
1700 try:
1701 return obj.getValidators()
1702 except:
1703 return None
1704 class Meta:
1705 model = PlanetStackPrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08001706 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001707
1708class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001709 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001710
1711 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1712 validators = serializers.SerializerMethodField("getValidators")
1713 def getHumanReadableName(self, obj):
1714 return str(obj)
1715 def getValidators(self, obj):
1716 try:
1717 return obj.getValidators()
1718 except:
1719 return None
1720 class Meta:
1721 model = PlanetStackPrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08001722 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001723
1724
1725
1726
1727class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001728 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001729
1730 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1731 validators = serializers.SerializerMethodField("getValidators")
1732 def getHumanReadableName(self, obj):
1733 return str(obj)
1734 def getValidators(self, obj):
1735 try:
1736 return obj.getValidators()
1737 except:
1738 return None
1739 class Meta:
1740 model = User
Scott Baker84cf39e2015-01-30 15:41:39 -08001741 fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001742
1743class UserIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001744 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001745
1746 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1747 validators = serializers.SerializerMethodField("getValidators")
1748 def getHumanReadableName(self, obj):
1749 return str(obj)
1750 def getValidators(self, obj):
1751 try:
1752 return obj.getValidators()
1753 except:
1754 return None
1755 class Meta:
1756 model = User
Scott Baker84cf39e2015-01-30 15:41:39 -08001757 fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',)
Scott Baker515dc9e2014-12-22 09:29:05 -08001758
1759
1760
1761
1762class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001763 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001764
1765
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001766 images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1767
1768
1769
Scott Baker515dc9e2014-12-22 09:29:05 -08001770 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1771
1772
Scott Baker191f9b22015-01-12 13:16:39 -08001773
1774 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1775
1776
Scott Baker515dc9e2014-12-22 09:29:05 -08001777 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1778 validators = serializers.SerializerMethodField("getValidators")
1779 def getHumanReadableName(self, obj):
1780 return str(obj)
1781 def getValidators(self, obj):
1782 try:
1783 return obj.getValidators()
1784 except:
1785 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001786 class Meta:
1787 model = Deployment
Scott Baker84cf39e2015-01-30 15:41:39 -08001788 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001789
Scott Baker515dc9e2014-12-22 09:29:05 -08001790class DeploymentIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001791 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001792
1793
Scott Baker201f7da2014-12-23 10:56:06 -08001794 images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all())
Scott Bakerbf4ef6d2014-12-22 15:59:33 -08001795
1796
1797
Scott Baker201f7da2014-12-23 10:56:06 -08001798 sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08001799
1800
Scott Baker191f9b22015-01-12 13:16:39 -08001801
1802 flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all())
1803
1804
Tony Mack06c8e472014-11-30 15:53:08 -05001805 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1806 validators = serializers.SerializerMethodField("getValidators")
Scott Baker515dc9e2014-12-22 09:29:05 -08001807 def getHumanReadableName(self, obj):
1808 return str(obj)
1809 def getValidators(self, obj):
Tony Mack06c8e472014-11-30 15:53:08 -05001810 try:
1811 return obj.getValidators()
1812 except:
Scott Baker515dc9e2014-12-22 09:29:05 -08001813 return None
1814 class Meta:
1815 model = Deployment
Scott Baker84cf39e2015-01-30 15:41:39 -08001816 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',)
Tony Mack06c8e472014-11-30 15:53:08 -05001817
1818
Sapan Bhatiadea39432014-06-13 03:10:36 -04001819
1820
1821class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001822 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001823
Scott Bakerb744f1c2014-11-21 11:32:24 -08001824 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001825 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001826 def getHumanReadableName(self, obj):
1827 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001828 def getValidators(self, obj):
1829 try:
1830 return obj.getValidators()
1831 except:
1832 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001833 class Meta:
1834 model = Reservation
Scott Baker84cf39e2015-01-30 15:41:39 -08001835 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001836
Scott Baker515dc9e2014-12-22 09:29:05 -08001837class ReservationIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001838 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001839
Scott Bakerb744f1c2014-11-21 11:32:24 -08001840 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001841 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001842 def getHumanReadableName(self, obj):
1843 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001844 def getValidators(self, obj):
1845 try:
1846 return obj.getValidators()
1847 except:
1848 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001849 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001850 model = Reservation
Scott Baker84cf39e2015-01-30 15:41:39 -08001851 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001852
1853
Scott Baker0caeaf02014-06-19 11:12:55 -07001854
1855
Scott Bakerb744f1c2014-11-21 11:32:24 -08001856class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001857 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001858
1859 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001860 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001861 def getHumanReadableName(self, obj):
1862 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001863 def getValidators(self, obj):
1864 try:
1865 return obj.getValidators()
1866 except:
1867 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001868 class Meta:
1869 model = SitePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08001870 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001871
Scott Baker515dc9e2014-12-22 09:29:05 -08001872class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001873 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001874
1875 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001876 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001877 def getHumanReadableName(self, obj):
1878 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001879 def getValidators(self, obj):
1880 try:
1881 return obj.getValidators()
1882 except:
1883 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001884 class Meta:
Scott Bakerb744f1c2014-11-21 11:32:24 -08001885 model = SitePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08001886 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001887
1888
1889
1890
Scott Baker191f9b22015-01-12 13:16:39 -08001891class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001892 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001893
1894 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001895 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001896 def getHumanReadableName(self, obj):
1897 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001898 def getValidators(self, obj):
1899 try:
1900 return obj.getValidators()
1901 except:
1902 return None
Scott Bakerb744f1c2014-11-21 11:32:24 -08001903 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08001904 model = ControllerSlice
Scott Baker84cf39e2015-01-30 15:41:39 -08001905 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08001906
Scott Baker191f9b22015-01-12 13:16:39 -08001907class ControllerSliceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001908 id = IdField()
Scott Bakerb744f1c2014-11-21 11:32:24 -08001909
1910 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001911 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001912 def getHumanReadableName(self, obj):
1913 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001914 def getValidators(self, obj):
1915 try:
1916 return obj.getValidators()
1917 except:
1918 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001919 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08001920 model = ControllerSlice
Scott Baker84cf39e2015-01-30 15:41:39 -08001921 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001922
1923
Sapan Bhatiadea39432014-06-13 03:10:36 -04001924
1925
Scott Bakerf2c0c512014-12-22 17:35:34 -08001926class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001927 id = IdField()
Scott Bakerf2c0c512014-12-22 17:35:34 -08001928
1929 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1930 validators = serializers.SerializerMethodField("getValidators")
1931 def getHumanReadableName(self, obj):
1932 return str(obj)
1933 def getValidators(self, obj):
1934 try:
1935 return obj.getValidators()
1936 except:
1937 return None
1938 class Meta:
1939 model = ControllerDashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001940 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakerf2c0c512014-12-22 17:35:34 -08001941
1942class ControllerDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001943 id = IdField()
Scott Bakerf2c0c512014-12-22 17:35:34 -08001944
1945 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1946 validators = serializers.SerializerMethodField("getValidators")
1947 def getHumanReadableName(self, obj):
1948 return str(obj)
1949 def getValidators(self, obj):
1950 try:
1951 return obj.getValidators()
1952 except:
1953 return None
1954 class Meta:
1955 model = ControllerDashboardView
Scott Baker84cf39e2015-01-30 15:41:39 -08001956 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakerf2c0c512014-12-22 17:35:34 -08001957
1958
1959
1960
Sapan Bhatiadea39432014-06-13 03:10:36 -04001961class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001962 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001963
Scott Bakerb744f1c2014-11-21 11:32:24 -08001964 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001965 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001966 def getHumanReadableName(self, obj):
1967 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001968 def getValidators(self, obj):
1969 try:
1970 return obj.getValidators()
1971 except:
1972 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07001973 class Meta:
1974 model = Account
Scott Baker84cf39e2015-01-30 15:41:39 -08001975 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001976
Scott Baker515dc9e2014-12-22 09:29:05 -08001977class AccountIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001978 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07001979
Scott Bakerb744f1c2014-11-21 11:32:24 -08001980 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08001981 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08001982 def getHumanReadableName(self, obj):
1983 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08001984 def getValidators(self, obj):
1985 try:
1986 return obj.getValidators()
1987 except:
1988 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08001989 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07001990 model = Account
Scott Baker84cf39e2015-01-30 15:41:39 -08001991 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001992
1993
Sapan Bhatiadea39432014-06-13 03:10:36 -04001994
1995
Scott Baker515dc9e2014-12-22 09:29:05 -08001996class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08001997 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08001998
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 = ControllerRole
Scott Baker84cf39e2015-01-30 15:41:39 -08002010 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002011
2012class ControllerRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002013 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002014
2015 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2016 validators = serializers.SerializerMethodField("getValidators")
2017 def getHumanReadableName(self, obj):
2018 return str(obj)
2019 def getValidators(self, obj):
2020 try:
2021 return obj.getValidators()
2022 except:
2023 return None
2024 class Meta:
2025 model = ControllerRole
Scott Baker84cf39e2015-01-30 15:41:39 -08002026 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002027
2028
2029
2030
Scott Baker0caeaf02014-06-19 11:12:55 -07002031class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002032 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002033
Scott Bakerb744f1c2014-11-21 11:32:24 -08002034 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002035 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002036 def getHumanReadableName(self, obj):
2037 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002038 def getValidators(self, obj):
2039 try:
2040 return obj.getValidators()
2041 except:
2042 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002043 class Meta:
2044 model = NetworkParameterType
Scott Baker84cf39e2015-01-30 15:41:39 -08002045 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07002046
Scott Baker515dc9e2014-12-22 09:29:05 -08002047class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002048 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002049
Scott Bakerb744f1c2014-11-21 11:32:24 -08002050 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002051 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002052 def getHumanReadableName(self, obj):
2053 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002054 def getValidators(self, obj):
2055 try:
2056 return obj.getValidators()
2057 except:
2058 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002059 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002060 model = NetworkParameterType
Scott Baker84cf39e2015-01-30 15:41:39 -08002061 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07002062
2063
Sapan Bhatiadea39432014-06-13 03:10:36 -04002064
2065
Scott Baker89a7b7c2014-10-07 00:10:17 -07002066class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002067 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002068
Scott Bakerb744f1c2014-11-21 11:32:24 -08002069 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002070 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002071 def getHumanReadableName(self, obj):
2072 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002073 def getValidators(self, obj):
2074 try:
2075 return obj.getValidators()
2076 except:
2077 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002078 class Meta:
2079 model = SiteCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08002080 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002081
Scott Baker515dc9e2014-12-22 09:29:05 -08002082class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002083 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002084
Scott Bakerb744f1c2014-11-21 11:32:24 -08002085 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002086 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002087 def getHumanReadableName(self, obj):
2088 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002089 def getValidators(self, obj):
2090 try:
2091 return obj.getValidators()
2092 except:
2093 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002094 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002095 model = SiteCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08002096 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002097
2098
Scott Baker0caeaf02014-06-19 11:12:55 -07002099
2100
Scott Baker515dc9e2014-12-22 09:29:05 -08002101class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002102 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002103
Scott Bakerb744f1c2014-11-21 11:32:24 -08002104 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002105 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002106 def getHumanReadableName(self, obj):
2107 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002108 def getValidators(self, obj):
2109 try:
2110 return obj.getValidators()
2111 except:
2112 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002113 class Meta:
Scott Baker515dc9e2014-12-22 09:29:05 -08002114 model = DeploymentPrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08002115 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002116
Scott Baker515dc9e2014-12-22 09:29:05 -08002117class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002118 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002119
Scott Bakerb744f1c2014-11-21 11:32:24 -08002120 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002121 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002122 def getHumanReadableName(self, obj):
2123 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002124 def getValidators(self, obj):
2125 try:
2126 return obj.getValidators()
2127 except:
2128 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002129 class Meta:
2130 model = DeploymentPrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08002131 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',)
Scott Baker8b533192014-11-17 22:32:19 -08002132
2133
2134
2135
Scott Baker191f9b22015-01-12 13:16:39 -08002136class ControllerSlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002137 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002138
Scott Bakerb744f1c2014-11-21 11:32:24 -08002139 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002140 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002141 def getHumanReadableName(self, obj):
2142 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002143 def getValidators(self, obj):
2144 try:
2145 return obj.getValidators()
2146 except:
2147 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002148 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08002149 model = ControllerSlicePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08002150 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002151
Scott Baker191f9b22015-01-12 13:16:39 -08002152class ControllerSlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002153 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002154
2155 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2156 validators = serializers.SerializerMethodField("getValidators")
2157 def getHumanReadableName(self, obj):
2158 return str(obj)
2159 def getValidators(self, obj):
2160 try:
2161 return obj.getValidators()
2162 except:
2163 return None
2164 class Meta:
Scott Baker191f9b22015-01-12 13:16:39 -08002165 model = ControllerSlicePrivilege
Scott Baker84cf39e2015-01-30 15:41:39 -08002166 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08002167
2168
2169
2170
2171class SiteDeploymentSerializer(serializers.HyperlinkedModelSerializer):
2172 id = IdField()
2173
2174 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2175 validators = serializers.SerializerMethodField("getValidators")
2176 def getHumanReadableName(self, obj):
2177 return str(obj)
2178 def getValidators(self, obj):
2179 try:
2180 return obj.getValidators()
2181 except:
2182 return None
2183 class Meta:
2184 model = SiteDeployment
Scott Baker84cf39e2015-01-30 15:41:39 -08002185 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker191f9b22015-01-12 13:16:39 -08002186
2187class SiteDeploymentIdSerializer(XOSModelSerializer):
2188 id = IdField()
2189
2190 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2191 validators = serializers.SerializerMethodField("getValidators")
2192 def getHumanReadableName(self, obj):
2193 return str(obj)
2194 def getValidators(self, obj):
2195 try:
2196 return obj.getValidators()
2197 except:
2198 return None
2199 class Meta:
2200 model = SiteDeployment
Scott Baker84cf39e2015-01-30 15:41:39 -08002201 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002202
2203
2204
2205
2206class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002207 id = IdField()
Scott Baker515dc9e2014-12-22 09:29:05 -08002208
2209 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
2210 validators = serializers.SerializerMethodField("getValidators")
2211 def getHumanReadableName(self, obj):
2212 return str(obj)
2213 def getValidators(self, obj):
2214 try:
2215 return obj.getValidators()
2216 except:
2217 return None
2218 class Meta:
2219 model = DeploymentRole
Scott Baker84cf39e2015-01-30 15:41:39 -08002220 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002221
Scott Baker515dc9e2014-12-22 09:29:05 -08002222class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002223 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002224
Scott Bakerb744f1c2014-11-21 11:32:24 -08002225 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002226 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002227 def getHumanReadableName(self, obj):
2228 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002229 def getValidators(self, obj):
2230 try:
2231 return obj.getValidators()
2232 except:
2233 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002234 class Meta:
2235 model = DeploymentRole
Scott Baker84cf39e2015-01-30 15:41:39 -08002236 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002237
2238
Sapan Bhatiadea39432014-06-13 03:10:36 -04002239
2240
Scott Baker89a7b7c2014-10-07 00:10:17 -07002241class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002242 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002243
Scott Bakerb744f1c2014-11-21 11:32:24 -08002244 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002245 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002246 def getHumanReadableName(self, obj):
2247 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002248 def getValidators(self, obj):
2249 try:
2250 return obj.getValidators()
2251 except:
2252 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002253 class Meta:
2254 model = UserCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08002255 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07002256
Scott Baker515dc9e2014-12-22 09:29:05 -08002257class UserCredentialIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002258 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002259
Scott Bakerb744f1c2014-11-21 11:32:24 -08002260 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002261 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002262 def getHumanReadableName(self, obj):
2263 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002264 def getValidators(self, obj):
2265 try:
2266 return obj.getValidators()
2267 except:
2268 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002269 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002270 model = UserCredential
Scott Baker84cf39e2015-01-30 15:41:39 -08002271 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08002272
2273
2274
2275
Scott Baker0caeaf02014-06-19 11:12:55 -07002276class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002277 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002278
Scott Bakerb744f1c2014-11-21 11:32:24 -08002279 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002280 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002281 def getHumanReadableName(self, obj):
2282 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002283 def getValidators(self, obj):
2284 try:
2285 return obj.getValidators()
2286 except:
2287 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002288 class Meta:
2289 model = SliceTag
Scott Baker84cf39e2015-01-30 15:41:39 -08002290 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002291
Scott Baker515dc9e2014-12-22 09:29:05 -08002292class SliceTagIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002293 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002294
Scott Bakerb744f1c2014-11-21 11:32:24 -08002295 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002296 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002297 def getHumanReadableName(self, obj):
2298 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002299 def getValidators(self, obj):
2300 try:
2301 return obj.getValidators()
2302 except:
2303 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002304 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002305 model = SliceTag
Scott Baker84cf39e2015-01-30 15:41:39 -08002306 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07002307
2308
Scott Baker0caeaf02014-06-19 11:12:55 -07002309
2310
Scott Bakerf2c0c512014-12-22 17:35:34 -08002311class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002312 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002313
Scott Bakerb744f1c2014-11-21 11:32:24 -08002314 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002315 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002316 def getHumanReadableName(self, obj):
2317 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002318 def getValidators(self, obj):
2319 try:
2320 return obj.getValidators()
2321 except:
2322 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002323 class Meta:
Scott Bakerf2c0c512014-12-22 17:35:34 -08002324 model = NetworkTemplate
Scott Baker84cf39e2015-01-30 15:41:39 -08002325 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07002326
Scott Bakerf2c0c512014-12-22 17:35:34 -08002327class NetworkTemplateIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002328 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002329
Scott Bakerb744f1c2014-11-21 11:32:24 -08002330 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002331 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002332 def getHumanReadableName(self, obj):
2333 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002334 def getValidators(self, obj):
2335 try:
2336 return obj.getValidators()
2337 except:
2338 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002339 class Meta:
Scott Bakerf2c0c512014-12-22 17:35:34 -08002340 model = NetworkTemplate
Scott Baker84cf39e2015-01-30 15:41:39 -08002341 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07002342
2343
Sapan Bhatiadea39432014-06-13 03:10:36 -04002344
2345
2346class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002347 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002348
Scott Baker515dc9e2014-12-22 09:29:05 -08002349
2350 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2351
2352
2353
2354 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
2355
2356
Scott Bakerb744f1c2014-11-21 11:32:24 -08002357 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002358 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002359 def getHumanReadableName(self, obj):
2360 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002361 def getValidators(self, obj):
2362 try:
2363 return obj.getValidators()
2364 except:
2365 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002366 class Meta:
2367 model = Router
Scott Baker84cf39e2015-01-30 15:41:39 -08002368 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002369
Scott Baker515dc9e2014-12-22 09:29:05 -08002370class RouterIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002371 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002372
Scott Baker515dc9e2014-12-22 09:29:05 -08002373
Scott Baker201f7da2014-12-23 10:56:06 -08002374 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08002375
2376
2377
Scott Baker201f7da2014-12-23 10:56:06 -08002378 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker515dc9e2014-12-22 09:29:05 -08002379
2380
Scott Bakerb744f1c2014-11-21 11:32:24 -08002381 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002382 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002383 def getHumanReadableName(self, obj):
2384 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002385 def getValidators(self, obj):
2386 try:
2387 return obj.getValidators()
2388 except:
2389 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002390 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002391 model = Router
Scott Baker84cf39e2015-01-30 15:41:39 -08002392 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07002393
2394
Sapan Bhatiadea39432014-06-13 03:10:36 -04002395
2396
Scott Baker0caeaf02014-06-19 11:12:55 -07002397class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002398 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002399
Scott Bakerb744f1c2014-11-21 11:32:24 -08002400 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002401 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002402 def getHumanReadableName(self, obj):
2403 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002404 def getValidators(self, obj):
2405 try:
2406 return obj.getValidators()
2407 except:
2408 return None
Scott Baker2bcbf372014-10-29 23:41:11 -07002409 class Meta:
2410 model = ServiceResource
Scott Baker84cf39e2015-01-30 15:41:39 -08002411 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002412
Scott Baker515dc9e2014-12-22 09:29:05 -08002413class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Bakerf0480fb2014-12-23 11:12:07 -08002414 id = IdField()
Scott Baker2bcbf372014-10-29 23:41:11 -07002415
Scott Bakerb744f1c2014-11-21 11:32:24 -08002416 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker96eb3fd2014-11-25 00:53:25 -08002417 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerb744f1c2014-11-21 11:32:24 -08002418 def getHumanReadableName(self, obj):
2419 return str(obj)
Scott Baker96eb3fd2014-11-25 00:53:25 -08002420 def getValidators(self, obj):
2421 try:
2422 return obj.getValidators()
2423 except:
2424 return None
Scott Baker515dc9e2014-12-22 09:29:05 -08002425 class Meta:
Scott Baker2bcbf372014-10-29 23:41:11 -07002426 model = ServiceResource
Scott Baker84cf39e2015-01-30 15:41:39 -08002427 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07002428
2429
Sapan Bhatiadea39432014-06-13 03:10:36 -04002430
2431
2432serializerLookUp = {
2433
Scott Baker0caeaf02014-06-19 11:12:55 -07002434 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002435
Scott Baker515dc9e2014-12-22 09:29:05 -08002436 ControllerImages: ControllerImagesSerializer,
2437
Scott Baker191f9b22015-01-12 13:16:39 -08002438 ControllerSitePrivilege: ControllerSitePrivilegeSerializer,
2439
Sapan Bhatiadea39432014-06-13 03:10:36 -04002440 Image: ImageSerializer,
2441
Scott Baker0caeaf02014-06-19 11:12:55 -07002442 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002443
2444 Site: SiteSerializer,
2445
Scott Baker0caeaf02014-06-19 11:12:55 -07002446 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002447
2448 Tag: TagSerializer,
2449
2450 Invoice: InvoiceSerializer,
2451
Scott Baker0caeaf02014-06-19 11:12:55 -07002452 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002453
Scott Baker89a7b7c2014-10-07 00:10:17 -07002454 PlanetStackRole: PlanetStackRoleSerializer,
2455
Scott Baker0caeaf02014-06-19 11:12:55 -07002456 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002457
Scott Baker191f9b22015-01-12 13:16:39 -08002458 Flavor: FlavorSerializer,
2459
2460 ControllerSite: ControllerSiteSerializer,
2461
Scott Baker89a7b7c2014-10-07 00:10:17 -07002462 Project: ProjectSerializer,
2463
Sapan Bhatiadea39432014-06-13 03:10:36 -04002464 Slice: SliceSerializer,
2465
2466 Network: NetworkSerializer,
2467
2468 Service: ServiceSerializer,
2469
Scott Baker0caeaf02014-06-19 11:12:55 -07002470 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002471
Scott Baker191f9b22015-01-12 13:16:39 -08002472 PlanetStack: PlanetStackSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002473
2474 Charge: ChargeSerializer,
2475
2476 Role: RoleSerializer,
2477
Scott Baker0caeaf02014-06-19 11:12:55 -07002478 UsableObject: UsableObjectSerializer,
2479
2480 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002481
Scott Baker89a7b7c2014-10-07 00:10:17 -07002482 SliceCredential: SliceCredentialSerializer,
2483
Sapan Bhatiadea39432014-06-13 03:10:36 -04002484 Sliver: SliverSerializer,
2485
2486 Node: NodeSerializer,
2487
Scott Baker0caeaf02014-06-19 11:12:55 -07002488 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002489
Scott Baker191f9b22015-01-12 13:16:39 -08002490 ControllerNetwork: ControllerNetworkSerializer,
2491
Scott Baker515dc9e2014-12-22 09:29:05 -08002492 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002493
Scott Baker191f9b22015-01-12 13:16:39 -08002494 ControllerUser: ControllerUserSerializer,
2495
Scott Bakerb744f1c2014-11-21 11:32:24 -08002496 ReservedResource: ReservedResourceSerializer,
Scott Baker8b533192014-11-17 22:32:19 -08002497
Scott Baker515dc9e2014-12-22 09:29:05 -08002498 Payment: PaymentSerializer,
2499
Scott Baker0caeaf02014-06-19 11:12:55 -07002500 NetworkSlice: NetworkSliceSerializer,
2501
2502 UserDashboardView: UserDashboardViewSerializer,
2503
Scott Baker515dc9e2014-12-22 09:29:05 -08002504 Controller: ControllerSerializer,
2505
Scott Baker0caeaf02014-06-19 11:12:55 -07002506 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002507
2508 User: UserSerializer,
2509
2510 Deployment: DeploymentSerializer,
2511
2512 Reservation: ReservationSerializer,
2513
Scott Baker0caeaf02014-06-19 11:12:55 -07002514 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002515
Scott Baker191f9b22015-01-12 13:16:39 -08002516 ControllerSlice: ControllerSliceSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002517
Scott Bakerf2c0c512014-12-22 17:35:34 -08002518 ControllerDashboardView: ControllerDashboardViewSerializer,
2519
Sapan Bhatiadea39432014-06-13 03:10:36 -04002520 Account: AccountSerializer,
2521
Scott Baker515dc9e2014-12-22 09:29:05 -08002522 ControllerRole: ControllerRoleSerializer,
2523
Scott Baker0caeaf02014-06-19 11:12:55 -07002524 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002525
Scott Baker89a7b7c2014-10-07 00:10:17 -07002526 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002527
Scott Baker515dc9e2014-12-22 09:29:05 -08002528 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002529
Scott Baker191f9b22015-01-12 13:16:39 -08002530 ControllerSlicePrivilege: ControllerSlicePrivilegeSerializer,
2531
2532 SiteDeployment: SiteDeploymentSerializer,
Scott Baker515dc9e2014-12-22 09:29:05 -08002533
2534 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002535
Scott Baker89a7b7c2014-10-07 00:10:17 -07002536 UserCredential: UserCredentialSerializer,
2537
Scott Baker0caeaf02014-06-19 11:12:55 -07002538 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002539
Scott Bakerf2c0c512014-12-22 17:35:34 -08002540 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002541
2542 Router: RouterSerializer,
2543
Scott Baker0caeaf02014-06-19 11:12:55 -07002544 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002545
2546 None: None,
2547 }
2548
Scott Baker89a7b7c2014-10-07 00:10:17 -07002549class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
2550
2551 # To handle fine-grained field permissions, we have to check can_update
2552 # the object has been updated but before it has been saved.
2553
2554 def update(self, request, *args, **kwargs):
2555 partial = kwargs.pop('partial', False)
2556 self.object = self.get_object_or_none()
2557
2558 serializer = self.get_serializer(self.object, data=request.DATA,
2559 files=request.FILES, partial=partial)
2560
2561 if not serializer.is_valid():
Scott Baker96eb3fd2014-11-25 00:53:25 -08002562 response = {"error": "validation",
2563 "specific_error": "not serializer.is_valid()",
2564 "reasons": serializer.errors}
2565 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002566
2567 try:
2568 self.pre_save(serializer.object)
2569 except ValidationError as err:
2570 # full_clean on model instance may be called in pre_save,
2571 # so we have to handle eventual errors.
Scott Baker96eb3fd2014-11-25 00:53:25 -08002572 response = {"error": "validation",
2573 "specific_error": "ValidationError in pre_save",
2574 "reasons": err.message_dict}
2575 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002576
2577 if serializer.object is not None:
2578 if not serializer.object.can_update(request.user):
2579 return Response(status=status.HTTP_400_BAD_REQUEST)
2580
2581 if self.object is None:
2582 self.object = serializer.save(force_insert=True)
2583 self.post_save(self.object, created=True)
2584 return Response(serializer.data, status=status.HTTP_201_CREATED)
2585
2586 self.object = serializer.save(force_update=True)
2587 self.post_save(self.object, created=False)
2588 return Response(serializer.data, status=status.HTTP_200_OK)
2589
2590 def destroy(self, request, *args, **kwargs):
2591 obj = self.get_object()
2592 if obj.can_update(request.user):
Scott Baker15af5652015-02-02 14:33:08 -08002593 return super(PlanetStackRetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002594 else:
2595 return Response(status=status.HTTP_400_BAD_REQUEST)
2596
Scott Baker15af5652015-02-02 14:33:08 -08002597 def handle_exception(self, exc):
2598 # REST API drops the string attached to Django's PermissionDenied
2599 # exception, and replaces it with a generic "Permission Denied"
2600 if isinstance(exc, DjangoPermissionDenied):
2601 response=Response({'detail': str(exc)}, status=status.HTTP_403_FORBIDDEN)
2602 response.exception=True
2603 return response
2604 else:
2605 return super(PlanetStackRetrieveUpdateDestroyAPIView, self).handle_exception(exc)
2606
2607class PlanetStackListCreateAPIView(generics.ListCreateAPIView):
2608 def handle_exception(self, exc):
2609 # REST API drops the string attached to Django's PermissionDenied
2610 # exception, and replaces it with a generic "Permission Denied"
2611 if isinstance(exc, DjangoPermissionDenied):
2612 response=Response({'detail': str(exc)}, status=status.HTTP_403_FORBIDDEN)
2613 response.exception=True
2614 return response
2615 else:
2616 return super(PlanetStackListCreateAPIView, self).handle_exception(exc)
Scott Baker89a7b7c2014-10-07 00:10:17 -07002617
Sapan Bhatiadea39432014-06-13 03:10:36 -04002618# Based on core/views/*.py
2619
2620
Scott Baker15af5652015-02-02 14:33:08 -08002621class ServiceAttributeList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002622 queryset = ServiceAttribute.objects.select_related().all()
2623 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002624 id_serializer_class = ServiceAttributeIdSerializer
2625 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002626 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -07002627
2628 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002629 no_hyperlinks=False
2630 if hasattr(self.request,"QUERY_PARAMS"):
2631 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002632 if (no_hyperlinks):
2633 return self.id_serializer_class
2634 else:
2635 return self.serializer_class
2636
Scott Baker0caeaf02014-06-19 11:12:55 -07002637 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002638 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002639 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002640 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002641
Scott Baker0caeaf02014-06-19 11:12:55 -07002642 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002643 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2644 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002645 response = {"error": "validation",
2646 "specific_error": "not serializer.is_valid()",
2647 "reasons": serializer.errors}
2648 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002649 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002650 obj.caller = request.user
2651 if obj.can_update(request.user):
2652 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
2653 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002654 raise Exception("failed obj.can_update")
2655
2656 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
2657 if (ret.status_code%100 != 200):
2658 raise Exception(ret.data)
2659
2660 return ret
2661
Scott Baker0caeaf02014-06-19 11:12:55 -07002662
Scott Baker89a7b7c2014-10-07 00:10:17 -07002663class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002664 queryset = ServiceAttribute.objects.select_related().all()
2665 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002666 id_serializer_class = ServiceAttributeIdSerializer
2667
2668 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002669 no_hyperlinks=False
2670 if hasattr(self.request,"QUERY_PARAMS"):
2671 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002672 if (no_hyperlinks):
2673 return self.id_serializer_class
2674 else:
2675 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002676
Scott Baker0caeaf02014-06-19 11:12:55 -07002677 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002678 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002679 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002680 return ServiceAttribute.select_by_user(self.request.user)
2681
Scott Baker89a7b7c2014-10-07 00:10:17 -07002682 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002683
Scott Baker89a7b7c2014-10-07 00:10:17 -07002684 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002685
2686
2687
Scott Baker15af5652015-02-02 14:33:08 -08002688class ControllerImagesList(PlanetStackListCreateAPIView):
Scott Baker515dc9e2014-12-22 09:29:05 -08002689 queryset = ControllerImages.objects.select_related().all()
2690 serializer_class = ControllerImagesSerializer
2691 id_serializer_class = ControllerImagesIdSerializer
2692 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002693 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -08002694
2695 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002696 no_hyperlinks=False
2697 if hasattr(self.request,"QUERY_PARAMS"):
2698 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08002699 if (no_hyperlinks):
2700 return self.id_serializer_class
2701 else:
2702 return self.serializer_class
2703
2704 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002705 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002706 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08002707 return ControllerImages.select_by_user(self.request.user)
2708
2709 def create(self, request, *args, **kwargs):
2710 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2711 if not (serializer.is_valid()):
2712 response = {"error": "validation",
2713 "specific_error": "not serializer.is_valid()",
2714 "reasons": serializer.errors}
2715 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2716 obj = serializer.object
2717 obj.caller = request.user
2718 if obj.can_update(request.user):
2719 return super(ControllerImagesList, self).create(request, *args, **kwargs)
2720 else:
2721 raise Exception("failed obj.can_update")
2722
2723 ret = super(ControllerImagesList, self).create(request, *args, **kwargs)
2724 if (ret.status_code%100 != 200):
2725 raise Exception(ret.data)
2726
2727 return ret
2728
2729
2730class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2731 queryset = ControllerImages.objects.select_related().all()
2732 serializer_class = ControllerImagesSerializer
2733 id_serializer_class = ControllerImagesIdSerializer
2734
2735 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002736 no_hyperlinks=False
2737 if hasattr(self.request,"QUERY_PARAMS"):
2738 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08002739 if (no_hyperlinks):
2740 return self.id_serializer_class
2741 else:
2742 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002743
Scott Baker515dc9e2014-12-22 09:29:05 -08002744 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002745 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002746 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08002747 return ControllerImages.select_by_user(self.request.user)
2748
2749 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2750
2751 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2752
2753
2754
Scott Baker15af5652015-02-02 14:33:08 -08002755class ControllerSitePrivilegeList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08002756 queryset = ControllerSitePrivilege.objects.select_related().all()
2757 serializer_class = ControllerSitePrivilegeSerializer
2758 id_serializer_class = ControllerSitePrivilegeIdSerializer
2759 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002760 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08002761
2762 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002763 no_hyperlinks=False
2764 if hasattr(self.request,"QUERY_PARAMS"):
2765 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08002766 if (no_hyperlinks):
2767 return self.id_serializer_class
2768 else:
2769 return self.serializer_class
2770
2771 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002772 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002773 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08002774 return ControllerSitePrivilege.select_by_user(self.request.user)
2775
2776 def create(self, request, *args, **kwargs):
2777 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2778 if not (serializer.is_valid()):
2779 response = {"error": "validation",
2780 "specific_error": "not serializer.is_valid()",
2781 "reasons": serializer.errors}
2782 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2783 obj = serializer.object
2784 obj.caller = request.user
2785 if obj.can_update(request.user):
2786 return super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
2787 else:
2788 raise Exception("failed obj.can_update")
2789
2790 ret = super(ControllerSitePrivilegeList, self).create(request, *args, **kwargs)
2791 if (ret.status_code%100 != 200):
2792 raise Exception(ret.data)
2793
2794 return ret
2795
2796
2797class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2798 queryset = ControllerSitePrivilege.objects.select_related().all()
2799 serializer_class = ControllerSitePrivilegeSerializer
2800 id_serializer_class = ControllerSitePrivilegeIdSerializer
2801
2802 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002803 no_hyperlinks=False
2804 if hasattr(self.request,"QUERY_PARAMS"):
2805 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08002806 if (no_hyperlinks):
2807 return self.id_serializer_class
2808 else:
2809 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002810
Scott Baker191f9b22015-01-12 13:16:39 -08002811 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002812 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002813 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08002814 return ControllerSitePrivilege.select_by_user(self.request.user)
2815
2816 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2817
2818 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2819
2820
2821
Scott Baker15af5652015-02-02 14:33:08 -08002822class ImageList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002823 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002824 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002825 id_serializer_class = ImageIdSerializer
2826 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002827 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','disk_format','container_format','path','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002828
2829 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002830 no_hyperlinks=False
2831 if hasattr(self.request,"QUERY_PARAMS"):
2832 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002833 if (no_hyperlinks):
2834 return self.id_serializer_class
2835 else:
2836 return self.serializer_class
2837
Scott Baker0caeaf02014-06-19 11:12:55 -07002838 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002839 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002840 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002841 return Image.select_by_user(self.request.user)
2842
2843 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002844 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2845 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002846 response = {"error": "validation",
2847 "specific_error": "not serializer.is_valid()",
2848 "reasons": serializer.errors}
2849 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002850 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002851 obj.caller = request.user
2852 if obj.can_update(request.user):
2853 return super(ImageList, self).create(request, *args, **kwargs)
2854 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002855 raise Exception("failed obj.can_update")
2856
2857 ret = super(ImageList, self).create(request, *args, **kwargs)
2858 if (ret.status_code%100 != 200):
2859 raise Exception(ret.data)
2860
2861 return ret
2862
Sapan Bhatiadea39432014-06-13 03:10:36 -04002863
Scott Baker89a7b7c2014-10-07 00:10:17 -07002864class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002865 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002866 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002867 id_serializer_class = ImageIdSerializer
2868
2869 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002870 no_hyperlinks=False
2871 if hasattr(self.request,"QUERY_PARAMS"):
2872 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002873 if (no_hyperlinks):
2874 return self.id_serializer_class
2875 else:
2876 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002877
Scott Baker0caeaf02014-06-19 11:12:55 -07002878 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002879 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002880 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002881 return Image.select_by_user(self.request.user)
2882
Scott Baker89a7b7c2014-10-07 00:10:17 -07002883 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002884
Scott Baker89a7b7c2014-10-07 00:10:17 -07002885 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002886
2887
2888
Scott Baker15af5652015-02-02 14:33:08 -08002889class NetworkParameterList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002890 queryset = NetworkParameter.objects.select_related().all()
2891 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002892 id_serializer_class = NetworkParameterIdSerializer
2893 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002894 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002895
2896 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002897 no_hyperlinks=False
2898 if hasattr(self.request,"QUERY_PARAMS"):
2899 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002900 if (no_hyperlinks):
2901 return self.id_serializer_class
2902 else:
2903 return self.serializer_class
2904
Scott Baker0caeaf02014-06-19 11:12:55 -07002905 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002906 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002907 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002908 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002909
Scott Baker0caeaf02014-06-19 11:12:55 -07002910 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002911 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2912 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002913 response = {"error": "validation",
2914 "specific_error": "not serializer.is_valid()",
2915 "reasons": serializer.errors}
2916 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002917 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002918 obj.caller = request.user
2919 if obj.can_update(request.user):
2920 return super(NetworkParameterList, self).create(request, *args, **kwargs)
2921 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002922 raise Exception("failed obj.can_update")
2923
2924 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
2925 if (ret.status_code%100 != 200):
2926 raise Exception(ret.data)
2927
2928 return ret
2929
Scott Baker0caeaf02014-06-19 11:12:55 -07002930
Scott Baker89a7b7c2014-10-07 00:10:17 -07002931class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002932 queryset = NetworkParameter.objects.select_related().all()
2933 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002934 id_serializer_class = NetworkParameterIdSerializer
2935
2936 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002937 no_hyperlinks=False
2938 if hasattr(self.request,"QUERY_PARAMS"):
2939 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002940 if (no_hyperlinks):
2941 return self.id_serializer_class
2942 else:
2943 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08002944
Scott Baker0caeaf02014-06-19 11:12:55 -07002945 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002946 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002947 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002948 return NetworkParameter.select_by_user(self.request.user)
2949
Scott Baker89a7b7c2014-10-07 00:10:17 -07002950 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002951
Scott Baker89a7b7c2014-10-07 00:10:17 -07002952 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002953
2954
2955
Scott Baker15af5652015-02-02 14:33:08 -08002956class SiteList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002957 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002958 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002959 id_serializer_class = SiteIdSerializer
2960 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08002961 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
Scott Baker46b58542014-08-11 17:26:12 -07002962
2963 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08002964 no_hyperlinks=False
2965 if hasattr(self.request,"QUERY_PARAMS"):
2966 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002967 if (no_hyperlinks):
2968 return self.id_serializer_class
2969 else:
2970 return self.serializer_class
2971
Scott Baker0caeaf02014-06-19 11:12:55 -07002972 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08002973 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08002974 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002975 return Site.select_by_user(self.request.user)
2976
2977 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08002978 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2979 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08002980 response = {"error": "validation",
2981 "specific_error": "not serializer.is_valid()",
2982 "reasons": serializer.errors}
2983 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08002984 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002985 obj.caller = request.user
2986 if obj.can_update(request.user):
2987 return super(SiteList, self).create(request, *args, **kwargs)
2988 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07002989 raise Exception("failed obj.can_update")
2990
2991 ret = super(SiteList, self).create(request, *args, **kwargs)
2992 if (ret.status_code%100 != 200):
2993 raise Exception(ret.data)
2994
2995 return ret
2996
Sapan Bhatiadea39432014-06-13 03:10:36 -04002997
Scott Baker89a7b7c2014-10-07 00:10:17 -07002998class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002999 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003000 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003001 id_serializer_class = SiteIdSerializer
3002
3003 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003004 no_hyperlinks=False
3005 if hasattr(self.request,"QUERY_PARAMS"):
3006 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003007 if (no_hyperlinks):
3008 return self.id_serializer_class
3009 else:
3010 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003011
Scott Baker0caeaf02014-06-19 11:12:55 -07003012 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003013 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003014 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003015 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003016
Scott Baker89a7b7c2014-10-07 00:10:17 -07003017 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003018
Scott Baker89a7b7c2014-10-07 00:10:17 -07003019 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003020
3021
3022
Scott Baker15af5652015-02-02 14:33:08 -08003023class SliceRoleList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003024 queryset = SliceRole.objects.select_related().all()
3025 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003026 id_serializer_class = SliceRoleIdSerializer
3027 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003028 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07003029
3030 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003031 no_hyperlinks=False
3032 if hasattr(self.request,"QUERY_PARAMS"):
3033 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003034 if (no_hyperlinks):
3035 return self.id_serializer_class
3036 else:
3037 return self.serializer_class
3038
Scott Baker0caeaf02014-06-19 11:12:55 -07003039 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003040 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003041 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003042 return SliceRole.select_by_user(self.request.user)
3043
3044 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003045 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3046 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003047 response = {"error": "validation",
3048 "specific_error": "not serializer.is_valid()",
3049 "reasons": serializer.errors}
3050 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003051 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003052 obj.caller = request.user
3053 if obj.can_update(request.user):
3054 return super(SliceRoleList, self).create(request, *args, **kwargs)
3055 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003056 raise Exception("failed obj.can_update")
3057
3058 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
3059 if (ret.status_code%100 != 200):
3060 raise Exception(ret.data)
3061
3062 return ret
3063
Scott Baker0caeaf02014-06-19 11:12:55 -07003064
Scott Baker89a7b7c2014-10-07 00:10:17 -07003065class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003066 queryset = SliceRole.objects.select_related().all()
3067 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003068 id_serializer_class = SliceRoleIdSerializer
3069
3070 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003071 no_hyperlinks=False
3072 if hasattr(self.request,"QUERY_PARAMS"):
3073 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003074 if (no_hyperlinks):
3075 return self.id_serializer_class
3076 else:
3077 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003078
Scott Baker0caeaf02014-06-19 11:12:55 -07003079 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003080 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003081 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003082 return SliceRole.select_by_user(self.request.user)
3083
Scott Baker89a7b7c2014-10-07 00:10:17 -07003084 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003085
Scott Baker89a7b7c2014-10-07 00:10:17 -07003086 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003087
3088
3089
Scott Baker15af5652015-02-02 14:33:08 -08003090class TagList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003091 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003092 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003093 id_serializer_class = TagIdSerializer
3094 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003095 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07003096
3097 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003098 no_hyperlinks=False
3099 if hasattr(self.request,"QUERY_PARAMS"):
3100 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003101 if (no_hyperlinks):
3102 return self.id_serializer_class
3103 else:
3104 return self.serializer_class
3105
Scott Baker0caeaf02014-06-19 11:12:55 -07003106 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003107 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003108 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003109 return Tag.select_by_user(self.request.user)
3110
3111 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003112 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3113 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003114 response = {"error": "validation",
3115 "specific_error": "not serializer.is_valid()",
3116 "reasons": serializer.errors}
3117 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003118 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003119 obj.caller = request.user
3120 if obj.can_update(request.user):
3121 return super(TagList, self).create(request, *args, **kwargs)
3122 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003123 raise Exception("failed obj.can_update")
3124
3125 ret = super(TagList, self).create(request, *args, **kwargs)
3126 if (ret.status_code%100 != 200):
3127 raise Exception(ret.data)
3128
3129 return ret
3130
Sapan Bhatiadea39432014-06-13 03:10:36 -04003131
Scott Baker89a7b7c2014-10-07 00:10:17 -07003132class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003133 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003134 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003135 id_serializer_class = TagIdSerializer
3136
3137 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003138 no_hyperlinks=False
3139 if hasattr(self.request,"QUERY_PARAMS"):
3140 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003141 if (no_hyperlinks):
3142 return self.id_serializer_class
3143 else:
3144 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003145
Scott Baker0caeaf02014-06-19 11:12:55 -07003146 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003147 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003148 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003149 return Tag.select_by_user(self.request.user)
3150
Scott Baker89a7b7c2014-10-07 00:10:17 -07003151 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003152
Scott Baker89a7b7c2014-10-07 00:10:17 -07003153 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003154
3155
3156
Scott Baker15af5652015-02-02 14:33:08 -08003157class InvoiceList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003158 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003159 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003160 id_serializer_class = InvoiceIdSerializer
3161 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003162 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -07003163
3164 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003165 no_hyperlinks=False
3166 if hasattr(self.request,"QUERY_PARAMS"):
3167 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003168 if (no_hyperlinks):
3169 return self.id_serializer_class
3170 else:
3171 return self.serializer_class
3172
Scott Baker0caeaf02014-06-19 11:12:55 -07003173 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003174 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003175 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003176 return Invoice.select_by_user(self.request.user)
3177
3178 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003179 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3180 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003181 response = {"error": "validation",
3182 "specific_error": "not serializer.is_valid()",
3183 "reasons": serializer.errors}
3184 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003185 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003186 obj.caller = request.user
3187 if obj.can_update(request.user):
3188 return super(InvoiceList, self).create(request, *args, **kwargs)
3189 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003190 raise Exception("failed obj.can_update")
3191
3192 ret = super(InvoiceList, self).create(request, *args, **kwargs)
3193 if (ret.status_code%100 != 200):
3194 raise Exception(ret.data)
3195
3196 return ret
3197
Sapan Bhatiadea39432014-06-13 03:10:36 -04003198
Scott Baker89a7b7c2014-10-07 00:10:17 -07003199class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003200 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003201 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003202 id_serializer_class = InvoiceIdSerializer
3203
3204 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003205 no_hyperlinks=False
3206 if hasattr(self.request,"QUERY_PARAMS"):
3207 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003208 if (no_hyperlinks):
3209 return self.id_serializer_class
3210 else:
3211 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003212
Scott Baker0caeaf02014-06-19 11:12:55 -07003213 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003214 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003215 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003216 return Invoice.select_by_user(self.request.user)
3217
Scott Baker89a7b7c2014-10-07 00:10:17 -07003218 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003219
Scott Baker89a7b7c2014-10-07 00:10:17 -07003220 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003221
3222
3223
Scott Baker15af5652015-02-02 14:33:08 -08003224class SlicePrivilegeList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003225 queryset = SlicePrivilege.objects.select_related().all()
3226 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003227 id_serializer_class = SlicePrivilegeIdSerializer
3228 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003229 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -07003230
3231 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003232 no_hyperlinks=False
3233 if hasattr(self.request,"QUERY_PARAMS"):
3234 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003235 if (no_hyperlinks):
3236 return self.id_serializer_class
3237 else:
3238 return self.serializer_class
3239
Scott Baker0caeaf02014-06-19 11:12:55 -07003240 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003241 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003242 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003243 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003244
Scott Baker0caeaf02014-06-19 11:12:55 -07003245 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003246 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3247 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003248 response = {"error": "validation",
3249 "specific_error": "not serializer.is_valid()",
3250 "reasons": serializer.errors}
3251 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003252 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003253 obj.caller = request.user
3254 if obj.can_update(request.user):
3255 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3256 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003257 raise Exception("failed obj.can_update")
3258
3259 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
3260 if (ret.status_code%100 != 200):
3261 raise Exception(ret.data)
3262
3263 return ret
3264
Scott Baker0caeaf02014-06-19 11:12:55 -07003265
Scott Baker89a7b7c2014-10-07 00:10:17 -07003266class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003267 queryset = SlicePrivilege.objects.select_related().all()
3268 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003269 id_serializer_class = SlicePrivilegeIdSerializer
3270
3271 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003272 no_hyperlinks=False
3273 if hasattr(self.request,"QUERY_PARAMS"):
3274 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003275 if (no_hyperlinks):
3276 return self.id_serializer_class
3277 else:
3278 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003279
Scott Baker0caeaf02014-06-19 11:12:55 -07003280 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003281 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003282 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003283 return SlicePrivilege.select_by_user(self.request.user)
3284
Scott Baker89a7b7c2014-10-07 00:10:17 -07003285 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3286
3287 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3288
3289
3290
Scott Baker15af5652015-02-02 14:33:08 -08003291class PlanetStackRoleList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003292 queryset = PlanetStackRole.objects.select_related().all()
3293 serializer_class = PlanetStackRoleSerializer
3294 id_serializer_class = PlanetStackRoleIdSerializer
3295 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003296 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003297
3298 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003299 no_hyperlinks=False
3300 if hasattr(self.request,"QUERY_PARAMS"):
3301 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003302 if (no_hyperlinks):
3303 return self.id_serializer_class
3304 else:
3305 return self.serializer_class
3306
3307 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003308 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003309 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003310 return PlanetStackRole.select_by_user(self.request.user)
3311
3312 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003313 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3314 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003315 response = {"error": "validation",
3316 "specific_error": "not serializer.is_valid()",
3317 "reasons": serializer.errors}
3318 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003319 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003320 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003321 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003322 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003323 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003324 raise Exception("failed obj.can_update")
3325
3326 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
3327 if (ret.status_code%100 != 200):
3328 raise Exception(ret.data)
3329
3330 return ret
3331
Scott Baker0caeaf02014-06-19 11:12:55 -07003332
Scott Baker89a7b7c2014-10-07 00:10:17 -07003333class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3334 queryset = PlanetStackRole.objects.select_related().all()
3335 serializer_class = PlanetStackRoleSerializer
3336 id_serializer_class = PlanetStackRoleIdSerializer
3337
3338 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003339 no_hyperlinks=False
3340 if hasattr(self.request,"QUERY_PARAMS"):
3341 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003342 if (no_hyperlinks):
3343 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003344 else:
Scott Baker89a7b7c2014-10-07 00:10:17 -07003345 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003346
Scott Baker89a7b7c2014-10-07 00:10:17 -07003347 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003348 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003349 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003350 return PlanetStackRole.select_by_user(self.request.user)
3351
3352 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3353
3354 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003355
3356
3357
Scott Baker15af5652015-02-02 14:33:08 -08003358class NetworkSliverList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003359 queryset = NetworkSliver.objects.select_related().all()
3360 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003361 id_serializer_class = NetworkSliverIdSerializer
3362 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003363 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -07003364
3365 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003366 no_hyperlinks=False
3367 if hasattr(self.request,"QUERY_PARAMS"):
3368 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003369 if (no_hyperlinks):
3370 return self.id_serializer_class
3371 else:
3372 return self.serializer_class
3373
Scott Baker0caeaf02014-06-19 11:12:55 -07003374 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003375 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003376 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003377 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003378
Scott Baker0caeaf02014-06-19 11:12:55 -07003379 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003380 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3381 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003382 response = {"error": "validation",
3383 "specific_error": "not serializer.is_valid()",
3384 "reasons": serializer.errors}
3385 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003386 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003387 obj.caller = request.user
3388 if obj.can_update(request.user):
3389 return super(NetworkSliverList, self).create(request, *args, **kwargs)
3390 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003391 raise Exception("failed obj.can_update")
3392
3393 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
3394 if (ret.status_code%100 != 200):
3395 raise Exception(ret.data)
3396
3397 return ret
3398
Scott Baker0caeaf02014-06-19 11:12:55 -07003399
Scott Baker89a7b7c2014-10-07 00:10:17 -07003400class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003401 queryset = NetworkSliver.objects.select_related().all()
3402 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003403 id_serializer_class = NetworkSliverIdSerializer
3404
3405 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003406 no_hyperlinks=False
3407 if hasattr(self.request,"QUERY_PARAMS"):
3408 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003409 if (no_hyperlinks):
3410 return self.id_serializer_class
3411 else:
3412 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003413
Scott Baker0caeaf02014-06-19 11:12:55 -07003414 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003415 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003416 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003417 return NetworkSliver.select_by_user(self.request.user)
3418
Scott Baker89a7b7c2014-10-07 00:10:17 -07003419 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003420
Scott Baker89a7b7c2014-10-07 00:10:17 -07003421 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003422
3423
3424
Scott Baker15af5652015-02-02 14:33:08 -08003425class FlavorList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08003426 queryset = Flavor.objects.select_related().all()
3427 serializer_class = FlavorSerializer
3428 id_serializer_class = FlavorIdSerializer
3429 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003430 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',)
Scott Baker191f9b22015-01-12 13:16:39 -08003431
3432 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003433 no_hyperlinks=False
3434 if hasattr(self.request,"QUERY_PARAMS"):
3435 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08003436 if (no_hyperlinks):
3437 return self.id_serializer_class
3438 else:
3439 return self.serializer_class
3440
3441 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003442 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003443 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003444 return Flavor.select_by_user(self.request.user)
3445
3446 def create(self, request, *args, **kwargs):
3447 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3448 if not (serializer.is_valid()):
3449 response = {"error": "validation",
3450 "specific_error": "not serializer.is_valid()",
3451 "reasons": serializer.errors}
3452 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3453 obj = serializer.object
3454 obj.caller = request.user
3455 if obj.can_update(request.user):
3456 return super(FlavorList, self).create(request, *args, **kwargs)
3457 else:
3458 raise Exception("failed obj.can_update")
3459
3460 ret = super(FlavorList, self).create(request, *args, **kwargs)
3461 if (ret.status_code%100 != 200):
3462 raise Exception(ret.data)
3463
3464 return ret
3465
3466
3467class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3468 queryset = Flavor.objects.select_related().all()
3469 serializer_class = FlavorSerializer
3470 id_serializer_class = FlavorIdSerializer
3471
3472 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003473 no_hyperlinks=False
3474 if hasattr(self.request,"QUERY_PARAMS"):
3475 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08003476 if (no_hyperlinks):
3477 return self.id_serializer_class
3478 else:
3479 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003480
Scott Baker191f9b22015-01-12 13:16:39 -08003481 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003482 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003483 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003484 return Flavor.select_by_user(self.request.user)
3485
3486 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3487
3488 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3489
3490
3491
Scott Baker15af5652015-02-02 14:33:08 -08003492class ControllerSiteList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08003493 queryset = ControllerSite.objects.select_related().all()
3494 serializer_class = ControllerSiteSerializer
3495 id_serializer_class = ControllerSiteIdSerializer
3496 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003497 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08003498
3499 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003500 no_hyperlinks=False
3501 if hasattr(self.request,"QUERY_PARAMS"):
3502 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08003503 if (no_hyperlinks):
3504 return self.id_serializer_class
3505 else:
3506 return self.serializer_class
3507
3508 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003509 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003510 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003511 return ControllerSite.select_by_user(self.request.user)
3512
3513 def create(self, request, *args, **kwargs):
3514 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3515 if not (serializer.is_valid()):
3516 response = {"error": "validation",
3517 "specific_error": "not serializer.is_valid()",
3518 "reasons": serializer.errors}
3519 return Response(response, status=status.HTTP_400_BAD_REQUEST)
3520 obj = serializer.object
3521 obj.caller = request.user
3522 if obj.can_update(request.user):
3523 return super(ControllerSiteList, self).create(request, *args, **kwargs)
3524 else:
3525 raise Exception("failed obj.can_update")
3526
3527 ret = super(ControllerSiteList, self).create(request, *args, **kwargs)
3528 if (ret.status_code%100 != 200):
3529 raise Exception(ret.data)
3530
3531 return ret
3532
3533
3534class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3535 queryset = ControllerSite.objects.select_related().all()
3536 serializer_class = ControllerSiteSerializer
3537 id_serializer_class = ControllerSiteIdSerializer
3538
3539 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003540 no_hyperlinks=False
3541 if hasattr(self.request,"QUERY_PARAMS"):
3542 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08003543 if (no_hyperlinks):
3544 return self.id_serializer_class
3545 else:
3546 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003547
Scott Baker191f9b22015-01-12 13:16:39 -08003548 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003549 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003550 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003551 return ControllerSite.select_by_user(self.request.user)
3552
3553 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3554
3555 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3556
3557
3558
Scott Baker15af5652015-02-02 14:33:08 -08003559class ProjectList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003560 queryset = Project.objects.select_related().all()
3561 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003562 id_serializer_class = ProjectIdSerializer
3563 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003564 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07003565
3566 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003567 no_hyperlinks=False
3568 if hasattr(self.request,"QUERY_PARAMS"):
3569 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003570 if (no_hyperlinks):
3571 return self.id_serializer_class
3572 else:
3573 return self.serializer_class
3574
Scott Baker0caeaf02014-06-19 11:12:55 -07003575 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003576 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003577 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003578 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003579
Scott Baker0caeaf02014-06-19 11:12:55 -07003580 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003581 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3582 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003583 response = {"error": "validation",
3584 "specific_error": "not serializer.is_valid()",
3585 "reasons": serializer.errors}
3586 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003587 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07003588 obj.caller = request.user
3589 if obj.can_update(request.user):
3590 return super(ProjectList, self).create(request, *args, **kwargs)
3591 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003592 raise Exception("failed obj.can_update")
3593
3594 ret = super(ProjectList, self).create(request, *args, **kwargs)
3595 if (ret.status_code%100 != 200):
3596 raise Exception(ret.data)
3597
3598 return ret
3599
Scott Baker0caeaf02014-06-19 11:12:55 -07003600
Scott Baker89a7b7c2014-10-07 00:10:17 -07003601class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003602 queryset = Project.objects.select_related().all()
3603 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003604 id_serializer_class = ProjectIdSerializer
3605
3606 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003607 no_hyperlinks=False
3608 if hasattr(self.request,"QUERY_PARAMS"):
3609 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003610 if (no_hyperlinks):
3611 return self.id_serializer_class
3612 else:
3613 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003614
Scott Baker0caeaf02014-06-19 11:12:55 -07003615 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003616 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003617 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003618 return Project.select_by_user(self.request.user)
3619
Scott Baker89a7b7c2014-10-07 00:10:17 -07003620 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3621
3622 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3623
3624
3625
Scott Baker15af5652015-02-02 14:33:08 -08003626class SliceList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003627 queryset = Slice.objects.select_related().all()
3628 serializer_class = SliceSerializer
3629 id_serializer_class = SliceIdSerializer
3630 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003631 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','service','network','serviceClass','creator','default_flavor','default_image','mount_data_sets','networks','networks',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003632
3633 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003634 no_hyperlinks=False
3635 if hasattr(self.request,"QUERY_PARAMS"):
3636 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003637 if (no_hyperlinks):
3638 return self.id_serializer_class
3639 else:
3640 return self.serializer_class
3641
3642 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003643 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003644 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003645 return Slice.select_by_user(self.request.user)
3646
3647 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003648 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3649 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003650 response = {"error": "validation",
3651 "specific_error": "not serializer.is_valid()",
3652 "reasons": serializer.errors}
3653 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003654 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003655 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003656 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003657 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003658 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003659 raise Exception("failed obj.can_update")
3660
3661 ret = super(SliceList, self).create(request, *args, **kwargs)
3662 if (ret.status_code%100 != 200):
3663 raise Exception(ret.data)
3664
3665 return ret
3666
Scott Baker0caeaf02014-06-19 11:12:55 -07003667
Scott Baker89a7b7c2014-10-07 00:10:17 -07003668class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3669 queryset = Slice.objects.select_related().all()
3670 serializer_class = SliceSerializer
3671 id_serializer_class = SliceIdSerializer
3672
3673 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003674 no_hyperlinks=False
3675 if hasattr(self.request,"QUERY_PARAMS"):
3676 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003677 if (no_hyperlinks):
3678 return self.id_serializer_class
3679 else:
3680 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003681
Scott Baker89a7b7c2014-10-07 00:10:17 -07003682 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003683 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003684 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003685 return Slice.select_by_user(self.request.user)
3686
3687 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3688
3689 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3690
3691
3692
Scott Baker15af5652015-02-02 14:33:08 -08003693class NetworkList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003694 queryset = Network.objects.select_related().all()
3695 serializer_class = NetworkSerializer
3696 id_serializer_class = NetworkIdSerializer
3697 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003698 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteed_bandwidth','permit_all_slices','topology_parameters','controller_url','controller_parameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003699
3700 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003701 no_hyperlinks=False
3702 if hasattr(self.request,"QUERY_PARAMS"):
3703 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003704 if (no_hyperlinks):
3705 return self.id_serializer_class
3706 else:
3707 return self.serializer_class
3708
3709 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003710 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003711 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003712 return Network.select_by_user(self.request.user)
3713
3714 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003715 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3716 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003717 response = {"error": "validation",
3718 "specific_error": "not serializer.is_valid()",
3719 "reasons": serializer.errors}
3720 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003721 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003722 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07003723 if obj.can_update(request.user):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003724 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07003725 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003726 raise Exception("failed obj.can_update")
3727
3728 ret = super(NetworkList, self).create(request, *args, **kwargs)
3729 if (ret.status_code%100 != 200):
3730 raise Exception(ret.data)
3731
3732 return ret
3733
Scott Baker89a7b7c2014-10-07 00:10:17 -07003734
3735class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3736 queryset = Network.objects.select_related().all()
3737 serializer_class = NetworkSerializer
3738 id_serializer_class = NetworkIdSerializer
3739
3740 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003741 no_hyperlinks=False
3742 if hasattr(self.request,"QUERY_PARAMS"):
3743 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003744 if (no_hyperlinks):
3745 return self.id_serializer_class
3746 else:
3747 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003748
Scott Baker89a7b7c2014-10-07 00:10:17 -07003749 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003750 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003751 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003752 return Network.select_by_user(self.request.user)
3753
3754 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3755
3756 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3757
3758
3759
Scott Baker15af5652015-02-02 14:33:08 -08003760class ServiceList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003761 queryset = Service.objects.select_related().all()
3762 serializer_class = ServiceSerializer
3763 id_serializer_class = ServiceIdSerializer
3764 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003765 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003766
3767 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003768 no_hyperlinks=False
3769 if hasattr(self.request,"QUERY_PARAMS"):
3770 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003771 if (no_hyperlinks):
3772 return self.id_serializer_class
3773 else:
3774 return self.serializer_class
3775
3776 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003777 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003778 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003779 return Service.select_by_user(self.request.user)
3780
3781 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003782 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3783 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003784 response = {"error": "validation",
3785 "specific_error": "not serializer.is_valid()",
3786 "reasons": serializer.errors}
3787 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003788 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003789 obj.caller = request.user
3790 if obj.can_update(request.user):
3791 return super(ServiceList, self).create(request, *args, **kwargs)
3792 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003793 raise Exception("failed obj.can_update")
3794
3795 ret = super(ServiceList, self).create(request, *args, **kwargs)
3796 if (ret.status_code%100 != 200):
3797 raise Exception(ret.data)
3798
3799 return ret
3800
Scott Baker89a7b7c2014-10-07 00:10:17 -07003801
3802class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3803 queryset = Service.objects.select_related().all()
3804 serializer_class = ServiceSerializer
3805 id_serializer_class = ServiceIdSerializer
3806
3807 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003808 no_hyperlinks=False
3809 if hasattr(self.request,"QUERY_PARAMS"):
3810 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003811 if (no_hyperlinks):
3812 return self.id_serializer_class
3813 else:
3814 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003815
Scott Baker89a7b7c2014-10-07 00:10:17 -07003816 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003817 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003818 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003819 return Service.select_by_user(self.request.user)
3820
3821 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3822
3823 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3824
3825
3826
Scott Baker15af5652015-02-02 14:33:08 -08003827class ServiceClassList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003828 queryset = ServiceClass.objects.select_related().all()
3829 serializer_class = ServiceClassSerializer
3830 id_serializer_class = ServiceClassIdSerializer
3831 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003832 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003833
3834 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003835 no_hyperlinks=False
3836 if hasattr(self.request,"QUERY_PARAMS"):
3837 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003838 if (no_hyperlinks):
3839 return self.id_serializer_class
3840 else:
3841 return self.serializer_class
3842
3843 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003844 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003845 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003846 return ServiceClass.select_by_user(self.request.user)
3847
3848 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003849 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3850 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003851 response = {"error": "validation",
3852 "specific_error": "not serializer.is_valid()",
3853 "reasons": serializer.errors}
3854 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003855 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003856 obj.caller = request.user
3857 if obj.can_update(request.user):
3858 return super(ServiceClassList, self).create(request, *args, **kwargs)
3859 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003860 raise Exception("failed obj.can_update")
3861
3862 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3863 if (ret.status_code%100 != 200):
3864 raise Exception(ret.data)
3865
3866 return ret
3867
Scott Baker89a7b7c2014-10-07 00:10:17 -07003868
3869class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3870 queryset = ServiceClass.objects.select_related().all()
3871 serializer_class = ServiceClassSerializer
3872 id_serializer_class = ServiceClassIdSerializer
3873
3874 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003875 no_hyperlinks=False
3876 if hasattr(self.request,"QUERY_PARAMS"):
3877 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003878 if (no_hyperlinks):
3879 return self.id_serializer_class
3880 else:
3881 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003882
Scott Baker89a7b7c2014-10-07 00:10:17 -07003883 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003884 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003885 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003886 return ServiceClass.select_by_user(self.request.user)
3887
3888 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3889
3890 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3891
3892
3893
Scott Baker15af5652015-02-02 14:33:08 -08003894class PlanetStackList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08003895 queryset = PlanetStack.objects.select_related().all()
3896 serializer_class = PlanetStackSerializer
3897 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003898 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003899 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003900
3901 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003902 no_hyperlinks=False
3903 if hasattr(self.request,"QUERY_PARAMS"):
3904 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003905 if (no_hyperlinks):
3906 return self.id_serializer_class
3907 else:
3908 return self.serializer_class
3909
3910 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003911 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003912 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003913 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003914
3915 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003916 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3917 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003918 response = {"error": "validation",
3919 "specific_error": "not serializer.is_valid()",
3920 "reasons": serializer.errors}
3921 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003922 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003923 obj.caller = request.user
3924 if obj.can_update(request.user):
Scott Baker191f9b22015-01-12 13:16:39 -08003925 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003926 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003927 raise Exception("failed obj.can_update")
3928
Scott Baker191f9b22015-01-12 13:16:39 -08003929 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07003930 if (ret.status_code%100 != 200):
3931 raise Exception(ret.data)
3932
3933 return ret
3934
Scott Baker89a7b7c2014-10-07 00:10:17 -07003935
Scott Baker191f9b22015-01-12 13:16:39 -08003936class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3937 queryset = PlanetStack.objects.select_related().all()
3938 serializer_class = PlanetStackSerializer
3939 id_serializer_class = PlanetStackIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07003940
3941 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003942 no_hyperlinks=False
3943 if hasattr(self.request,"QUERY_PARAMS"):
3944 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003945 if (no_hyperlinks):
3946 return self.id_serializer_class
3947 else:
3948 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08003949
Scott Baker89a7b7c2014-10-07 00:10:17 -07003950 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003951 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003952 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08003953 return PlanetStack.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003954
3955 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3956
3957 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3958
3959
3960
Scott Baker15af5652015-02-02 14:33:08 -08003961class ChargeList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07003962 queryset = Charge.objects.select_related().all()
3963 serializer_class = ChargeSerializer
3964 id_serializer_class = ChargeIdSerializer
3965 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08003966 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003967
3968 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08003969 no_hyperlinks=False
3970 if hasattr(self.request,"QUERY_PARAMS"):
3971 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07003972 if (no_hyperlinks):
3973 return self.id_serializer_class
3974 else:
3975 return self.serializer_class
3976
3977 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08003978 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08003979 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07003980 return Charge.select_by_user(self.request.user)
3981
3982 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08003983 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3984 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08003985 response = {"error": "validation",
3986 "specific_error": "not serializer.is_valid()",
3987 "reasons": serializer.errors}
3988 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08003989 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07003990 obj.caller = request.user
3991 if obj.can_update(request.user):
3992 return super(ChargeList, self).create(request, *args, **kwargs)
3993 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07003994 raise Exception("failed obj.can_update")
3995
3996 ret = super(ChargeList, self).create(request, *args, **kwargs)
3997 if (ret.status_code%100 != 200):
3998 raise Exception(ret.data)
3999
4000 return ret
4001
Scott Baker89a7b7c2014-10-07 00:10:17 -07004002
4003class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4004 queryset = Charge.objects.select_related().all()
4005 serializer_class = ChargeSerializer
4006 id_serializer_class = ChargeIdSerializer
4007
4008 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004009 no_hyperlinks=False
4010 if hasattr(self.request,"QUERY_PARAMS"):
4011 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004012 if (no_hyperlinks):
4013 return self.id_serializer_class
4014 else:
4015 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004016
Scott Baker89a7b7c2014-10-07 00:10:17 -07004017 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004018 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004019 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004020 return Charge.select_by_user(self.request.user)
4021
4022 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4023
4024 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4025
4026
4027
Scott Baker15af5652015-02-02 14:33:08 -08004028class RoleList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004029 queryset = Role.objects.select_related().all()
4030 serializer_class = RoleSerializer
4031 id_serializer_class = RoleIdSerializer
4032 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004033 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004034
4035 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004036 no_hyperlinks=False
4037 if hasattr(self.request,"QUERY_PARAMS"):
4038 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004039 if (no_hyperlinks):
4040 return self.id_serializer_class
4041 else:
4042 return self.serializer_class
4043
4044 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004045 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004046 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004047 return Role.select_by_user(self.request.user)
4048
4049 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004050 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4051 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004052 response = {"error": "validation",
4053 "specific_error": "not serializer.is_valid()",
4054 "reasons": serializer.errors}
4055 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004056 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004057 obj.caller = request.user
4058 if obj.can_update(request.user):
4059 return super(RoleList, self).create(request, *args, **kwargs)
4060 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004061 raise Exception("failed obj.can_update")
4062
4063 ret = super(RoleList, self).create(request, *args, **kwargs)
4064 if (ret.status_code%100 != 200):
4065 raise Exception(ret.data)
4066
4067 return ret
4068
Scott Baker89a7b7c2014-10-07 00:10:17 -07004069
4070class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4071 queryset = Role.objects.select_related().all()
4072 serializer_class = RoleSerializer
4073 id_serializer_class = RoleIdSerializer
4074
4075 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004076 no_hyperlinks=False
4077 if hasattr(self.request,"QUERY_PARAMS"):
4078 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004079 if (no_hyperlinks):
4080 return self.id_serializer_class
4081 else:
4082 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004083
Scott Baker89a7b7c2014-10-07 00:10:17 -07004084 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004085 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004086 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004087 return Role.select_by_user(self.request.user)
4088
4089 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4090
4091 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4092
4093
4094
Scott Baker15af5652015-02-02 14:33:08 -08004095class UsableObjectList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004096 queryset = UsableObject.objects.select_related().all()
4097 serializer_class = UsableObjectSerializer
4098 id_serializer_class = UsableObjectIdSerializer
4099 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004100 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004101
4102 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004103 no_hyperlinks=False
4104 if hasattr(self.request,"QUERY_PARAMS"):
4105 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004106 if (no_hyperlinks):
4107 return self.id_serializer_class
4108 else:
4109 return self.serializer_class
4110
4111 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004112 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004113 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004114 return UsableObject.select_by_user(self.request.user)
4115
4116 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004117 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4118 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004119 response = {"error": "validation",
4120 "specific_error": "not serializer.is_valid()",
4121 "reasons": serializer.errors}
4122 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004123 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004124 obj.caller = request.user
4125 if obj.can_update(request.user):
4126 return super(UsableObjectList, self).create(request, *args, **kwargs)
4127 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004128 raise Exception("failed obj.can_update")
4129
4130 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
4131 if (ret.status_code%100 != 200):
4132 raise Exception(ret.data)
4133
4134 return ret
4135
Scott Baker89a7b7c2014-10-07 00:10:17 -07004136
4137class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4138 queryset = UsableObject.objects.select_related().all()
4139 serializer_class = UsableObjectSerializer
4140 id_serializer_class = UsableObjectIdSerializer
4141
4142 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004143 no_hyperlinks=False
4144 if hasattr(self.request,"QUERY_PARAMS"):
4145 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004146 if (no_hyperlinks):
4147 return self.id_serializer_class
4148 else:
4149 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004150
Scott Baker89a7b7c2014-10-07 00:10:17 -07004151 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004152 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004153 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004154 return UsableObject.select_by_user(self.request.user)
4155
4156 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4157
4158 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4159
4160
Scott Baker191f9b22015-01-12 13:16:39 -08004161
Scott Baker15af5652015-02-02 14:33:08 -08004162class SiteRoleList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004163 queryset = SiteRole.objects.select_related().all()
4164 serializer_class = SiteRoleSerializer
4165 id_serializer_class = SiteRoleIdSerializer
4166 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004167 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004168
4169 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004170 no_hyperlinks=False
4171 if hasattr(self.request,"QUERY_PARAMS"):
4172 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004173 if (no_hyperlinks):
4174 return self.id_serializer_class
4175 else:
4176 return self.serializer_class
4177
4178 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004179 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004180 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004181 return SiteRole.select_by_user(self.request.user)
4182
4183 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004184 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4185 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004186 response = {"error": "validation",
4187 "specific_error": "not serializer.is_valid()",
4188 "reasons": serializer.errors}
4189 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004190 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004191 obj.caller = request.user
4192 if obj.can_update(request.user):
4193 return super(SiteRoleList, self).create(request, *args, **kwargs)
4194 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004195 raise Exception("failed obj.can_update")
4196
4197 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
4198 if (ret.status_code%100 != 200):
4199 raise Exception(ret.data)
4200
4201 return ret
4202
Scott Baker89a7b7c2014-10-07 00:10:17 -07004203
4204class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4205 queryset = SiteRole.objects.select_related().all()
4206 serializer_class = SiteRoleSerializer
4207 id_serializer_class = SiteRoleIdSerializer
4208
4209 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004210 no_hyperlinks=False
4211 if hasattr(self.request,"QUERY_PARAMS"):
4212 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004213 if (no_hyperlinks):
4214 return self.id_serializer_class
4215 else:
4216 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004217
Scott Baker89a7b7c2014-10-07 00:10:17 -07004218 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004219 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004220 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004221 return SiteRole.select_by_user(self.request.user)
4222
4223 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4224
4225 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4226
4227
4228
Scott Baker15af5652015-02-02 14:33:08 -08004229class SliceCredentialList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004230 queryset = SliceCredential.objects.select_related().all()
4231 serializer_class = SliceCredentialSerializer
4232 id_serializer_class = SliceCredentialIdSerializer
4233 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004234 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004235
4236 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004237 no_hyperlinks=False
4238 if hasattr(self.request,"QUERY_PARAMS"):
4239 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004240 if (no_hyperlinks):
4241 return self.id_serializer_class
4242 else:
4243 return self.serializer_class
4244
4245 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004246 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004247 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004248 return SliceCredential.select_by_user(self.request.user)
4249
4250 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004251 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4252 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004253 response = {"error": "validation",
4254 "specific_error": "not serializer.is_valid()",
4255 "reasons": serializer.errors}
4256 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004257 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004258 obj.caller = request.user
4259 if obj.can_update(request.user):
4260 return super(SliceCredentialList, self).create(request, *args, **kwargs)
4261 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004262 raise Exception("failed obj.can_update")
4263
4264 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
4265 if (ret.status_code%100 != 200):
4266 raise Exception(ret.data)
4267
4268 return ret
4269
Scott Baker89a7b7c2014-10-07 00:10:17 -07004270
4271class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4272 queryset = SliceCredential.objects.select_related().all()
4273 serializer_class = SliceCredentialSerializer
4274 id_serializer_class = SliceCredentialIdSerializer
4275
4276 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004277 no_hyperlinks=False
4278 if hasattr(self.request,"QUERY_PARAMS"):
4279 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004280 if (no_hyperlinks):
4281 return self.id_serializer_class
4282 else:
4283 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004284
Scott Baker89a7b7c2014-10-07 00:10:17 -07004285 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004286 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004287 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004288 return SliceCredential.select_by_user(self.request.user)
4289
4290 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4291
4292 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4293
4294
4295
Scott Baker15af5652015-02-02 14:33:08 -08004296class SliverList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004297 queryset = Sliver.objects.select_related().all()
4298 serializer_class = SliverSerializer
4299 id_serializer_class = SliverIdSerializer
4300 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004301 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','instance_id','instance_uuid','name','instance_name','ip','image','creator','slice','deployment','node','numberCores','flavor','userData','networks',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004302
4303 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004304 no_hyperlinks=False
4305 if hasattr(self.request,"QUERY_PARAMS"):
4306 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004307 if (no_hyperlinks):
4308 return self.id_serializer_class
4309 else:
4310 return self.serializer_class
4311
4312 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004313 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004314 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004315 return Sliver.select_by_user(self.request.user)
4316
4317 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004318 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4319 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004320 response = {"error": "validation",
4321 "specific_error": "not serializer.is_valid()",
4322 "reasons": serializer.errors}
4323 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004324 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004325 obj.caller = request.user
4326 if obj.can_update(request.user):
4327 return super(SliverList, self).create(request, *args, **kwargs)
4328 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004329 raise Exception("failed obj.can_update")
4330
4331 ret = super(SliverList, self).create(request, *args, **kwargs)
4332 if (ret.status_code%100 != 200):
4333 raise Exception(ret.data)
4334
4335 return ret
4336
Scott Baker89a7b7c2014-10-07 00:10:17 -07004337
4338class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4339 queryset = Sliver.objects.select_related().all()
4340 serializer_class = SliverSerializer
4341 id_serializer_class = SliverIdSerializer
4342
4343 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004344 no_hyperlinks=False
4345 if hasattr(self.request,"QUERY_PARAMS"):
4346 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004347 if (no_hyperlinks):
4348 return self.id_serializer_class
4349 else:
4350 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004351
Scott Baker89a7b7c2014-10-07 00:10:17 -07004352 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004353 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004354 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004355 return Sliver.select_by_user(self.request.user)
4356
4357 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4358
4359 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4360
4361
4362
Scott Baker15af5652015-02-02 14:33:08 -08004363class NodeList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004364 queryset = Node.objects.select_related().all()
4365 serializer_class = NodeSerializer
4366 id_serializer_class = NodeIdSerializer
4367 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004368 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004369
4370 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004371 no_hyperlinks=False
4372 if hasattr(self.request,"QUERY_PARAMS"):
4373 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004374 if (no_hyperlinks):
4375 return self.id_serializer_class
4376 else:
4377 return self.serializer_class
4378
4379 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004380 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004381 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004382 return Node.select_by_user(self.request.user)
4383
4384 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004385 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4386 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004387 response = {"error": "validation",
4388 "specific_error": "not serializer.is_valid()",
4389 "reasons": serializer.errors}
4390 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004391 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004392 obj.caller = request.user
4393 if obj.can_update(request.user):
4394 return super(NodeList, self).create(request, *args, **kwargs)
4395 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004396 raise Exception("failed obj.can_update")
4397
4398 ret = super(NodeList, self).create(request, *args, **kwargs)
4399 if (ret.status_code%100 != 200):
4400 raise Exception(ret.data)
4401
4402 return ret
4403
Scott Baker89a7b7c2014-10-07 00:10:17 -07004404
4405class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4406 queryset = Node.objects.select_related().all()
4407 serializer_class = NodeSerializer
4408 id_serializer_class = NodeIdSerializer
4409
4410 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004411 no_hyperlinks=False
4412 if hasattr(self.request,"QUERY_PARAMS"):
4413 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004414 if (no_hyperlinks):
4415 return self.id_serializer_class
4416 else:
4417 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004418
Scott Baker89a7b7c2014-10-07 00:10:17 -07004419 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004420 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004421 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004422 return Node.select_by_user(self.request.user)
4423
4424 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4425
4426 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4427
4428
4429
Scott Baker15af5652015-02-02 14:33:08 -08004430class DashboardViewList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004431 queryset = DashboardView.objects.select_related().all()
4432 serializer_class = DashboardViewSerializer
4433 id_serializer_class = DashboardViewIdSerializer
4434 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004435 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004436
4437 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004438 no_hyperlinks=False
4439 if hasattr(self.request,"QUERY_PARAMS"):
4440 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004441 if (no_hyperlinks):
4442 return self.id_serializer_class
4443 else:
4444 return self.serializer_class
4445
4446 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004447 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004448 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004449 return DashboardView.select_by_user(self.request.user)
4450
4451 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004452 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4453 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004454 response = {"error": "validation",
4455 "specific_error": "not serializer.is_valid()",
4456 "reasons": serializer.errors}
4457 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004458 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004459 obj.caller = request.user
4460 if obj.can_update(request.user):
4461 return super(DashboardViewList, self).create(request, *args, **kwargs)
4462 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004463 raise Exception("failed obj.can_update")
4464
4465 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
4466 if (ret.status_code%100 != 200):
4467 raise Exception(ret.data)
4468
4469 return ret
4470
Scott Baker89a7b7c2014-10-07 00:10:17 -07004471
4472class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4473 queryset = DashboardView.objects.select_related().all()
4474 serializer_class = DashboardViewSerializer
4475 id_serializer_class = DashboardViewIdSerializer
4476
4477 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004478 no_hyperlinks=False
4479 if hasattr(self.request,"QUERY_PARAMS"):
4480 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004481 if (no_hyperlinks):
4482 return self.id_serializer_class
4483 else:
4484 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004485
Scott Baker89a7b7c2014-10-07 00:10:17 -07004486 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004487 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004488 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004489 return DashboardView.select_by_user(self.request.user)
4490
4491 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4492
4493 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4494
Scott Baker89a7b7c2014-10-07 00:10:17 -07004495
Scott Baker57c725c2014-11-12 01:13:53 -08004496
Scott Baker15af5652015-02-02 14:33:08 -08004497class ControllerNetworkList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08004498 queryset = ControllerNetwork.objects.select_related().all()
4499 serializer_class = ControllerNetworkSerializer
4500 id_serializer_class = ControllerNetworkIdSerializer
4501 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004502 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Baker191f9b22015-01-12 13:16:39 -08004503
4504 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004505 no_hyperlinks=False
4506 if hasattr(self.request,"QUERY_PARAMS"):
4507 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08004508 if (no_hyperlinks):
4509 return self.id_serializer_class
4510 else:
4511 return self.serializer_class
4512
4513 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004514 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004515 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08004516 return ControllerNetwork.select_by_user(self.request.user)
4517
4518 def create(self, request, *args, **kwargs):
4519 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4520 if not (serializer.is_valid()):
4521 response = {"error": "validation",
4522 "specific_error": "not serializer.is_valid()",
4523 "reasons": serializer.errors}
4524 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4525 obj = serializer.object
4526 obj.caller = request.user
4527 if obj.can_update(request.user):
4528 return super(ControllerNetworkList, self).create(request, *args, **kwargs)
4529 else:
4530 raise Exception("failed obj.can_update")
4531
4532 ret = super(ControllerNetworkList, self).create(request, *args, **kwargs)
4533 if (ret.status_code%100 != 200):
4534 raise Exception(ret.data)
4535
4536 return ret
4537
4538
4539class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4540 queryset = ControllerNetwork.objects.select_related().all()
4541 serializer_class = ControllerNetworkSerializer
4542 id_serializer_class = ControllerNetworkIdSerializer
4543
4544 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004545 no_hyperlinks=False
4546 if hasattr(self.request,"QUERY_PARAMS"):
4547 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08004548 if (no_hyperlinks):
4549 return self.id_serializer_class
4550 else:
4551 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004552
Scott Baker191f9b22015-01-12 13:16:39 -08004553 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004554 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004555 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08004556 return ControllerNetwork.select_by_user(self.request.user)
4557
4558 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4559
4560 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4561
4562
4563
Scott Baker15af5652015-02-02 14:33:08 -08004564class ImageDeploymentsList(PlanetStackListCreateAPIView):
Scott Baker515dc9e2014-12-22 09:29:05 -08004565 queryset = ImageDeployments.objects.select_related().all()
4566 serializer_class = ImageDeploymentsSerializer
4567 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004568 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004569 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004570
4571 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004572 no_hyperlinks=False
4573 if hasattr(self.request,"QUERY_PARAMS"):
4574 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004575 if (no_hyperlinks):
4576 return self.id_serializer_class
4577 else:
4578 return self.serializer_class
4579
4580 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004581 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004582 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004583 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004584
4585 def create(self, request, *args, **kwargs):
4586 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4587 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004588 response = {"error": "validation",
4589 "specific_error": "not serializer.is_valid()",
4590 "reasons": serializer.errors}
4591 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004592 obj = serializer.object
4593 obj.caller = request.user
4594 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08004595 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004596 else:
4597 raise Exception("failed obj.can_update")
4598
Scott Baker515dc9e2014-12-22 09:29:05 -08004599 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004600 if (ret.status_code%100 != 200):
4601 raise Exception(ret.data)
4602
4603 return ret
4604
4605
Scott Baker515dc9e2014-12-22 09:29:05 -08004606class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4607 queryset = ImageDeployments.objects.select_related().all()
4608 serializer_class = ImageDeploymentsSerializer
4609 id_serializer_class = ImageDeploymentsIdSerializer
Scott Bakerb744f1c2014-11-21 11:32:24 -08004610
4611 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004612 no_hyperlinks=False
4613 if hasattr(self.request,"QUERY_PARAMS"):
4614 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004615 if (no_hyperlinks):
4616 return self.id_serializer_class
4617 else:
4618 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004619
Scott Bakerb744f1c2014-11-21 11:32:24 -08004620 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004621 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004622 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004623 return ImageDeployments.select_by_user(self.request.user)
Scott Bakerb744f1c2014-11-21 11:32:24 -08004624
4625 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4626
4627 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4628
Scott Bakerb744f1c2014-11-21 11:32:24 -08004629
4630
Scott Baker15af5652015-02-02 14:33:08 -08004631class ControllerUserList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08004632 queryset = ControllerUser.objects.select_related().all()
4633 serializer_class = ControllerUserSerializer
4634 id_serializer_class = ControllerUserIdSerializer
4635 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004636 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Baker191f9b22015-01-12 13:16:39 -08004637
4638 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004639 no_hyperlinks=False
4640 if hasattr(self.request,"QUERY_PARAMS"):
4641 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08004642 if (no_hyperlinks):
4643 return self.id_serializer_class
4644 else:
4645 return self.serializer_class
4646
4647 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004648 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004649 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08004650 return ControllerUser.select_by_user(self.request.user)
4651
4652 def create(self, request, *args, **kwargs):
4653 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4654 if not (serializer.is_valid()):
4655 response = {"error": "validation",
4656 "specific_error": "not serializer.is_valid()",
4657 "reasons": serializer.errors}
4658 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4659 obj = serializer.object
4660 obj.caller = request.user
4661 if obj.can_update(request.user):
4662 return super(ControllerUserList, self).create(request, *args, **kwargs)
4663 else:
4664 raise Exception("failed obj.can_update")
4665
4666 ret = super(ControllerUserList, self).create(request, *args, **kwargs)
4667 if (ret.status_code%100 != 200):
4668 raise Exception(ret.data)
4669
4670 return ret
4671
4672
4673class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4674 queryset = ControllerUser.objects.select_related().all()
4675 serializer_class = ControllerUserSerializer
4676 id_serializer_class = ControllerUserIdSerializer
4677
4678 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004679 no_hyperlinks=False
4680 if hasattr(self.request,"QUERY_PARAMS"):
4681 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08004682 if (no_hyperlinks):
4683 return self.id_serializer_class
4684 else:
4685 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004686
Scott Baker191f9b22015-01-12 13:16:39 -08004687 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004688 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004689 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08004690 return ControllerUser.select_by_user(self.request.user)
4691
4692 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4693
4694 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4695
4696
4697
Scott Baker15af5652015-02-02 14:33:08 -08004698class ReservedResourceList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004699 queryset = ReservedResource.objects.select_related().all()
4700 serializer_class = ReservedResourceSerializer
4701 id_serializer_class = ReservedResourceIdSerializer
4702 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004703 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004704
4705 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004706 no_hyperlinks=False
4707 if hasattr(self.request,"QUERY_PARAMS"):
4708 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004709 if (no_hyperlinks):
4710 return self.id_serializer_class
4711 else:
4712 return self.serializer_class
4713
4714 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004715 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004716 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004717 return ReservedResource.select_by_user(self.request.user)
4718
4719 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004720 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4721 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004722 response = {"error": "validation",
4723 "specific_error": "not serializer.is_valid()",
4724 "reasons": serializer.errors}
4725 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004726 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004727 obj.caller = request.user
4728 if obj.can_update(request.user):
4729 return super(ReservedResourceList, self).create(request, *args, **kwargs)
4730 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004731 raise Exception("failed obj.can_update")
4732
4733 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
4734 if (ret.status_code%100 != 200):
4735 raise Exception(ret.data)
4736
4737 return ret
4738
Scott Baker89a7b7c2014-10-07 00:10:17 -07004739
4740class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4741 queryset = ReservedResource.objects.select_related().all()
4742 serializer_class = ReservedResourceSerializer
4743 id_serializer_class = ReservedResourceIdSerializer
4744
4745 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004746 no_hyperlinks=False
4747 if hasattr(self.request,"QUERY_PARAMS"):
4748 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004749 if (no_hyperlinks):
4750 return self.id_serializer_class
4751 else:
4752 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004753
Scott Baker89a7b7c2014-10-07 00:10:17 -07004754 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004755 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004756 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004757 return ReservedResource.select_by_user(self.request.user)
4758
4759 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4760
4761 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4762
4763
4764
Scott Baker15af5652015-02-02 14:33:08 -08004765class PaymentList(PlanetStackListCreateAPIView):
Scott Baker515dc9e2014-12-22 09:29:05 -08004766 queryset = Payment.objects.select_related().all()
4767 serializer_class = PaymentSerializer
4768 id_serializer_class = PaymentIdSerializer
4769 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004770 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Baker515dc9e2014-12-22 09:29:05 -08004771
4772 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004773 no_hyperlinks=False
4774 if hasattr(self.request,"QUERY_PARAMS"):
4775 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08004776 if (no_hyperlinks):
4777 return self.id_serializer_class
4778 else:
4779 return self.serializer_class
4780
4781 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004782 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004783 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004784 return Payment.select_by_user(self.request.user)
4785
4786 def create(self, request, *args, **kwargs):
4787 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4788 if not (serializer.is_valid()):
4789 response = {"error": "validation",
4790 "specific_error": "not serializer.is_valid()",
4791 "reasons": serializer.errors}
4792 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4793 obj = serializer.object
4794 obj.caller = request.user
4795 if obj.can_update(request.user):
4796 return super(PaymentList, self).create(request, *args, **kwargs)
4797 else:
4798 raise Exception("failed obj.can_update")
4799
4800 ret = super(PaymentList, self).create(request, *args, **kwargs)
4801 if (ret.status_code%100 != 200):
4802 raise Exception(ret.data)
4803
4804 return ret
4805
4806
4807class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4808 queryset = Payment.objects.select_related().all()
4809 serializer_class = PaymentSerializer
4810 id_serializer_class = PaymentIdSerializer
4811
4812 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004813 no_hyperlinks=False
4814 if hasattr(self.request,"QUERY_PARAMS"):
4815 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08004816 if (no_hyperlinks):
4817 return self.id_serializer_class
4818 else:
4819 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004820
Scott Baker515dc9e2014-12-22 09:29:05 -08004821 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004822 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004823 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004824 return Payment.select_by_user(self.request.user)
4825
4826 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4827
4828 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4829
4830
4831
Scott Baker15af5652015-02-02 14:33:08 -08004832class NetworkSliceList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004833 queryset = NetworkSlice.objects.select_related().all()
4834 serializer_class = NetworkSliceSerializer
4835 id_serializer_class = NetworkSliceIdSerializer
4836 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004837 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004838
4839 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004840 no_hyperlinks=False
4841 if hasattr(self.request,"QUERY_PARAMS"):
4842 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004843 if (no_hyperlinks):
4844 return self.id_serializer_class
4845 else:
4846 return self.serializer_class
4847
4848 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004849 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004850 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004851 return NetworkSlice.select_by_user(self.request.user)
4852
4853 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004854 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4855 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-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 Baker57c725c2014-11-12 01:13:53 -08004860 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004861 obj.caller = request.user
4862 if obj.can_update(request.user):
4863 return super(NetworkSliceList, self).create(request, *args, **kwargs)
4864 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004865 raise Exception("failed obj.can_update")
4866
4867 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
4868 if (ret.status_code%100 != 200):
4869 raise Exception(ret.data)
4870
4871 return ret
4872
Scott Baker89a7b7c2014-10-07 00:10:17 -07004873
4874class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4875 queryset = NetworkSlice.objects.select_related().all()
4876 serializer_class = NetworkSliceSerializer
4877 id_serializer_class = NetworkSliceIdSerializer
4878
4879 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004880 no_hyperlinks=False
4881 if hasattr(self.request,"QUERY_PARAMS"):
4882 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004883 if (no_hyperlinks):
4884 return self.id_serializer_class
4885 else:
4886 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004887
Scott Baker89a7b7c2014-10-07 00:10:17 -07004888 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004889 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004890 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004891 return NetworkSlice.select_by_user(self.request.user)
4892
4893 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4894
4895 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4896
4897
4898
Scott Baker15af5652015-02-02 14:33:08 -08004899class UserDashboardViewList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07004900 queryset = UserDashboardView.objects.select_related().all()
4901 serializer_class = UserDashboardViewSerializer
4902 id_serializer_class = UserDashboardViewIdSerializer
4903 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004904 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004905
4906 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004907 no_hyperlinks=False
4908 if hasattr(self.request,"QUERY_PARAMS"):
4909 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004910 if (no_hyperlinks):
4911 return self.id_serializer_class
4912 else:
4913 return self.serializer_class
4914
4915 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004916 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004917 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004918 return UserDashboardView.select_by_user(self.request.user)
4919
4920 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08004921 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4922 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08004923 response = {"error": "validation",
4924 "specific_error": "not serializer.is_valid()",
4925 "reasons": serializer.errors}
4926 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08004927 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07004928 obj.caller = request.user
4929 if obj.can_update(request.user):
4930 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4931 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07004932 raise Exception("failed obj.can_update")
4933
4934 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4935 if (ret.status_code%100 != 200):
4936 raise Exception(ret.data)
4937
4938 return ret
4939
Scott Baker89a7b7c2014-10-07 00:10:17 -07004940
4941class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4942 queryset = UserDashboardView.objects.select_related().all()
4943 serializer_class = UserDashboardViewSerializer
4944 id_serializer_class = UserDashboardViewIdSerializer
4945
4946 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004947 no_hyperlinks=False
4948 if hasattr(self.request,"QUERY_PARAMS"):
4949 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07004950 if (no_hyperlinks):
4951 return self.id_serializer_class
4952 else:
4953 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08004954
Scott Baker89a7b7c2014-10-07 00:10:17 -07004955 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004956 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004957 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07004958 return UserDashboardView.select_by_user(self.request.user)
4959
4960 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4961
4962 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4963
4964
4965
Scott Baker15af5652015-02-02 14:33:08 -08004966class ControllerList(PlanetStackListCreateAPIView):
Scott Baker515dc9e2014-12-22 09:29:05 -08004967 queryset = Controller.objects.select_related().all()
4968 serializer_class = ControllerSerializer
4969 id_serializer_class = ControllerIdSerializer
4970 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08004971 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','backend_type','version','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',)
Scott Baker515dc9e2014-12-22 09:29:05 -08004972
4973 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08004974 no_hyperlinks=False
4975 if hasattr(self.request,"QUERY_PARAMS"):
4976 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08004977 if (no_hyperlinks):
4978 return self.id_serializer_class
4979 else:
4980 return self.serializer_class
4981
4982 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08004983 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08004984 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08004985 return Controller.select_by_user(self.request.user)
4986
4987 def create(self, request, *args, **kwargs):
4988 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4989 if not (serializer.is_valid()):
4990 response = {"error": "validation",
4991 "specific_error": "not serializer.is_valid()",
4992 "reasons": serializer.errors}
4993 return Response(response, status=status.HTTP_400_BAD_REQUEST)
4994 obj = serializer.object
4995 obj.caller = request.user
4996 if obj.can_update(request.user):
4997 return super(ControllerList, self).create(request, *args, **kwargs)
4998 else:
4999 raise Exception("failed obj.can_update")
5000
5001 ret = super(ControllerList, self).create(request, *args, **kwargs)
5002 if (ret.status_code%100 != 200):
5003 raise Exception(ret.data)
5004
5005 return ret
5006
5007
5008class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5009 queryset = Controller.objects.select_related().all()
5010 serializer_class = ControllerSerializer
5011 id_serializer_class = ControllerIdSerializer
5012
5013 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005014 no_hyperlinks=False
5015 if hasattr(self.request,"QUERY_PARAMS"):
5016 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005017 if (no_hyperlinks):
5018 return self.id_serializer_class
5019 else:
5020 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005021
Scott Baker515dc9e2014-12-22 09:29:05 -08005022 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005023 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005024 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005025 return Controller.select_by_user(self.request.user)
5026
5027 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5028
5029 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5030
5031
5032
Scott Baker15af5652015-02-02 14:33:08 -08005033class PlanetStackPrivilegeList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07005034 queryset = PlanetStackPrivilege.objects.select_related().all()
5035 serializer_class = PlanetStackPrivilegeSerializer
5036 id_serializer_class = PlanetStackPrivilegeIdSerializer
5037 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005038 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005039
5040 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005041 no_hyperlinks=False
5042 if hasattr(self.request,"QUERY_PARAMS"):
5043 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005044 if (no_hyperlinks):
5045 return self.id_serializer_class
5046 else:
5047 return self.serializer_class
5048
5049 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005050 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005051 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005052 return PlanetStackPrivilege.select_by_user(self.request.user)
5053
5054 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005055 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5056 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005057 response = {"error": "validation",
5058 "specific_error": "not serializer.is_valid()",
5059 "reasons": serializer.errors}
5060 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005061 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005062 obj.caller = request.user
5063 if obj.can_update(request.user):
5064 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
5065 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005066 raise Exception("failed obj.can_update")
5067
5068 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
5069 if (ret.status_code%100 != 200):
5070 raise Exception(ret.data)
5071
5072 return ret
5073
Scott Baker89a7b7c2014-10-07 00:10:17 -07005074
5075class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5076 queryset = PlanetStackPrivilege.objects.select_related().all()
5077 serializer_class = PlanetStackPrivilegeSerializer
5078 id_serializer_class = PlanetStackPrivilegeIdSerializer
5079
5080 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005081 no_hyperlinks=False
5082 if hasattr(self.request,"QUERY_PARAMS"):
5083 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005084 if (no_hyperlinks):
5085 return self.id_serializer_class
5086 else:
5087 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005088
Scott Baker89a7b7c2014-10-07 00:10:17 -07005089 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005090 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005091 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005092 return PlanetStackPrivilege.select_by_user(self.request.user)
5093
5094 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5095
5096 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5097
5098
5099
Scott Baker15af5652015-02-02 14:33:08 -08005100class UserList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07005101 queryset = User.objects.select_related().all()
5102 serializer_class = UserSerializer
5103 id_serializer_class = UserIdSerializer
5104 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005105 filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','is_registering','created','updated','enacted','policed','backend_status','deleted','timezone',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005106
5107 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005108 no_hyperlinks=False
5109 if hasattr(self.request,"QUERY_PARAMS"):
5110 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005111 if (no_hyperlinks):
5112 return self.id_serializer_class
5113 else:
5114 return self.serializer_class
5115
5116 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005117 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005118 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005119 return User.select_by_user(self.request.user)
5120
5121 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005122 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5123 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005124 response = {"error": "validation",
5125 "specific_error": "not serializer.is_valid()",
5126 "reasons": serializer.errors}
5127 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005128 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005129 obj.caller = request.user
5130 if obj.can_update(request.user):
5131 return super(UserList, self).create(request, *args, **kwargs)
5132 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005133 raise Exception("failed obj.can_update")
5134
5135 ret = super(UserList, self).create(request, *args, **kwargs)
5136 if (ret.status_code%100 != 200):
5137 raise Exception(ret.data)
5138
5139 return ret
5140
Scott Baker89a7b7c2014-10-07 00:10:17 -07005141
5142class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5143 queryset = User.objects.select_related().all()
5144 serializer_class = UserSerializer
5145 id_serializer_class = UserIdSerializer
5146
5147 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005148 no_hyperlinks=False
5149 if hasattr(self.request,"QUERY_PARAMS"):
5150 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005151 if (no_hyperlinks):
5152 return self.id_serializer_class
5153 else:
5154 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005155
Scott Baker89a7b7c2014-10-07 00:10:17 -07005156 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005157 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005158 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005159 return User.select_by_user(self.request.user)
5160
5161 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5162
5163 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5164
5165
5166
Scott Baker15af5652015-02-02 14:33:08 -08005167class DeploymentList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07005168 queryset = Deployment.objects.select_related().all()
5169 serializer_class = DeploymentSerializer
5170 id_serializer_class = DeploymentIdSerializer
5171 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005172 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005173
5174 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005175 no_hyperlinks=False
5176 if hasattr(self.request,"QUERY_PARAMS"):
5177 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005178 if (no_hyperlinks):
5179 return self.id_serializer_class
5180 else:
5181 return self.serializer_class
5182
5183 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005184 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005185 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005186 return Deployment.select_by_user(self.request.user)
5187
5188 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005189 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5190 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005191 response = {"error": "validation",
5192 "specific_error": "not serializer.is_valid()",
5193 "reasons": serializer.errors}
5194 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005195 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005196 obj.caller = request.user
5197 if obj.can_update(request.user):
5198 return super(DeploymentList, self).create(request, *args, **kwargs)
5199 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005200 raise Exception("failed obj.can_update")
5201
5202 ret = super(DeploymentList, self).create(request, *args, **kwargs)
5203 if (ret.status_code%100 != 200):
5204 raise Exception(ret.data)
5205
5206 return ret
5207
Scott Baker89a7b7c2014-10-07 00:10:17 -07005208
5209class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5210 queryset = Deployment.objects.select_related().all()
5211 serializer_class = DeploymentSerializer
5212 id_serializer_class = DeploymentIdSerializer
5213
5214 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005215 no_hyperlinks=False
5216 if hasattr(self.request,"QUERY_PARAMS"):
5217 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005218 if (no_hyperlinks):
5219 return self.id_serializer_class
5220 else:
5221 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005222
Scott Baker89a7b7c2014-10-07 00:10:17 -07005223 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005224 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005225 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005226 return Deployment.select_by_user(self.request.user)
5227
5228 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5229
5230 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5231
5232
5233
Scott Baker15af5652015-02-02 14:33:08 -08005234class ReservationList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07005235 queryset = Reservation.objects.select_related().all()
5236 serializer_class = ReservationSerializer
5237 id_serializer_class = ReservationIdSerializer
5238 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005239 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005240
5241 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005242 no_hyperlinks=False
5243 if hasattr(self.request,"QUERY_PARAMS"):
5244 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005245 if (no_hyperlinks):
5246 return self.id_serializer_class
5247 else:
5248 return self.serializer_class
5249
5250 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005251 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005252 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005253 return Reservation.select_by_user(self.request.user)
5254
5255 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005256 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5257 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005258 response = {"error": "validation",
5259 "specific_error": "not serializer.is_valid()",
5260 "reasons": serializer.errors}
5261 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005262 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005263 obj.caller = request.user
5264 if obj.can_update(request.user):
5265 return super(ReservationList, self).create(request, *args, **kwargs)
5266 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005267 raise Exception("failed obj.can_update")
5268
5269 ret = super(ReservationList, self).create(request, *args, **kwargs)
5270 if (ret.status_code%100 != 200):
5271 raise Exception(ret.data)
5272
5273 return ret
5274
Scott Baker89a7b7c2014-10-07 00:10:17 -07005275
5276class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5277 queryset = Reservation.objects.select_related().all()
5278 serializer_class = ReservationSerializer
5279 id_serializer_class = ReservationIdSerializer
5280
5281 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005282 no_hyperlinks=False
5283 if hasattr(self.request,"QUERY_PARAMS"):
5284 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005285 if (no_hyperlinks):
5286 return self.id_serializer_class
5287 else:
5288 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005289
Scott Baker89a7b7c2014-10-07 00:10:17 -07005290 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005291 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005292 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005293 return Reservation.select_by_user(self.request.user)
5294
5295 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5296
5297 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5298
Scott Baker89a7b7c2014-10-07 00:10:17 -07005299
Scott Baker57c725c2014-11-12 01:13:53 -08005300
Scott Baker15af5652015-02-02 14:33:08 -08005301class SitePrivilegeList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07005302 queryset = SitePrivilege.objects.select_related().all()
5303 serializer_class = SitePrivilegeSerializer
5304 id_serializer_class = SitePrivilegeIdSerializer
5305 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005306 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005307
5308 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005309 no_hyperlinks=False
5310 if hasattr(self.request,"QUERY_PARAMS"):
5311 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005312 if (no_hyperlinks):
5313 return self.id_serializer_class
5314 else:
5315 return self.serializer_class
5316
5317 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005318 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005319 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005320 return SitePrivilege.select_by_user(self.request.user)
5321
5322 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005323 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5324 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005325 response = {"error": "validation",
5326 "specific_error": "not serializer.is_valid()",
5327 "reasons": serializer.errors}
5328 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005329 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005330 obj.caller = request.user
5331 if obj.can_update(request.user):
5332 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
5333 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005334 raise Exception("failed obj.can_update")
5335
5336 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
5337 if (ret.status_code%100 != 200):
5338 raise Exception(ret.data)
5339
5340 return ret
5341
Scott Baker89a7b7c2014-10-07 00:10:17 -07005342
5343class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5344 queryset = SitePrivilege.objects.select_related().all()
5345 serializer_class = SitePrivilegeSerializer
5346 id_serializer_class = SitePrivilegeIdSerializer
5347
5348 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005349 no_hyperlinks=False
5350 if hasattr(self.request,"QUERY_PARAMS"):
5351 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005352 if (no_hyperlinks):
5353 return self.id_serializer_class
5354 else:
5355 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005356
Scott Baker89a7b7c2014-10-07 00:10:17 -07005357 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005358 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005359 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005360 return SitePrivilege.select_by_user(self.request.user)
5361
5362 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5363
5364 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5365
5366
5367
Scott Baker15af5652015-02-02 14:33:08 -08005368class ControllerSliceList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08005369 queryset = ControllerSlice.objects.select_related().all()
5370 serializer_class = ControllerSliceSerializer
5371 id_serializer_class = ControllerSliceIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005372 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005373 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005374
5375 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005376 no_hyperlinks=False
5377 if hasattr(self.request,"QUERY_PARAMS"):
5378 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005379 if (no_hyperlinks):
5380 return self.id_serializer_class
5381 else:
5382 return self.serializer_class
5383
5384 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005385 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005386 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005387 return ControllerSlice.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005388
5389 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005390 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5391 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005392 response = {"error": "validation",
5393 "specific_error": "not serializer.is_valid()",
5394 "reasons": serializer.errors}
5395 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005396 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005397 obj.caller = request.user
5398 if obj.can_update(request.user):
Scott Baker191f9b22015-01-12 13:16:39 -08005399 return super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005400 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005401 raise Exception("failed obj.can_update")
5402
Scott Baker191f9b22015-01-12 13:16:39 -08005403 ret = super(ControllerSliceList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005404 if (ret.status_code%100 != 200):
5405 raise Exception(ret.data)
5406
5407 return ret
5408
Scott Baker89a7b7c2014-10-07 00:10:17 -07005409
Scott Baker191f9b22015-01-12 13:16:39 -08005410class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5411 queryset = ControllerSlice.objects.select_related().all()
5412 serializer_class = ControllerSliceSerializer
5413 id_serializer_class = ControllerSliceIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005414
5415 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005416 no_hyperlinks=False
5417 if hasattr(self.request,"QUERY_PARAMS"):
5418 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005419 if (no_hyperlinks):
5420 return self.id_serializer_class
5421 else:
5422 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005423
Scott Baker89a7b7c2014-10-07 00:10:17 -07005424 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005425 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005426 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005427 return ControllerSlice.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005428
5429 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5430
5431 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5432
Scott Baker89a7b7c2014-10-07 00:10:17 -07005433
Scott Baker57c725c2014-11-12 01:13:53 -08005434
Scott Baker15af5652015-02-02 14:33:08 -08005435class ControllerDashboardViewList(PlanetStackListCreateAPIView):
Scott Bakerf2c0c512014-12-22 17:35:34 -08005436 queryset = ControllerDashboardView.objects.select_related().all()
5437 serializer_class = ControllerDashboardViewSerializer
5438 id_serializer_class = ControllerDashboardViewIdSerializer
5439 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005440 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakerf2c0c512014-12-22 17:35:34 -08005441
5442 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005443 no_hyperlinks=False
5444 if hasattr(self.request,"QUERY_PARAMS"):
5445 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerf2c0c512014-12-22 17:35:34 -08005446 if (no_hyperlinks):
5447 return self.id_serializer_class
5448 else:
5449 return self.serializer_class
5450
5451 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005452 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005453 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerf2c0c512014-12-22 17:35:34 -08005454 return ControllerDashboardView.select_by_user(self.request.user)
5455
5456 def create(self, request, *args, **kwargs):
5457 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5458 if not (serializer.is_valid()):
5459 response = {"error": "validation",
5460 "specific_error": "not serializer.is_valid()",
5461 "reasons": serializer.errors}
5462 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5463 obj = serializer.object
5464 obj.caller = request.user
5465 if obj.can_update(request.user):
5466 return super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
5467 else:
5468 raise Exception("failed obj.can_update")
5469
5470 ret = super(ControllerDashboardViewList, self).create(request, *args, **kwargs)
5471 if (ret.status_code%100 != 200):
5472 raise Exception(ret.data)
5473
5474 return ret
5475
5476
5477class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5478 queryset = ControllerDashboardView.objects.select_related().all()
5479 serializer_class = ControllerDashboardViewSerializer
5480 id_serializer_class = ControllerDashboardViewIdSerializer
5481
5482 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005483 no_hyperlinks=False
5484 if hasattr(self.request,"QUERY_PARAMS"):
5485 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerf2c0c512014-12-22 17:35:34 -08005486 if (no_hyperlinks):
5487 return self.id_serializer_class
5488 else:
5489 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005490
Scott Bakerf2c0c512014-12-22 17:35:34 -08005491 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005492 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005493 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerf2c0c512014-12-22 17:35:34 -08005494 return ControllerDashboardView.select_by_user(self.request.user)
5495
5496 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5497
5498 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5499
5500
5501
Scott Baker15af5652015-02-02 14:33:08 -08005502class AccountList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07005503 queryset = Account.objects.select_related().all()
5504 serializer_class = AccountSerializer
5505 id_serializer_class = AccountIdSerializer
5506 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005507 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005508
5509 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005510 no_hyperlinks=False
5511 if hasattr(self.request,"QUERY_PARAMS"):
5512 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005513 if (no_hyperlinks):
5514 return self.id_serializer_class
5515 else:
5516 return self.serializer_class
5517
5518 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005519 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005520 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005521 return Account.select_by_user(self.request.user)
5522
5523 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005524 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5525 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005526 response = {"error": "validation",
5527 "specific_error": "not serializer.is_valid()",
5528 "reasons": serializer.errors}
5529 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005530 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005531 obj.caller = request.user
5532 if obj.can_update(request.user):
5533 return super(AccountList, self).create(request, *args, **kwargs)
5534 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005535 raise Exception("failed obj.can_update")
5536
5537 ret = super(AccountList, self).create(request, *args, **kwargs)
5538 if (ret.status_code%100 != 200):
5539 raise Exception(ret.data)
5540
5541 return ret
5542
Scott Baker89a7b7c2014-10-07 00:10:17 -07005543
5544class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5545 queryset = Account.objects.select_related().all()
5546 serializer_class = AccountSerializer
5547 id_serializer_class = AccountIdSerializer
5548
5549 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005550 no_hyperlinks=False
5551 if hasattr(self.request,"QUERY_PARAMS"):
5552 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005553 if (no_hyperlinks):
5554 return self.id_serializer_class
5555 else:
5556 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005557
Scott Baker89a7b7c2014-10-07 00:10:17 -07005558 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005559 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005560 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005561 return Account.select_by_user(self.request.user)
5562
5563 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5564
5565 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5566
5567
5568
Scott Baker15af5652015-02-02 14:33:08 -08005569class ControllerRoleList(PlanetStackListCreateAPIView):
Scott Baker515dc9e2014-12-22 09:29:05 -08005570 queryset = ControllerRole.objects.select_related().all()
5571 serializer_class = ControllerRoleSerializer
5572 id_serializer_class = ControllerRoleIdSerializer
5573 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005574 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker515dc9e2014-12-22 09:29:05 -08005575
5576 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005577 no_hyperlinks=False
5578 if hasattr(self.request,"QUERY_PARAMS"):
5579 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005580 if (no_hyperlinks):
5581 return self.id_serializer_class
5582 else:
5583 return self.serializer_class
5584
5585 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005586 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005587 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005588 return ControllerRole.select_by_user(self.request.user)
5589
5590 def create(self, request, *args, **kwargs):
5591 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5592 if not (serializer.is_valid()):
5593 response = {"error": "validation",
5594 "specific_error": "not serializer.is_valid()",
5595 "reasons": serializer.errors}
5596 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5597 obj = serializer.object
5598 obj.caller = request.user
5599 if obj.can_update(request.user):
5600 return super(ControllerRoleList, self).create(request, *args, **kwargs)
5601 else:
5602 raise Exception("failed obj.can_update")
5603
5604 ret = super(ControllerRoleList, self).create(request, *args, **kwargs)
5605 if (ret.status_code%100 != 200):
5606 raise Exception(ret.data)
5607
5608 return ret
5609
5610
5611class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5612 queryset = ControllerRole.objects.select_related().all()
5613 serializer_class = ControllerRoleSerializer
5614 id_serializer_class = ControllerRoleIdSerializer
5615
5616 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005617 no_hyperlinks=False
5618 if hasattr(self.request,"QUERY_PARAMS"):
5619 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005620 if (no_hyperlinks):
5621 return self.id_serializer_class
5622 else:
5623 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005624
Scott Baker515dc9e2014-12-22 09:29:05 -08005625 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005626 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005627 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005628 return ControllerRole.select_by_user(self.request.user)
5629
5630 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5631
5632 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5633
5634
5635
Scott Baker15af5652015-02-02 14:33:08 -08005636class NetworkParameterTypeList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07005637 queryset = NetworkParameterType.objects.select_related().all()
5638 serializer_class = NetworkParameterTypeSerializer
5639 id_serializer_class = NetworkParameterTypeIdSerializer
5640 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005641 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005642
5643 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005644 no_hyperlinks=False
5645 if hasattr(self.request,"QUERY_PARAMS"):
5646 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005647 if (no_hyperlinks):
5648 return self.id_serializer_class
5649 else:
5650 return self.serializer_class
5651
5652 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005653 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005654 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005655 return NetworkParameterType.select_by_user(self.request.user)
5656
5657 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005658 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5659 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005660 response = {"error": "validation",
5661 "specific_error": "not serializer.is_valid()",
5662 "reasons": serializer.errors}
5663 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005664 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005665 obj.caller = request.user
5666 if obj.can_update(request.user):
5667 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5668 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005669 raise Exception("failed obj.can_update")
5670
5671 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
5672 if (ret.status_code%100 != 200):
5673 raise Exception(ret.data)
5674
5675 return ret
5676
Scott Baker89a7b7c2014-10-07 00:10:17 -07005677
5678class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5679 queryset = NetworkParameterType.objects.select_related().all()
5680 serializer_class = NetworkParameterTypeSerializer
5681 id_serializer_class = NetworkParameterTypeIdSerializer
5682
5683 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005684 no_hyperlinks=False
5685 if hasattr(self.request,"QUERY_PARAMS"):
5686 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005687 if (no_hyperlinks):
5688 return self.id_serializer_class
5689 else:
5690 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005691
Scott Baker89a7b7c2014-10-07 00:10:17 -07005692 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005693 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005694 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005695 return NetworkParameterType.select_by_user(self.request.user)
5696
5697 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5698
5699 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5700
5701
5702
Scott Baker15af5652015-02-02 14:33:08 -08005703class SiteCredentialList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07005704 queryset = SiteCredential.objects.select_related().all()
5705 serializer_class = SiteCredentialSerializer
5706 id_serializer_class = SiteCredentialIdSerializer
5707 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005708 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005709
5710 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005711 no_hyperlinks=False
5712 if hasattr(self.request,"QUERY_PARAMS"):
5713 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005714 if (no_hyperlinks):
5715 return self.id_serializer_class
5716 else:
5717 return self.serializer_class
5718
5719 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005720 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005721 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005722 return SiteCredential.select_by_user(self.request.user)
5723
5724 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005725 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5726 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005727 response = {"error": "validation",
5728 "specific_error": "not serializer.is_valid()",
5729 "reasons": serializer.errors}
5730 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005731 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005732 obj.caller = request.user
5733 if obj.can_update(request.user):
5734 return super(SiteCredentialList, self).create(request, *args, **kwargs)
5735 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005736 raise Exception("failed obj.can_update")
5737
5738 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
5739 if (ret.status_code%100 != 200):
5740 raise Exception(ret.data)
5741
5742 return ret
5743
Scott Baker89a7b7c2014-10-07 00:10:17 -07005744
5745class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5746 queryset = SiteCredential.objects.select_related().all()
5747 serializer_class = SiteCredentialSerializer
5748 id_serializer_class = SiteCredentialIdSerializer
5749
5750 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005751 no_hyperlinks=False
5752 if hasattr(self.request,"QUERY_PARAMS"):
5753 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005754 if (no_hyperlinks):
5755 return self.id_serializer_class
5756 else:
5757 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005758
Scott Baker89a7b7c2014-10-07 00:10:17 -07005759 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005760 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005761 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07005762 return SiteCredential.select_by_user(self.request.user)
5763
5764 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5765
5766 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5767
5768
5769
Scott Baker15af5652015-02-02 14:33:08 -08005770class DeploymentPrivilegeList(PlanetStackListCreateAPIView):
Scott Baker515dc9e2014-12-22 09:29:05 -08005771 queryset = DeploymentPrivilege.objects.select_related().all()
5772 serializer_class = DeploymentPrivilegeSerializer
5773 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005774 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005775 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005776
5777 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005778 no_hyperlinks=False
5779 if hasattr(self.request,"QUERY_PARAMS"):
5780 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005781 if (no_hyperlinks):
5782 return self.id_serializer_class
5783 else:
5784 return self.serializer_class
5785
5786 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005787 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005788 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005789 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005790
5791 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005792 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5793 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005794 response = {"error": "validation",
5795 "specific_error": "not serializer.is_valid()",
5796 "reasons": serializer.errors}
5797 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005798 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07005799 obj.caller = request.user
5800 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08005801 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005802 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07005803 raise Exception("failed obj.can_update")
5804
Scott Baker515dc9e2014-12-22 09:29:05 -08005805 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07005806 if (ret.status_code%100 != 200):
5807 raise Exception(ret.data)
5808
5809 return ret
5810
Scott Baker89a7b7c2014-10-07 00:10:17 -07005811
Scott Baker515dc9e2014-12-22 09:29:05 -08005812class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5813 queryset = DeploymentPrivilege.objects.select_related().all()
5814 serializer_class = DeploymentPrivilegeSerializer
5815 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005816
5817 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005818 no_hyperlinks=False
5819 if hasattr(self.request,"QUERY_PARAMS"):
5820 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005821 if (no_hyperlinks):
5822 return self.id_serializer_class
5823 else:
5824 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005825
Scott Baker89a7b7c2014-10-07 00:10:17 -07005826 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005827 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005828 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005829 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005830
5831 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5832
5833 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5834
5835
5836
Scott Baker15af5652015-02-02 14:33:08 -08005837class ControllerSlicePrivilegeList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08005838 queryset = ControllerSlicePrivilege.objects.select_related().all()
5839 serializer_class = ControllerSlicePrivilegeSerializer
5840 id_serializer_class = ControllerSlicePrivilegeIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005841 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005842 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Baker515dc9e2014-12-22 09:29:05 -08005843
5844 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005845 no_hyperlinks=False
5846 if hasattr(self.request,"QUERY_PARAMS"):
5847 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005848 if (no_hyperlinks):
5849 return self.id_serializer_class
5850 else:
5851 return self.serializer_class
5852
5853 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005854 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005855 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005856 return ControllerSlicePrivilege.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005857
5858 def create(self, request, *args, **kwargs):
5859 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5860 if not (serializer.is_valid()):
5861 response = {"error": "validation",
5862 "specific_error": "not serializer.is_valid()",
5863 "reasons": serializer.errors}
5864 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5865 obj = serializer.object
5866 obj.caller = request.user
5867 if obj.can_update(request.user):
Scott Baker191f9b22015-01-12 13:16:39 -08005868 return super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005869 else:
5870 raise Exception("failed obj.can_update")
5871
Scott Baker191f9b22015-01-12 13:16:39 -08005872 ret = super(ControllerSlicePrivilegeList, self).create(request, *args, **kwargs)
Scott Baker515dc9e2014-12-22 09:29:05 -08005873 if (ret.status_code%100 != 200):
5874 raise Exception(ret.data)
5875
5876 return ret
5877
5878
Scott Baker191f9b22015-01-12 13:16:39 -08005879class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5880 queryset = ControllerSlicePrivilege.objects.select_related().all()
5881 serializer_class = ControllerSlicePrivilegeSerializer
5882 id_serializer_class = ControllerSlicePrivilegeIdSerializer
Scott Baker515dc9e2014-12-22 09:29:05 -08005883
5884 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005885 no_hyperlinks=False
5886 if hasattr(self.request,"QUERY_PARAMS"):
5887 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker515dc9e2014-12-22 09:29:05 -08005888 if (no_hyperlinks):
5889 return self.id_serializer_class
5890 else:
5891 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005892
Scott Baker515dc9e2014-12-22 09:29:05 -08005893 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005894 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005895 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005896 return ControllerSlicePrivilege.select_by_user(self.request.user)
5897
5898 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5899
5900 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5901
5902
5903
Scott Baker15af5652015-02-02 14:33:08 -08005904class SiteDeploymentList(PlanetStackListCreateAPIView):
Scott Baker191f9b22015-01-12 13:16:39 -08005905 queryset = SiteDeployment.objects.select_related().all()
5906 serializer_class = SiteDeploymentSerializer
5907 id_serializer_class = SiteDeploymentIdSerializer
5908 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005909 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Baker191f9b22015-01-12 13:16:39 -08005910
5911 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005912 no_hyperlinks=False
5913 if hasattr(self.request,"QUERY_PARAMS"):
5914 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08005915 if (no_hyperlinks):
5916 return self.id_serializer_class
5917 else:
5918 return self.serializer_class
5919
5920 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005921 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005922 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005923 return SiteDeployment.select_by_user(self.request.user)
5924
5925 def create(self, request, *args, **kwargs):
5926 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5927 if not (serializer.is_valid()):
5928 response = {"error": "validation",
5929 "specific_error": "not serializer.is_valid()",
5930 "reasons": serializer.errors}
5931 return Response(response, status=status.HTTP_400_BAD_REQUEST)
5932 obj = serializer.object
5933 obj.caller = request.user
5934 if obj.can_update(request.user):
5935 return super(SiteDeploymentList, self).create(request, *args, **kwargs)
5936 else:
5937 raise Exception("failed obj.can_update")
5938
5939 ret = super(SiteDeploymentList, self).create(request, *args, **kwargs)
5940 if (ret.status_code%100 != 200):
5941 raise Exception(ret.data)
5942
5943 return ret
5944
5945
5946class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5947 queryset = SiteDeployment.objects.select_related().all()
5948 serializer_class = SiteDeploymentSerializer
5949 id_serializer_class = SiteDeploymentIdSerializer
5950
5951 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005952 no_hyperlinks=False
5953 if hasattr(self.request,"QUERY_PARAMS"):
5954 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker191f9b22015-01-12 13:16:39 -08005955 if (no_hyperlinks):
5956 return self.id_serializer_class
5957 else:
5958 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08005959
Scott Baker191f9b22015-01-12 13:16:39 -08005960 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005961 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005962 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker191f9b22015-01-12 13:16:39 -08005963 return SiteDeployment.select_by_user(self.request.user)
Scott Baker515dc9e2014-12-22 09:29:05 -08005964
5965 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5966
5967 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5968
5969
5970
Scott Baker15af5652015-02-02 14:33:08 -08005971class DeploymentRoleList(PlanetStackListCreateAPIView):
Scott Baker515dc9e2014-12-22 09:29:05 -08005972 queryset = DeploymentRole.objects.select_related().all()
5973 serializer_class = DeploymentRoleSerializer
5974 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07005975 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08005976 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005977
5978 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08005979 no_hyperlinks=False
5980 if hasattr(self.request,"QUERY_PARAMS"):
5981 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005982 if (no_hyperlinks):
5983 return self.id_serializer_class
5984 else:
5985 return self.serializer_class
5986
5987 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08005988 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08005989 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08005990 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07005991
5992 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08005993 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5994 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08005995 response = {"error": "validation",
5996 "specific_error": "not serializer.is_valid()",
5997 "reasons": serializer.errors}
5998 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08005999 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07006000 obj.caller = request.user
6001 if obj.can_update(request.user):
Scott Baker515dc9e2014-12-22 09:29:05 -08006002 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006003 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006004 raise Exception("failed obj.can_update")
6005
Scott Baker515dc9e2014-12-22 09:29:05 -08006006 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07006007 if (ret.status_code%100 != 200):
6008 raise Exception(ret.data)
6009
6010 return ret
6011
Scott Baker89a7b7c2014-10-07 00:10:17 -07006012
Scott Baker515dc9e2014-12-22 09:29:05 -08006013class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
6014 queryset = DeploymentRole.objects.select_related().all()
6015 serializer_class = DeploymentRoleSerializer
6016 id_serializer_class = DeploymentRoleIdSerializer
Scott Baker89a7b7c2014-10-07 00:10:17 -07006017
6018 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006019 no_hyperlinks=False
6020 if hasattr(self.request,"QUERY_PARAMS"):
6021 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006022 if (no_hyperlinks):
6023 return self.id_serializer_class
6024 else:
6025 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006026
Scott Baker89a7b7c2014-10-07 00:10:17 -07006027 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006028 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006029 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker515dc9e2014-12-22 09:29:05 -08006030 return DeploymentRole.select_by_user(self.request.user)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006031
6032 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
6033
6034 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
6035
6036
6037
Scott Baker15af5652015-02-02 14:33:08 -08006038class UserCredentialList(PlanetStackListCreateAPIView):
Scott Baker89a7b7c2014-10-07 00:10:17 -07006039 queryset = UserCredential.objects.select_related().all()
6040 serializer_class = UserCredentialSerializer
6041 id_serializer_class = UserCredentialIdSerializer
6042 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006043 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006044
6045 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006046 no_hyperlinks=False
6047 if hasattr(self.request,"QUERY_PARAMS"):
6048 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006049 if (no_hyperlinks):
6050 return self.id_serializer_class
6051 else:
6052 return self.serializer_class
6053
6054 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006055 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006056 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07006057 return UserCredential.select_by_user(self.request.user)
6058
6059 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006060 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6061 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006062 response = {"error": "validation",
6063 "specific_error": "not serializer.is_valid()",
6064 "reasons": serializer.errors}
6065 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006066 obj = serializer.object
Scott Baker89a7b7c2014-10-07 00:10:17 -07006067 obj.caller = request.user
6068 if obj.can_update(request.user):
6069 return super(UserCredentialList, self).create(request, *args, **kwargs)
6070 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006071 raise Exception("failed obj.can_update")
6072
6073 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
6074 if (ret.status_code%100 != 200):
6075 raise Exception(ret.data)
6076
6077 return ret
6078
Scott Baker89a7b7c2014-10-07 00:10:17 -07006079
6080class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
6081 queryset = UserCredential.objects.select_related().all()
6082 serializer_class = UserCredentialSerializer
6083 id_serializer_class = UserCredentialIdSerializer
6084
6085 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006086 no_hyperlinks=False
6087 if hasattr(self.request,"QUERY_PARAMS"):
6088 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker89a7b7c2014-10-07 00:10:17 -07006089 if (no_hyperlinks):
6090 return self.id_serializer_class
6091 else:
6092 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006093
Scott Baker89a7b7c2014-10-07 00:10:17 -07006094 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006095 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006096 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker89a7b7c2014-10-07 00:10:17 -07006097 return UserCredential.select_by_user(self.request.user)
6098
6099 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
6100
6101 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
6102
Scott Baker89a7b7c2014-10-07 00:10:17 -07006103
Scott Baker57c725c2014-11-12 01:13:53 -08006104
Scott Baker15af5652015-02-02 14:33:08 -08006105class SliceTagList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006106 queryset = SliceTag.objects.select_related().all()
6107 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006108 id_serializer_class = SliceTagIdSerializer
6109 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006110 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07006111
6112 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006113 no_hyperlinks=False
6114 if hasattr(self.request,"QUERY_PARAMS"):
6115 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006116 if (no_hyperlinks):
6117 return self.id_serializer_class
6118 else:
6119 return self.serializer_class
6120
Scott Baker0caeaf02014-06-19 11:12:55 -07006121 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006122 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006123 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006124 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04006125
Scott Baker0caeaf02014-06-19 11:12:55 -07006126 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006127 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6128 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006129 response = {"error": "validation",
6130 "specific_error": "not serializer.is_valid()",
6131 "reasons": serializer.errors}
6132 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006133 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07006134 obj.caller = request.user
6135 if obj.can_update(request.user):
6136 return super(SliceTagList, self).create(request, *args, **kwargs)
6137 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006138 raise Exception("failed obj.can_update")
6139
6140 ret = super(SliceTagList, self).create(request, *args, **kwargs)
6141 if (ret.status_code%100 != 200):
6142 raise Exception(ret.data)
6143
6144 return ret
6145
Scott Baker0caeaf02014-06-19 11:12:55 -07006146
Scott Baker89a7b7c2014-10-07 00:10:17 -07006147class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006148 queryset = SliceTag.objects.select_related().all()
6149 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006150 id_serializer_class = SliceTagIdSerializer
6151
6152 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006153 no_hyperlinks=False
6154 if hasattr(self.request,"QUERY_PARAMS"):
6155 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006156 if (no_hyperlinks):
6157 return self.id_serializer_class
6158 else:
6159 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006160
Scott Baker0caeaf02014-06-19 11:12:55 -07006161 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006162 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006163 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006164 return SliceTag.select_by_user(self.request.user)
6165
Scott Baker89a7b7c2014-10-07 00:10:17 -07006166 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07006167
Scott Baker89a7b7c2014-10-07 00:10:17 -07006168 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04006169
6170
6171
Scott Baker15af5652015-02-02 14:33:08 -08006172class NetworkTemplateList(PlanetStackListCreateAPIView):
Scott Bakerf2c0c512014-12-22 17:35:34 -08006173 queryset = NetworkTemplate.objects.select_related().all()
6174 serializer_class = NetworkTemplateSerializer
6175 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006176 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006177 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','guaranteed_bandwidth','visibility','translation','shared_network_name','shared_network_id','topology_kind','controller_kind',)
Scott Baker46b58542014-08-11 17:26:12 -07006178
6179 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006180 no_hyperlinks=False
6181 if hasattr(self.request,"QUERY_PARAMS"):
6182 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006183 if (no_hyperlinks):
6184 return self.id_serializer_class
6185 else:
6186 return self.serializer_class
6187
Scott Baker0caeaf02014-06-19 11:12:55 -07006188 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006189 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006190 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerf2c0c512014-12-22 17:35:34 -08006191 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04006192
Scott Baker0caeaf02014-06-19 11:12:55 -07006193 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006194 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6195 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006196 response = {"error": "validation",
6197 "specific_error": "not serializer.is_valid()",
6198 "reasons": serializer.errors}
6199 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006200 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07006201 obj.caller = request.user
6202 if obj.can_update(request.user):
Scott Bakerf2c0c512014-12-22 17:35:34 -08006203 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07006204 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006205 raise Exception("failed obj.can_update")
6206
Scott Bakerf2c0c512014-12-22 17:35:34 -08006207 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
Scott Baker2bcbf372014-10-29 23:41:11 -07006208 if (ret.status_code%100 != 200):
6209 raise Exception(ret.data)
6210
6211 return ret
6212
Scott Baker0caeaf02014-06-19 11:12:55 -07006213
Scott Bakerf2c0c512014-12-22 17:35:34 -08006214class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
6215 queryset = NetworkTemplate.objects.select_related().all()
6216 serializer_class = NetworkTemplateSerializer
6217 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006218
6219 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006220 no_hyperlinks=False
6221 if hasattr(self.request,"QUERY_PARAMS"):
6222 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006223 if (no_hyperlinks):
6224 return self.id_serializer_class
6225 else:
6226 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006227
Scott Baker0caeaf02014-06-19 11:12:55 -07006228 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006229 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006230 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerf2c0c512014-12-22 17:35:34 -08006231 return NetworkTemplate.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07006232
Scott Baker89a7b7c2014-10-07 00:10:17 -07006233 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07006234
Scott Baker89a7b7c2014-10-07 00:10:17 -07006235 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04006236
6237
6238
Scott Baker15af5652015-02-02 14:33:08 -08006239class RouterList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006240 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04006241 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006242 id_serializer_class = RouterIdSerializer
6243 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006244 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07006245
6246 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006247 no_hyperlinks=False
6248 if hasattr(self.request,"QUERY_PARAMS"):
6249 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006250 if (no_hyperlinks):
6251 return self.id_serializer_class
6252 else:
6253 return self.serializer_class
6254
Scott Baker0caeaf02014-06-19 11:12:55 -07006255 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006256 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006257 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006258 return Router.select_by_user(self.request.user)
6259
6260 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006261 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6262 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006263 response = {"error": "validation",
6264 "specific_error": "not serializer.is_valid()",
6265 "reasons": serializer.errors}
6266 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006267 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07006268 obj.caller = request.user
6269 if obj.can_update(request.user):
6270 return super(RouterList, self).create(request, *args, **kwargs)
6271 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006272 raise Exception("failed obj.can_update")
6273
6274 ret = super(RouterList, self).create(request, *args, **kwargs)
6275 if (ret.status_code%100 != 200):
6276 raise Exception(ret.data)
6277
6278 return ret
6279
Sapan Bhatiadea39432014-06-13 03:10:36 -04006280
Scott Baker89a7b7c2014-10-07 00:10:17 -07006281class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006282 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04006283 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006284 id_serializer_class = RouterIdSerializer
6285
6286 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006287 no_hyperlinks=False
6288 if hasattr(self.request,"QUERY_PARAMS"):
6289 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006290 if (no_hyperlinks):
6291 return self.id_serializer_class
6292 else:
6293 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006294
Scott Baker0caeaf02014-06-19 11:12:55 -07006295 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006296 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006297 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006298 return Router.select_by_user(self.request.user)
6299
Scott Baker89a7b7c2014-10-07 00:10:17 -07006300 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07006301
Scott Baker89a7b7c2014-10-07 00:10:17 -07006302 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04006303
6304
6305
Scott Baker15af5652015-02-02 14:33:08 -08006306class ServiceResourceList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006307 queryset = ServiceResource.objects.select_related().all()
6308 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006309 id_serializer_class = ServiceResourceIdSerializer
6310 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker84cf39e2015-01-30 15:41:39 -08006311 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07006312
6313 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006314 no_hyperlinks=False
6315 if hasattr(self.request,"QUERY_PARAMS"):
6316 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006317 if (no_hyperlinks):
6318 return self.id_serializer_class
6319 else:
6320 return self.serializer_class
6321
Scott Baker0caeaf02014-06-19 11:12:55 -07006322 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006323 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006324 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006325 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04006326
Scott Baker0caeaf02014-06-19 11:12:55 -07006327 def create(self, request, *args, **kwargs):
Scott Baker57c725c2014-11-12 01:13:53 -08006328 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
6329 if not (serializer.is_valid()):
Scott Baker96eb3fd2014-11-25 00:53:25 -08006330 response = {"error": "validation",
6331 "specific_error": "not serializer.is_valid()",
6332 "reasons": serializer.errors}
6333 return Response(response, status=status.HTTP_400_BAD_REQUEST)
Scott Baker57c725c2014-11-12 01:13:53 -08006334 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07006335 obj.caller = request.user
6336 if obj.can_update(request.user):
6337 return super(ServiceResourceList, self).create(request, *args, **kwargs)
6338 else:
Scott Baker2bcbf372014-10-29 23:41:11 -07006339 raise Exception("failed obj.can_update")
6340
6341 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
6342 if (ret.status_code%100 != 200):
6343 raise Exception(ret.data)
6344
6345 return ret
6346
Scott Baker0caeaf02014-06-19 11:12:55 -07006347
Scott Baker89a7b7c2014-10-07 00:10:17 -07006348class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07006349 queryset = ServiceResource.objects.select_related().all()
6350 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07006351 id_serializer_class = ServiceResourceIdSerializer
6352
6353 def get_serializer_class(self):
Scott Baker84cf39e2015-01-30 15:41:39 -08006354 no_hyperlinks=False
6355 if hasattr(self.request,"QUERY_PARAMS"):
6356 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07006357 if (no_hyperlinks):
6358 return self.id_serializer_class
6359 else:
6360 return self.serializer_class
Scott Baker84cf39e2015-01-30 15:41:39 -08006361
Scott Baker0caeaf02014-06-19 11:12:55 -07006362 def get_queryset(self):
Scott Baker20101af2015-02-02 10:41:12 -08006363 if (not self.request.user.is_authenticated()):
Scott Baker4af864e2015-02-02 13:53:46 -08006364 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07006365 return ServiceResource.select_by_user(self.request.user)
6366
Scott Baker89a7b7c2014-10-07 00:10:17 -07006367 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07006368
Scott Baker89a7b7c2014-10-07 00:10:17 -07006369 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04006370
Sapan Bhatiadea39432014-06-13 03:10:36 -04006371
6372