blob: 8912903e6b52bcbeeb376c5fb7d22baff3a64405 [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07006from rest_framework import status
Scott Bakerf3816ac2014-11-12 01:13:53 -08007from rest_framework.generics import GenericAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04008from core.models import *
9from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -070010from rest_framework import filters
Scott Baker55a2e292014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Scott Bakercb60f8a2015-02-02 13:53:46 -080012from rest_framework.exceptions import PermissionDenied as RestFrameworkPermissionDenied
Scott Baker923f0962015-02-02 14:33:08 -080013from django.core.exceptions import PermissionDenied as DjangoPermissionDenied
Sapan Bhatiadea39432014-06-13 03:10:36 -040014
Scott Bakerc8af5752014-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 Baker08898c12014-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 Bakerf3816ac2014-11-12 01:13:53 -080026
Scott Baker08898c12014-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 Baker08898c12014-10-29 23:41:11 -070033 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040034"""
35
Scott Baker55a2e292014-11-10 16:31:15 -080036def get_REST_patterns():
37 return patterns('',
Scott Bakerdd442112015-02-02 15:53:37 -080038 url(r'^xos/$', api_root),
Scott Baker55a2e292014-11-10 16:31:15 -080039
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080042
Scott Bakerdd442112015-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 Bakerc1d11912014-12-22 09:29:05 -080045
Scott Bakerdd442112015-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 Bakeree9c5bf2015-01-12 13:16:39 -080048
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080051
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080054
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080057
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080060
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080063
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080066
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080069
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080072
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080075
Scott Bakerdd442112015-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 Bakeree9c5bf2015-01-12 13:16:39 -080078
Scott Bakerdd442112015-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 Bakeree9c5bf2015-01-12 13:16:39 -080081
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080084
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080087
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080090
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080093
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080096
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -080099
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800102
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800105
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800108
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800111
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800114
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800117
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800120
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800123
Scott Bakerdd442112015-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 Bakeree9c5bf2015-01-12 13:16:39 -0800126
Scott Bakerdd442112015-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 Baker196ffef2014-11-21 11:32:24 -0800129
Scott Bakerdd442112015-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 Bakeree9c5bf2015-01-12 13:16:39 -0800132
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800135
Scott Bakerdd442112015-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 Bakerc1d11912014-12-22 09:29:05 -0800138
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800141
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800144
Scott Bakerdd442112015-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 Bakerc1d11912014-12-22 09:29:05 -0800147
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800150
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800153
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800156
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800159
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800162
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800165
Scott Bakerdd442112015-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 Bakera6a0c772014-12-22 17:35:34 -0800168
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800171
Scott Bakerdd442112015-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 Bakerc1d11912014-12-22 09:29:05 -0800174
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800177
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800180
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800183
Scott Bakerdd442112015-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 Bakeree9c5bf2015-01-12 13:16:39 -0800186
Scott Bakerdd442112015-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 Bakerc1d11912014-12-22 09:29:05 -0800189
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800192
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800195
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800198
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800201
Scott Bakerdd442112015-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 Baker55a2e292014-11-10 16:31:15 -0800204
Scott Bakerdd442112015-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 Baker55a2e292014-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 Baker08898c12014-10-29 23:41:11 -0700213 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800214 'controllerimageses': reverse('controllerimages-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800215 'controllersiteprivileges': reverse('controllersiteprivilege-list', request=request, format=format),
Scott Baker08898c12014-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 Bakeree9c5bf2015-01-12 13:16:39 -0800225 'flavors': reverse('flavor-list', request=request, format=format),
226 'controllersites': reverse('controllersite-list', request=request, format=format),
Scott Baker08898c12014-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 Bakeree9c5bf2015-01-12 13:16:39 -0800232 'planetstacks': reverse('planetstack-list', request=request, format=format),
Scott Baker08898c12014-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 Bakeree9c5bf2015-01-12 13:16:39 -0800241 'controllernetworks': reverse('controllernetwork-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800242 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800243 'controllerusers': reverse('controlleruser-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700244 'reservedresources': reverse('reservedresource-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800245 'payments': reverse('payment-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700246 'networkslices': reverse('networkslice-list', request=request, format=format),
247 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800248 'controllers': reverse('controller-list', request=request, format=format),
Scott Baker08898c12014-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 Baker08898c12014-10-29 23:41:11 -0700253 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800254 'controllerslices': reverse('controllerslice-list', request=request, format=format),
Scott Bakera6a0c772014-12-22 17:35:34 -0800255 'controllerdashboardviews': reverse('controllerdashboardview-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700256 'accounts': reverse('account-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800257 'controllerroles': reverse('controllerrole-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700258 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
259 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800260 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800261 'controllersliceprivileges': reverse('controllersliceprivilege-list', request=request, format=format),
262 'sitedeployments': reverse('sitedeployment-list', request=request, format=format),
Scott Bakerc1d11912014-12-22 09:29:05 -0800263 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700264 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700265 'slicetags': reverse('slicetag-list', request=request, format=format),
Scott Bakera6a0c772014-12-22 17:35:34 -0800266 'networktemplates': reverse('networktemplate-list', request=request, format=format),
Scott Baker08898c12014-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 Bakerc1d11912014-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 Bakerdd442112015-02-02 15:53:37 -0800278 through table. In xos, most of the through tables we have
Scott Bakerc1d11912014-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 Bakerc8af5752014-12-23 11:12:07 -0800329 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700330
Scott Baker196ffef2014-11-21 11:32:24 -0800331 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800332 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800333 def getHumanReadableName(self, obj):
334 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800335 def getValidators(self, obj):
336 try:
337 return obj.getValidators()
338 except:
339 return None
Scott Baker08898c12014-10-29 23:41:11 -0700340 class Meta:
341 model = ServiceAttribute
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800344class ServiceAttributeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800345 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700346
Scott Baker196ffef2014-11-21 11:32:24 -0800347 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800348 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800349 def getHumanReadableName(self, obj):
350 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800351 def getValidators(self, obj):
352 try:
353 return obj.getValidators()
354 except:
355 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800356 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700357 model = ServiceAttribute
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800363class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800364 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800378
379class ControllerImagesIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800380 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800394
395
396
397
Scott Bakeree9c5bf2015-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 Baker5e140a32015-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 Bakeree9c5bf2015-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 Baker5e140a32015-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 Bakeree9c5bf2015-01-12 13:16:39 -0800429
430
431
432
Sapan Bhatiadea39432014-06-13 03:10:36 -0400433class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800434 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700435
Scott Baker93a79a92014-12-22 15:59:33 -0800436
437 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
438
439
Scott Baker196ffef2014-11-21 11:32:24 -0800440 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800441 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800442 def getHumanReadableName(self, obj):
443 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800444 def getValidators(self, obj):
445 try:
446 return obj.getValidators()
447 except:
448 return None
Scott Baker08898c12014-10-29 23:41:11 -0700449 class Meta:
450 model = Image
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800453class ImageIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800454 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700455
Scott Baker93a79a92014-12-22 15:59:33 -0800456
Scott Bakera3134fe2014-12-23 10:56:06 -0800457 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Baker93a79a92014-12-22 15:59:33 -0800458
459
Scott Baker196ffef2014-11-21 11:32:24 -0800460 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800461 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800462 def getHumanReadableName(self, obj):
463 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800464 def getValidators(self, obj):
465 try:
466 return obj.getValidators()
467 except:
468 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800469 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700470 model = Image
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -0800477 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700478
Scott Baker196ffef2014-11-21 11:32:24 -0800479 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800480 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800481 def getHumanReadableName(self, obj):
482 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800483 def getValidators(self, obj):
484 try:
485 return obj.getValidators()
486 except:
487 return None
Scott Baker08898c12014-10-29 23:41:11 -0700488 class Meta:
489 model = NetworkParameter
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800492class NetworkParameterIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800493 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700494
Scott Baker196ffef2014-11-21 11:32:24 -0800495 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800496 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800497 def getHumanReadableName(self, obj):
498 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800499 def getValidators(self, obj):
500 try:
501 return obj.getValidators()
502 except:
503 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800504 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700505 model = NetworkParameter
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -0800512 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700513
Scott Bakerc1d11912014-12-22 09:29:05 -0800514
515 deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail')
516
517
Scott Baker196ffef2014-11-21 11:32:24 -0800518 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800519 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800520 def getHumanReadableName(self, obj):
521 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800522 def getValidators(self, obj):
523 try:
524 return obj.getValidators()
525 except:
526 return None
Scott Baker08898c12014-10-29 23:41:11 -0700527 class Meta:
528 model = Site
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800531class SiteIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800532 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700533
Scott Bakerc1d11912014-12-22 09:29:05 -0800534
Scott Bakera3134fe2014-12-23 10:56:06 -0800535 deployments = serializers.PrimaryKeyRelatedField(many=True, queryset = Deployment.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -0800536
537
Scott Baker196ffef2014-11-21 11:32:24 -0800538 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800539 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800540 def getHumanReadableName(self, obj):
541 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800542 def getValidators(self, obj):
543 try:
544 return obj.getValidators()
545 except:
546 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800547 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700548 model = Site
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -0800555 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700556
Scott Baker196ffef2014-11-21 11:32:24 -0800557 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800558 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800559 def getHumanReadableName(self, obj):
560 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800561 def getValidators(self, obj):
562 try:
563 return obj.getValidators()
564 except:
565 return None
Scott Baker08898c12014-10-29 23:41:11 -0700566 class Meta:
567 model = SliceRole
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800570class SliceRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800571 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700572
Scott Baker196ffef2014-11-21 11:32:24 -0800573 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800574 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800575 def getHumanReadableName(self, obj):
576 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800577 def getValidators(self, obj):
578 try:
579 return obj.getValidators()
580 except:
581 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800582 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700583 model = SliceRole
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -0800590 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700591
Scott Baker196ffef2014-11-21 11:32:24 -0800592 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800593 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800594 def getHumanReadableName(self, obj):
595 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800596 def getValidators(self, obj):
597 try:
598 return obj.getValidators()
599 except:
600 return None
Scott Baker08898c12014-10-29 23:41:11 -0700601 class Meta:
602 model = Tag
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800605class TagIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800606 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700607
Scott Baker196ffef2014-11-21 11:32:24 -0800608 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800609 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800610 def getHumanReadableName(self, obj):
611 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800612 def getValidators(self, obj):
613 try:
614 return obj.getValidators()
615 except:
616 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800617 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700618 model = Tag
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -0800625 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700626
Scott Baker196ffef2014-11-21 11:32:24 -0800627 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800628 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800629 def getHumanReadableName(self, obj):
630 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800631 def getValidators(self, obj):
632 try:
633 return obj.getValidators()
634 except:
635 return None
Scott Baker08898c12014-10-29 23:41:11 -0700636 class Meta:
637 model = Invoice
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800640class InvoiceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800641 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700642
Scott Baker196ffef2014-11-21 11:32:24 -0800643 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800644 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800645 def getHumanReadableName(self, obj):
646 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800647 def getValidators(self, obj):
648 try:
649 return obj.getValidators()
650 except:
651 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800652 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700653 model = Invoice
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -0800660 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700661
Scott Baker196ffef2014-11-21 11:32:24 -0800662 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800663 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800664 def getHumanReadableName(self, obj):
665 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800666 def getValidators(self, obj):
667 try:
668 return obj.getValidators()
669 except:
670 return None
Scott Baker08898c12014-10-29 23:41:11 -0700671 class Meta:
672 model = SlicePrivilege
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800675class SlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800676 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700677
Scott Baker196ffef2014-11-21 11:32:24 -0800678 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800679 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800680 def getHumanReadableName(self, obj):
681 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800682 def getValidators(self, obj):
683 try:
684 return obj.getValidators()
685 except:
686 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800687 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700688 model = SlicePrivilege
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -0700694class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800695 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700696
Scott Baker196ffef2014-11-21 11:32:24 -0800697 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800698 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800699 def getHumanReadableName(self, obj):
700 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800701 def getValidators(self, obj):
702 try:
703 return obj.getValidators()
704 except:
705 return None
Scott Baker08898c12014-10-29 23:41:11 -0700706 class Meta:
707 model = PlanetStackRole
Scott Baker5e140a32015-01-30 15:41:39 -0800708 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700709
Scott Bakerc1d11912014-12-22 09:29:05 -0800710class PlanetStackRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800711 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700712
Scott Baker196ffef2014-11-21 11:32:24 -0800713 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800714 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800715 def getHumanReadableName(self, obj):
716 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800717 def getValidators(self, obj):
718 try:
719 return obj.getValidators()
720 except:
721 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800722 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700723 model = PlanetStackRole
Scott Baker5e140a32015-01-30 15:41:39 -0800724 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700725
726
727
728
Scott Baker0caeaf02014-06-19 11:12:55 -0700729class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800730 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700731
Scott Baker196ffef2014-11-21 11:32:24 -0800732 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800733 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800734 def getHumanReadableName(self, obj):
735 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800736 def getValidators(self, obj):
737 try:
738 return obj.getValidators()
739 except:
740 return None
Scott Baker08898c12014-10-29 23:41:11 -0700741 class Meta:
742 model = NetworkSliver
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800745class NetworkSliverIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800746 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700747
Scott Baker196ffef2014-11-21 11:32:24 -0800748 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800749 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800750 def getHumanReadableName(self, obj):
751 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800752 def getValidators(self, obj):
753 try:
754 return obj.getValidators()
755 except:
756 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800757 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700758 model = NetworkSliver
Scott Baker5e140a32015-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 Bakeree9c5bf2015-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 Baker5e140a32015-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 Bakeree9c5bf2015-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 Baker5e140a32015-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 Bakeree9c5bf2015-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 Baker5e140a32015-01-30 15:41:39 -0800821 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Bakeree9c5bf2015-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 Baker5e140a32015-01-30 15:41:39 -0800837 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Bakeree9c5bf2015-01-12 13:16:39 -0800838
839
840
841
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700842class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800843 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700844
Scott Baker196ffef2014-11-21 11:32:24 -0800845 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800846 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800847 def getHumanReadableName(self, obj):
848 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800849 def getValidators(self, obj):
850 try:
851 return obj.getValidators()
852 except:
853 return None
Scott Baker08898c12014-10-29 23:41:11 -0700854 class Meta:
855 model = Project
Scott Baker5e140a32015-01-30 15:41:39 -0800856 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700857
Scott Bakerc1d11912014-12-22 09:29:05 -0800858class ProjectIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800859 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700860
Scott Baker196ffef2014-11-21 11:32:24 -0800861 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800862 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800863 def getHumanReadableName(self, obj):
864 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800865 def getValidators(self, obj):
866 try:
867 return obj.getValidators()
868 except:
869 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800870 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700871 model = Project
Scott Baker5e140a32015-01-30 15:41:39 -0800872 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700873
874
875
876
Sapan Bhatiadea39432014-06-13 03:10:36 -0400877class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800878 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700879
880
881 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
882
883
884
Scott Baker08898c12014-10-29 23:41:11 -0700885 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
886
887
Scott Baker196ffef2014-11-21 11:32:24 -0800888 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800889 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800890 def getHumanReadableName(self, obj):
891 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800892 def getValidators(self, obj):
893 try:
894 return obj.getValidators()
895 except:
896 return None
Scott Baker08898c12014-10-29 23:41:11 -0700897 class Meta:
898 model = Slice
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800901class SliceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800902 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700903
904
Scott Bakera3134fe2014-12-23 10:56:06 -0800905 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700906
907
908
Scott Bakera3134fe2014-12-23 10:56:06 -0800909 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700910
911
Scott Baker196ffef2014-11-21 11:32:24 -0800912 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800913 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800914 def getHumanReadableName(self, obj):
915 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800916 def getValidators(self, obj):
917 try:
918 return obj.getValidators()
919 except:
920 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800921 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700922 model = Slice
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -0800929 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700930
931
Scott Bakerc1d11912014-12-22 09:29:05 -0800932 slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail')
Scott Baker08898c12014-10-29 23:41:11 -0700933
934
935
Scott Bakerc1d11912014-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 Baker08898c12014-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 Baker196ffef2014-11-21 11:32:24 -0800951 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800952 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800953 def getHumanReadableName(self, obj):
954 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800955 def getValidators(self, obj):
956 try:
957 return obj.getValidators()
958 except:
959 return None
Scott Baker08898c12014-10-29 23:41:11 -0700960 class Meta:
961 model = Network
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -0800964class NetworkIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -0800965 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -0700966
967
Scott Bakera3134fe2014-12-23 10:56:06 -0800968 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700969
970
971
Scott Bakera3134fe2014-12-23 10:56:06 -0800972 slices = serializers.PrimaryKeyRelatedField(many=True, queryset = Slice.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700973
974
975
Scott Bakera3134fe2014-12-23 10:56:06 -0800976 slivers = serializers.PrimaryKeyRelatedField(many=True, queryset = Sliver.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700977
978
979
Scott Bakera3134fe2014-12-23 10:56:06 -0800980 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -0800981
982
983
Scott Bakera3134fe2014-12-23 10:56:06 -0800984 routers = serializers.PrimaryKeyRelatedField(many=True, queryset = Router.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -0700985
986
Scott Baker196ffef2014-11-21 11:32:24 -0800987 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -0800988 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -0800989 def getHumanReadableName(self, obj):
990 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -0800991 def getValidators(self, obj):
992 try:
993 return obj.getValidators()
994 except:
995 return None
Scott Bakerc1d11912014-12-22 09:29:05 -0800996 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -0700997 model = Network
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08001004 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001005
Scott Baker196ffef2014-11-21 11:32:24 -08001006 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001007 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001008 def getHumanReadableName(self, obj):
1009 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001010 def getValidators(self, obj):
1011 try:
1012 return obj.getValidators()
1013 except:
1014 return None
Scott Baker08898c12014-10-29 23:41:11 -07001015 class Meta:
1016 model = Service
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001019class ServiceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001020 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001021
Scott Baker196ffef2014-11-21 11:32:24 -08001022 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001023 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001024 def getHumanReadableName(self, obj):
1025 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001026 def getValidators(self, obj):
1027 try:
1028 return obj.getValidators()
1029 except:
1030 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001031 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001032 model = Service
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08001039 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001040
Scott Baker196ffef2014-11-21 11:32:24 -08001041 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001042 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001043 def getHumanReadableName(self, obj):
1044 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001045 def getValidators(self, obj):
1046 try:
1047 return obj.getValidators()
1048 except:
1049 return None
Scott Baker08898c12014-10-29 23:41:11 -07001050 class Meta:
1051 model = ServiceClass
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001054class ServiceClassIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001055 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001056
Scott Baker196ffef2014-11-21 11:32:24 -08001057 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001058 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001059 def getHumanReadableName(self, obj):
1060 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001061 def getValidators(self, obj):
1062 try:
1063 return obj.getValidators()
1064 except:
1065 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001066 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001067 model = ServiceClass
Scott Baker5e140a32015-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 Bakeree9c5bf2015-01-12 13:16:39 -08001073class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001074 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001075
Scott Baker196ffef2014-11-21 11:32:24 -08001076 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001077 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001078 def getHumanReadableName(self, obj):
1079 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001080 def getValidators(self, obj):
1081 try:
1082 return obj.getValidators()
1083 except:
1084 return None
Scott Baker08898c12014-10-29 23:41:11 -07001085 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001086 model = PlanetStack
Scott Baker5e140a32015-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 Bakeree9c5bf2015-01-12 13:16:39 -08001089class PlanetStackIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001090 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001091
Scott Baker196ffef2014-11-21 11:32:24 -08001092 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001093 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001094 def getHumanReadableName(self, obj):
1095 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001096 def getValidators(self, obj):
1097 try:
1098 return obj.getValidators()
1099 except:
1100 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001101 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001102 model = PlanetStack
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08001109 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001110
Scott Baker196ffef2014-11-21 11:32:24 -08001111 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001112 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001113 def getHumanReadableName(self, obj):
1114 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001115 def getValidators(self, obj):
1116 try:
1117 return obj.getValidators()
1118 except:
1119 return None
Scott Baker08898c12014-10-29 23:41:11 -07001120 class Meta:
1121 model = Charge
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001124class ChargeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001125 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001126
Scott Baker196ffef2014-11-21 11:32:24 -08001127 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001128 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001129 def getHumanReadableName(self, obj):
1130 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001131 def getValidators(self, obj):
1132 try:
1133 return obj.getValidators()
1134 except:
1135 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001136 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001137 model = Charge
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08001144 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001145
Scott Baker196ffef2014-11-21 11:32:24 -08001146 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001147 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001148 def getHumanReadableName(self, obj):
1149 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001150 def getValidators(self, obj):
1151 try:
1152 return obj.getValidators()
1153 except:
1154 return None
Scott Baker08898c12014-10-29 23:41:11 -07001155 class Meta:
1156 model = Role
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001159class RoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001160 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001161
Scott Baker196ffef2014-11-21 11:32:24 -08001162 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001163 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001164 def getHumanReadableName(self, obj):
1165 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001166 def getValidators(self, obj):
1167 try:
1168 return obj.getValidators()
1169 except:
1170 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001171 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001172 model = Role
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08001179 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001180
Scott Baker196ffef2014-11-21 11:32:24 -08001181 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001182 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001183 def getHumanReadableName(self, obj):
1184 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001185 def getValidators(self, obj):
1186 try:
1187 return obj.getValidators()
1188 except:
1189 return None
Scott Baker08898c12014-10-29 23:41:11 -07001190 class Meta:
1191 model = UsableObject
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001194class UsableObjectIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001195 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001196
Scott Baker196ffef2014-11-21 11:32:24 -08001197 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001198 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001199 def getHumanReadableName(self, obj):
1200 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001201 def getValidators(self, obj):
1202 try:
1203 return obj.getValidators()
1204 except:
1205 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001206 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001207 model = UsableObject
Scott Baker5e140a32015-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 Bakeree9c5bf2015-01-12 13:16:39 -08001210
1211
1212
Scott Baker0caeaf02014-06-19 11:12:55 -07001213class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001214 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001215
Scott Baker196ffef2014-11-21 11:32:24 -08001216 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001217 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001218 def getHumanReadableName(self, obj):
1219 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001220 def getValidators(self, obj):
1221 try:
1222 return obj.getValidators()
1223 except:
1224 return None
Scott Baker08898c12014-10-29 23:41:11 -07001225 class Meta:
1226 model = SiteRole
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001229class SiteRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001230 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001231
Scott Baker196ffef2014-11-21 11:32:24 -08001232 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001233 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001234 def getHumanReadableName(self, obj):
1235 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001236 def getValidators(self, obj):
1237 try:
1238 return obj.getValidators()
1239 except:
1240 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001241 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001242 model = SiteRole
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -07001248class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001249 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001250
Scott Baker196ffef2014-11-21 11:32:24 -08001251 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001252 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001253 def getHumanReadableName(self, obj):
1254 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001255 def getValidators(self, obj):
1256 try:
1257 return obj.getValidators()
1258 except:
1259 return None
Scott Baker08898c12014-10-29 23:41:11 -07001260 class Meta:
1261 model = SliceCredential
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -07001263
Scott Bakerc1d11912014-12-22 09:29:05 -08001264class SliceCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001265 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001266
Scott Baker196ffef2014-11-21 11:32:24 -08001267 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001268 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001269 def getHumanReadableName(self, obj):
1270 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001271 def getValidators(self, obj):
1272 try:
1273 return obj.getValidators()
1274 except:
1275 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001276 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001277 model = SliceCredential
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -07001279
1280
1281
1282
Sapan Bhatiadea39432014-06-13 03:10:36 -04001283class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001284 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001285
1286
1287 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
1288
1289
Scott Baker196ffef2014-11-21 11:32:24 -08001290 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001291 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001292 def getHumanReadableName(self, obj):
1293 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001294 def getValidators(self, obj):
1295 try:
1296 return obj.getValidators()
1297 except:
1298 return None
Scott Baker08898c12014-10-29 23:41:11 -07001299 class Meta:
1300 model = Sliver
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001303class SliverIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001304 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001305
1306
Scott Bakera3134fe2014-12-23 10:56:06 -08001307 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -07001308
1309
Scott Baker196ffef2014-11-21 11:32:24 -08001310 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001311 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001312 def getHumanReadableName(self, obj):
1313 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001314 def getValidators(self, obj):
1315 try:
1316 return obj.getValidators()
1317 except:
1318 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001319 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001320 model = Sliver
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08001327 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001328
Scott Baker196ffef2014-11-21 11:32:24 -08001329 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001330 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001331 def getHumanReadableName(self, obj):
1332 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001333 def getValidators(self, obj):
1334 try:
1335 return obj.getValidators()
1336 except:
1337 return None
Scott Baker08898c12014-10-29 23:41:11 -07001338 class Meta:
1339 model = Node
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001342class NodeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001343 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001344
Scott Baker196ffef2014-11-21 11:32:24 -08001345 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001346 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001347 def getHumanReadableName(self, obj):
1348 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001349 def getValidators(self, obj):
1350 try:
1351 return obj.getValidators()
1352 except:
1353 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001354 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001355 model = Node
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08001362 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001363
Scott Bakerc1d11912014-12-22 09:29:05 -08001364
1365 controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail')
1366
1367
Scott Baker196ffef2014-11-21 11:32:24 -08001368 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001369 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001370 def getHumanReadableName(self, obj):
1371 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001372 def getValidators(self, obj):
1373 try:
1374 return obj.getValidators()
1375 except:
1376 return None
Scott Baker08898c12014-10-29 23:41:11 -07001377 class Meta:
1378 model = DashboardView
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001381class DashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001382 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001383
Scott Bakerc1d11912014-12-22 09:29:05 -08001384
Scott Bakera3134fe2014-12-23 10:56:06 -08001385 controllers = serializers.PrimaryKeyRelatedField(many=True, queryset = Controller.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08001386
1387
Scott Baker196ffef2014-11-21 11:32:24 -08001388 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001389 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001390 def getHumanReadableName(self, obj):
1391 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001392 def getValidators(self, obj):
1393 try:
1394 return obj.getValidators()
1395 except:
1396 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001397 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001398 model = DashboardView
Scott Baker5e140a32015-01-30 15:41:39 -08001399 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',)
Scott Baker196ffef2014-11-21 11:32:24 -08001400
1401
1402
1403
Scott Bakeree9c5bf2015-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 Baker5e140a32015-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 Bakeree9c5bf2015-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 Baker5e140a32015-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 Bakeree9c5bf2015-01-12 13:16:39 -08001435
1436
1437
1438
Scott Bakerc1d11912014-12-22 09:29:05 -08001439class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001440 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001441
1442 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001443 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001444 def getHumanReadableName(self, obj):
1445 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001446 def getValidators(self, obj):
1447 try:
1448 return obj.getValidators()
1449 except:
1450 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001451 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001452 model = ImageDeployments
Scott Baker5e140a32015-01-30 15:41:39 -08001453 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',)
Scott Baker196ffef2014-11-21 11:32:24 -08001454
Scott Bakerc1d11912014-12-22 09:29:05 -08001455class ImageDeploymentsIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001456 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001457
1458 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001459 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001460 def getHumanReadableName(self, obj):
1461 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001462 def getValidators(self, obj):
1463 try:
1464 return obj.getValidators()
1465 except:
1466 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001467 class Meta:
1468 model = ImageDeployments
Scott Baker5e140a32015-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 Bakeree9c5bf2015-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 Baker5e140a32015-01-30 15:41:39 -08001488 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Bakeree9c5bf2015-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 Baker5e140a32015-01-30 15:41:39 -08001504 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001505
1506
1507
1508
Scott Baker0caeaf02014-06-19 11:12:55 -07001509class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001510 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001511
Scott Baker196ffef2014-11-21 11:32:24 -08001512 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001513 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001514 def getHumanReadableName(self, obj):
1515 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001516 def getValidators(self, obj):
1517 try:
1518 return obj.getValidators()
1519 except:
1520 return None
Scott Baker08898c12014-10-29 23:41:11 -07001521 class Meta:
1522 model = ReservedResource
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001525class ReservedResourceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001526 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001527
Scott Baker196ffef2014-11-21 11:32:24 -08001528 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001529 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001530 def getHumanReadableName(self, obj):
1531 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001532 def getValidators(self, obj):
1533 try:
1534 return obj.getValidators()
1535 except:
1536 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001537 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001538 model = ReservedResource
Scott Baker5e140a32015-01-30 15:41:39 -08001539 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001540
1541
1542
1543
Scott Bakerc1d11912014-12-22 09:29:05 -08001544class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001545 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-01-30 15:41:39 -08001558 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Bakerc1d11912014-12-22 09:29:05 -08001559
1560class PaymentIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001561 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-01-30 15:41:39 -08001574 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Bakerc1d11912014-12-22 09:29:05 -08001575
1576
1577
1578
Scott Baker0caeaf02014-06-19 11:12:55 -07001579class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001580 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001581
Scott Baker196ffef2014-11-21 11:32:24 -08001582 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001583 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001584 def getHumanReadableName(self, obj):
1585 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001586 def getValidators(self, obj):
1587 try:
1588 return obj.getValidators()
1589 except:
1590 return None
Scott Baker08898c12014-10-29 23:41:11 -07001591 class Meta:
1592 model = NetworkSlice
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001595class NetworkSliceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001596 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001597
Scott Baker196ffef2014-11-21 11:32:24 -08001598 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001599 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001600 def getHumanReadableName(self, obj):
1601 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001602 def getValidators(self, obj):
1603 try:
1604 return obj.getValidators()
1605 except:
1606 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001607 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001608 model = NetworkSlice
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08001615 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001616
Scott Baker196ffef2014-11-21 11:32:24 -08001617 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001618 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001619 def getHumanReadableName(self, obj):
1620 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001621 def getValidators(self, obj):
1622 try:
1623 return obj.getValidators()
1624 except:
1625 return None
Scott Baker08898c12014-10-29 23:41:11 -07001626 class Meta:
1627 model = UserDashboardView
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001630class UserDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001631 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001632
Scott Baker196ffef2014-11-21 11:32:24 -08001633 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001634 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001635 def getHumanReadableName(self, obj):
1636 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001637 def getValidators(self, obj):
1638 try:
1639 return obj.getValidators()
1640 except:
Scott Bakerc1d11912014-12-22 09:29:05 -08001641 return None
1642 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001643 model = UserDashboardView
Scott Baker5e140a32015-01-30 15:41:39 -08001644 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001645
1646
1647
1648
Scott Bakerc1d11912014-12-22 09:29:05 -08001649class ControllerSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001650 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001651
Scott Bakerc1d11912014-12-22 09:29:05 -08001652
1653 dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail')
1654
1655
Scott Baker196ffef2014-11-21 11:32:24 -08001656 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001657 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerc1d11912014-12-22 09:29:05 -08001658 def getHumanReadableName(self, obj):
Scott Baker196ffef2014-11-21 11:32:24 -08001659 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001660 def getValidators(self, obj):
1661 try:
1662 return obj.getValidators()
1663 except:
1664 return None
Scott Baker08898c12014-10-29 23:41:11 -07001665 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08001666 model = Controller
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001669class ControllerIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001670 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001671
1672
Scott Bakera3134fe2014-12-23 10:56:06 -08001673 dashboardviews = serializers.PrimaryKeyRelatedField(many=True, queryset = DashboardView.objects.all())
Scott Baker08898c12014-10-29 23:41:11 -07001674
1675
Scott Baker196ffef2014-11-21 11:32:24 -08001676 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001677 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001678 def getHumanReadableName(self, obj):
1679 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001680 def getValidators(self, obj):
1681 try:
1682 return obj.getValidators()
1683 except:
1684 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001685 class Meta:
1686 model = Controller
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001688
1689
1690
1691
1692class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001693 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-01-30 15:41:39 -08001706 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Bakerc1d11912014-12-22 09:29:05 -08001707
1708class PlanetStackPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001709 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-01-30 15:41:39 -08001722 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Bakerc1d11912014-12-22 09:29:05 -08001723
1724
1725
1726
1727class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001728 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001742
1743class UserIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001744 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001758
1759
1760
1761
1762class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001763 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001764
1765
Scott Baker93a79a92014-12-22 15:59:33 -08001766 images = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='image-detail')
1767
1768
1769
Scott Bakerc1d11912014-12-22 09:29:05 -08001770 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1771
1772
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001773
1774 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1775
1776
Scott Bakerc1d11912014-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 Baker08898c12014-10-29 23:41:11 -07001786 class Meta:
1787 model = Deployment
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001790class DeploymentIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001791 id = IdField()
Scott Bakerc1d11912014-12-22 09:29:05 -08001792
1793
Scott Bakera3134fe2014-12-23 10:56:06 -08001794 images = serializers.PrimaryKeyRelatedField(many=True, queryset = Image.objects.all())
Scott Baker93a79a92014-12-22 15:59:33 -08001795
1796
1797
Scott Bakera3134fe2014-12-23 10:56:06 -08001798 sites = serializers.PrimaryKeyRelatedField(many=True, queryset = Site.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08001799
1800
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001801
1802 flavors = serializers.PrimaryKeyRelatedField(many=True, queryset = Flavor.objects.all())
1803
1804
Tony Mack336e0f92014-11-30 15:53:08 -05001805 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1806 validators = serializers.SerializerMethodField("getValidators")
Scott Bakerc1d11912014-12-22 09:29:05 -08001807 def getHumanReadableName(self, obj):
1808 return str(obj)
1809 def getValidators(self, obj):
Tony Mack336e0f92014-11-30 15:53:08 -05001810 try:
1811 return obj.getValidators()
1812 except:
Scott Bakerc1d11912014-12-22 09:29:05 -08001813 return None
1814 class Meta:
1815 model = Deployment
Scott Baker5e140a32015-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 Mack336e0f92014-11-30 15:53:08 -05001817
1818
Sapan Bhatiadea39432014-06-13 03:10:36 -04001819
1820
1821class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001822 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001823
Scott Baker196ffef2014-11-21 11:32:24 -08001824 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001825 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001826 def getHumanReadableName(self, obj):
1827 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001828 def getValidators(self, obj):
1829 try:
1830 return obj.getValidators()
1831 except:
1832 return None
Scott Baker08898c12014-10-29 23:41:11 -07001833 class Meta:
1834 model = Reservation
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001837class ReservationIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001838 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001839
Scott Baker196ffef2014-11-21 11:32:24 -08001840 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001841 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001842 def getHumanReadableName(self, obj):
1843 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001844 def getValidators(self, obj):
1845 try:
1846 return obj.getValidators()
1847 except:
1848 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001849 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001850 model = Reservation
Scott Baker5e140a32015-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 Baker196ffef2014-11-21 11:32:24 -08001856class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001857 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001858
1859 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001860 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001861 def getHumanReadableName(self, obj):
1862 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001863 def getValidators(self, obj):
1864 try:
1865 return obj.getValidators()
1866 except:
1867 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001868 class Meta:
1869 model = SitePrivilege
Scott Baker5e140a32015-01-30 15:41:39 -08001870 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001871
Scott Bakerc1d11912014-12-22 09:29:05 -08001872class SitePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001873 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001874
1875 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001876 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001877 def getHumanReadableName(self, obj):
1878 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001879 def getValidators(self, obj):
1880 try:
1881 return obj.getValidators()
1882 except:
1883 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001884 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -08001885 model = SitePrivilege
Scott Baker5e140a32015-01-30 15:41:39 -08001886 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Baker196ffef2014-11-21 11:32:24 -08001887
1888
1889
1890
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001891class ControllerSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001892 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001893
1894 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001895 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001896 def getHumanReadableName(self, obj):
1897 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001898 def getValidators(self, obj):
1899 try:
1900 return obj.getValidators()
1901 except:
1902 return None
Scott Baker196ffef2014-11-21 11:32:24 -08001903 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001904 model = ControllerSlice
Scott Baker5e140a32015-01-30 15:41:39 -08001905 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',)
Scott Baker196ffef2014-11-21 11:32:24 -08001906
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001907class ControllerSliceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001908 id = IdField()
Scott Baker196ffef2014-11-21 11:32:24 -08001909
1910 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001911 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001912 def getHumanReadableName(self, obj):
1913 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001914 def getValidators(self, obj):
1915 try:
1916 return obj.getValidators()
1917 except:
1918 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001919 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08001920 model = ControllerSlice
Scott Baker5e140a32015-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 Bakera6a0c772014-12-22 17:35:34 -08001926class ControllerDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001927 id = IdField()
Scott Bakera6a0c772014-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 Baker5e140a32015-01-30 15:41:39 -08001940 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakera6a0c772014-12-22 17:35:34 -08001941
1942class ControllerDashboardViewIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001943 id = IdField()
Scott Bakera6a0c772014-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 Baker5e140a32015-01-30 15:41:39 -08001956 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakera6a0c772014-12-22 17:35:34 -08001957
1958
1959
1960
Sapan Bhatiadea39432014-06-13 03:10:36 -04001961class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001962 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001963
Scott Baker196ffef2014-11-21 11:32:24 -08001964 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001965 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001966 def getHumanReadableName(self, obj):
1967 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001968 def getValidators(self, obj):
1969 try:
1970 return obj.getValidators()
1971 except:
1972 return None
Scott Baker08898c12014-10-29 23:41:11 -07001973 class Meta:
1974 model = Account
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001977class AccountIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001978 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07001979
Scott Baker196ffef2014-11-21 11:32:24 -08001980 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08001981 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08001982 def getHumanReadableName(self, obj):
1983 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08001984 def getValidators(self, obj):
1985 try:
1986 return obj.getValidators()
1987 except:
1988 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08001989 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07001990 model = Account
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08001996class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08001997 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-01-30 15:41:39 -08002010 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Bakerc1d11912014-12-22 09:29:05 -08002011
2012class ControllerRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002013 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-01-30 15:41:39 -08002026 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Bakerc1d11912014-12-22 09:29:05 -08002027
2028
2029
2030
Scott Baker0caeaf02014-06-19 11:12:55 -07002031class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002032 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002033
Scott Baker196ffef2014-11-21 11:32:24 -08002034 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002035 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002036 def getHumanReadableName(self, obj):
2037 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002038 def getValidators(self, obj):
2039 try:
2040 return obj.getValidators()
2041 except:
2042 return None
Scott Baker08898c12014-10-29 23:41:11 -07002043 class Meta:
2044 model = NetworkParameterType
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002047class NetworkParameterTypeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002048 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002049
Scott Baker196ffef2014-11-21 11:32:24 -08002050 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002051 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002052 def getHumanReadableName(self, obj):
2053 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002054 def getValidators(self, obj):
2055 try:
2056 return obj.getValidators()
2057 except:
2058 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002059 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002060 model = NetworkParameterType
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -07002066class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002067 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002068
Scott Baker196ffef2014-11-21 11:32:24 -08002069 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002070 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002071 def getHumanReadableName(self, obj):
2072 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002073 def getValidators(self, obj):
2074 try:
2075 return obj.getValidators()
2076 except:
2077 return None
Scott Baker08898c12014-10-29 23:41:11 -07002078 class Meta:
2079 model = SiteCredential
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002082class SiteCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002083 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002084
Scott Baker196ffef2014-11-21 11:32:24 -08002085 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002086 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002087 def getHumanReadableName(self, obj):
2088 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002089 def getValidators(self, obj):
2090 try:
2091 return obj.getValidators()
2092 except:
2093 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002094 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002095 model = SiteCredential
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002101class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002102 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002103
Scott Baker196ffef2014-11-21 11:32:24 -08002104 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002105 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002106 def getHumanReadableName(self, obj):
2107 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002108 def getValidators(self, obj):
2109 try:
2110 return obj.getValidators()
2111 except:
2112 return None
Scott Baker08898c12014-10-29 23:41:11 -07002113 class Meta:
Scott Bakerc1d11912014-12-22 09:29:05 -08002114 model = DeploymentPrivilege
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002117class DeploymentPrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002118 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002119
Scott Baker196ffef2014-11-21 11:32:24 -08002120 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002121 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002122 def getHumanReadableName(self, obj):
2123 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002124 def getValidators(self, obj):
2125 try:
2126 return obj.getValidators()
2127 except:
2128 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002129 class Meta:
2130 model = DeploymentPrivilege
Scott Baker5e140a32015-01-30 15:41:39 -08002131 fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',)
Scott Baker645dc9d2014-11-17 22:32:19 -08002132
2133
2134
2135
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002136class ControllerSlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002137 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002138
Scott Baker196ffef2014-11-21 11:32:24 -08002139 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002140 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002141 def getHumanReadableName(self, obj):
2142 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002143 def getValidators(self, obj):
2144 try:
2145 return obj.getValidators()
2146 except:
2147 return None
Scott Baker08898c12014-10-29 23:41:11 -07002148 class Meta:
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002149 model = ControllerSlicePrivilege
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002151
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002152class ControllerSlicePrivilegeIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002153 id = IdField()
Scott Bakerc1d11912014-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 Bakeree9c5bf2015-01-12 13:16:39 -08002165 model = ControllerSlicePrivilege
Scott Baker5e140a32015-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 Bakeree9c5bf2015-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 Baker5e140a32015-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 Bakeree9c5bf2015-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 Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002202
2203
2204
2205
2206class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002207 id = IdField()
Scott Bakerc1d11912014-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 Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002222class DeploymentRoleIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002223 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002224
Scott Baker196ffef2014-11-21 11:32:24 -08002225 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002226 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002227 def getHumanReadableName(self, obj):
2228 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002229 def getValidators(self, obj):
2230 try:
2231 return obj.getValidators()
2232 except:
2233 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002234 class Meta:
2235 model = DeploymentRole
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -07002241class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002242 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002243
Scott Baker196ffef2014-11-21 11:32:24 -08002244 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002245 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002246 def getHumanReadableName(self, obj):
2247 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002248 def getValidators(self, obj):
2249 try:
2250 return obj.getValidators()
2251 except:
2252 return None
Scott Baker08898c12014-10-29 23:41:11 -07002253 class Meta:
2254 model = UserCredential
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002257class UserCredentialIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002258 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002259
Scott Baker196ffef2014-11-21 11:32:24 -08002260 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002261 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002262 def getHumanReadableName(self, obj):
2263 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002264 def getValidators(self, obj):
2265 try:
2266 return obj.getValidators()
2267 except:
2268 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002269 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002270 model = UserCredential
Scott Baker5e140a32015-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 Baker196ffef2014-11-21 11:32:24 -08002272
2273
2274
2275
Scott Baker0caeaf02014-06-19 11:12:55 -07002276class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002277 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002278
Scott Baker196ffef2014-11-21 11:32:24 -08002279 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002280 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002281 def getHumanReadableName(self, obj):
2282 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002283 def getValidators(self, obj):
2284 try:
2285 return obj.getValidators()
2286 except:
2287 return None
Scott Baker08898c12014-10-29 23:41:11 -07002288 class Meta:
2289 model = SliceTag
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002292class SliceTagIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002293 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002294
Scott Baker196ffef2014-11-21 11:32:24 -08002295 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002296 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002297 def getHumanReadableName(self, obj):
2298 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002299 def getValidators(self, obj):
2300 try:
2301 return obj.getValidators()
2302 except:
2303 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002304 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002305 model = SliceTag
Scott Baker5e140a32015-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 Bakera6a0c772014-12-22 17:35:34 -08002311class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002312 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002313
Scott Baker196ffef2014-11-21 11:32:24 -08002314 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002315 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002316 def getHumanReadableName(self, obj):
2317 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002318 def getValidators(self, obj):
2319 try:
2320 return obj.getValidators()
2321 except:
2322 return None
Scott Baker08898c12014-10-29 23:41:11 -07002323 class Meta:
Scott Bakera6a0c772014-12-22 17:35:34 -08002324 model = NetworkTemplate
Scott Baker5e140a32015-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 Bakera6a0c772014-12-22 17:35:34 -08002327class NetworkTemplateIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002328 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002329
Scott Baker196ffef2014-11-21 11:32:24 -08002330 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002331 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002332 def getHumanReadableName(self, obj):
2333 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002334 def getValidators(self, obj):
2335 try:
2336 return obj.getValidators()
2337 except:
2338 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002339 class Meta:
Scott Bakera6a0c772014-12-22 17:35:34 -08002340 model = NetworkTemplate
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08002347 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002348
Scott Bakerc1d11912014-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 Baker196ffef2014-11-21 11:32:24 -08002357 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002358 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002359 def getHumanReadableName(self, obj):
2360 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002361 def getValidators(self, obj):
2362 try:
2363 return obj.getValidators()
2364 except:
2365 return None
Scott Baker08898c12014-10-29 23:41:11 -07002366 class Meta:
2367 model = Router
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002370class RouterIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002371 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002372
Scott Bakerc1d11912014-12-22 09:29:05 -08002373
Scott Bakera3134fe2014-12-23 10:56:06 -08002374 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08002375
2376
2377
Scott Bakera3134fe2014-12-23 10:56:06 -08002378 networks = serializers.PrimaryKeyRelatedField(many=True, queryset = Network.objects.all())
Scott Bakerc1d11912014-12-22 09:29:05 -08002379
2380
Scott Baker196ffef2014-11-21 11:32:24 -08002381 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002382 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002383 def getHumanReadableName(self, obj):
2384 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002385 def getValidators(self, obj):
2386 try:
2387 return obj.getValidators()
2388 except:
2389 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002390 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002391 model = Router
Scott Baker5e140a32015-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 Bakerc8af5752014-12-23 11:12:07 -08002398 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002399
Scott Baker196ffef2014-11-21 11:32:24 -08002400 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002401 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002402 def getHumanReadableName(self, obj):
2403 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002404 def getValidators(self, obj):
2405 try:
2406 return obj.getValidators()
2407 except:
2408 return None
Scott Baker08898c12014-10-29 23:41:11 -07002409 class Meta:
2410 model = ServiceResource
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002413class ServiceResourceIdSerializer(XOSModelSerializer):
Scott Bakerc8af5752014-12-23 11:12:07 -08002414 id = IdField()
Scott Baker08898c12014-10-29 23:41:11 -07002415
Scott Baker196ffef2014-11-21 11:32:24 -08002416 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
Scott Baker351148c2014-11-25 00:53:25 -08002417 validators = serializers.SerializerMethodField("getValidators")
Scott Baker196ffef2014-11-21 11:32:24 -08002418 def getHumanReadableName(self, obj):
2419 return str(obj)
Scott Baker351148c2014-11-25 00:53:25 -08002420 def getValidators(self, obj):
2421 try:
2422 return obj.getValidators()
2423 except:
2424 return None
Scott Bakerc1d11912014-12-22 09:29:05 -08002425 class Meta:
Scott Baker08898c12014-10-29 23:41:11 -07002426 model = ServiceResource
Scott Baker5e140a32015-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 Bakerc1d11912014-12-22 09:29:05 -08002436 ControllerImages: ControllerImagesSerializer,
2437
Scott Bakeree9c5bf2015-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 Bakerdcb9b5d2014-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 Bakeree9c5bf2015-01-12 13:16:39 -08002458 Flavor: FlavorSerializer,
2459
2460 ControllerSite: ControllerSiteSerializer,
2461
Scott Bakerdcb9b5d2014-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 Bakeree9c5bf2015-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 Bakerdcb9b5d2014-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 Bakeree9c5bf2015-01-12 13:16:39 -08002490 ControllerNetwork: ControllerNetworkSerializer,
2491
Scott Bakerc1d11912014-12-22 09:29:05 -08002492 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002493
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002494 ControllerUser: ControllerUserSerializer,
2495
Scott Baker196ffef2014-11-21 11:32:24 -08002496 ReservedResource: ReservedResourceSerializer,
Scott Baker645dc9d2014-11-17 22:32:19 -08002497
Scott Bakerc1d11912014-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 Bakerc1d11912014-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 Bakeree9c5bf2015-01-12 13:16:39 -08002516 ControllerSlice: ControllerSliceSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07002517
Scott Bakera6a0c772014-12-22 17:35:34 -08002518 ControllerDashboardView: ControllerDashboardViewSerializer,
2519
Sapan Bhatiadea39432014-06-13 03:10:36 -04002520 Account: AccountSerializer,
2521
Scott Bakerc1d11912014-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 Bakerdcb9b5d2014-10-07 00:10:17 -07002526 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002527
Scott Bakerc1d11912014-12-22 09:29:05 -08002528 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002529
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002530 ControllerSlicePrivilege: ControllerSlicePrivilegeSerializer,
2531
2532 SiteDeployment: SiteDeploymentSerializer,
Scott Bakerc1d11912014-12-22 09:29:05 -08002533
2534 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04002535
Scott Bakerdcb9b5d2014-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 Bakera6a0c772014-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 Bakerdcb9b5d2014-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 Baker351148c2014-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 Bakerdcb9b5d2014-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 Baker351148c2014-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 Bakerdcb9b5d2014-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:
Scott Bakercba0ffe2015-02-03 15:02:17 -08002582 raise Exception("Use the List API for creating objects")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002583
2584 self.object = serializer.save(force_update=True)
2585 self.post_save(self.object, created=False)
2586 return Response(serializer.data, status=status.HTTP_200_OK)
2587
2588 def destroy(self, request, *args, **kwargs):
2589 obj = self.get_object()
2590 if obj.can_update(request.user):
Scott Baker923f0962015-02-02 14:33:08 -08002591 return super(PlanetStackRetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002592 else:
2593 return Response(status=status.HTTP_400_BAD_REQUEST)
2594
Scott Baker923f0962015-02-02 14:33:08 -08002595 def handle_exception(self, exc):
2596 # REST API drops the string attached to Django's PermissionDenied
2597 # exception, and replaces it with a generic "Permission Denied"
2598 if isinstance(exc, DjangoPermissionDenied):
2599 response=Response({'detail': str(exc)}, status=status.HTTP_403_FORBIDDEN)
2600 response.exception=True
2601 return response
2602 else:
2603 return super(PlanetStackRetrieveUpdateDestroyAPIView, self).handle_exception(exc)
2604
2605class PlanetStackListCreateAPIView(generics.ListCreateAPIView):
2606 def handle_exception(self, exc):
2607 # REST API drops the string attached to Django's PermissionDenied
2608 # exception, and replaces it with a generic "Permission Denied"
2609 if isinstance(exc, DjangoPermissionDenied):
2610 response=Response({'detail': str(exc)}, status=status.HTTP_403_FORBIDDEN)
2611 response.exception=True
2612 return response
2613 else:
2614 return super(PlanetStackListCreateAPIView, self).handle_exception(exc)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002615
Scott Bakercba0ffe2015-02-03 15:02:17 -08002616 def create(self, request, *args, **kwargs):
2617 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2618 if not (serializer.is_valid()):
2619 response = {"error": "validation",
2620 "specific_error": "not serializer.is_valid()",
2621 "reasons": serializer.errors}
2622 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2623
2624 # now do XOS can_update permission checking
2625
2626 obj = serializer.object
2627 obj.caller = request.user
2628 if not obj.can_update(request.user):
2629 response = {"error": "validation",
2630 "specific_error": "failed can_update",
2631 "reasons": []}
2632 return Response(response, status=status.HTTP_400_BAD_REQUEST)
2633
2634 # stuff below is from generics.ListCreateAPIView
2635
2636 if (hasattr(self, "pre_save")):
2637 # rest_framework 2.x
2638 self.pre_save(serializer.object)
2639 self.object = serializer.save(force_insert=True)
2640 self.post_save(self.object, created=True)
2641 else:
2642 # rest_framework 3.x
2643 self.perform_create(serializer)
2644
2645 headers = self.get_success_headers(serializer.data)
2646 return Response(serializer.data, status=status.HTTP_201_CREATED,
2647 headers=headers)
2648
Sapan Bhatiadea39432014-06-13 03:10:36 -04002649# Based on core/views/*.py
2650
2651
Scott Baker923f0962015-02-02 14:33:08 -08002652class ServiceAttributeList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002653 queryset = ServiceAttribute.objects.select_related().all()
2654 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002655 id_serializer_class = ServiceAttributeIdSerializer
2656 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08002657 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -07002658
2659 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002660 no_hyperlinks=False
2661 if hasattr(self.request,"QUERY_PARAMS"):
2662 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002663 if (no_hyperlinks):
2664 return self.id_serializer_class
2665 else:
2666 return self.serializer_class
2667
Scott Baker0caeaf02014-06-19 11:12:55 -07002668 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002669 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002670 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002671 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002672
Scott Baker0caeaf02014-06-19 11:12:55 -07002673
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002674class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002675 queryset = ServiceAttribute.objects.select_related().all()
2676 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002677 id_serializer_class = ServiceAttributeIdSerializer
2678
2679 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002680 no_hyperlinks=False
2681 if hasattr(self.request,"QUERY_PARAMS"):
2682 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002683 if (no_hyperlinks):
2684 return self.id_serializer_class
2685 else:
2686 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08002687
Scott Baker0caeaf02014-06-19 11:12:55 -07002688 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002689 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002690 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002691 return ServiceAttribute.select_by_user(self.request.user)
2692
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002693 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002694
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002695 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002696
2697
2698
Scott Baker923f0962015-02-02 14:33:08 -08002699class ControllerImagesList(PlanetStackListCreateAPIView):
Scott Bakerc1d11912014-12-22 09:29:05 -08002700 queryset = ControllerImages.objects.select_related().all()
2701 serializer_class = ControllerImagesSerializer
2702 id_serializer_class = ControllerImagesIdSerializer
2703 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08002704 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','controller','glance_image_id',)
Scott Bakerc1d11912014-12-22 09:29:05 -08002705
2706 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002707 no_hyperlinks=False
2708 if hasattr(self.request,"QUERY_PARAMS"):
2709 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08002710 if (no_hyperlinks):
2711 return self.id_serializer_class
2712 else:
2713 return self.serializer_class
2714
2715 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002716 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002717 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08002718 return ControllerImages.select_by_user(self.request.user)
2719
Scott Bakerc1d11912014-12-22 09:29:05 -08002720
2721class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2722 queryset = ControllerImages.objects.select_related().all()
2723 serializer_class = ControllerImagesSerializer
2724 id_serializer_class = ControllerImagesIdSerializer
2725
2726 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002727 no_hyperlinks=False
2728 if hasattr(self.request,"QUERY_PARAMS"):
2729 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08002730 if (no_hyperlinks):
2731 return self.id_serializer_class
2732 else:
2733 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08002734
Scott Bakerc1d11912014-12-22 09:29:05 -08002735 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002736 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002737 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08002738 return ControllerImages.select_by_user(self.request.user)
2739
2740 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2741
2742 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2743
2744
2745
Scott Baker923f0962015-02-02 14:33:08 -08002746class ControllerSitePrivilegeList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002747 queryset = ControllerSitePrivilege.objects.select_related().all()
2748 serializer_class = ControllerSitePrivilegeSerializer
2749 id_serializer_class = ControllerSitePrivilegeIdSerializer
2750 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08002751 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','site_privilege','role_id',)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002752
2753 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002754 no_hyperlinks=False
2755 if hasattr(self.request,"QUERY_PARAMS"):
2756 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002757 if (no_hyperlinks):
2758 return self.id_serializer_class
2759 else:
2760 return self.serializer_class
2761
2762 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002763 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002764 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002765 return ControllerSitePrivilege.select_by_user(self.request.user)
2766
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002767
2768class ControllerSitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2769 queryset = ControllerSitePrivilege.objects.select_related().all()
2770 serializer_class = ControllerSitePrivilegeSerializer
2771 id_serializer_class = ControllerSitePrivilegeIdSerializer
2772
2773 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002774 no_hyperlinks=False
2775 if hasattr(self.request,"QUERY_PARAMS"):
2776 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002777 if (no_hyperlinks):
2778 return self.id_serializer_class
2779 else:
2780 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08002781
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002782 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002783 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002784 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08002785 return ControllerSitePrivilege.select_by_user(self.request.user)
2786
2787 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2788
2789 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2790
2791
2792
Scott Baker923f0962015-02-02 14:33:08 -08002793class ImageList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002794 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002795 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002796 id_serializer_class = ImageIdSerializer
2797 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08002798 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 -07002799
2800 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002801 no_hyperlinks=False
2802 if hasattr(self.request,"QUERY_PARAMS"):
2803 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002804 if (no_hyperlinks):
2805 return self.id_serializer_class
2806 else:
2807 return self.serializer_class
2808
Scott Baker0caeaf02014-06-19 11:12:55 -07002809 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002810 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002811 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002812 return Image.select_by_user(self.request.user)
2813
Sapan Bhatiadea39432014-06-13 03:10:36 -04002814
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002815class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002816 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002817 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002818 id_serializer_class = ImageIdSerializer
2819
2820 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002821 no_hyperlinks=False
2822 if hasattr(self.request,"QUERY_PARAMS"):
2823 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002824 if (no_hyperlinks):
2825 return self.id_serializer_class
2826 else:
2827 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08002828
Scott Baker0caeaf02014-06-19 11:12:55 -07002829 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002830 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002831 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002832 return Image.select_by_user(self.request.user)
2833
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002834 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002835
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002836 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002837
2838
2839
Scott Baker923f0962015-02-02 14:33:08 -08002840class NetworkParameterList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002841 queryset = NetworkParameter.objects.select_related().all()
2842 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002843 id_serializer_class = NetworkParameterIdSerializer
2844 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08002845 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 -07002846
2847 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002848 no_hyperlinks=False
2849 if hasattr(self.request,"QUERY_PARAMS"):
2850 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002851 if (no_hyperlinks):
2852 return self.id_serializer_class
2853 else:
2854 return self.serializer_class
2855
Scott Baker0caeaf02014-06-19 11:12:55 -07002856 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002857 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002858 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002859 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002860
Scott Baker0caeaf02014-06-19 11:12:55 -07002861
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002862class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002863 queryset = NetworkParameter.objects.select_related().all()
2864 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002865 id_serializer_class = NetworkParameterIdSerializer
2866
2867 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002868 no_hyperlinks=False
2869 if hasattr(self.request,"QUERY_PARAMS"):
2870 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002871 if (no_hyperlinks):
2872 return self.id_serializer_class
2873 else:
2874 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08002875
Scott Baker0caeaf02014-06-19 11:12:55 -07002876 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002877 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002878 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002879 return NetworkParameter.select_by_user(self.request.user)
2880
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002881 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002882
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002883 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002884
2885
2886
Scott Baker923f0962015-02-02 14:33:08 -08002887class SiteList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002888 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002889 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002890 id_serializer_class = SiteIdSerializer
2891 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08002892 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 -07002893
2894 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002895 no_hyperlinks=False
2896 if hasattr(self.request,"QUERY_PARAMS"):
2897 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002898 if (no_hyperlinks):
2899 return self.id_serializer_class
2900 else:
2901 return self.serializer_class
2902
Scott Baker0caeaf02014-06-19 11:12:55 -07002903 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002904 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002905 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002906 return Site.select_by_user(self.request.user)
2907
Sapan Bhatiadea39432014-06-13 03:10:36 -04002908
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002909class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002910 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002911 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002912 id_serializer_class = SiteIdSerializer
2913
2914 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002915 no_hyperlinks=False
2916 if hasattr(self.request,"QUERY_PARAMS"):
2917 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002918 if (no_hyperlinks):
2919 return self.id_serializer_class
2920 else:
2921 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08002922
Scott Baker0caeaf02014-06-19 11:12:55 -07002923 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002924 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002925 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002926 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002927
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002928 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002929
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002930 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002931
2932
2933
Scott Baker923f0962015-02-02 14:33:08 -08002934class SliceRoleList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002935 queryset = SliceRole.objects.select_related().all()
2936 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002937 id_serializer_class = SliceRoleIdSerializer
2938 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08002939 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07002940
2941 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002942 no_hyperlinks=False
2943 if hasattr(self.request,"QUERY_PARAMS"):
2944 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002945 if (no_hyperlinks):
2946 return self.id_serializer_class
2947 else:
2948 return self.serializer_class
2949
Scott Baker0caeaf02014-06-19 11:12:55 -07002950 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002951 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002952 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002953 return SliceRole.select_by_user(self.request.user)
2954
Scott Baker0caeaf02014-06-19 11:12:55 -07002955
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002956class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002957 queryset = SliceRole.objects.select_related().all()
2958 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002959 id_serializer_class = SliceRoleIdSerializer
2960
2961 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002962 no_hyperlinks=False
2963 if hasattr(self.request,"QUERY_PARAMS"):
2964 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002965 if (no_hyperlinks):
2966 return self.id_serializer_class
2967 else:
2968 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08002969
Scott Baker0caeaf02014-06-19 11:12:55 -07002970 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002971 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002972 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07002973 return SliceRole.select_by_user(self.request.user)
2974
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002975 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002976
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002977 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002978
2979
2980
Scott Baker923f0962015-02-02 14:33:08 -08002981class TagList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002982 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002983 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002984 id_serializer_class = TagIdSerializer
2985 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08002986 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 -07002987
2988 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08002989 no_hyperlinks=False
2990 if hasattr(self.request,"QUERY_PARAMS"):
2991 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07002992 if (no_hyperlinks):
2993 return self.id_serializer_class
2994 else:
2995 return self.serializer_class
2996
Scott Baker0caeaf02014-06-19 11:12:55 -07002997 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08002998 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08002999 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003000 return Tag.select_by_user(self.request.user)
3001
Sapan Bhatiadea39432014-06-13 03:10:36 -04003002
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003003class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003004 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003005 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003006 id_serializer_class = TagIdSerializer
3007
3008 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003009 no_hyperlinks=False
3010 if hasattr(self.request,"QUERY_PARAMS"):
3011 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003012 if (no_hyperlinks):
3013 return self.id_serializer_class
3014 else:
3015 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003016
Scott Baker0caeaf02014-06-19 11:12:55 -07003017 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003018 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003019 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003020 return Tag.select_by_user(self.request.user)
3021
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003022 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003023
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003024 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003025
3026
3027
Scott Baker923f0962015-02-02 14:33:08 -08003028class InvoiceList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003029 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003030 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003031 id_serializer_class = InvoiceIdSerializer
3032 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003033 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -07003034
3035 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003036 no_hyperlinks=False
3037 if hasattr(self.request,"QUERY_PARAMS"):
3038 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003039 if (no_hyperlinks):
3040 return self.id_serializer_class
3041 else:
3042 return self.serializer_class
3043
Scott Baker0caeaf02014-06-19 11:12:55 -07003044 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003045 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003046 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003047 return Invoice.select_by_user(self.request.user)
3048
Sapan Bhatiadea39432014-06-13 03:10:36 -04003049
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003050class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003051 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04003052 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003053 id_serializer_class = InvoiceIdSerializer
3054
3055 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003056 no_hyperlinks=False
3057 if hasattr(self.request,"QUERY_PARAMS"):
3058 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003059 if (no_hyperlinks):
3060 return self.id_serializer_class
3061 else:
3062 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003063
Scott Baker0caeaf02014-06-19 11:12:55 -07003064 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003065 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003066 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003067 return Invoice.select_by_user(self.request.user)
3068
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003069 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003070
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003071 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003072
3073
3074
Scott Baker923f0962015-02-02 14:33:08 -08003075class SlicePrivilegeList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003076 queryset = SlicePrivilege.objects.select_related().all()
3077 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003078 id_serializer_class = SlicePrivilegeIdSerializer
3079 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003080 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -07003081
3082 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003083 no_hyperlinks=False
3084 if hasattr(self.request,"QUERY_PARAMS"):
3085 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003086 if (no_hyperlinks):
3087 return self.id_serializer_class
3088 else:
3089 return self.serializer_class
3090
Scott Baker0caeaf02014-06-19 11:12:55 -07003091 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003092 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003093 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003094 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003095
Scott Baker0caeaf02014-06-19 11:12:55 -07003096
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003097class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003098 queryset = SlicePrivilege.objects.select_related().all()
3099 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003100 id_serializer_class = SlicePrivilegeIdSerializer
3101
3102 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003103 no_hyperlinks=False
3104 if hasattr(self.request,"QUERY_PARAMS"):
3105 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003106 if (no_hyperlinks):
3107 return self.id_serializer_class
3108 else:
3109 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003110
Scott Baker0caeaf02014-06-19 11:12:55 -07003111 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003112 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003113 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003114 return SlicePrivilege.select_by_user(self.request.user)
3115
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003116 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3117
3118 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3119
3120
3121
Scott Baker923f0962015-02-02 14:33:08 -08003122class PlanetStackRoleList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003123 queryset = PlanetStackRole.objects.select_related().all()
3124 serializer_class = PlanetStackRoleSerializer
3125 id_serializer_class = PlanetStackRoleIdSerializer
3126 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003127 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003128
3129 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003130 no_hyperlinks=False
3131 if hasattr(self.request,"QUERY_PARAMS"):
3132 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003133 if (no_hyperlinks):
3134 return self.id_serializer_class
3135 else:
3136 return self.serializer_class
3137
3138 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003139 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003140 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003141 return PlanetStackRole.select_by_user(self.request.user)
3142
Scott Baker0caeaf02014-06-19 11:12:55 -07003143
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003144class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3145 queryset = PlanetStackRole.objects.select_related().all()
3146 serializer_class = PlanetStackRoleSerializer
3147 id_serializer_class = PlanetStackRoleIdSerializer
3148
3149 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003150 no_hyperlinks=False
3151 if hasattr(self.request,"QUERY_PARAMS"):
3152 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003153 if (no_hyperlinks):
3154 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07003155 else:
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003156 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003157
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003158 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003159 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003160 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003161 return PlanetStackRole.select_by_user(self.request.user)
3162
3163 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3164
3165 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003166
3167
3168
Scott Baker923f0962015-02-02 14:33:08 -08003169class NetworkSliverList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003170 queryset = NetworkSliver.objects.select_related().all()
3171 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003172 id_serializer_class = NetworkSliverIdSerializer
3173 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003174 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -07003175
3176 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003177 no_hyperlinks=False
3178 if hasattr(self.request,"QUERY_PARAMS"):
3179 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003180 if (no_hyperlinks):
3181 return self.id_serializer_class
3182 else:
3183 return self.serializer_class
3184
Scott Baker0caeaf02014-06-19 11:12:55 -07003185 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003186 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003187 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003188 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003189
Scott Baker0caeaf02014-06-19 11:12:55 -07003190
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003191class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003192 queryset = NetworkSliver.objects.select_related().all()
3193 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003194 id_serializer_class = NetworkSliverIdSerializer
3195
3196 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003197 no_hyperlinks=False
3198 if hasattr(self.request,"QUERY_PARAMS"):
3199 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003200 if (no_hyperlinks):
3201 return self.id_serializer_class
3202 else:
3203 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003204
Scott Baker0caeaf02014-06-19 11:12:55 -07003205 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003206 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003207 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003208 return NetworkSliver.select_by_user(self.request.user)
3209
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003210 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07003211
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003212 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04003213
3214
3215
Scott Baker923f0962015-02-02 14:33:08 -08003216class FlavorList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003217 queryset = Flavor.objects.select_related().all()
3218 serializer_class = FlavorSerializer
3219 id_serializer_class = FlavorIdSerializer
3220 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003221 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','flavor','order','default','deployments',)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003222
3223 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003224 no_hyperlinks=False
3225 if hasattr(self.request,"QUERY_PARAMS"):
3226 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003227 if (no_hyperlinks):
3228 return self.id_serializer_class
3229 else:
3230 return self.serializer_class
3231
3232 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003233 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003234 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003235 return Flavor.select_by_user(self.request.user)
3236
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003237
3238class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3239 queryset = Flavor.objects.select_related().all()
3240 serializer_class = FlavorSerializer
3241 id_serializer_class = FlavorIdSerializer
3242
3243 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003244 no_hyperlinks=False
3245 if hasattr(self.request,"QUERY_PARAMS"):
3246 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003247 if (no_hyperlinks):
3248 return self.id_serializer_class
3249 else:
3250 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003251
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003252 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003253 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003254 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003255 return Flavor.select_by_user(self.request.user)
3256
3257 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3258
3259 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3260
3261
3262
Scott Baker923f0962015-02-02 14:33:08 -08003263class ControllerSiteList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003264 queryset = ControllerSite.objects.select_related().all()
3265 serializer_class = ControllerSiteSerializer
3266 id_serializer_class = ControllerSiteIdSerializer
3267 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003268 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','controller','tenant_id',)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003269
3270 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003271 no_hyperlinks=False
3272 if hasattr(self.request,"QUERY_PARAMS"):
3273 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003274 if (no_hyperlinks):
3275 return self.id_serializer_class
3276 else:
3277 return self.serializer_class
3278
3279 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003280 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003281 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003282 return ControllerSite.select_by_user(self.request.user)
3283
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003284
3285class ControllerSiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3286 queryset = ControllerSite.objects.select_related().all()
3287 serializer_class = ControllerSiteSerializer
3288 id_serializer_class = ControllerSiteIdSerializer
3289
3290 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003291 no_hyperlinks=False
3292 if hasattr(self.request,"QUERY_PARAMS"):
3293 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003294 if (no_hyperlinks):
3295 return self.id_serializer_class
3296 else:
3297 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003298
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003299 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003300 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003301 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003302 return ControllerSite.select_by_user(self.request.user)
3303
3304 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3305
3306 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3307
3308
3309
Scott Baker923f0962015-02-02 14:33:08 -08003310class ProjectList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003311 queryset = Project.objects.select_related().all()
3312 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003313 id_serializer_class = ProjectIdSerializer
3314 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003315 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -07003316
3317 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003318 no_hyperlinks=False
3319 if hasattr(self.request,"QUERY_PARAMS"):
3320 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003321 if (no_hyperlinks):
3322 return self.id_serializer_class
3323 else:
3324 return self.serializer_class
3325
Scott Baker0caeaf02014-06-19 11:12:55 -07003326 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003327 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003328 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003329 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04003330
Scott Baker0caeaf02014-06-19 11:12:55 -07003331
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003332class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07003333 queryset = Project.objects.select_related().all()
3334 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07003335 id_serializer_class = ProjectIdSerializer
3336
3337 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003338 no_hyperlinks=False
3339 if hasattr(self.request,"QUERY_PARAMS"):
3340 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07003341 if (no_hyperlinks):
3342 return self.id_serializer_class
3343 else:
3344 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003345
Scott Baker0caeaf02014-06-19 11:12:55 -07003346 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003347 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003348 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07003349 return Project.select_by_user(self.request.user)
3350
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003351 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3352
3353 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3354
3355
3356
Scott Baker923f0962015-02-02 14:33:08 -08003357class SliceList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003358 queryset = Slice.objects.select_related().all()
3359 serializer_class = SliceSerializer
3360 id_serializer_class = SliceIdSerializer
3361 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003362 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 Bakerdcb9b5d2014-10-07 00:10:17 -07003363
3364 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003365 no_hyperlinks=False
3366 if hasattr(self.request,"QUERY_PARAMS"):
3367 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003368 if (no_hyperlinks):
3369 return self.id_serializer_class
3370 else:
3371 return self.serializer_class
3372
3373 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003374 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003375 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003376 return Slice.select_by_user(self.request.user)
3377
Scott Baker0caeaf02014-06-19 11:12:55 -07003378
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003379class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3380 queryset = Slice.objects.select_related().all()
3381 serializer_class = SliceSerializer
3382 id_serializer_class = SliceIdSerializer
3383
3384 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003385 no_hyperlinks=False
3386 if hasattr(self.request,"QUERY_PARAMS"):
3387 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003388 if (no_hyperlinks):
3389 return self.id_serializer_class
3390 else:
3391 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003392
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003393 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003394 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003395 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003396 return Slice.select_by_user(self.request.user)
3397
3398 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3399
3400 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3401
3402
3403
Scott Baker923f0962015-02-02 14:33:08 -08003404class NetworkList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003405 queryset = Network.objects.select_related().all()
3406 serializer_class = NetworkSerializer
3407 id_serializer_class = NetworkIdSerializer
3408 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003409 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 Bakerdcb9b5d2014-10-07 00:10:17 -07003410
3411 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003412 no_hyperlinks=False
3413 if hasattr(self.request,"QUERY_PARAMS"):
3414 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003415 if (no_hyperlinks):
3416 return self.id_serializer_class
3417 else:
3418 return self.serializer_class
3419
3420 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003421 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003422 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003423 return Network.select_by_user(self.request.user)
3424
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003425
3426class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3427 queryset = Network.objects.select_related().all()
3428 serializer_class = NetworkSerializer
3429 id_serializer_class = NetworkIdSerializer
3430
3431 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003432 no_hyperlinks=False
3433 if hasattr(self.request,"QUERY_PARAMS"):
3434 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003435 if (no_hyperlinks):
3436 return self.id_serializer_class
3437 else:
3438 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003439
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003440 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003441 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003442 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003443 return Network.select_by_user(self.request.user)
3444
3445 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3446
3447 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3448
3449
3450
Scott Baker923f0962015-02-02 14:33:08 -08003451class ServiceList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003452 queryset = Service.objects.select_related().all()
3453 serializer_class = ServiceSerializer
3454 id_serializer_class = ServiceIdSerializer
3455 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003456 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003457
3458 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003459 no_hyperlinks=False
3460 if hasattr(self.request,"QUERY_PARAMS"):
3461 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003462 if (no_hyperlinks):
3463 return self.id_serializer_class
3464 else:
3465 return self.serializer_class
3466
3467 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003468 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003469 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003470 return Service.select_by_user(self.request.user)
3471
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003472
3473class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3474 queryset = Service.objects.select_related().all()
3475 serializer_class = ServiceSerializer
3476 id_serializer_class = ServiceIdSerializer
3477
3478 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003479 no_hyperlinks=False
3480 if hasattr(self.request,"QUERY_PARAMS"):
3481 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003482 if (no_hyperlinks):
3483 return self.id_serializer_class
3484 else:
3485 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003486
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003487 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003488 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003489 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003490 return Service.select_by_user(self.request.user)
3491
3492 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3493
3494 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3495
3496
3497
Scott Baker923f0962015-02-02 14:33:08 -08003498class ServiceClassList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003499 queryset = ServiceClass.objects.select_related().all()
3500 serializer_class = ServiceClassSerializer
3501 id_serializer_class = ServiceClassIdSerializer
3502 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003503 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003504
3505 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003506 no_hyperlinks=False
3507 if hasattr(self.request,"QUERY_PARAMS"):
3508 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003509 if (no_hyperlinks):
3510 return self.id_serializer_class
3511 else:
3512 return self.serializer_class
3513
3514 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003515 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003516 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003517 return ServiceClass.select_by_user(self.request.user)
3518
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003519
3520class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3521 queryset = ServiceClass.objects.select_related().all()
3522 serializer_class = ServiceClassSerializer
3523 id_serializer_class = ServiceClassIdSerializer
3524
3525 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003526 no_hyperlinks=False
3527 if hasattr(self.request,"QUERY_PARAMS"):
3528 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003529 if (no_hyperlinks):
3530 return self.id_serializer_class
3531 else:
3532 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003533
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003534 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003535 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003536 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003537 return ServiceClass.select_by_user(self.request.user)
3538
3539 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3540
3541 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3542
3543
3544
Scott Baker923f0962015-02-02 14:33:08 -08003545class PlanetStackList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003546 queryset = PlanetStack.objects.select_related().all()
3547 serializer_class = PlanetStackSerializer
3548 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003549 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003550 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','description',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003551
3552 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003553 no_hyperlinks=False
3554 if hasattr(self.request,"QUERY_PARAMS"):
3555 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003556 if (no_hyperlinks):
3557 return self.id_serializer_class
3558 else:
3559 return self.serializer_class
3560
3561 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003562 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003563 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003564 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003565
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003566
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003567class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3568 queryset = PlanetStack.objects.select_related().all()
3569 serializer_class = PlanetStackSerializer
3570 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003571
3572 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003573 no_hyperlinks=False
3574 if hasattr(self.request,"QUERY_PARAMS"):
3575 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003576 if (no_hyperlinks):
3577 return self.id_serializer_class
3578 else:
3579 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003580
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003581 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003582 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003583 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003584 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003585
3586 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3587
3588 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3589
3590
3591
Scott Baker923f0962015-02-02 14:33:08 -08003592class ChargeList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003593 queryset = Charge.objects.select_related().all()
3594 serializer_class = ChargeSerializer
3595 id_serializer_class = ChargeIdSerializer
3596 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003597 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003598
3599 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003600 no_hyperlinks=False
3601 if hasattr(self.request,"QUERY_PARAMS"):
3602 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003603 if (no_hyperlinks):
3604 return self.id_serializer_class
3605 else:
3606 return self.serializer_class
3607
3608 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003609 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003610 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003611 return Charge.select_by_user(self.request.user)
3612
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003613
3614class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3615 queryset = Charge.objects.select_related().all()
3616 serializer_class = ChargeSerializer
3617 id_serializer_class = ChargeIdSerializer
3618
3619 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003620 no_hyperlinks=False
3621 if hasattr(self.request,"QUERY_PARAMS"):
3622 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003623 if (no_hyperlinks):
3624 return self.id_serializer_class
3625 else:
3626 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003627
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003628 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003629 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003630 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003631 return Charge.select_by_user(self.request.user)
3632
3633 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3634
3635 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3636
3637
3638
Scott Baker923f0962015-02-02 14:33:08 -08003639class RoleList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003640 queryset = Role.objects.select_related().all()
3641 serializer_class = RoleSerializer
3642 id_serializer_class = RoleIdSerializer
3643 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003644 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role_type','role','description','content_type',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003645
3646 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003647 no_hyperlinks=False
3648 if hasattr(self.request,"QUERY_PARAMS"):
3649 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003650 if (no_hyperlinks):
3651 return self.id_serializer_class
3652 else:
3653 return self.serializer_class
3654
3655 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003656 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003657 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003658 return Role.select_by_user(self.request.user)
3659
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003660
3661class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3662 queryset = Role.objects.select_related().all()
3663 serializer_class = RoleSerializer
3664 id_serializer_class = RoleIdSerializer
3665
3666 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003667 no_hyperlinks=False
3668 if hasattr(self.request,"QUERY_PARAMS"):
3669 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003670 if (no_hyperlinks):
3671 return self.id_serializer_class
3672 else:
3673 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003674
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003675 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003676 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003677 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003678 return Role.select_by_user(self.request.user)
3679
3680 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3681
3682 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3683
3684
3685
Scott Baker923f0962015-02-02 14:33:08 -08003686class UsableObjectList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003687 queryset = UsableObject.objects.select_related().all()
3688 serializer_class = UsableObjectSerializer
3689 id_serializer_class = UsableObjectIdSerializer
3690 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003691 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003692
3693 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003694 no_hyperlinks=False
3695 if hasattr(self.request,"QUERY_PARAMS"):
3696 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003697 if (no_hyperlinks):
3698 return self.id_serializer_class
3699 else:
3700 return self.serializer_class
3701
3702 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003703 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003704 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003705 return UsableObject.select_by_user(self.request.user)
3706
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003707
3708class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3709 queryset = UsableObject.objects.select_related().all()
3710 serializer_class = UsableObjectSerializer
3711 id_serializer_class = UsableObjectIdSerializer
3712
3713 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003714 no_hyperlinks=False
3715 if hasattr(self.request,"QUERY_PARAMS"):
3716 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003717 if (no_hyperlinks):
3718 return self.id_serializer_class
3719 else:
3720 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003721
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003722 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003723 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003724 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003725 return UsableObject.select_by_user(self.request.user)
3726
3727 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3728
3729 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3730
3731
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003732
Scott Baker923f0962015-02-02 14:33:08 -08003733class SiteRoleList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003734 queryset = SiteRole.objects.select_related().all()
3735 serializer_class = SiteRoleSerializer
3736 id_serializer_class = SiteRoleIdSerializer
3737 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003738 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003739
3740 def get_serializer_class(self):
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -07003744 if (no_hyperlinks):
3745 return self.id_serializer_class
3746 else:
3747 return self.serializer_class
3748
3749 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003750 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003751 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003752 return SiteRole.select_by_user(self.request.user)
3753
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003754
3755class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3756 queryset = SiteRole.objects.select_related().all()
3757 serializer_class = SiteRoleSerializer
3758 id_serializer_class = SiteRoleIdSerializer
3759
3760 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003761 no_hyperlinks=False
3762 if hasattr(self.request,"QUERY_PARAMS"):
3763 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003764 if (no_hyperlinks):
3765 return self.id_serializer_class
3766 else:
3767 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003768
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003769 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003770 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003771 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003772 return SiteRole.select_by_user(self.request.user)
3773
3774 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3775
3776 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3777
3778
3779
Scott Baker923f0962015-02-02 14:33:08 -08003780class SliceCredentialList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003781 queryset = SliceCredential.objects.select_related().all()
3782 serializer_class = SliceCredentialSerializer
3783 id_serializer_class = SliceCredentialIdSerializer
3784 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003785 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003786
3787 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003788 no_hyperlinks=False
3789 if hasattr(self.request,"QUERY_PARAMS"):
3790 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003791 if (no_hyperlinks):
3792 return self.id_serializer_class
3793 else:
3794 return self.serializer_class
3795
3796 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003797 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003798 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003799 return SliceCredential.select_by_user(self.request.user)
3800
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003801
3802class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3803 queryset = SliceCredential.objects.select_related().all()
3804 serializer_class = SliceCredentialSerializer
3805 id_serializer_class = SliceCredentialIdSerializer
3806
3807 def get_serializer_class(self):
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -07003811 if (no_hyperlinks):
3812 return self.id_serializer_class
3813 else:
3814 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003815
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003816 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003817 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003818 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003819 return SliceCredential.select_by_user(self.request.user)
3820
3821 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3822
3823 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3824
3825
3826
Scott Baker923f0962015-02-02 14:33:08 -08003827class SliverList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003828 queryset = Sliver.objects.select_related().all()
3829 serializer_class = SliverSerializer
3830 id_serializer_class = SliverIdSerializer
3831 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003832 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 Bakerdcb9b5d2014-10-07 00:10:17 -07003833
3834 def get_serializer_class(self):
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-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 Baker960431e2015-02-02 10:41:12 -08003844 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003845 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003846 return Sliver.select_by_user(self.request.user)
3847
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003848
3849class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3850 queryset = Sliver.objects.select_related().all()
3851 serializer_class = SliverSerializer
3852 id_serializer_class = SliverIdSerializer
3853
3854 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003855 no_hyperlinks=False
3856 if hasattr(self.request,"QUERY_PARAMS"):
3857 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003858 if (no_hyperlinks):
3859 return self.id_serializer_class
3860 else:
3861 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003862
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003863 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003864 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003865 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003866 return Sliver.select_by_user(self.request.user)
3867
3868 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3869
3870 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3871
3872
3873
Scott Baker923f0962015-02-02 14:33:08 -08003874class NodeList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003875 queryset = Node.objects.select_related().all()
3876 serializer_class = NodeSerializer
3877 id_serializer_class = NodeIdSerializer
3878 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003879 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','site_deployment','site',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003880
3881 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003882 no_hyperlinks=False
3883 if hasattr(self.request,"QUERY_PARAMS"):
3884 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003885 if (no_hyperlinks):
3886 return self.id_serializer_class
3887 else:
3888 return self.serializer_class
3889
3890 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003891 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003892 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003893 return Node.select_by_user(self.request.user)
3894
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003895
3896class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3897 queryset = Node.objects.select_related().all()
3898 serializer_class = NodeSerializer
3899 id_serializer_class = NodeIdSerializer
3900
3901 def get_serializer_class(self):
Scott Baker5e140a32015-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 Bakerdcb9b5d2014-10-07 00:10:17 -07003905 if (no_hyperlinks):
3906 return self.id_serializer_class
3907 else:
3908 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003909
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003910 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003911 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003912 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003913 return Node.select_by_user(self.request.user)
3914
3915 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3916
3917 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3918
3919
3920
Scott Baker923f0962015-02-02 14:33:08 -08003921class DashboardViewList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003922 queryset = DashboardView.objects.select_related().all()
3923 serializer_class = DashboardViewSerializer
3924 id_serializer_class = DashboardViewIdSerializer
3925 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003926 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','url','enabled','controllers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003927
3928 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003929 no_hyperlinks=False
3930 if hasattr(self.request,"QUERY_PARAMS"):
3931 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003932 if (no_hyperlinks):
3933 return self.id_serializer_class
3934 else:
3935 return self.serializer_class
3936
3937 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003938 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003939 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003940 return DashboardView.select_by_user(self.request.user)
3941
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003942
3943class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3944 queryset = DashboardView.objects.select_related().all()
3945 serializer_class = DashboardViewSerializer
3946 id_serializer_class = DashboardViewIdSerializer
3947
3948 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003949 no_hyperlinks=False
3950 if hasattr(self.request,"QUERY_PARAMS"):
3951 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003952 if (no_hyperlinks):
3953 return self.id_serializer_class
3954 else:
3955 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08003956
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003957 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003958 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003959 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003960 return DashboardView.select_by_user(self.request.user)
3961
3962 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3963
3964 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3965
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003966
Scott Bakerf3816ac2014-11-12 01:13:53 -08003967
Scott Baker923f0962015-02-02 14:33:08 -08003968class ControllerNetworkList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003969 queryset = ControllerNetwork.objects.select_related().all()
3970 serializer_class = ControllerNetworkSerializer
3971 id_serializer_class = ControllerNetworkIdSerializer
3972 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08003973 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003974
3975 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003976 no_hyperlinks=False
3977 if hasattr(self.request,"QUERY_PARAMS"):
3978 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003979 if (no_hyperlinks):
3980 return self.id_serializer_class
3981 else:
3982 return self.serializer_class
3983
3984 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08003985 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08003986 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003987 return ControllerNetwork.select_by_user(self.request.user)
3988
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003989
3990class ControllerNetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3991 queryset = ControllerNetwork.objects.select_related().all()
3992 serializer_class = ControllerNetworkSerializer
3993 id_serializer_class = ControllerNetworkIdSerializer
3994
3995 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08003996 no_hyperlinks=False
3997 if hasattr(self.request,"QUERY_PARAMS"):
3998 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08003999 if (no_hyperlinks):
4000 return self.id_serializer_class
4001 else:
4002 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004003
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004004 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004005 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004006 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004007 return ControllerNetwork.select_by_user(self.request.user)
4008
4009 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4010
4011 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4012
4013
4014
Scott Baker923f0962015-02-02 14:33:08 -08004015class ImageDeploymentsList(PlanetStackListCreateAPIView):
Scott Bakerc1d11912014-12-22 09:29:05 -08004016 queryset = ImageDeployments.objects.select_related().all()
4017 serializer_class = ImageDeploymentsSerializer
4018 id_serializer_class = ImageDeploymentsIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004019 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004020 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','image','deployment',)
Scott Baker196ffef2014-11-21 11:32:24 -08004021
4022 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004023 no_hyperlinks=False
4024 if hasattr(self.request,"QUERY_PARAMS"):
4025 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker196ffef2014-11-21 11:32:24 -08004026 if (no_hyperlinks):
4027 return self.id_serializer_class
4028 else:
4029 return self.serializer_class
4030
4031 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004032 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004033 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004034 return ImageDeployments.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004035
Scott Baker196ffef2014-11-21 11:32:24 -08004036
Scott Bakerc1d11912014-12-22 09:29:05 -08004037class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4038 queryset = ImageDeployments.objects.select_related().all()
4039 serializer_class = ImageDeploymentsSerializer
4040 id_serializer_class = ImageDeploymentsIdSerializer
Scott Baker196ffef2014-11-21 11:32:24 -08004041
4042 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004043 no_hyperlinks=False
4044 if hasattr(self.request,"QUERY_PARAMS"):
4045 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker196ffef2014-11-21 11:32:24 -08004046 if (no_hyperlinks):
4047 return self.id_serializer_class
4048 else:
4049 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004050
Scott Baker196ffef2014-11-21 11:32:24 -08004051 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004052 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004053 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004054 return ImageDeployments.select_by_user(self.request.user)
Scott Baker196ffef2014-11-21 11:32:24 -08004055
4056 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4057
4058 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4059
Scott Baker196ffef2014-11-21 11:32:24 -08004060
4061
Scott Baker923f0962015-02-02 14:33:08 -08004062class ControllerUserList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004063 queryset = ControllerUser.objects.select_related().all()
4064 serializer_class = ControllerUserSerializer
4065 id_serializer_class = ControllerUserIdSerializer
4066 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004067 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','controller','kuser_id',)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004068
4069 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004070 no_hyperlinks=False
4071 if hasattr(self.request,"QUERY_PARAMS"):
4072 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004073 if (no_hyperlinks):
4074 return self.id_serializer_class
4075 else:
4076 return self.serializer_class
4077
4078 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004079 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004080 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004081 return ControllerUser.select_by_user(self.request.user)
4082
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004083
4084class ControllerUserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4085 queryset = ControllerUser.objects.select_related().all()
4086 serializer_class = ControllerUserSerializer
4087 id_serializer_class = ControllerUserIdSerializer
4088
4089 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004090 no_hyperlinks=False
4091 if hasattr(self.request,"QUERY_PARAMS"):
4092 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004093 if (no_hyperlinks):
4094 return self.id_serializer_class
4095 else:
4096 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004097
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004098 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004099 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004100 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004101 return ControllerUser.select_by_user(self.request.user)
4102
4103 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4104
4105 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4106
4107
4108
Scott Baker923f0962015-02-02 14:33:08 -08004109class ReservedResourceList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004110 queryset = ReservedResource.objects.select_related().all()
4111 serializer_class = ReservedResourceSerializer
4112 id_serializer_class = ReservedResourceIdSerializer
4113 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004114 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004115
4116 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004117 no_hyperlinks=False
4118 if hasattr(self.request,"QUERY_PARAMS"):
4119 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004120 if (no_hyperlinks):
4121 return self.id_serializer_class
4122 else:
4123 return self.serializer_class
4124
4125 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004126 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004127 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004128 return ReservedResource.select_by_user(self.request.user)
4129
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004130
4131class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4132 queryset = ReservedResource.objects.select_related().all()
4133 serializer_class = ReservedResourceSerializer
4134 id_serializer_class = ReservedResourceIdSerializer
4135
4136 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004137 no_hyperlinks=False
4138 if hasattr(self.request,"QUERY_PARAMS"):
4139 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004140 if (no_hyperlinks):
4141 return self.id_serializer_class
4142 else:
4143 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004144
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004145 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004146 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004147 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004148 return ReservedResource.select_by_user(self.request.user)
4149
4150 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4151
4152 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4153
4154
4155
Scott Baker923f0962015-02-02 14:33:08 -08004156class PaymentList(PlanetStackListCreateAPIView):
Scott Bakerc1d11912014-12-22 09:29:05 -08004157 queryset = Payment.objects.select_related().all()
4158 serializer_class = PaymentSerializer
4159 id_serializer_class = PaymentIdSerializer
4160 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004161 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','account','amount','date',)
Scott Bakerc1d11912014-12-22 09:29:05 -08004162
4163 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004164 no_hyperlinks=False
4165 if hasattr(self.request,"QUERY_PARAMS"):
4166 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08004167 if (no_hyperlinks):
4168 return self.id_serializer_class
4169 else:
4170 return self.serializer_class
4171
4172 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004173 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004174 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004175 return Payment.select_by_user(self.request.user)
4176
Scott Bakerc1d11912014-12-22 09:29:05 -08004177
4178class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4179 queryset = Payment.objects.select_related().all()
4180 serializer_class = PaymentSerializer
4181 id_serializer_class = PaymentIdSerializer
4182
4183 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004184 no_hyperlinks=False
4185 if hasattr(self.request,"QUERY_PARAMS"):
4186 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08004187 if (no_hyperlinks):
4188 return self.id_serializer_class
4189 else:
4190 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004191
Scott Bakerc1d11912014-12-22 09:29:05 -08004192 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004193 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004194 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004195 return Payment.select_by_user(self.request.user)
4196
4197 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4198
4199 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4200
4201
4202
Scott Baker923f0962015-02-02 14:33:08 -08004203class NetworkSliceList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004204 queryset = NetworkSlice.objects.select_related().all()
4205 serializer_class = NetworkSliceSerializer
4206 id_serializer_class = NetworkSliceIdSerializer
4207 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004208 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','network','slice',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004209
4210 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004211 no_hyperlinks=False
4212 if hasattr(self.request,"QUERY_PARAMS"):
4213 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004214 if (no_hyperlinks):
4215 return self.id_serializer_class
4216 else:
4217 return self.serializer_class
4218
4219 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004220 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004221 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004222 return NetworkSlice.select_by_user(self.request.user)
4223
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004224
4225class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4226 queryset = NetworkSlice.objects.select_related().all()
4227 serializer_class = NetworkSliceSerializer
4228 id_serializer_class = NetworkSliceIdSerializer
4229
4230 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004231 no_hyperlinks=False
4232 if hasattr(self.request,"QUERY_PARAMS"):
4233 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004234 if (no_hyperlinks):
4235 return self.id_serializer_class
4236 else:
4237 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004238
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004239 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004240 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004241 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004242 return NetworkSlice.select_by_user(self.request.user)
4243
4244 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4245
4246 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4247
4248
4249
Scott Baker923f0962015-02-02 14:33:08 -08004250class UserDashboardViewList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004251 queryset = UserDashboardView.objects.select_related().all()
4252 serializer_class = UserDashboardViewSerializer
4253 id_serializer_class = UserDashboardViewIdSerializer
4254 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004255 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','dashboardView','order',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004256
4257 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004258 no_hyperlinks=False
4259 if hasattr(self.request,"QUERY_PARAMS"):
4260 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004261 if (no_hyperlinks):
4262 return self.id_serializer_class
4263 else:
4264 return self.serializer_class
4265
4266 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004267 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004268 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004269 return UserDashboardView.select_by_user(self.request.user)
4270
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004271
4272class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4273 queryset = UserDashboardView.objects.select_related().all()
4274 serializer_class = UserDashboardViewSerializer
4275 id_serializer_class = UserDashboardViewIdSerializer
4276
4277 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004278 no_hyperlinks=False
4279 if hasattr(self.request,"QUERY_PARAMS"):
4280 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004281 if (no_hyperlinks):
4282 return self.id_serializer_class
4283 else:
4284 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004285
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004286 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004287 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004288 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004289 return UserDashboardView.select_by_user(self.request.user)
4290
4291 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4292
4293 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4294
4295
4296
Scott Baker923f0962015-02-02 14:33:08 -08004297class ControllerList(PlanetStackListCreateAPIView):
Scott Bakerc1d11912014-12-22 09:29:05 -08004298 queryset = Controller.objects.select_related().all()
4299 serializer_class = ControllerSerializer
4300 id_serializer_class = ControllerIdSerializer
4301 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004302 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 Bakerc1d11912014-12-22 09:29:05 -08004303
4304 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004305 no_hyperlinks=False
4306 if hasattr(self.request,"QUERY_PARAMS"):
4307 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08004308 if (no_hyperlinks):
4309 return self.id_serializer_class
4310 else:
4311 return self.serializer_class
4312
4313 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004314 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004315 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004316 return Controller.select_by_user(self.request.user)
4317
Scott Bakerc1d11912014-12-22 09:29:05 -08004318
4319class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4320 queryset = Controller.objects.select_related().all()
4321 serializer_class = ControllerSerializer
4322 id_serializer_class = ControllerIdSerializer
4323
4324 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004325 no_hyperlinks=False
4326 if hasattr(self.request,"QUERY_PARAMS"):
4327 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08004328 if (no_hyperlinks):
4329 return self.id_serializer_class
4330 else:
4331 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004332
Scott Bakerc1d11912014-12-22 09:29:05 -08004333 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004334 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004335 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004336 return Controller.select_by_user(self.request.user)
4337
4338 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4339
4340 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4341
4342
4343
Scott Baker923f0962015-02-02 14:33:08 -08004344class PlanetStackPrivilegeList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004345 queryset = PlanetStackPrivilege.objects.select_related().all()
4346 serializer_class = PlanetStackPrivilegeSerializer
4347 id_serializer_class = PlanetStackPrivilegeIdSerializer
4348 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004349 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','planetstack','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004350
4351 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004352 no_hyperlinks=False
4353 if hasattr(self.request,"QUERY_PARAMS"):
4354 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004355 if (no_hyperlinks):
4356 return self.id_serializer_class
4357 else:
4358 return self.serializer_class
4359
4360 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004361 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004362 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004363 return PlanetStackPrivilege.select_by_user(self.request.user)
4364
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004365
4366class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4367 queryset = PlanetStackPrivilege.objects.select_related().all()
4368 serializer_class = PlanetStackPrivilegeSerializer
4369 id_serializer_class = PlanetStackPrivilegeIdSerializer
4370
4371 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004372 no_hyperlinks=False
4373 if hasattr(self.request,"QUERY_PARAMS"):
4374 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004375 if (no_hyperlinks):
4376 return self.id_serializer_class
4377 else:
4378 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004379
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004380 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004381 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004382 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004383 return PlanetStackPrivilege.select_by_user(self.request.user)
4384
4385 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4386
4387 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4388
4389
4390
Scott Baker923f0962015-02-02 14:33:08 -08004391class UserList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004392 queryset = User.objects.select_related().all()
4393 serializer_class = UserSerializer
4394 id_serializer_class = UserIdSerializer
4395 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004396 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 Bakerdcb9b5d2014-10-07 00:10:17 -07004397
4398 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004399 no_hyperlinks=False
4400 if hasattr(self.request,"QUERY_PARAMS"):
4401 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004402 if (no_hyperlinks):
4403 return self.id_serializer_class
4404 else:
4405 return self.serializer_class
4406
4407 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004408 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004409 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004410 return User.select_by_user(self.request.user)
4411
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004412
4413class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4414 queryset = User.objects.select_related().all()
4415 serializer_class = UserSerializer
4416 id_serializer_class = UserIdSerializer
4417
4418 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004419 no_hyperlinks=False
4420 if hasattr(self.request,"QUERY_PARAMS"):
4421 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004422 if (no_hyperlinks):
4423 return self.id_serializer_class
4424 else:
4425 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004426
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004427 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004428 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004429 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004430 return User.select_by_user(self.request.user)
4431
4432 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4433
4434 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4435
4436
4437
Scott Baker923f0962015-02-02 14:33:08 -08004438class DeploymentList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004439 queryset = Deployment.objects.select_related().all()
4440 serializer_class = DeploymentSerializer
4441 id_serializer_class = DeploymentIdSerializer
4442 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004443 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','accessControl','images','sites','flavors',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004444
4445 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004446 no_hyperlinks=False
4447 if hasattr(self.request,"QUERY_PARAMS"):
4448 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004449 if (no_hyperlinks):
4450 return self.id_serializer_class
4451 else:
4452 return self.serializer_class
4453
4454 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004455 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004456 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004457 return Deployment.select_by_user(self.request.user)
4458
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004459
4460class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4461 queryset = Deployment.objects.select_related().all()
4462 serializer_class = DeploymentSerializer
4463 id_serializer_class = DeploymentIdSerializer
4464
4465 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004466 no_hyperlinks=False
4467 if hasattr(self.request,"QUERY_PARAMS"):
4468 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004469 if (no_hyperlinks):
4470 return self.id_serializer_class
4471 else:
4472 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004473
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004474 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004475 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004476 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004477 return Deployment.select_by_user(self.request.user)
4478
4479 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4480
4481 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4482
4483
4484
Scott Baker923f0962015-02-02 14:33:08 -08004485class ReservationList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004486 queryset = Reservation.objects.select_related().all()
4487 serializer_class = ReservationSerializer
4488 id_serializer_class = ReservationIdSerializer
4489 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004490 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','startTime','slice','duration',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004491
4492 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004493 no_hyperlinks=False
4494 if hasattr(self.request,"QUERY_PARAMS"):
4495 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004496 if (no_hyperlinks):
4497 return self.id_serializer_class
4498 else:
4499 return self.serializer_class
4500
4501 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004502 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004503 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004504 return Reservation.select_by_user(self.request.user)
4505
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004506
4507class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4508 queryset = Reservation.objects.select_related().all()
4509 serializer_class = ReservationSerializer
4510 id_serializer_class = ReservationIdSerializer
4511
4512 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004513 no_hyperlinks=False
4514 if hasattr(self.request,"QUERY_PARAMS"):
4515 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004516 if (no_hyperlinks):
4517 return self.id_serializer_class
4518 else:
4519 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004520
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004521 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004522 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004523 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004524 return Reservation.select_by_user(self.request.user)
4525
4526 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4527
4528 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4529
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004530
Scott Bakerf3816ac2014-11-12 01:13:53 -08004531
Scott Baker923f0962015-02-02 14:33:08 -08004532class SitePrivilegeList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004533 queryset = SitePrivilege.objects.select_related().all()
4534 serializer_class = SitePrivilegeSerializer
4535 id_serializer_class = SitePrivilegeIdSerializer
4536 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004537 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','site','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004538
4539 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004540 no_hyperlinks=False
4541 if hasattr(self.request,"QUERY_PARAMS"):
4542 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004543 if (no_hyperlinks):
4544 return self.id_serializer_class
4545 else:
4546 return self.serializer_class
4547
4548 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004549 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004550 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004551 return SitePrivilege.select_by_user(self.request.user)
4552
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004553
4554class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4555 queryset = SitePrivilege.objects.select_related().all()
4556 serializer_class = SitePrivilegeSerializer
4557 id_serializer_class = SitePrivilegeIdSerializer
4558
4559 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004560 no_hyperlinks=False
4561 if hasattr(self.request,"QUERY_PARAMS"):
4562 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004563 if (no_hyperlinks):
4564 return self.id_serializer_class
4565 else:
4566 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004567
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004568 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004569 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004570 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004571 return SitePrivilege.select_by_user(self.request.user)
4572
4573 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4574
4575 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4576
4577
4578
Scott Baker923f0962015-02-02 14:33:08 -08004579class ControllerSliceList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004580 queryset = ControllerSlice.objects.select_related().all()
4581 serializer_class = ControllerSliceSerializer
4582 id_serializer_class = ControllerSliceIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004583 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004584 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice','tenant_id',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004585
4586 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004587 no_hyperlinks=False
4588 if hasattr(self.request,"QUERY_PARAMS"):
4589 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004590 if (no_hyperlinks):
4591 return self.id_serializer_class
4592 else:
4593 return self.serializer_class
4594
4595 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004596 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004597 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004598 return ControllerSlice.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004599
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004600
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004601class ControllerSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4602 queryset = ControllerSlice.objects.select_related().all()
4603 serializer_class = ControllerSliceSerializer
4604 id_serializer_class = ControllerSliceIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004605
4606 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004607 no_hyperlinks=False
4608 if hasattr(self.request,"QUERY_PARAMS"):
4609 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004610 if (no_hyperlinks):
4611 return self.id_serializer_class
4612 else:
4613 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004614
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004615 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004616 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004617 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004618 return ControllerSlice.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004619
4620 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4621
4622 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4623
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004624
Scott Bakerf3816ac2014-11-12 01:13:53 -08004625
Scott Baker923f0962015-02-02 14:33:08 -08004626class ControllerDashboardViewList(PlanetStackListCreateAPIView):
Scott Bakera6a0c772014-12-22 17:35:34 -08004627 queryset = ControllerDashboardView.objects.select_related().all()
4628 serializer_class = ControllerDashboardViewSerializer
4629 id_serializer_class = ControllerDashboardViewIdSerializer
4630 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004631 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','dashboardView','enabled','url',)
Scott Bakera6a0c772014-12-22 17:35:34 -08004632
4633 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004634 no_hyperlinks=False
4635 if hasattr(self.request,"QUERY_PARAMS"):
4636 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakera6a0c772014-12-22 17:35:34 -08004637 if (no_hyperlinks):
4638 return self.id_serializer_class
4639 else:
4640 return self.serializer_class
4641
4642 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004643 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004644 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakera6a0c772014-12-22 17:35:34 -08004645 return ControllerDashboardView.select_by_user(self.request.user)
4646
Scott Bakera6a0c772014-12-22 17:35:34 -08004647
4648class ControllerDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4649 queryset = ControllerDashboardView.objects.select_related().all()
4650 serializer_class = ControllerDashboardViewSerializer
4651 id_serializer_class = ControllerDashboardViewIdSerializer
4652
4653 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004654 no_hyperlinks=False
4655 if hasattr(self.request,"QUERY_PARAMS"):
4656 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakera6a0c772014-12-22 17:35:34 -08004657 if (no_hyperlinks):
4658 return self.id_serializer_class
4659 else:
4660 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004661
Scott Bakera6a0c772014-12-22 17:35:34 -08004662 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004663 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004664 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakera6a0c772014-12-22 17:35:34 -08004665 return ControllerDashboardView.select_by_user(self.request.user)
4666
4667 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4668
4669 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4670
4671
4672
Scott Baker923f0962015-02-02 14:33:08 -08004673class AccountList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004674 queryset = Account.objects.select_related().all()
4675 serializer_class = AccountSerializer
4676 id_serializer_class = AccountIdSerializer
4677 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004678 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004679
4680 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004681 no_hyperlinks=False
4682 if hasattr(self.request,"QUERY_PARAMS"):
4683 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004684 if (no_hyperlinks):
4685 return self.id_serializer_class
4686 else:
4687 return self.serializer_class
4688
4689 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004690 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004691 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004692 return Account.select_by_user(self.request.user)
4693
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004694
4695class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4696 queryset = Account.objects.select_related().all()
4697 serializer_class = AccountSerializer
4698 id_serializer_class = AccountIdSerializer
4699
4700 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004701 no_hyperlinks=False
4702 if hasattr(self.request,"QUERY_PARAMS"):
4703 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004704 if (no_hyperlinks):
4705 return self.id_serializer_class
4706 else:
4707 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004708
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004709 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004710 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004711 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004712 return Account.select_by_user(self.request.user)
4713
4714 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4715
4716 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4717
4718
4719
Scott Baker923f0962015-02-02 14:33:08 -08004720class ControllerRoleList(PlanetStackListCreateAPIView):
Scott Bakerc1d11912014-12-22 09:29:05 -08004721 queryset = ControllerRole.objects.select_related().all()
4722 serializer_class = ControllerRoleSerializer
4723 id_serializer_class = ControllerRoleIdSerializer
4724 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004725 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Bakerc1d11912014-12-22 09:29:05 -08004726
4727 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004728 no_hyperlinks=False
4729 if hasattr(self.request,"QUERY_PARAMS"):
4730 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08004731 if (no_hyperlinks):
4732 return self.id_serializer_class
4733 else:
4734 return self.serializer_class
4735
4736 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004737 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004738 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004739 return ControllerRole.select_by_user(self.request.user)
4740
Scott Bakerc1d11912014-12-22 09:29:05 -08004741
4742class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4743 queryset = ControllerRole.objects.select_related().all()
4744 serializer_class = ControllerRoleSerializer
4745 id_serializer_class = ControllerRoleIdSerializer
4746
4747 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004748 no_hyperlinks=False
4749 if hasattr(self.request,"QUERY_PARAMS"):
4750 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08004751 if (no_hyperlinks):
4752 return self.id_serializer_class
4753 else:
4754 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004755
Scott Bakerc1d11912014-12-22 09:29:05 -08004756 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004757 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004758 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004759 return ControllerRole.select_by_user(self.request.user)
4760
4761 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4762
4763 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4764
4765
4766
Scott Baker923f0962015-02-02 14:33:08 -08004767class NetworkParameterTypeList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004768 queryset = NetworkParameterType.objects.select_related().all()
4769 serializer_class = NetworkParameterTypeSerializer
4770 id_serializer_class = NetworkParameterTypeIdSerializer
4771 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004772 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','description',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004773
4774 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004775 no_hyperlinks=False
4776 if hasattr(self.request,"QUERY_PARAMS"):
4777 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004778 if (no_hyperlinks):
4779 return self.id_serializer_class
4780 else:
4781 return self.serializer_class
4782
4783 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004784 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004785 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004786 return NetworkParameterType.select_by_user(self.request.user)
4787
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004788
4789class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4790 queryset = NetworkParameterType.objects.select_related().all()
4791 serializer_class = NetworkParameterTypeSerializer
4792 id_serializer_class = NetworkParameterTypeIdSerializer
4793
4794 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004795 no_hyperlinks=False
4796 if hasattr(self.request,"QUERY_PARAMS"):
4797 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004798 if (no_hyperlinks):
4799 return self.id_serializer_class
4800 else:
4801 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004802
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004803 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004804 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004805 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004806 return NetworkParameterType.select_by_user(self.request.user)
4807
4808 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4809
4810 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4811
4812
4813
Scott Baker923f0962015-02-02 14:33:08 -08004814class SiteCredentialList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004815 queryset = SiteCredential.objects.select_related().all()
4816 serializer_class = SiteCredentialSerializer
4817 id_serializer_class = SiteCredentialIdSerializer
4818 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004819 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004820
4821 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004822 no_hyperlinks=False
4823 if hasattr(self.request,"QUERY_PARAMS"):
4824 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004825 if (no_hyperlinks):
4826 return self.id_serializer_class
4827 else:
4828 return self.serializer_class
4829
4830 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004831 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004832 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004833 return SiteCredential.select_by_user(self.request.user)
4834
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004835
4836class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4837 queryset = SiteCredential.objects.select_related().all()
4838 serializer_class = SiteCredentialSerializer
4839 id_serializer_class = SiteCredentialIdSerializer
4840
4841 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004842 no_hyperlinks=False
4843 if hasattr(self.request,"QUERY_PARAMS"):
4844 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004845 if (no_hyperlinks):
4846 return self.id_serializer_class
4847 else:
4848 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004849
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004850 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004851 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004852 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004853 return SiteCredential.select_by_user(self.request.user)
4854
4855 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4856
4857 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4858
4859
4860
Scott Baker923f0962015-02-02 14:33:08 -08004861class DeploymentPrivilegeList(PlanetStackListCreateAPIView):
Scott Bakerc1d11912014-12-22 09:29:05 -08004862 queryset = DeploymentPrivilege.objects.select_related().all()
4863 serializer_class = DeploymentPrivilegeSerializer
4864 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004865 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004866 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','deployment','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004867
4868 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004869 no_hyperlinks=False
4870 if hasattr(self.request,"QUERY_PARAMS"):
4871 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004872 if (no_hyperlinks):
4873 return self.id_serializer_class
4874 else:
4875 return self.serializer_class
4876
4877 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004878 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004879 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004880 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004881
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004882
Scott Bakerc1d11912014-12-22 09:29:05 -08004883class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4884 queryset = DeploymentPrivilege.objects.select_related().all()
4885 serializer_class = DeploymentPrivilegeSerializer
4886 id_serializer_class = DeploymentPrivilegeIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004887
4888 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004889 no_hyperlinks=False
4890 if hasattr(self.request,"QUERY_PARAMS"):
4891 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004892 if (no_hyperlinks):
4893 return self.id_serializer_class
4894 else:
4895 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004896
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004897 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004898 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004899 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08004900 return DeploymentPrivilege.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004901
4902 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4903
4904 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4905
4906
4907
Scott Baker923f0962015-02-02 14:33:08 -08004908class ControllerSlicePrivilegeList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004909 queryset = ControllerSlicePrivilege.objects.select_related().all()
4910 serializer_class = ControllerSlicePrivilegeSerializer
4911 id_serializer_class = ControllerSlicePrivilegeIdSerializer
Scott Bakerc1d11912014-12-22 09:29:05 -08004912 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004913 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','controller','slice_privilege','role_id',)
Scott Bakerc1d11912014-12-22 09:29:05 -08004914
4915 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004916 no_hyperlinks=False
4917 if hasattr(self.request,"QUERY_PARAMS"):
4918 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08004919 if (no_hyperlinks):
4920 return self.id_serializer_class
4921 else:
4922 return self.serializer_class
4923
4924 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004925 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004926 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004927 return ControllerSlicePrivilege.select_by_user(self.request.user)
Scott Bakerc1d11912014-12-22 09:29:05 -08004928
Scott Bakerc1d11912014-12-22 09:29:05 -08004929
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004930class ControllerSlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4931 queryset = ControllerSlicePrivilege.objects.select_related().all()
4932 serializer_class = ControllerSlicePrivilegeSerializer
4933 id_serializer_class = ControllerSlicePrivilegeIdSerializer
Scott Bakerc1d11912014-12-22 09:29:05 -08004934
4935 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004936 no_hyperlinks=False
4937 if hasattr(self.request,"QUERY_PARAMS"):
4938 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerc1d11912014-12-22 09:29:05 -08004939 if (no_hyperlinks):
4940 return self.id_serializer_class
4941 else:
4942 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004943
Scott Bakerc1d11912014-12-22 09:29:05 -08004944 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004945 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004946 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004947 return ControllerSlicePrivilege.select_by_user(self.request.user)
4948
4949 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4950
4951 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4952
4953
4954
Scott Baker923f0962015-02-02 14:33:08 -08004955class SiteDeploymentList(PlanetStackListCreateAPIView):
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004956 queryset = SiteDeployment.objects.select_related().all()
4957 serializer_class = SiteDeploymentSerializer
4958 id_serializer_class = SiteDeploymentIdSerializer
4959 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08004960 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','site','deployment','controller','availability_zone',)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004961
4962 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004963 no_hyperlinks=False
4964 if hasattr(self.request,"QUERY_PARAMS"):
4965 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004966 if (no_hyperlinks):
4967 return self.id_serializer_class
4968 else:
4969 return self.serializer_class
4970
4971 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004972 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004973 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004974 return SiteDeployment.select_by_user(self.request.user)
4975
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004976
4977class SiteDeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4978 queryset = SiteDeployment.objects.select_related().all()
4979 serializer_class = SiteDeploymentSerializer
4980 id_serializer_class = SiteDeploymentIdSerializer
4981
4982 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08004983 no_hyperlinks=False
4984 if hasattr(self.request,"QUERY_PARAMS"):
4985 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004986 if (no_hyperlinks):
4987 return self.id_serializer_class
4988 else:
4989 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08004990
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004991 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08004992 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08004993 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakeree9c5bf2015-01-12 13:16:39 -08004994 return SiteDeployment.select_by_user(self.request.user)
Scott Bakerc1d11912014-12-22 09:29:05 -08004995
4996 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4997
4998 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4999
5000
5001
Scott Baker923f0962015-02-02 14:33:08 -08005002class DeploymentRoleList(PlanetStackListCreateAPIView):
Scott Bakerc1d11912014-12-22 09:29:05 -08005003 queryset = DeploymentRole.objects.select_related().all()
5004 serializer_class = DeploymentRoleSerializer
5005 id_serializer_class = DeploymentRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005006 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08005007 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005008
5009 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005010 no_hyperlinks=False
5011 if hasattr(self.request,"QUERY_PARAMS"):
5012 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005013 if (no_hyperlinks):
5014 return self.id_serializer_class
5015 else:
5016 return self.serializer_class
5017
5018 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005019 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005020 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08005021 return DeploymentRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005022
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005023
Scott Bakerc1d11912014-12-22 09:29:05 -08005024class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5025 queryset = DeploymentRole.objects.select_related().all()
5026 serializer_class = DeploymentRoleSerializer
5027 id_serializer_class = DeploymentRoleIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005028
5029 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005030 no_hyperlinks=False
5031 if hasattr(self.request,"QUERY_PARAMS"):
5032 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005033 if (no_hyperlinks):
5034 return self.id_serializer_class
5035 else:
5036 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08005037
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005038 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005039 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005040 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerc1d11912014-12-22 09:29:05 -08005041 return DeploymentRole.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005042
5043 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5044
5045 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5046
5047
5048
Scott Baker923f0962015-02-02 14:33:08 -08005049class UserCredentialList(PlanetStackListCreateAPIView):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005050 queryset = UserCredential.objects.select_related().all()
5051 serializer_class = UserCredentialSerializer
5052 id_serializer_class = UserCredentialIdSerializer
5053 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08005054 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','user','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005055
5056 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005057 no_hyperlinks=False
5058 if hasattr(self.request,"QUERY_PARAMS"):
5059 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005060 if (no_hyperlinks):
5061 return self.id_serializer_class
5062 else:
5063 return self.serializer_class
5064
5065 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005066 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005067 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005068 return UserCredential.select_by_user(self.request.user)
5069
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005070
5071class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5072 queryset = UserCredential.objects.select_related().all()
5073 serializer_class = UserCredentialSerializer
5074 id_serializer_class = UserCredentialIdSerializer
5075
5076 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005077 no_hyperlinks=False
5078 if hasattr(self.request,"QUERY_PARAMS"):
5079 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005080 if (no_hyperlinks):
5081 return self.id_serializer_class
5082 else:
5083 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08005084
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005085 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005086 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005087 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005088 return UserCredential.select_by_user(self.request.user)
5089
5090 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5091
5092 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5093
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005094
Scott Bakerf3816ac2014-11-12 01:13:53 -08005095
Scott Baker923f0962015-02-02 14:33:08 -08005096class SliceTagList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005097 queryset = SliceTag.objects.select_related().all()
5098 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005099 id_serializer_class = SliceTagIdSerializer
5100 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08005101 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07005102
5103 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005104 no_hyperlinks=False
5105 if hasattr(self.request,"QUERY_PARAMS"):
5106 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07005107 if (no_hyperlinks):
5108 return self.id_serializer_class
5109 else:
5110 return self.serializer_class
5111
Scott Baker0caeaf02014-06-19 11:12:55 -07005112 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005113 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005114 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07005115 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005116
Scott Baker0caeaf02014-06-19 11:12:55 -07005117
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005118class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005119 queryset = SliceTag.objects.select_related().all()
5120 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005121 id_serializer_class = SliceTagIdSerializer
5122
5123 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005124 no_hyperlinks=False
5125 if hasattr(self.request,"QUERY_PARAMS"):
5126 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07005127 if (no_hyperlinks):
5128 return self.id_serializer_class
5129 else:
5130 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08005131
Scott Baker0caeaf02014-06-19 11:12:55 -07005132 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005133 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005134 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07005135 return SliceTag.select_by_user(self.request.user)
5136
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005137 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005138
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005139 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005140
5141
5142
Scott Baker923f0962015-02-02 14:33:08 -08005143class NetworkTemplateList(PlanetStackListCreateAPIView):
Scott Bakera6a0c772014-12-22 17:35:34 -08005144 queryset = NetworkTemplate.objects.select_related().all()
5145 serializer_class = NetworkTemplateSerializer
5146 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005147 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08005148 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 -07005149
5150 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005151 no_hyperlinks=False
5152 if hasattr(self.request,"QUERY_PARAMS"):
5153 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07005154 if (no_hyperlinks):
5155 return self.id_serializer_class
5156 else:
5157 return self.serializer_class
5158
Scott Baker0caeaf02014-06-19 11:12:55 -07005159 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005160 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005161 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakera6a0c772014-12-22 17:35:34 -08005162 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005163
Scott Baker0caeaf02014-06-19 11:12:55 -07005164
Scott Bakera6a0c772014-12-22 17:35:34 -08005165class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5166 queryset = NetworkTemplate.objects.select_related().all()
5167 serializer_class = NetworkTemplateSerializer
5168 id_serializer_class = NetworkTemplateIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005169
5170 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005171 no_hyperlinks=False
5172 if hasattr(self.request,"QUERY_PARAMS"):
5173 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07005174 if (no_hyperlinks):
5175 return self.id_serializer_class
5176 else:
5177 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08005178
Scott Baker0caeaf02014-06-19 11:12:55 -07005179 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005180 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005181 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Bakera6a0c772014-12-22 17:35:34 -08005182 return NetworkTemplate.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07005183
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005184 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005185
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005186 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005187
5188
5189
Scott Baker923f0962015-02-02 14:33:08 -08005190class RouterList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005191 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005192 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005193 id_serializer_class = RouterIdSerializer
5194 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08005195 filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','name','owner','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -07005196
5197 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005198 no_hyperlinks=False
5199 if hasattr(self.request,"QUERY_PARAMS"):
5200 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07005201 if (no_hyperlinks):
5202 return self.id_serializer_class
5203 else:
5204 return self.serializer_class
5205
Scott Baker0caeaf02014-06-19 11:12:55 -07005206 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005207 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005208 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07005209 return Router.select_by_user(self.request.user)
5210
Sapan Bhatiadea39432014-06-13 03:10:36 -04005211
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005212class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005213 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005214 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005215 id_serializer_class = RouterIdSerializer
5216
5217 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005218 no_hyperlinks=False
5219 if hasattr(self.request,"QUERY_PARAMS"):
5220 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07005221 if (no_hyperlinks):
5222 return self.id_serializer_class
5223 else:
5224 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08005225
Scott Baker0caeaf02014-06-19 11:12:55 -07005226 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005227 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005228 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07005229 return Router.select_by_user(self.request.user)
5230
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005231 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005232
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005233 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005234
5235
5236
Scott Baker923f0962015-02-02 14:33:08 -08005237class ServiceResourceList(PlanetStackListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005238 queryset = ServiceResource.objects.select_related().all()
5239 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005240 id_serializer_class = ServiceResourceIdSerializer
5241 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker5e140a32015-01-30 15:41:39 -08005242 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 -07005243
5244 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005245 no_hyperlinks=False
5246 if hasattr(self.request,"QUERY_PARAMS"):
5247 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07005248 if (no_hyperlinks):
5249 return self.id_serializer_class
5250 else:
5251 return self.serializer_class
5252
Scott Baker0caeaf02014-06-19 11:12:55 -07005253 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005254 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005255 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07005256 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005257
Scott Baker0caeaf02014-06-19 11:12:55 -07005258
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005259class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005260 queryset = ServiceResource.objects.select_related().all()
5261 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005262 id_serializer_class = ServiceResourceIdSerializer
5263
5264 def get_serializer_class(self):
Scott Baker5e140a32015-01-30 15:41:39 -08005265 no_hyperlinks=False
5266 if hasattr(self.request,"QUERY_PARAMS"):
5267 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
Scott Baker46b58542014-08-11 17:26:12 -07005268 if (no_hyperlinks):
5269 return self.id_serializer_class
5270 else:
5271 return self.serializer_class
Scott Baker5e140a32015-01-30 15:41:39 -08005272
Scott Baker0caeaf02014-06-19 11:12:55 -07005273 def get_queryset(self):
Scott Baker960431e2015-02-02 10:41:12 -08005274 if (not self.request.user.is_authenticated()):
Scott Bakercb60f8a2015-02-02 13:53:46 -08005275 raise RestFrameworkPermissionDenied("You must be authenticated in order to use this API")
Scott Baker0caeaf02014-06-19 11:12:55 -07005276 return ServiceResource.select_by_user(self.request.user)
5277
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005278 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005279
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005280 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005281
Sapan Bhatiadea39432014-06-13 03:10:36 -04005282
5283