blob: 5fba0c40e4987509ee08ee543c715824633b9b43 [file] [log] [blame]
Sapan Bhatiadea39432014-06-13 03:10:36 -04001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
Scott Baker0caeaf02014-06-19 11:12:55 -07005from rest_framework import generics
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07006from rest_framework import status
Scott Bakerf3816ac2014-11-12 01:13:53 -08007from rest_framework.generics import GenericAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04008from core.models import *
9from django.forms import widgets
Scott Baker46b58542014-08-11 17:26:12 -070010from rest_framework import filters
Scott Baker55a2e292014-11-10 16:31:15 -080011from django.conf.urls import patterns, url
Sapan Bhatiadea39432014-06-13 03:10:36 -040012
13"""
Scott Baker08898c12014-10-29 23:41:11 -070014 Schema of the generator object:
15 all: Set of all Model objects
16 all_if(regex): Set of Model objects that match regex
Scott Bakerf3816ac2014-11-12 01:13:53 -080017
Scott Baker08898c12014-10-29 23:41:11 -070018 Model object:
19 plural: English plural of object name
20 camel: CamelCase version of object name
21 refs: list of references to other Model objects
22 props: list of properties minus refs
Sapan Bhatiadea39432014-06-13 03:10:36 -040023
Scott Baker08898c12014-10-29 23:41:11 -070024 TODO: Deal with subnets
Sapan Bhatiadea39432014-06-13 03:10:36 -040025"""
26
Scott Baker55a2e292014-11-10 16:31:15 -080027def get_REST_patterns():
28 return patterns('',
29 url(r'^plstackapi/$', api_root),
30
31 url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'),
32 url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080033# url(r'plstackapi/serviceattributes/!new/$', ServiceAttributeNew.as_view(), name ='serviceattribute-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080034
35 url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'),
36 url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080037# url(r'plstackapi/images/!new/$', ImageNew.as_view(), name ='image-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080038
39 url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'),
40 url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080041# url(r'plstackapi/networkparameters/!new/$', NetworkParameterNew.as_view(), name ='networkparameter-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080042
43 url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'),
44 url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080045# url(r'plstackapi/sites/!new/$', SiteNew.as_view(), name ='site-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080046
47 url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'),
48 url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080049# url(r'plstackapi/slice_roles/!new/$', SliceRoleNew.as_view(), name ='slicerole-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080050
51 url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'),
52 url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080053# url(r'plstackapi/tags/!new/$', TagNew.as_view(), name ='tag-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080054
55 url(r'plstackapi/invoices/$', InvoiceList.as_view(), name='invoice-list'),
56 url(r'plstackapi/invoices/(?P<pk>[a-zA-Z0-9\-]+)/$', InvoiceDetail.as_view(), name ='invoice-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080057# url(r'plstackapi/invoices/!new/$', InvoiceNew.as_view(), name ='invoice-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080058
59 url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'),
60 url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080061# url(r'plstackapi/slice_privileges/!new/$', SlicePrivilegeNew.as_view(), name ='sliceprivilege-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080062
63 url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'),
64 url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080065# url(r'plstackapi/planetstackroles/!new/$', PlanetStackRoleNew.as_view(), name ='planetstackrole-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080066
67 url(r'plstackapi/networkslivers/$', NetworkSliverList.as_view(), name='networksliver-list'),
68 url(r'plstackapi/networkslivers/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliverDetail.as_view(), name ='networksliver-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080069# url(r'plstackapi/networkslivers/!new/$', NetworkSliverNew.as_view(), name ='networksliver-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080070
71 url(r'plstackapi/networkdeployments/$', NetworkDeploymentsList.as_view(), name='networkdeployments-list'),
72 url(r'plstackapi/networkdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDeploymentsDetail.as_view(), name ='networkdeployments-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080073# url(r'plstackapi/networkdeployments/!new/$', NetworkDeploymentsNew.as_view(), name ='networkdeployments-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080074
75 url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'),
76 url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080077# url(r'plstackapi/flavors/!new/$', FlavorNew.as_view(), name ='flavor-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080078
79 url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'),
80 url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080081# url(r'plstackapi/projects/!new/$', ProjectNew.as_view(), name ='project-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080082
83 url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'),
84 url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080085# url(r'plstackapi/slices/!new/$', SliceNew.as_view(), name ='slice-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080086
87 url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'),
88 url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080089# url(r'plstackapi/networks/!new/$', NetworkNew.as_view(), name ='network-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080090
91 url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'),
92 url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080093# url(r'plstackapi/services/!new/$', ServiceNew.as_view(), name ='service-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080094
95 url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'),
96 url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -080097# url(r'plstackapi/serviceclasses/!new/$', ServiceClassNew.as_view(), name ='serviceclass-new'),
Scott Baker55a2e292014-11-10 16:31:15 -080098
Scott Baker196ffef2014-11-21 11:32:24 -080099 url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'),
100 url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'),
101# url(r'plstackapi/payments/!new/$', PaymentNew.as_view(), name ='payment-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800102
103 url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'),
104 url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800105# url(r'plstackapi/charges/!new/$', ChargeNew.as_view(), name ='charge-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800106
107 url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'),
108 url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800109# url(r'plstackapi/roles/!new/$', RoleNew.as_view(), name ='role-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800110
111 url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'),
112 url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800113# url(r'plstackapi/usableobjects/!new/$', UsableObjectNew.as_view(), name ='usableobject-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800114
115 url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'),
116 url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800117# url(r'plstackapi/site_roles/!new/$', SiteRoleNew.as_view(), name ='siterole-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800118
119 url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'),
120 url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800121# url(r'plstackapi/slicecredentials/!new/$', SliceCredentialNew.as_view(), name ='slicecredential-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800122
123 url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'),
124 url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800125# url(r'plstackapi/slivers/!new/$', SliverNew.as_view(), name ='sliver-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800126
127 url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'),
128 url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800129# url(r'plstackapi/nodes/!new/$', NodeNew.as_view(), name ='node-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800130
131 url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'),
132 url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800133# url(r'plstackapi/dashboardviews/!new/$', DashboardViewNew.as_view(), name ='dashboardview-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800134
Scott Baker196ffef2014-11-21 11:32:24 -0800135 url(r'plstackapi/imagedeployments/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'),
136 url(r'plstackapi/imagedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'),
137# url(r'plstackapi/imagedeployments/!new/$', ImageDeploymentsNew.as_view(), name ='imagedeployments-new'),
138
Scott Baker55a2e292014-11-10 16:31:15 -0800139 url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'),
140 url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800141# url(r'plstackapi/reservedresources/!new/$', ReservedResourceNew.as_view(), name ='reservedresource-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800142
143 url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'),
144 url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800145# url(r'plstackapi/networkslices/!new/$', NetworkSliceNew.as_view(), name ='networkslice-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800146
147 url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'),
148 url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800149# url(r'plstackapi/userdashboardviews/!new/$', UserDashboardViewNew.as_view(), name ='userdashboardview-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800150
151 url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'),
152 url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800153# url(r'plstackapi/planetstackprivileges/!new/$', PlanetStackPrivilegeNew.as_view(), name ='planetstackprivilege-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800154
155 url(r'plstackapi/users/$', UserList.as_view(), name='user-list'),
156 url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800157# url(r'plstackapi/users/!new/$', UserNew.as_view(), name ='user-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800158
159 url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'),
160 url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800161# url(r'plstackapi/deployments/!new/$', DeploymentNew.as_view(), name ='deployment-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800162
163 url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'),
164 url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800165# url(r'plstackapi/reservations/!new/$', ReservationNew.as_view(), name ='reservation-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800166
Scott Baker72bcf352014-11-21 11:36:19 -0800167 url(r'plstackapi/slicedeployments/$', SliceDeploymentsList.as_view(), name='slicedeployments-list'),
168 url(r'plstackapi/slicedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDeploymentsDetail.as_view(), name ='slicedeployments-detail'),
169# url(r'plstackapi/slicedeployments/!new/$', SliceDeploymentsNew.as_view(), name ='slicedeployments-new'),
Scott Baker196ffef2014-11-21 11:32:24 -0800170
Scott Baker55a2e292014-11-10 16:31:15 -0800171 url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'),
172 url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800173# url(r'plstackapi/siteprivileges/!new/$', SitePrivilegeNew.as_view(), name ='siteprivilege-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800174
Scott Baker196ffef2014-11-21 11:32:24 -0800175 url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'),
176 url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'),
177# url(r'plstackapi/planetstacks/!new/$', PlanetStackNew.as_view(), name ='planetstack-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800178
Scott Baker72bcf352014-11-21 11:36:19 -0800179 url(r'plstackapi/userdeployments/$', UserDeploymentsList.as_view(), name='userdeployments-list'),
180 url(r'plstackapi/userdeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDeploymentsDetail.as_view(), name ='userdeployments-detail'),
181# url(r'plstackapi/userdeployments/!new/$', UserDeploymentsNew.as_view(), name ='userdeployments-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800182
183 url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'),
184 url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800185# url(r'plstackapi/accounts/!new/$', AccountNew.as_view(), name ='account-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800186
187 url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'),
188 url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800189# url(r'plstackapi/networkparametertypes/!new/$', NetworkParameterTypeNew.as_view(), name ='networkparametertype-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800190
191 url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'),
192 url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800193# url(r'plstackapi/sitecredentials/!new/$', SiteCredentialNew.as_view(), name ='sitecredential-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800194
195 url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'),
196 url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800197# url(r'plstackapi/deploymentprivileges/!new/$', DeploymentPrivilegeNew.as_view(), name ='deploymentprivilege-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800198
199 url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'),
200 url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800201# url(r'plstackapi/deploymentroles/!new/$', DeploymentRoleNew.as_view(), name ='deploymentrole-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800202
203 url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'),
204 url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800205# url(r'plstackapi/usercredentials/!new/$', UserCredentialNew.as_view(), name ='usercredential-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800206
Scott Baker196ffef2014-11-21 11:32:24 -0800207 url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'),
208 url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'),
209# url(r'plstackapi/sitedeployments/!new/$', SiteDeploymentsNew.as_view(), name ='sitedeployments-new'),
210
Scott Baker55a2e292014-11-10 16:31:15 -0800211 url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'),
212 url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800213# url(r'plstackapi/slicetags/!new/$', SliceTagNew.as_view(), name ='slicetag-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800214
215 url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'),
216 url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800217# url(r'plstackapi/networktemplates/!new/$', NetworkTemplateNew.as_view(), name ='networktemplate-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800218
219 url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'),
220 url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800221# url(r'plstackapi/routers/!new/$', RouterNew.as_view(), name ='router-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800222
223 url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'),
224 url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'),
Scott Bakerf3816ac2014-11-12 01:13:53 -0800225# url(r'plstackapi/serviceresources/!new/$', ServiceResourceNew.as_view(), name ='serviceresource-new'),
Scott Baker55a2e292014-11-10 16:31:15 -0800226
227 )
Sapan Bhatiadea39432014-06-13 03:10:36 -0400228
229@api_view(['GET'])
230def api_root(request, format=None):
231 return Response({
Scott Baker08898c12014-10-29 23:41:11 -0700232 'serviceattributes': reverse('serviceattribute-list', request=request, format=format),
233 'images': reverse('image-list', request=request, format=format),
234 'networkparameters': reverse('networkparameter-list', request=request, format=format),
235 'sites': reverse('site-list', request=request, format=format),
236 'sliceroles': reverse('slicerole-list', request=request, format=format),
237 'tags': reverse('tag-list', request=request, format=format),
238 'invoices': reverse('invoice-list', request=request, format=format),
239 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format),
240 'planetstackroles': reverse('planetstackrole-list', request=request, format=format),
241 'networkslivers': reverse('networksliver-list', request=request, format=format),
242 'networkdeploymentses': reverse('networkdeployments-list', request=request, format=format),
243 'flavors': reverse('flavor-list', request=request, format=format),
244 'projects': reverse('project-list', request=request, format=format),
245 'slices': reverse('slice-list', request=request, format=format),
246 'networks': reverse('network-list', request=request, format=format),
247 'services': reverse('service-list', request=request, format=format),
248 'serviceclasses': reverse('serviceclass-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800249 'payments': reverse('payment-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700250 'charges': reverse('charge-list', request=request, format=format),
251 'roles': reverse('role-list', request=request, format=format),
252 'usableobjects': reverse('usableobject-list', request=request, format=format),
253 'siteroles': reverse('siterole-list', request=request, format=format),
254 'slicecredentials': reverse('slicecredential-list', request=request, format=format),
255 'slivers': reverse('sliver-list', request=request, format=format),
256 'nodes': reverse('node-list', request=request, format=format),
257 'dashboardviews': reverse('dashboardview-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800258 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700259 'reservedresources': reverse('reservedresource-list', request=request, format=format),
260 'networkslices': reverse('networkslice-list', request=request, format=format),
261 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format),
262 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format),
263 'users': reverse('user-list', request=request, format=format),
264 'deployments': reverse('deployment-list', request=request, format=format),
265 'reservations': reverse('reservation-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800266 'slicedeploymentses': reverse('slicedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700267 'siteprivileges': reverse('siteprivilege-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800268 'planetstacks': reverse('planetstack-list', request=request, format=format),
269 'userdeploymentses': reverse('userdeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700270 'accounts': reverse('account-list', request=request, format=format),
271 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format),
272 'sitecredentials': reverse('sitecredential-list', request=request, format=format),
273 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format),
274 'deploymentroles': reverse('deploymentrole-list', request=request, format=format),
275 'usercredentials': reverse('usercredential-list', request=request, format=format),
Scott Baker196ffef2014-11-21 11:32:24 -0800276 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format),
Scott Baker08898c12014-10-29 23:41:11 -0700277 'slicetags': reverse('slicetag-list', request=request, format=format),
278 'networktemplates': reverse('networktemplate-list', request=request, format=format),
279 'routers': reverse('router-list', request=request, format=format),
280 'serviceresources': reverse('serviceresource-list', request=request, format=format),
281
Sapan Bhatiadea39432014-06-13 03:10:36 -0400282 })
283
284# Based on serializers.py
285
286
287
Scott Baker0caeaf02014-06-19 11:12:55 -0700288class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700289 id = serializers.Field()
290
Scott Baker196ffef2014-11-21 11:32:24 -0800291 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
292 def getHumanReadableName(self, obj):
293 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700294 class Meta:
295 model = ServiceAttribute
Scott Baker196ffef2014-11-21 11:32:24 -0800296 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700297
298class ServiceAttributeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700299 id = serializers.Field()
300
Scott Baker196ffef2014-11-21 11:32:24 -0800301 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
302 def getHumanReadableName(self, obj):
303 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700304 class Meta:
305 model = ServiceAttribute
Scott Baker196ffef2014-11-21 11:32:24 -0800306 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','value','service',)
Scott Baker46b58542014-08-11 17:26:12 -0700307
308
Sapan Bhatiadea39432014-06-13 03:10:36 -0400309
310
311class ImageSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700312 id = serializers.Field()
313
Scott Baker196ffef2014-11-21 11:32:24 -0800314 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
315 def getHumanReadableName(self, obj):
316 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700317 class Meta:
318 model = Image
Scott Baker196ffef2014-11-21 11:32:24 -0800319 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700320
321class ImageIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700322 id = serializers.Field()
323
Scott Baker196ffef2014-11-21 11:32:24 -0800324 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
325 def getHumanReadableName(self, obj):
326 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700327 class Meta:
328 model = Image
Scott Baker196ffef2014-11-21 11:32:24 -0800329 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
Scott Baker46b58542014-08-11 17:26:12 -0700330
331
Sapan Bhatiadea39432014-06-13 03:10:36 -0400332
333
Scott Baker0caeaf02014-06-19 11:12:55 -0700334class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700335 id = serializers.Field()
336
Scott Baker196ffef2014-11-21 11:32:24 -0800337 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
338 def getHumanReadableName(self, obj):
339 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700340 class Meta:
341 model = NetworkParameter
Scott Baker196ffef2014-11-21 11:32:24 -0800342 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700343
344class NetworkParameterIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700345 id = serializers.Field()
346
Scott Baker196ffef2014-11-21 11:32:24 -0800347 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
348 def getHumanReadableName(self, obj):
349 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700350 class Meta:
351 model = NetworkParameter
Scott Baker196ffef2014-11-21 11:32:24 -0800352 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700353
354
Sapan Bhatiadea39432014-06-13 03:10:36 -0400355
356
357class SiteSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700358 id = serializers.Field()
359
Scott Baker196ffef2014-11-21 11:32:24 -0800360 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
361 def getHumanReadableName(self, obj):
362 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700363 class Meta:
364 model = Site
Scott Baker196ffef2014-11-21 11:32:24 -0800365 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Scott Baker46b58542014-08-11 17:26:12 -0700366
367class SiteIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700368 id = serializers.Field()
369
Scott Baker196ffef2014-11-21 11:32:24 -0800370 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
371 def getHumanReadableName(self, obj):
372 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700373 class Meta:
374 model = Site
Scott Baker196ffef2014-11-21 11:32:24 -0800375 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
Scott Baker46b58542014-08-11 17:26:12 -0700376
377
Sapan Bhatiadea39432014-06-13 03:10:36 -0400378
379
Scott Baker0caeaf02014-06-19 11:12:55 -0700380class SliceRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700381 id = serializers.Field()
382
Scott Baker196ffef2014-11-21 11:32:24 -0800383 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
384 def getHumanReadableName(self, obj):
385 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700386 class Meta:
387 model = SliceRole
Scott Baker196ffef2014-11-21 11:32:24 -0800388 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700389
390class SliceRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700391 id = serializers.Field()
392
Scott Baker196ffef2014-11-21 11:32:24 -0800393 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
394 def getHumanReadableName(self, obj):
395 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700396 class Meta:
397 model = SliceRole
Scott Baker196ffef2014-11-21 11:32:24 -0800398 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700399
400
Sapan Bhatiadea39432014-06-13 03:10:36 -0400401
402
403class TagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700404 id = serializers.Field()
405
Scott Baker196ffef2014-11-21 11:32:24 -0800406 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
407 def getHumanReadableName(self, obj):
408 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700409 class Meta:
410 model = Tag
Scott Baker196ffef2014-11-21 11:32:24 -0800411 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700412
413class TagIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700414 id = serializers.Field()
415
Scott Baker196ffef2014-11-21 11:32:24 -0800416 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
417 def getHumanReadableName(self, obj):
418 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700419 class Meta:
420 model = Tag
Scott Baker196ffef2014-11-21 11:32:24 -0800421 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700422
423
Sapan Bhatiadea39432014-06-13 03:10:36 -0400424
425
426class InvoiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700427 id = serializers.Field()
428
Scott Baker196ffef2014-11-21 11:32:24 -0800429 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
430 def getHumanReadableName(self, obj):
431 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700432 class Meta:
433 model = Invoice
Scott Baker196ffef2014-11-21 11:32:24 -0800434 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700435
436class InvoiceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700437 id = serializers.Field()
438
Scott Baker196ffef2014-11-21 11:32:24 -0800439 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
440 def getHumanReadableName(self, obj):
441 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700442 class Meta:
443 model = Invoice
Scott Baker196ffef2014-11-21 11:32:24 -0800444 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','date','account',)
Scott Baker46b58542014-08-11 17:26:12 -0700445
446
Sapan Bhatiadea39432014-06-13 03:10:36 -0400447
448
Scott Baker0caeaf02014-06-19 11:12:55 -0700449class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700450 id = serializers.Field()
451
Scott Baker196ffef2014-11-21 11:32:24 -0800452 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
453 def getHumanReadableName(self, obj):
454 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700455 class Meta:
456 model = SlicePrivilege
Scott Baker196ffef2014-11-21 11:32:24 -0800457 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700458
459class SlicePrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700460 id = serializers.Field()
461
Scott Baker196ffef2014-11-21 11:32:24 -0800462 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
463 def getHumanReadableName(self, obj):
464 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700465 class Meta:
466 model = SlicePrivilege
Scott Baker196ffef2014-11-21 11:32:24 -0800467 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700468
469
Scott Baker0caeaf02014-06-19 11:12:55 -0700470
471
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700472class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700473 id = serializers.Field()
474
Scott Baker196ffef2014-11-21 11:32:24 -0800475 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
476 def getHumanReadableName(self, obj):
477 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700478 class Meta:
479 model = PlanetStackRole
Scott Baker196ffef2014-11-21 11:32:24 -0800480 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700481
482class PlanetStackRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700483 id = serializers.Field()
484
Scott Baker196ffef2014-11-21 11:32:24 -0800485 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
486 def getHumanReadableName(self, obj):
487 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700488 class Meta:
489 model = PlanetStackRole
Scott Baker196ffef2014-11-21 11:32:24 -0800490 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700491
492
493
494
Scott Baker0caeaf02014-06-19 11:12:55 -0700495class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700496 id = serializers.Field()
497
Scott Baker196ffef2014-11-21 11:32:24 -0800498 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
499 def getHumanReadableName(self, obj):
500 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700501 class Meta:
502 model = NetworkSliver
Scott Baker196ffef2014-11-21 11:32:24 -0800503 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700504
505class NetworkSliverIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700506 id = serializers.Field()
507
Scott Baker196ffef2014-11-21 11:32:24 -0800508 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
509 def getHumanReadableName(self, obj):
510 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700511 class Meta:
512 model = NetworkSliver
Scott Baker196ffef2014-11-21 11:32:24 -0800513 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700514
515
Scott Baker0caeaf02014-06-19 11:12:55 -0700516
517
518class NetworkDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700519 id = serializers.Field()
520
Scott Baker196ffef2014-11-21 11:32:24 -0800521 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
522 def getHumanReadableName(self, obj):
523 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700524 class Meta:
525 model = NetworkDeployments
Scott Baker196ffef2014-11-21 11:32:24 -0800526 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700527
528class NetworkDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700529 id = serializers.Field()
530
Scott Baker196ffef2014-11-21 11:32:24 -0800531 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
532 def getHumanReadableName(self, obj):
533 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700534 class Meta:
535 model = NetworkDeployments
Scott Baker196ffef2014-11-21 11:32:24 -0800536 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
Scott Baker46b58542014-08-11 17:26:12 -0700537
538
Sapan Bhatiadea39432014-06-13 03:10:36 -0400539
540
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700541class FlavorSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700542 id = serializers.Field()
543
Scott Baker196ffef2014-11-21 11:32:24 -0800544 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
545 def getHumanReadableName(self, obj):
546 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700547 class Meta:
548 model = Flavor
Scott Baker196ffef2014-11-21 11:32:24 -0800549 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700550
551class FlavorIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700552 id = serializers.Field()
553
Scott Baker196ffef2014-11-21 11:32:24 -0800554 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
555 def getHumanReadableName(self, obj):
556 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700557 class Meta:
558 model = Flavor
Scott Baker196ffef2014-11-21 11:32:24 -0800559 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700560
561
562
563
564class ProjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700565 id = serializers.Field()
566
Scott Baker196ffef2014-11-21 11:32:24 -0800567 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
568 def getHumanReadableName(self, obj):
569 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700570 class Meta:
571 model = Project
Scott Baker196ffef2014-11-21 11:32:24 -0800572 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700573
574class ProjectIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700575 id = serializers.Field()
576
Scott Baker196ffef2014-11-21 11:32:24 -0800577 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
578 def getHumanReadableName(self, obj):
579 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700580 class Meta:
581 model = Project
Scott Baker196ffef2014-11-21 11:32:24 -0800582 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700583
584
585
586
Sapan Bhatiadea39432014-06-13 03:10:36 -0400587class SliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700588 id = serializers.Field()
589
590
591 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
592
593
594
595 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
596
597
598
599 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
600
601
602
603 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
604
605
Scott Baker196ffef2014-11-21 11:32:24 -0800606 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
607 def getHumanReadableName(self, obj):
608 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700609 class Meta:
610 model = Slice
Scott Baker196ffef2014-11-21 11:32:24 -0800611 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700612
613class SliceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700614 id = serializers.Field()
615
616
617 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
618
619
620
621 availableNetworks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
622
623
624
625 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
626
627
628
629 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
630
631
Scott Baker196ffef2014-11-21 11:32:24 -0800632 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
633 def getHumanReadableName(self, obj):
634 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700635 class Meta:
636 model = Slice
Scott Baker196ffef2014-11-21 11:32:24 -0800637 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700638
639
Sapan Bhatiadea39432014-06-13 03:10:36 -0400640
641
642class NetworkSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700643 id = serializers.Field()
644
645
646 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
647
648
649
650 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
651
652
653
654 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
655
656
657
658 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
659
660
Scott Baker196ffef2014-11-21 11:32:24 -0800661 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
662 def getHumanReadableName(self, obj):
663 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700664 class Meta:
665 model = Network
Scott Baker196ffef2014-11-21 11:32:24 -0800666 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700667
668class NetworkIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700669 id = serializers.Field()
670
671
672 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
673
674
675
676 availableRouters = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
677
678
679
680 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
681
682
683
684 routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail')
685
686
Scott Baker196ffef2014-11-21 11:32:24 -0800687 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
688 def getHumanReadableName(self, obj):
689 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700690 class Meta:
691 model = Network
Scott Baker196ffef2014-11-21 11:32:24 -0800692 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Baker46b58542014-08-11 17:26:12 -0700693
694
Sapan Bhatiadea39432014-06-13 03:10:36 -0400695
696
697class ServiceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700698 id = serializers.Field()
699
Scott Baker196ffef2014-11-21 11:32:24 -0800700 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
701 def getHumanReadableName(self, obj):
702 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700703 class Meta:
704 model = Service
Scott Baker196ffef2014-11-21 11:32:24 -0800705 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700706
707class ServiceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700708 id = serializers.Field()
709
Scott Baker196ffef2014-11-21 11:32:24 -0800710 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
711 def getHumanReadableName(self, obj):
712 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700713 class Meta:
714 model = Service
Scott Baker196ffef2014-11-21 11:32:24 -0800715 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
Scott Baker46b58542014-08-11 17:26:12 -0700716
717
Sapan Bhatiadea39432014-06-13 03:10:36 -0400718
719
Scott Baker0caeaf02014-06-19 11:12:55 -0700720class ServiceClassSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700721 id = serializers.Field()
722
Scott Baker196ffef2014-11-21 11:32:24 -0800723 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
724 def getHumanReadableName(self, obj):
725 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700726 class Meta:
727 model = ServiceClass
Scott Baker196ffef2014-11-21 11:32:24 -0800728 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700729
730class ServiceClassIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700731 id = serializers.Field()
732
Scott Baker196ffef2014-11-21 11:32:24 -0800733 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
734 def getHumanReadableName(self, obj):
735 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700736 class Meta:
737 model = ServiceClass
Scott Baker196ffef2014-11-21 11:32:24 -0800738 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
Scott Baker46b58542014-08-11 17:26:12 -0700739
740
Sapan Bhatiadea39432014-06-13 03:10:36 -0400741
742
Scott Baker196ffef2014-11-21 11:32:24 -0800743class PaymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700744 id = serializers.Field()
745
Scott Baker196ffef2014-11-21 11:32:24 -0800746 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
747 def getHumanReadableName(self, obj):
748 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700749 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -0800750 model = Payment
751 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700752
Scott Baker196ffef2014-11-21 11:32:24 -0800753class PaymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700754 id = serializers.Field()
755
Scott Baker196ffef2014-11-21 11:32:24 -0800756 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
757 def getHumanReadableName(self, obj):
758 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700759 class Meta:
Scott Baker196ffef2014-11-21 11:32:24 -0800760 model = Payment
761 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Baker46b58542014-08-11 17:26:12 -0700762
763
Sapan Bhatiadea39432014-06-13 03:10:36 -0400764
765
766class ChargeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700767 id = serializers.Field()
768
Scott Baker196ffef2014-11-21 11:32:24 -0800769 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
770 def getHumanReadableName(self, obj):
771 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700772 class Meta:
773 model = Charge
Scott Baker196ffef2014-11-21 11:32:24 -0800774 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700775
776class ChargeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700777 id = serializers.Field()
778
Scott Baker196ffef2014-11-21 11:32:24 -0800779 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
780 def getHumanReadableName(self, obj):
781 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700782 class Meta:
783 model = Charge
Scott Baker196ffef2014-11-21 11:32:24 -0800784 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
Scott Baker46b58542014-08-11 17:26:12 -0700785
786
Sapan Bhatiadea39432014-06-13 03:10:36 -0400787
788
789class RoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700790 id = serializers.Field()
791
Scott Baker196ffef2014-11-21 11:32:24 -0800792 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
793 def getHumanReadableName(self, obj):
794 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700795 class Meta:
796 model = Role
Scott Baker196ffef2014-11-21 11:32:24 -0800797 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700798
799class RoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700800 id = serializers.Field()
801
Scott Baker196ffef2014-11-21 11:32:24 -0800802 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
803 def getHumanReadableName(self, obj):
804 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700805 class Meta:
806 model = Role
Scott Baker196ffef2014-11-21 11:32:24 -0800807 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
Scott Baker46b58542014-08-11 17:26:12 -0700808
809
Sapan Bhatiadea39432014-06-13 03:10:36 -0400810
811
Scott Baker0caeaf02014-06-19 11:12:55 -0700812class UsableObjectSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700813 id = serializers.Field()
814
Scott Baker196ffef2014-11-21 11:32:24 -0800815 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
816 def getHumanReadableName(self, obj):
817 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700818 class Meta:
819 model = UsableObject
Scott Baker196ffef2014-11-21 11:32:24 -0800820 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -0700821
822class UsableObjectIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700823 id = serializers.Field()
824
Scott Baker196ffef2014-11-21 11:32:24 -0800825 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
826 def getHumanReadableName(self, obj):
827 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700828 class Meta:
829 model = UsableObject
Scott Baker196ffef2014-11-21 11:32:24 -0800830 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name',)
Scott Baker46b58542014-08-11 17:26:12 -0700831
832
Sapan Bhatiadea39432014-06-13 03:10:36 -0400833
834
Scott Baker0caeaf02014-06-19 11:12:55 -0700835class SiteRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700836 id = serializers.Field()
837
Scott Baker196ffef2014-11-21 11:32:24 -0800838 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
839 def getHumanReadableName(self, obj):
840 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700841 class Meta:
842 model = SiteRole
Scott Baker196ffef2014-11-21 11:32:24 -0800843 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700844
845class SiteRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700846 id = serializers.Field()
847
Scott Baker196ffef2014-11-21 11:32:24 -0800848 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
849 def getHumanReadableName(self, obj):
850 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700851 class Meta:
852 model = SiteRole
Scott Baker196ffef2014-11-21 11:32:24 -0800853 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -0700854
855
Scott Baker0caeaf02014-06-19 11:12:55 -0700856
857
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700858class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700859 id = serializers.Field()
860
Scott Baker196ffef2014-11-21 11:32:24 -0800861 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
862 def getHumanReadableName(self, obj):
863 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700864 class Meta:
865 model = SliceCredential
Scott Baker196ffef2014-11-21 11:32:24 -0800866 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700867
868class SliceCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700869 id = serializers.Field()
870
Scott Baker196ffef2014-11-21 11:32:24 -0800871 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
872 def getHumanReadableName(self, obj):
873 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700874 class Meta:
875 model = SliceCredential
Scott Baker196ffef2014-11-21 11:32:24 -0800876 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -0700877
878
879
880
Sapan Bhatiadea39432014-06-13 03:10:36 -0400881class SliverSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700882 id = serializers.Field()
883
884
885 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
886
887
888
889 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
890
891
Scott Baker196ffef2014-11-21 11:32:24 -0800892 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
893 def getHumanReadableName(self, obj):
894 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700895 class Meta:
896 model = Sliver
Scott Baker196ffef2014-11-21 11:32:24 -0800897 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700898
899class SliverIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700900 id = serializers.Field()
901
902
903 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
904
905
906
907 networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail')
908
909
Scott Baker196ffef2014-11-21 11:32:24 -0800910 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
911 def getHumanReadableName(self, obj):
912 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700913 class Meta:
914 model = Sliver
Scott Baker196ffef2014-11-21 11:32:24 -0800915 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
Scott Baker46b58542014-08-11 17:26:12 -0700916
917
Sapan Bhatiadea39432014-06-13 03:10:36 -0400918
919
920class NodeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700921 id = serializers.Field()
922
Scott Baker196ffef2014-11-21 11:32:24 -0800923 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
924 def getHumanReadableName(self, obj):
925 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700926 class Meta:
927 model = Node
Scott Baker196ffef2014-11-21 11:32:24 -0800928 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -0700929
930class NodeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700931 id = serializers.Field()
932
Scott Baker196ffef2014-11-21 11:32:24 -0800933 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
934 def getHumanReadableName(self, obj):
935 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700936 class Meta:
937 model = Node
Scott Baker196ffef2014-11-21 11:32:24 -0800938 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
Scott Baker46b58542014-08-11 17:26:12 -0700939
940
Sapan Bhatiadea39432014-06-13 03:10:36 -0400941
942
Scott Baker0caeaf02014-06-19 11:12:55 -0700943class DashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700944 id = serializers.Field()
945
Scott Baker196ffef2014-11-21 11:32:24 -0800946 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
947 def getHumanReadableName(self, obj):
948 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700949 class Meta:
950 model = DashboardView
Scott Baker196ffef2014-11-21 11:32:24 -0800951 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','url',)
Scott Baker46b58542014-08-11 17:26:12 -0700952
953class DashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700954 id = serializers.Field()
955
Scott Baker196ffef2014-11-21 11:32:24 -0800956 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
957 def getHumanReadableName(self, obj):
958 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700959 class Meta:
960 model = DashboardView
Scott Baker196ffef2014-11-21 11:32:24 -0800961 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','url',)
962
963
964
965
966class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
967 id = serializers.Field()
968
969 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
970 def getHumanReadableName(self, obj):
971 return str(obj)
972 class Meta:
973 model = ImageDeployments
974 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
975
976class ImageDeploymentsIdSerializer(serializers.ModelSerializer):
977 id = serializers.Field()
978
979 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
980 def getHumanReadableName(self, obj):
981 return str(obj)
982 class Meta:
983 model = ImageDeployments
984 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
Scott Baker46b58542014-08-11 17:26:12 -0700985
986
Sapan Bhatiadea39432014-06-13 03:10:36 -0400987
988
Scott Baker0caeaf02014-06-19 11:12:55 -0700989class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -0700990 id = serializers.Field()
991
Scott Baker196ffef2014-11-21 11:32:24 -0800992 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
993 def getHumanReadableName(self, obj):
994 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -0700995 class Meta:
996 model = ReservedResource
Scott Baker196ffef2014-11-21 11:32:24 -0800997 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker46b58542014-08-11 17:26:12 -0700998
999class ReservedResourceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001000 id = serializers.Field()
1001
Scott Baker196ffef2014-11-21 11:32:24 -08001002 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1003 def getHumanReadableName(self, obj):
1004 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001005 class Meta:
1006 model = ReservedResource
Scott Baker196ffef2014-11-21 11:32:24 -08001007 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001008
1009
1010
1011
Scott Baker0caeaf02014-06-19 11:12:55 -07001012class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001013 id = serializers.Field()
1014
Scott Baker196ffef2014-11-21 11:32:24 -08001015 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1016 def getHumanReadableName(self, obj):
1017 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001018 class Meta:
1019 model = NetworkSlice
Scott Baker196ffef2014-11-21 11:32:24 -08001020 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001021
1022class NetworkSliceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001023 id = serializers.Field()
1024
Scott Baker196ffef2014-11-21 11:32:24 -08001025 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1026 def getHumanReadableName(self, obj):
1027 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001028 class Meta:
1029 model = NetworkSlice
Scott Baker196ffef2014-11-21 11:32:24 -08001030 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','network','slice',)
Scott Baker46b58542014-08-11 17:26:12 -07001031
1032
Scott Baker0caeaf02014-06-19 11:12:55 -07001033
1034
1035class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001036 id = serializers.Field()
1037
Scott Baker196ffef2014-11-21 11:32:24 -08001038 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1039 def getHumanReadableName(self, obj):
1040 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001041 class Meta:
1042 model = UserDashboardView
Scott Baker196ffef2014-11-21 11:32:24 -08001043 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker46b58542014-08-11 17:26:12 -07001044
1045class UserDashboardViewIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001046 id = serializers.Field()
1047
Scott Baker196ffef2014-11-21 11:32:24 -08001048 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1049 def getHumanReadableName(self, obj):
1050 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001051 class Meta:
1052 model = UserDashboardView
Scott Baker196ffef2014-11-21 11:32:24 -08001053 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001054
1055
1056
1057
Scott Baker0caeaf02014-06-19 11:12:55 -07001058class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001059 id = serializers.Field()
1060
Scott Baker196ffef2014-11-21 11:32:24 -08001061 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1062 def getHumanReadableName(self, obj):
1063 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001064 class Meta:
1065 model = PlanetStackPrivilege
Scott Baker196ffef2014-11-21 11:32:24 -08001066 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001067
1068class PlanetStackPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001069 id = serializers.Field()
1070
Scott Baker196ffef2014-11-21 11:32:24 -08001071 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1072 def getHumanReadableName(self, obj):
1073 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001074 class Meta:
1075 model = PlanetStackPrivilege
Scott Baker196ffef2014-11-21 11:32:24 -08001076 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001077
1078
Sapan Bhatiadea39432014-06-13 03:10:36 -04001079
1080
1081class UserSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001082 id = serializers.Field()
1083
Scott Baker196ffef2014-11-21 11:32:24 -08001084 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1085 def getHumanReadableName(self, obj):
1086 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001087 class Meta:
1088 model = User
Scott Baker196ffef2014-11-21 11:32:24 -08001089 fields = ('humanReadableName', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
Scott Baker46b58542014-08-11 17:26:12 -07001090
1091class UserIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001092 id = serializers.Field()
1093
Scott Baker196ffef2014-11-21 11:32:24 -08001094 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1095 def getHumanReadableName(self, obj):
1096 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001097 class Meta:
1098 model = User
Scott Baker196ffef2014-11-21 11:32:24 -08001099 fields = ('humanReadableName', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
Scott Baker46b58542014-08-11 17:26:12 -07001100
1101
Sapan Bhatiadea39432014-06-13 03:10:36 -04001102
1103
1104class DeploymentSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001105 id = serializers.Field()
1106
1107
1108 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1109
1110
1111
1112 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1113
1114
1115
1116 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1117
1118
1119
1120 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1121
1122
Scott Baker196ffef2014-11-21 11:32:24 -08001123 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1124 def getHumanReadableName(self, obj):
1125 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001126 class Meta:
1127 model = Deployment
Scott Baker196ffef2014-11-21 11:32:24 -08001128 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001129
1130class DeploymentIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001131 id = serializers.Field()
1132
1133
1134 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1135
1136
1137
1138 sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail')
1139
1140
1141
1142 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1143
1144
1145
1146 flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail')
1147
1148
Scott Baker196ffef2014-11-21 11:32:24 -08001149 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1150 def getHumanReadableName(self, obj):
1151 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001152 class Meta:
1153 model = Deployment
Scott Baker196ffef2014-11-21 11:32:24 -08001154 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
Scott Baker46b58542014-08-11 17:26:12 -07001155
1156
Sapan Bhatiadea39432014-06-13 03:10:36 -04001157
1158
1159class ReservationSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001160 id = serializers.Field()
1161
Scott Baker196ffef2014-11-21 11:32:24 -08001162 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1163 def getHumanReadableName(self, obj):
1164 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001165 class Meta:
1166 model = Reservation
Scott Baker196ffef2014-11-21 11:32:24 -08001167 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001168
1169class ReservationIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001170 id = serializers.Field()
1171
Scott Baker196ffef2014-11-21 11:32:24 -08001172 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1173 def getHumanReadableName(self, obj):
1174 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001175 class Meta:
1176 model = Reservation
Scott Baker196ffef2014-11-21 11:32:24 -08001177 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
Scott Baker46b58542014-08-11 17:26:12 -07001178
1179
Scott Baker0caeaf02014-06-19 11:12:55 -07001180
1181
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001182class SliceDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001183 id = serializers.Field()
1184
Scott Baker196ffef2014-11-21 11:32:24 -08001185 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1186 def getHumanReadableName(self, obj):
1187 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001188 class Meta:
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001189 model = SliceDeployments
Scott Baker196ffef2014-11-21 11:32:24 -08001190 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001191
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001192class SliceDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001193 id = serializers.Field()
1194
Scott Baker196ffef2014-11-21 11:32:24 -08001195 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1196 def getHumanReadableName(self, obj):
1197 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001198 class Meta:
Sapan Bhatiabf7856b2014-11-19 15:09:38 -05001199 model = SliceDeployments
Scott Baker196ffef2014-11-21 11:32:24 -08001200 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
1201
1202
1203
1204
1205class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer):
1206 id = serializers.Field()
1207
1208 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1209 def getHumanReadableName(self, obj):
1210 return str(obj)
1211 class Meta:
1212 model = SitePrivilege
1213 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
1214
1215class SitePrivilegeIdSerializer(serializers.ModelSerializer):
1216 id = serializers.Field()
1217
1218 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1219 def getHumanReadableName(self, obj):
1220 return str(obj)
1221 class Meta:
1222 model = SitePrivilege
1223 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','site','role',)
1224
1225
1226
1227
1228class PlanetStackSerializer(serializers.HyperlinkedModelSerializer):
1229 id = serializers.Field()
1230
1231 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1232 def getHumanReadableName(self, obj):
1233 return str(obj)
1234 class Meta:
1235 model = PlanetStack
1236 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','description',)
1237
1238class PlanetStackIdSerializer(serializers.ModelSerializer):
1239 id = serializers.Field()
1240
1241 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1242 def getHumanReadableName(self, obj):
1243 return str(obj)
1244 class Meta:
1245 model = PlanetStack
1246 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001247
1248
Sapan Bhatiadea39432014-06-13 03:10:36 -04001249
1250
Sapan Bhatia3f879692014-11-19 15:10:51 -05001251class UserDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001252 id = serializers.Field()
1253
Scott Baker196ffef2014-11-21 11:32:24 -08001254 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1255 def getHumanReadableName(self, obj):
1256 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001257 class Meta:
Sapan Bhatia3f879692014-11-19 15:10:51 -05001258 model = UserDeployments
Scott Baker196ffef2014-11-21 11:32:24 -08001259 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001260
Sapan Bhatia3f879692014-11-19 15:10:51 -05001261class UserDeploymentsIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001262 id = serializers.Field()
1263
Scott Baker196ffef2014-11-21 11:32:24 -08001264 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1265 def getHumanReadableName(self, obj):
1266 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001267 class Meta:
Sapan Bhatia3f879692014-11-19 15:10:51 -05001268 model = UserDeployments
Scott Baker196ffef2014-11-21 11:32:24 -08001269 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
Scott Baker46b58542014-08-11 17:26:12 -07001270
1271
Scott Baker0caeaf02014-06-19 11:12:55 -07001272
1273
Sapan Bhatiadea39432014-06-13 03:10:36 -04001274class AccountSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001275 id = serializers.Field()
1276
Scott Baker196ffef2014-11-21 11:32:24 -08001277 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1278 def getHumanReadableName(self, obj):
1279 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001280 class Meta:
1281 model = Account
Scott Baker196ffef2014-11-21 11:32:24 -08001282 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001283
1284class AccountIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001285 id = serializers.Field()
1286
Scott Baker196ffef2014-11-21 11:32:24 -08001287 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1288 def getHumanReadableName(self, obj):
1289 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001290 class Meta:
1291 model = Account
Scott Baker196ffef2014-11-21 11:32:24 -08001292 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site',)
Scott Baker46b58542014-08-11 17:26:12 -07001293
1294
Sapan Bhatiadea39432014-06-13 03:10:36 -04001295
1296
Scott Baker0caeaf02014-06-19 11:12:55 -07001297class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001298 id = serializers.Field()
1299
Scott Baker196ffef2014-11-21 11:32:24 -08001300 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1301 def getHumanReadableName(self, obj):
1302 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001303 class Meta:
1304 model = NetworkParameterType
Scott Baker196ffef2014-11-21 11:32:24 -08001305 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001306
1307class NetworkParameterTypeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001308 id = serializers.Field()
1309
Scott Baker196ffef2014-11-21 11:32:24 -08001310 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1311 def getHumanReadableName(self, obj):
1312 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001313 class Meta:
1314 model = NetworkParameterType
Scott Baker196ffef2014-11-21 11:32:24 -08001315 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description',)
Scott Baker46b58542014-08-11 17:26:12 -07001316
1317
Sapan Bhatiadea39432014-06-13 03:10:36 -04001318
1319
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001320class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001321 id = serializers.Field()
1322
Scott Baker196ffef2014-11-21 11:32:24 -08001323 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1324 def getHumanReadableName(self, obj):
1325 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001326 class Meta:
1327 model = SiteCredential
Scott Baker196ffef2014-11-21 11:32:24 -08001328 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001329
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001330class SiteCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001331 id = serializers.Field()
1332
Scott Baker196ffef2014-11-21 11:32:24 -08001333 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1334 def getHumanReadableName(self, obj):
1335 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001336 class Meta:
1337 model = SiteCredential
Scott Baker196ffef2014-11-21 11:32:24 -08001338 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001339
1340
Scott Baker0caeaf02014-06-19 11:12:55 -07001341
1342
1343class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001344 id = serializers.Field()
1345
Scott Baker196ffef2014-11-21 11:32:24 -08001346 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1347 def getHumanReadableName(self, obj):
1348 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001349 class Meta:
1350 model = DeploymentPrivilege
Scott Baker196ffef2014-11-21 11:32:24 -08001351 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001352
1353class DeploymentPrivilegeIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001354 id = serializers.Field()
1355
Scott Baker196ffef2014-11-21 11:32:24 -08001356 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1357 def getHumanReadableName(self, obj):
1358 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001359 class Meta:
1360 model = DeploymentPrivilege
Scott Baker196ffef2014-11-21 11:32:24 -08001361 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
Scott Baker645dc9d2014-11-17 22:32:19 -08001362
1363
1364
1365
Scott Baker0caeaf02014-06-19 11:12:55 -07001366class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001367 id = serializers.Field()
1368
Scott Baker196ffef2014-11-21 11:32:24 -08001369 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1370 def getHumanReadableName(self, obj):
1371 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001372 class Meta:
1373 model = DeploymentRole
Scott Baker196ffef2014-11-21 11:32:24 -08001374 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001375
1376class DeploymentRoleIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001377 id = serializers.Field()
1378
Scott Baker196ffef2014-11-21 11:32:24 -08001379 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1380 def getHumanReadableName(self, obj):
1381 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001382 class Meta:
1383 model = DeploymentRole
Scott Baker196ffef2014-11-21 11:32:24 -08001384 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','role',)
Scott Baker46b58542014-08-11 17:26:12 -07001385
1386
Sapan Bhatiadea39432014-06-13 03:10:36 -04001387
1388
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001389class UserCredentialSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001390 id = serializers.Field()
1391
Scott Baker196ffef2014-11-21 11:32:24 -08001392 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1393 def getHumanReadableName(self, obj):
1394 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001395 class Meta:
1396 model = UserCredential
Scott Baker196ffef2014-11-21 11:32:24 -08001397 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
Scott Baker46b58542014-08-11 17:26:12 -07001398
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001399class UserCredentialIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001400 id = serializers.Field()
1401
Scott Baker196ffef2014-11-21 11:32:24 -08001402 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1403 def getHumanReadableName(self, obj):
1404 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001405 class Meta:
1406 model = UserCredential
Scott Baker196ffef2014-11-21 11:32:24 -08001407 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
1408
1409
1410
1411
1412class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer):
1413 id = serializers.Field()
1414
1415 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1416 def getHumanReadableName(self, obj):
1417 return str(obj)
1418 class Meta:
1419 model = SiteDeployments
1420 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
1421
1422class SiteDeploymentsIdSerializer(serializers.ModelSerializer):
1423 id = serializers.Field()
1424
1425 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1426 def getHumanReadableName(self, obj):
1427 return str(obj)
1428 class Meta:
1429 model = SiteDeployments
1430 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001431
1432
1433
1434
Scott Baker0caeaf02014-06-19 11:12:55 -07001435class SliceTagSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001436 id = serializers.Field()
1437
Scott Baker196ffef2014-11-21 11:32:24 -08001438 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1439 def getHumanReadableName(self, obj):
1440 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001441 class Meta:
1442 model = SliceTag
Scott Baker196ffef2014-11-21 11:32:24 -08001443 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07001444
1445class SliceTagIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001446 id = serializers.Field()
1447
Scott Baker196ffef2014-11-21 11:32:24 -08001448 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1449 def getHumanReadableName(self, obj):
1450 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001451 class Meta:
1452 model = SliceTag
Scott Baker196ffef2014-11-21 11:32:24 -08001453 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',)
Scott Baker46b58542014-08-11 17:26:12 -07001454
1455
Scott Baker0caeaf02014-06-19 11:12:55 -07001456
1457
1458class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001459 id = serializers.Field()
1460
Scott Baker196ffef2014-11-21 11:32:24 -08001461 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1462 def getHumanReadableName(self, obj):
1463 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001464 class Meta:
1465 model = NetworkTemplate
Scott Baker196ffef2014-11-21 11:32:24 -08001466 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07001467
1468class NetworkTemplateIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001469 id = serializers.Field()
1470
Scott Baker196ffef2014-11-21 11:32:24 -08001471 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1472 def getHumanReadableName(self, obj):
1473 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001474 class Meta:
1475 model = NetworkTemplate
Scott Baker196ffef2014-11-21 11:32:24 -08001476 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07001477
1478
Sapan Bhatiadea39432014-06-13 03:10:36 -04001479
1480
1481class RouterSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001482 id = serializers.Field()
1483
Scott Baker196ffef2014-11-21 11:32:24 -08001484 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1485 def getHumanReadableName(self, obj):
1486 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001487 class Meta:
1488 model = Router
Scott Baker196ffef2014-11-21 11:32:24 -08001489 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07001490
1491class RouterIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001492 id = serializers.Field()
1493
Scott Baker196ffef2014-11-21 11:32:24 -08001494 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1495 def getHumanReadableName(self, obj):
1496 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001497 class Meta:
1498 model = Router
Scott Baker196ffef2014-11-21 11:32:24 -08001499 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','name','owner',)
Scott Baker46b58542014-08-11 17:26:12 -07001500
1501
Sapan Bhatiadea39432014-06-13 03:10:36 -04001502
1503
Scott Baker0caeaf02014-06-19 11:12:55 -07001504class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001505 id = serializers.Field()
1506
Scott Baker196ffef2014-11-21 11:32:24 -08001507 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1508 def getHumanReadableName(self, obj):
1509 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001510 class Meta:
1511 model = ServiceResource
Scott Baker196ffef2014-11-21 11:32:24 -08001512 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07001513
1514class ServiceResourceIdSerializer(serializers.ModelSerializer):
Scott Baker08898c12014-10-29 23:41:11 -07001515 id = serializers.Field()
1516
Scott Baker196ffef2014-11-21 11:32:24 -08001517 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
1518 def getHumanReadableName(self, obj):
1519 return str(obj)
Scott Baker08898c12014-10-29 23:41:11 -07001520 class Meta:
1521 model = ServiceResource
Scott Baker196ffef2014-11-21 11:32:24 -08001522 fields = ('humanReadableName', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
Scott Baker46b58542014-08-11 17:26:12 -07001523
1524
Sapan Bhatiadea39432014-06-13 03:10:36 -04001525
1526
1527serializerLookUp = {
1528
Scott Baker0caeaf02014-06-19 11:12:55 -07001529 ServiceAttribute: ServiceAttributeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001530
1531 Image: ImageSerializer,
1532
Scott Baker0caeaf02014-06-19 11:12:55 -07001533 NetworkParameter: NetworkParameterSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001534
1535 Site: SiteSerializer,
1536
Scott Baker0caeaf02014-06-19 11:12:55 -07001537 SliceRole: SliceRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001538
1539 Tag: TagSerializer,
1540
1541 Invoice: InvoiceSerializer,
1542
Scott Baker0caeaf02014-06-19 11:12:55 -07001543 SlicePrivilege: SlicePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001544
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001545 PlanetStackRole: PlanetStackRoleSerializer,
1546
Scott Baker0caeaf02014-06-19 11:12:55 -07001547 NetworkSliver: NetworkSliverSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001548
Scott Baker0caeaf02014-06-19 11:12:55 -07001549 NetworkDeployments: NetworkDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001550
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001551 Flavor: FlavorSerializer,
1552
1553 Project: ProjectSerializer,
1554
Sapan Bhatiadea39432014-06-13 03:10:36 -04001555 Slice: SliceSerializer,
1556
1557 Network: NetworkSerializer,
1558
1559 Service: ServiceSerializer,
1560
Scott Baker0caeaf02014-06-19 11:12:55 -07001561 ServiceClass: ServiceClassSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001562
Scott Baker196ffef2014-11-21 11:32:24 -08001563 Payment: PaymentSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001564
1565 Charge: ChargeSerializer,
1566
1567 Role: RoleSerializer,
1568
Scott Baker0caeaf02014-06-19 11:12:55 -07001569 UsableObject: UsableObjectSerializer,
1570
1571 SiteRole: SiteRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001572
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001573 SliceCredential: SliceCredentialSerializer,
1574
Sapan Bhatiadea39432014-06-13 03:10:36 -04001575 Sliver: SliverSerializer,
1576
1577 Node: NodeSerializer,
1578
Scott Baker0caeaf02014-06-19 11:12:55 -07001579 DashboardView: DashboardViewSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001580
Scott Baker196ffef2014-11-21 11:32:24 -08001581 ImageDeployments: ImageDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001582
Scott Baker196ffef2014-11-21 11:32:24 -08001583 ReservedResource: ReservedResourceSerializer,
Scott Baker645dc9d2014-11-17 22:32:19 -08001584
Scott Baker0caeaf02014-06-19 11:12:55 -07001585 NetworkSlice: NetworkSliceSerializer,
1586
1587 UserDashboardView: UserDashboardViewSerializer,
1588
1589 PlanetStackPrivilege: PlanetStackPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001590
1591 User: UserSerializer,
1592
1593 Deployment: DeploymentSerializer,
1594
1595 Reservation: ReservationSerializer,
1596
Scott Baker196ffef2014-11-21 11:32:24 -08001597 SliceDeployments: SliceDeploymentsSerializer,
1598
Scott Baker0caeaf02014-06-19 11:12:55 -07001599 SitePrivilege: SitePrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001600
Scott Baker196ffef2014-11-21 11:32:24 -08001601 PlanetStack: PlanetStackSerializer,
Scott Baker0caeaf02014-06-19 11:12:55 -07001602
Sapan Bhatia3f879692014-11-19 15:10:51 -05001603 UserDeployments: UserDeploymentsSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001604
1605 Account: AccountSerializer,
1606
Scott Baker0caeaf02014-06-19 11:12:55 -07001607 NetworkParameterType: NetworkParameterTypeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001608
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001609 SiteCredential: SiteCredentialSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001610
Scott Baker0caeaf02014-06-19 11:12:55 -07001611 DeploymentPrivilege: DeploymentPrivilegeSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001612
Scott Baker0caeaf02014-06-19 11:12:55 -07001613 DeploymentRole: DeploymentRoleSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001614
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001615 UserCredential: UserCredentialSerializer,
1616
Scott Baker196ffef2014-11-21 11:32:24 -08001617 SiteDeployments: SiteDeploymentsSerializer,
1618
Scott Baker0caeaf02014-06-19 11:12:55 -07001619 SliceTag: SliceTagSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001620
Scott Baker0caeaf02014-06-19 11:12:55 -07001621 NetworkTemplate: NetworkTemplateSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001622
1623 Router: RouterSerializer,
1624
Scott Baker0caeaf02014-06-19 11:12:55 -07001625 ServiceResource: ServiceResourceSerializer,
Sapan Bhatiadea39432014-06-13 03:10:36 -04001626
1627 None: None,
1628 }
1629
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001630class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView):
1631
1632 # To handle fine-grained field permissions, we have to check can_update
1633 # the object has been updated but before it has been saved.
1634
1635 def update(self, request, *args, **kwargs):
1636 partial = kwargs.pop('partial', False)
1637 self.object = self.get_object_or_none()
1638
1639 serializer = self.get_serializer(self.object, data=request.DATA,
1640 files=request.FILES, partial=partial)
1641
1642 if not serializer.is_valid():
1643 print "UpdateModelMixin: not serializer.is_valid"
1644 print serializer.errors
1645 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
1646
1647 try:
1648 self.pre_save(serializer.object)
1649 except ValidationError as err:
1650 # full_clean on model instance may be called in pre_save,
1651 # so we have to handle eventual errors.
1652 return Response(err.message_dict, status=status.HTTP_400_BAD_REQUEST)
1653
1654 if serializer.object is not None:
1655 if not serializer.object.can_update(request.user):
1656 return Response(status=status.HTTP_400_BAD_REQUEST)
1657
1658 if self.object is None:
1659 self.object = serializer.save(force_insert=True)
1660 self.post_save(self.object, created=True)
1661 return Response(serializer.data, status=status.HTTP_201_CREATED)
1662
1663 self.object = serializer.save(force_update=True)
1664 self.post_save(self.object, created=False)
1665 return Response(serializer.data, status=status.HTTP_200_OK)
1666
1667 def destroy(self, request, *args, **kwargs):
1668 obj = self.get_object()
1669 if obj.can_update(request.user):
Scott Baker08898c12014-10-29 23:41:11 -07001670 return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001671 else:
1672 return Response(status=status.HTTP_400_BAD_REQUEST)
1673
1674
Sapan Bhatiadea39432014-06-13 03:10:36 -04001675# Based on core/views/*.py
1676
1677
Scott Baker0caeaf02014-06-19 11:12:55 -07001678class ServiceAttributeList(generics.ListCreateAPIView):
1679 queryset = ServiceAttribute.objects.select_related().all()
1680 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001681 id_serializer_class = ServiceAttributeIdSerializer
1682 filter_backends = (filters.DjangoFilterBackend,)
1683 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',)
1684
1685 def get_serializer_class(self):
1686 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1687 if (no_hyperlinks):
1688 return self.id_serializer_class
1689 else:
1690 return self.serializer_class
1691
Scott Baker0caeaf02014-06-19 11:12:55 -07001692 def get_queryset(self):
1693 return ServiceAttribute.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001694
Scott Baker0caeaf02014-06-19 11:12:55 -07001695 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08001696 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
1697 if not (serializer.is_valid()):
1698 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
1699 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07001700 obj.caller = request.user
1701 if obj.can_update(request.user):
1702 return super(ServiceAttributeList, self).create(request, *args, **kwargs)
1703 else:
Scott Baker08898c12014-10-29 23:41:11 -07001704 raise Exception("failed obj.can_update")
1705
1706 ret = super(ServiceAttributeList, self).create(request, *args, **kwargs)
1707 if (ret.status_code%100 != 200):
1708 raise Exception(ret.data)
1709
1710 return ret
1711
Scott Baker0caeaf02014-06-19 11:12:55 -07001712
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001713class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001714 queryset = ServiceAttribute.objects.select_related().all()
1715 serializer_class = ServiceAttributeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001716 id_serializer_class = ServiceAttributeIdSerializer
1717
1718 def get_serializer_class(self):
1719 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1720 if (no_hyperlinks):
1721 return self.id_serializer_class
1722 else:
1723 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001724
1725 def get_queryset(self):
1726 return ServiceAttribute.select_by_user(self.request.user)
1727
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001728 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001729
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001730 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001731
Scott Bakerf3816ac2014-11-12 01:13:53 -08001732"""
1733 XXX smbaker: my intent was to create a view that would return 'new' objects
1734 filled with defaults. I solved it another way, so this code may soon be
1735 abandoned.
1736
1737class ServiceAttributeNew(GenericAPIView):
1738 serializer_class = ServiceAttributeSerializer
1739 id_serializer_class = ServiceAttributeIdSerializer
1740
1741 def get(self, request, *args, **kwargs):
1742 return self.makenew(request, *args, **kwargs)
1743
1744 def get_serializer_class(self):
1745 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1746 if (no_hyperlinks):
1747 return self.id_serializer_class
1748 else:
1749 return self.serializer_class
1750
1751 def makenew(self, request, *args, **kwargs):
1752 obj = ServiceAttribute()
1753 serializer = self.get_serializer(obj)
1754 return Response(serializer.data)
1755"""
1756
Sapan Bhatiadea39432014-06-13 03:10:36 -04001757
1758
1759class ImageList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001760 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001761 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001762 id_serializer_class = ImageIdSerializer
1763 filter_backends = (filters.DjangoFilterBackend,)
1764 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',)
1765
1766 def get_serializer_class(self):
1767 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1768 if (no_hyperlinks):
1769 return self.id_serializer_class
1770 else:
1771 return self.serializer_class
1772
Scott Baker0caeaf02014-06-19 11:12:55 -07001773 def get_queryset(self):
1774 return Image.select_by_user(self.request.user)
1775
1776 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08001777 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
1778 if not (serializer.is_valid()):
1779 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
1780 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07001781 obj.caller = request.user
1782 if obj.can_update(request.user):
1783 return super(ImageList, self).create(request, *args, **kwargs)
1784 else:
Scott Baker08898c12014-10-29 23:41:11 -07001785 raise Exception("failed obj.can_update")
1786
1787 ret = super(ImageList, self).create(request, *args, **kwargs)
1788 if (ret.status_code%100 != 200):
1789 raise Exception(ret.data)
1790
1791 return ret
1792
Sapan Bhatiadea39432014-06-13 03:10:36 -04001793
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001794class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001795 queryset = Image.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001796 serializer_class = ImageSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001797 id_serializer_class = ImageIdSerializer
1798
1799 def get_serializer_class(self):
1800 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1801 if (no_hyperlinks):
1802 return self.id_serializer_class
1803 else:
1804 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001805
1806 def get_queryset(self):
1807 return Image.select_by_user(self.request.user)
1808
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001809 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001810
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001811 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001812
Scott Bakerf3816ac2014-11-12 01:13:53 -08001813"""
1814 XXX smbaker: my intent was to create a view that would return 'new' objects
1815 filled with defaults. I solved it another way, so this code may soon be
1816 abandoned.
1817
1818class ImageNew(GenericAPIView):
1819 serializer_class = ImageSerializer
1820 id_serializer_class = ImageIdSerializer
1821
1822 def get(self, request, *args, **kwargs):
1823 return self.makenew(request, *args, **kwargs)
1824
1825 def get_serializer_class(self):
1826 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1827 if (no_hyperlinks):
1828 return self.id_serializer_class
1829 else:
1830 return self.serializer_class
1831
1832 def makenew(self, request, *args, **kwargs):
1833 obj = Image()
1834 serializer = self.get_serializer(obj)
1835 return Response(serializer.data)
1836"""
1837
Sapan Bhatiadea39432014-06-13 03:10:36 -04001838
1839
Scott Baker0caeaf02014-06-19 11:12:55 -07001840class NetworkParameterList(generics.ListCreateAPIView):
1841 queryset = NetworkParameter.objects.select_related().all()
1842 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001843 id_serializer_class = NetworkParameterIdSerializer
1844 filter_backends = (filters.DjangoFilterBackend,)
1845 filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',)
1846
1847 def get_serializer_class(self):
1848 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1849 if (no_hyperlinks):
1850 return self.id_serializer_class
1851 else:
1852 return self.serializer_class
1853
Scott Baker0caeaf02014-06-19 11:12:55 -07001854 def get_queryset(self):
1855 return NetworkParameter.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001856
Scott Baker0caeaf02014-06-19 11:12:55 -07001857 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08001858 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
1859 if not (serializer.is_valid()):
1860 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
1861 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07001862 obj.caller = request.user
1863 if obj.can_update(request.user):
1864 return super(NetworkParameterList, self).create(request, *args, **kwargs)
1865 else:
Scott Baker08898c12014-10-29 23:41:11 -07001866 raise Exception("failed obj.can_update")
1867
1868 ret = super(NetworkParameterList, self).create(request, *args, **kwargs)
1869 if (ret.status_code%100 != 200):
1870 raise Exception(ret.data)
1871
1872 return ret
1873
Scott Baker0caeaf02014-06-19 11:12:55 -07001874
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001875class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001876 queryset = NetworkParameter.objects.select_related().all()
1877 serializer_class = NetworkParameterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001878 id_serializer_class = NetworkParameterIdSerializer
1879
1880 def get_serializer_class(self):
1881 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1882 if (no_hyperlinks):
1883 return self.id_serializer_class
1884 else:
1885 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001886
1887 def get_queryset(self):
1888 return NetworkParameter.select_by_user(self.request.user)
1889
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001890 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001891
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001892 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001893
Scott Bakerf3816ac2014-11-12 01:13:53 -08001894"""
1895 XXX smbaker: my intent was to create a view that would return 'new' objects
1896 filled with defaults. I solved it another way, so this code may soon be
1897 abandoned.
1898
1899class NetworkParameterNew(GenericAPIView):
1900 serializer_class = NetworkParameterSerializer
1901 id_serializer_class = NetworkParameterIdSerializer
1902
1903 def get(self, request, *args, **kwargs):
1904 return self.makenew(request, *args, **kwargs)
1905
1906 def get_serializer_class(self):
1907 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1908 if (no_hyperlinks):
1909 return self.id_serializer_class
1910 else:
1911 return self.serializer_class
1912
1913 def makenew(self, request, *args, **kwargs):
1914 obj = NetworkParameter()
1915 serializer = self.get_serializer(obj)
1916 return Response(serializer.data)
1917"""
1918
Sapan Bhatiadea39432014-06-13 03:10:36 -04001919
1920
1921class SiteList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001922 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001923 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001924 id_serializer_class = SiteIdSerializer
1925 filter_backends = (filters.DjangoFilterBackend,)
1926 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name',)
1927
1928 def get_serializer_class(self):
1929 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1930 if (no_hyperlinks):
1931 return self.id_serializer_class
1932 else:
1933 return self.serializer_class
1934
Scott Baker0caeaf02014-06-19 11:12:55 -07001935 def get_queryset(self):
1936 return Site.select_by_user(self.request.user)
1937
1938 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08001939 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
1940 if not (serializer.is_valid()):
1941 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
1942 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07001943 obj.caller = request.user
1944 if obj.can_update(request.user):
1945 return super(SiteList, self).create(request, *args, **kwargs)
1946 else:
Scott Baker08898c12014-10-29 23:41:11 -07001947 raise Exception("failed obj.can_update")
1948
1949 ret = super(SiteList, self).create(request, *args, **kwargs)
1950 if (ret.status_code%100 != 200):
1951 raise Exception(ret.data)
1952
1953 return ret
1954
Sapan Bhatiadea39432014-06-13 03:10:36 -04001955
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001956class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07001957 queryset = Site.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04001958 serializer_class = SiteSerializer
Scott Baker46b58542014-08-11 17:26:12 -07001959 id_serializer_class = SiteIdSerializer
1960
1961 def get_serializer_class(self):
1962 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1963 if (no_hyperlinks):
1964 return self.id_serializer_class
1965 else:
1966 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07001967
1968 def get_queryset(self):
1969 return Site.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04001970
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001971 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04001972
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07001973 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07001974
Scott Bakerf3816ac2014-11-12 01:13:53 -08001975"""
1976 XXX smbaker: my intent was to create a view that would return 'new' objects
1977 filled with defaults. I solved it another way, so this code may soon be
1978 abandoned.
1979
1980class SiteNew(GenericAPIView):
1981 serializer_class = SiteSerializer
1982 id_serializer_class = SiteIdSerializer
1983
1984 def get(self, request, *args, **kwargs):
1985 return self.makenew(request, *args, **kwargs)
1986
1987 def get_serializer_class(self):
1988 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
1989 if (no_hyperlinks):
1990 return self.id_serializer_class
1991 else:
1992 return self.serializer_class
1993
1994 def makenew(self, request, *args, **kwargs):
1995 obj = Site()
1996 serializer = self.get_serializer(obj)
1997 return Response(serializer.data)
1998"""
1999
Scott Baker0caeaf02014-06-19 11:12:55 -07002000
2001
2002class SliceRoleList(generics.ListCreateAPIView):
2003 queryset = SliceRole.objects.select_related().all()
2004 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002005 id_serializer_class = SliceRoleIdSerializer
2006 filter_backends = (filters.DjangoFilterBackend,)
2007 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2008
2009 def get_serializer_class(self):
2010 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2011 if (no_hyperlinks):
2012 return self.id_serializer_class
2013 else:
2014 return self.serializer_class
2015
Scott Baker0caeaf02014-06-19 11:12:55 -07002016 def get_queryset(self):
2017 return SliceRole.select_by_user(self.request.user)
2018
2019 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002020 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2021 if not (serializer.is_valid()):
2022 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2023 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002024 obj.caller = request.user
2025 if obj.can_update(request.user):
2026 return super(SliceRoleList, self).create(request, *args, **kwargs)
2027 else:
Scott Baker08898c12014-10-29 23:41:11 -07002028 raise Exception("failed obj.can_update")
2029
2030 ret = super(SliceRoleList, self).create(request, *args, **kwargs)
2031 if (ret.status_code%100 != 200):
2032 raise Exception(ret.data)
2033
2034 return ret
2035
Scott Baker0caeaf02014-06-19 11:12:55 -07002036
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002037class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002038 queryset = SliceRole.objects.select_related().all()
2039 serializer_class = SliceRoleSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002040 id_serializer_class = SliceRoleIdSerializer
2041
2042 def get_serializer_class(self):
2043 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2044 if (no_hyperlinks):
2045 return self.id_serializer_class
2046 else:
2047 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002048
2049 def get_queryset(self):
2050 return SliceRole.select_by_user(self.request.user)
2051
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002052 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002053
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002054 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002055
Scott Bakerf3816ac2014-11-12 01:13:53 -08002056"""
2057 XXX smbaker: my intent was to create a view that would return 'new' objects
2058 filled with defaults. I solved it another way, so this code may soon be
2059 abandoned.
2060
2061class SliceRoleNew(GenericAPIView):
2062 serializer_class = SliceRoleSerializer
2063 id_serializer_class = SliceRoleIdSerializer
2064
2065 def get(self, request, *args, **kwargs):
2066 return self.makenew(request, *args, **kwargs)
2067
2068 def get_serializer_class(self):
2069 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2070 if (no_hyperlinks):
2071 return self.id_serializer_class
2072 else:
2073 return self.serializer_class
2074
2075 def makenew(self, request, *args, **kwargs):
2076 obj = SliceRole()
2077 serializer = self.get_serializer(obj)
2078 return Response(serializer.data)
2079"""
2080
Sapan Bhatiadea39432014-06-13 03:10:36 -04002081
2082
2083class TagList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002084 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002085 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002086 id_serializer_class = TagIdSerializer
2087 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002088 filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',)
Scott Baker46b58542014-08-11 17:26:12 -07002089
2090 def get_serializer_class(self):
2091 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2092 if (no_hyperlinks):
2093 return self.id_serializer_class
2094 else:
2095 return self.serializer_class
2096
Scott Baker0caeaf02014-06-19 11:12:55 -07002097 def get_queryset(self):
2098 return Tag.select_by_user(self.request.user)
2099
2100 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002101 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2102 if not (serializer.is_valid()):
2103 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2104 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002105 obj.caller = request.user
2106 if obj.can_update(request.user):
2107 return super(TagList, self).create(request, *args, **kwargs)
2108 else:
Scott Baker08898c12014-10-29 23:41:11 -07002109 raise Exception("failed obj.can_update")
2110
2111 ret = super(TagList, self).create(request, *args, **kwargs)
2112 if (ret.status_code%100 != 200):
2113 raise Exception(ret.data)
2114
2115 return ret
2116
Sapan Bhatiadea39432014-06-13 03:10:36 -04002117
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002118class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002119 queryset = Tag.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002120 serializer_class = TagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002121 id_serializer_class = TagIdSerializer
2122
2123 def get_serializer_class(self):
2124 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2125 if (no_hyperlinks):
2126 return self.id_serializer_class
2127 else:
2128 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002129
2130 def get_queryset(self):
2131 return Tag.select_by_user(self.request.user)
2132
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002133 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002134
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002135 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002136
Scott Bakerf3816ac2014-11-12 01:13:53 -08002137"""
2138 XXX smbaker: my intent was to create a view that would return 'new' objects
2139 filled with defaults. I solved it another way, so this code may soon be
2140 abandoned.
2141
2142class TagNew(GenericAPIView):
2143 serializer_class = TagSerializer
2144 id_serializer_class = TagIdSerializer
2145
2146 def get(self, request, *args, **kwargs):
2147 return self.makenew(request, *args, **kwargs)
2148
2149 def get_serializer_class(self):
2150 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2151 if (no_hyperlinks):
2152 return self.id_serializer_class
2153 else:
2154 return self.serializer_class
2155
2156 def makenew(self, request, *args, **kwargs):
2157 obj = Tag()
2158 serializer = self.get_serializer(obj)
2159 return Response(serializer.data)
2160"""
2161
Sapan Bhatiadea39432014-06-13 03:10:36 -04002162
2163
2164class InvoiceList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002165 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002166 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002167 id_serializer_class = InvoiceIdSerializer
2168 filter_backends = (filters.DjangoFilterBackend,)
2169 filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',)
2170
2171 def get_serializer_class(self):
2172 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2173 if (no_hyperlinks):
2174 return self.id_serializer_class
2175 else:
2176 return self.serializer_class
2177
Scott Baker0caeaf02014-06-19 11:12:55 -07002178 def get_queryset(self):
2179 return Invoice.select_by_user(self.request.user)
2180
2181 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002182 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2183 if not (serializer.is_valid()):
2184 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2185 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002186 obj.caller = request.user
2187 if obj.can_update(request.user):
2188 return super(InvoiceList, self).create(request, *args, **kwargs)
2189 else:
Scott Baker08898c12014-10-29 23:41:11 -07002190 raise Exception("failed obj.can_update")
2191
2192 ret = super(InvoiceList, self).create(request, *args, **kwargs)
2193 if (ret.status_code%100 != 200):
2194 raise Exception(ret.data)
2195
2196 return ret
2197
Sapan Bhatiadea39432014-06-13 03:10:36 -04002198
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002199class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002200 queryset = Invoice.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04002201 serializer_class = InvoiceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002202 id_serializer_class = InvoiceIdSerializer
2203
2204 def get_serializer_class(self):
2205 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2206 if (no_hyperlinks):
2207 return self.id_serializer_class
2208 else:
2209 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002210
2211 def get_queryset(self):
2212 return Invoice.select_by_user(self.request.user)
2213
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002214 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002215
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002216 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002217
Scott Bakerf3816ac2014-11-12 01:13:53 -08002218"""
2219 XXX smbaker: my intent was to create a view that would return 'new' objects
2220 filled with defaults. I solved it another way, so this code may soon be
2221 abandoned.
2222
2223class InvoiceNew(GenericAPIView):
2224 serializer_class = InvoiceSerializer
2225 id_serializer_class = InvoiceIdSerializer
2226
2227 def get(self, request, *args, **kwargs):
2228 return self.makenew(request, *args, **kwargs)
2229
2230 def get_serializer_class(self):
2231 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2232 if (no_hyperlinks):
2233 return self.id_serializer_class
2234 else:
2235 return self.serializer_class
2236
2237 def makenew(self, request, *args, **kwargs):
2238 obj = Invoice()
2239 serializer = self.get_serializer(obj)
2240 return Response(serializer.data)
2241"""
2242
Sapan Bhatiadea39432014-06-13 03:10:36 -04002243
2244
Scott Baker0caeaf02014-06-19 11:12:55 -07002245class SlicePrivilegeList(generics.ListCreateAPIView):
2246 queryset = SlicePrivilege.objects.select_related().all()
2247 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002248 id_serializer_class = SlicePrivilegeIdSerializer
2249 filter_backends = (filters.DjangoFilterBackend,)
2250 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',)
2251
2252 def get_serializer_class(self):
2253 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2254 if (no_hyperlinks):
2255 return self.id_serializer_class
2256 else:
2257 return self.serializer_class
2258
Scott Baker0caeaf02014-06-19 11:12:55 -07002259 def get_queryset(self):
2260 return SlicePrivilege.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002261
Scott Baker0caeaf02014-06-19 11:12:55 -07002262 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002263 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2264 if not (serializer.is_valid()):
2265 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2266 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002267 obj.caller = request.user
2268 if obj.can_update(request.user):
2269 return super(SlicePrivilegeList, self).create(request, *args, **kwargs)
2270 else:
Scott Baker08898c12014-10-29 23:41:11 -07002271 raise Exception("failed obj.can_update")
2272
2273 ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs)
2274 if (ret.status_code%100 != 200):
2275 raise Exception(ret.data)
2276
2277 return ret
2278
Scott Baker0caeaf02014-06-19 11:12:55 -07002279
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002280class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002281 queryset = SlicePrivilege.objects.select_related().all()
2282 serializer_class = SlicePrivilegeSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002283 id_serializer_class = SlicePrivilegeIdSerializer
2284
2285 def get_serializer_class(self):
2286 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2287 if (no_hyperlinks):
2288 return self.id_serializer_class
2289 else:
2290 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002291
2292 def get_queryset(self):
2293 return SlicePrivilege.select_by_user(self.request.user)
2294
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002295 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2296
2297 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2298
Scott Bakerf3816ac2014-11-12 01:13:53 -08002299"""
2300 XXX smbaker: my intent was to create a view that would return 'new' objects
2301 filled with defaults. I solved it another way, so this code may soon be
2302 abandoned.
2303
2304class SlicePrivilegeNew(GenericAPIView):
2305 serializer_class = SlicePrivilegeSerializer
2306 id_serializer_class = SlicePrivilegeIdSerializer
2307
2308 def get(self, request, *args, **kwargs):
2309 return self.makenew(request, *args, **kwargs)
2310
2311 def get_serializer_class(self):
2312 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2313 if (no_hyperlinks):
2314 return self.id_serializer_class
2315 else:
2316 return self.serializer_class
2317
2318 def makenew(self, request, *args, **kwargs):
2319 obj = SlicePrivilege()
2320 serializer = self.get_serializer(obj)
2321 return Response(serializer.data)
2322"""
2323
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002324
2325
2326class PlanetStackRoleList(generics.ListCreateAPIView):
2327 queryset = PlanetStackRole.objects.select_related().all()
2328 serializer_class = PlanetStackRoleSerializer
2329 id_serializer_class = PlanetStackRoleIdSerializer
2330 filter_backends = (filters.DjangoFilterBackend,)
2331 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
2332
2333 def get_serializer_class(self):
2334 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2335 if (no_hyperlinks):
2336 return self.id_serializer_class
2337 else:
2338 return self.serializer_class
2339
2340 def get_queryset(self):
2341 return PlanetStackRole.select_by_user(self.request.user)
2342
2343 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002344 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2345 if not (serializer.is_valid()):
2346 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2347 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002348 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07002349 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002350 return super(PlanetStackRoleList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002351 else:
Scott Baker08898c12014-10-29 23:41:11 -07002352 raise Exception("failed obj.can_update")
2353
2354 ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs)
2355 if (ret.status_code%100 != 200):
2356 raise Exception(ret.data)
2357
2358 return ret
2359
Scott Baker0caeaf02014-06-19 11:12:55 -07002360
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002361class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2362 queryset = PlanetStackRole.objects.select_related().all()
2363 serializer_class = PlanetStackRoleSerializer
2364 id_serializer_class = PlanetStackRoleIdSerializer
2365
2366 def get_serializer_class(self):
2367 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2368 if (no_hyperlinks):
2369 return self.id_serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002370 else:
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002371 return self.serializer_class
2372
2373 def get_queryset(self):
2374 return PlanetStackRole.select_by_user(self.request.user)
2375
2376 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2377
2378 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002379
Scott Bakerf3816ac2014-11-12 01:13:53 -08002380"""
2381 XXX smbaker: my intent was to create a view that would return 'new' objects
2382 filled with defaults. I solved it another way, so this code may soon be
2383 abandoned.
2384
2385class PlanetStackRoleNew(GenericAPIView):
2386 serializer_class = PlanetStackRoleSerializer
2387 id_serializer_class = PlanetStackRoleIdSerializer
2388
2389 def get(self, request, *args, **kwargs):
2390 return self.makenew(request, *args, **kwargs)
2391
2392 def get_serializer_class(self):
2393 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2394 if (no_hyperlinks):
2395 return self.id_serializer_class
2396 else:
2397 return self.serializer_class
2398
2399 def makenew(self, request, *args, **kwargs):
2400 obj = PlanetStackRole()
2401 serializer = self.get_serializer(obj)
2402 return Response(serializer.data)
2403"""
2404
Sapan Bhatiadea39432014-06-13 03:10:36 -04002405
2406
Scott Baker0caeaf02014-06-19 11:12:55 -07002407class NetworkSliverList(generics.ListCreateAPIView):
2408 queryset = NetworkSliver.objects.select_related().all()
2409 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002410 id_serializer_class = NetworkSliverIdSerializer
2411 filter_backends = (filters.DjangoFilterBackend,)
2412 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',)
2413
2414 def get_serializer_class(self):
2415 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2416 if (no_hyperlinks):
2417 return self.id_serializer_class
2418 else:
2419 return self.serializer_class
2420
Scott Baker0caeaf02014-06-19 11:12:55 -07002421 def get_queryset(self):
2422 return NetworkSliver.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002423
Scott Baker0caeaf02014-06-19 11:12:55 -07002424 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002425 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2426 if not (serializer.is_valid()):
2427 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2428 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002429 obj.caller = request.user
2430 if obj.can_update(request.user):
2431 return super(NetworkSliverList, self).create(request, *args, **kwargs)
2432 else:
Scott Baker08898c12014-10-29 23:41:11 -07002433 raise Exception("failed obj.can_update")
2434
2435 ret = super(NetworkSliverList, self).create(request, *args, **kwargs)
2436 if (ret.status_code%100 != 200):
2437 raise Exception(ret.data)
2438
2439 return ret
2440
Scott Baker0caeaf02014-06-19 11:12:55 -07002441
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002442class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002443 queryset = NetworkSliver.objects.select_related().all()
2444 serializer_class = NetworkSliverSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002445 id_serializer_class = NetworkSliverIdSerializer
2446
2447 def get_serializer_class(self):
2448 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2449 if (no_hyperlinks):
2450 return self.id_serializer_class
2451 else:
2452 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002453
2454 def get_queryset(self):
2455 return NetworkSliver.select_by_user(self.request.user)
2456
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002457 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002458
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002459 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002460
Scott Bakerf3816ac2014-11-12 01:13:53 -08002461"""
2462 XXX smbaker: my intent was to create a view that would return 'new' objects
2463 filled with defaults. I solved it another way, so this code may soon be
2464 abandoned.
2465
2466class NetworkSliverNew(GenericAPIView):
2467 serializer_class = NetworkSliverSerializer
2468 id_serializer_class = NetworkSliverIdSerializer
2469
2470 def get(self, request, *args, **kwargs):
2471 return self.makenew(request, *args, **kwargs)
2472
2473 def get_serializer_class(self):
2474 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2475 if (no_hyperlinks):
2476 return self.id_serializer_class
2477 else:
2478 return self.serializer_class
2479
2480 def makenew(self, request, *args, **kwargs):
2481 obj = NetworkSliver()
2482 serializer = self.get_serializer(obj)
2483 return Response(serializer.data)
2484"""
2485
Sapan Bhatiadea39432014-06-13 03:10:36 -04002486
2487
Scott Baker0caeaf02014-06-19 11:12:55 -07002488class NetworkDeploymentsList(generics.ListCreateAPIView):
2489 queryset = NetworkDeployments.objects.select_related().all()
2490 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002491 id_serializer_class = NetworkDeploymentsIdSerializer
2492 filter_backends = (filters.DjangoFilterBackend,)
2493 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','deployment','net_id','router_id','subnet_id','subnet',)
2494
2495 def get_serializer_class(self):
2496 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2497 if (no_hyperlinks):
2498 return self.id_serializer_class
2499 else:
2500 return self.serializer_class
2501
Scott Baker0caeaf02014-06-19 11:12:55 -07002502 def get_queryset(self):
2503 return NetworkDeployments.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002504
Scott Baker0caeaf02014-06-19 11:12:55 -07002505 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002506 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2507 if not (serializer.is_valid()):
2508 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2509 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002510 obj.caller = request.user
2511 if obj.can_update(request.user):
2512 return super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
2513 else:
Scott Baker08898c12014-10-29 23:41:11 -07002514 raise Exception("failed obj.can_update")
2515
2516 ret = super(NetworkDeploymentsList, self).create(request, *args, **kwargs)
2517 if (ret.status_code%100 != 200):
2518 raise Exception(ret.data)
2519
2520 return ret
2521
Scott Baker0caeaf02014-06-19 11:12:55 -07002522
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002523class NetworkDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002524 queryset = NetworkDeployments.objects.select_related().all()
2525 serializer_class = NetworkDeploymentsSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002526 id_serializer_class = NetworkDeploymentsIdSerializer
2527
2528 def get_serializer_class(self):
2529 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2530 if (no_hyperlinks):
2531 return self.id_serializer_class
2532 else:
2533 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002534
2535 def get_queryset(self):
2536 return NetworkDeployments.select_by_user(self.request.user)
2537
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002538 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002539
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002540 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002541
Scott Bakerf3816ac2014-11-12 01:13:53 -08002542"""
2543 XXX smbaker: my intent was to create a view that would return 'new' objects
2544 filled with defaults. I solved it another way, so this code may soon be
2545 abandoned.
2546
2547class NetworkDeploymentsNew(GenericAPIView):
2548 serializer_class = NetworkDeploymentsSerializer
2549 id_serializer_class = NetworkDeploymentsIdSerializer
2550
2551 def get(self, request, *args, **kwargs):
2552 return self.makenew(request, *args, **kwargs)
2553
2554 def get_serializer_class(self):
2555 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2556 if (no_hyperlinks):
2557 return self.id_serializer_class
2558 else:
2559 return self.serializer_class
2560
2561 def makenew(self, request, *args, **kwargs):
2562 obj = NetworkDeployments()
2563 serializer = self.get_serializer(obj)
2564 return Response(serializer.data)
2565"""
2566
Sapan Bhatiadea39432014-06-13 03:10:36 -04002567
2568
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002569class FlavorList(generics.ListCreateAPIView):
2570 queryset = Flavor.objects.select_related().all()
2571 serializer_class = FlavorSerializer
2572 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002573 filter_backends = (filters.DjangoFilterBackend,)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002574 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default',)
Scott Baker46b58542014-08-11 17:26:12 -07002575
2576 def get_serializer_class(self):
2577 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2578 if (no_hyperlinks):
2579 return self.id_serializer_class
2580 else:
2581 return self.serializer_class
2582
Scott Baker0caeaf02014-06-19 11:12:55 -07002583 def get_queryset(self):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002584 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002585
2586 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002587 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2588 if not (serializer.is_valid()):
2589 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2590 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002591 obj.caller = request.user
2592 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002593 return super(FlavorList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002594 else:
Scott Baker08898c12014-10-29 23:41:11 -07002595 raise Exception("failed obj.can_update")
2596
2597 ret = super(FlavorList, self).create(request, *args, **kwargs)
2598 if (ret.status_code%100 != 200):
2599 raise Exception(ret.data)
2600
2601 return ret
2602
Sapan Bhatiadea39432014-06-13 03:10:36 -04002603
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002604class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2605 queryset = Flavor.objects.select_related().all()
2606 serializer_class = FlavorSerializer
2607 id_serializer_class = FlavorIdSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002608
2609 def get_serializer_class(self):
2610 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2611 if (no_hyperlinks):
2612 return self.id_serializer_class
2613 else:
2614 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002615
2616 def get_queryset(self):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002617 return Flavor.select_by_user(self.request.user)
Scott Baker0caeaf02014-06-19 11:12:55 -07002618
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002619 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07002620
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002621 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04002622
Scott Bakerf3816ac2014-11-12 01:13:53 -08002623"""
2624 XXX smbaker: my intent was to create a view that would return 'new' objects
2625 filled with defaults. I solved it another way, so this code may soon be
2626 abandoned.
2627
2628class FlavorNew(GenericAPIView):
2629 serializer_class = FlavorSerializer
2630 id_serializer_class = FlavorIdSerializer
2631
2632 def get(self, request, *args, **kwargs):
2633 return self.makenew(request, *args, **kwargs)
2634
2635 def get_serializer_class(self):
2636 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2637 if (no_hyperlinks):
2638 return self.id_serializer_class
2639 else:
2640 return self.serializer_class
2641
2642 def makenew(self, request, *args, **kwargs):
2643 obj = Flavor()
2644 serializer = self.get_serializer(obj)
2645 return Response(serializer.data)
2646"""
2647
Sapan Bhatiadea39432014-06-13 03:10:36 -04002648
2649
Scott Baker0caeaf02014-06-19 11:12:55 -07002650class ProjectList(generics.ListCreateAPIView):
2651 queryset = Project.objects.select_related().all()
2652 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002653 id_serializer_class = ProjectIdSerializer
2654 filter_backends = (filters.DjangoFilterBackend,)
2655 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
2656
2657 def get_serializer_class(self):
2658 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2659 if (no_hyperlinks):
2660 return self.id_serializer_class
2661 else:
2662 return self.serializer_class
2663
Scott Baker0caeaf02014-06-19 11:12:55 -07002664 def get_queryset(self):
2665 return Project.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04002666
Scott Baker0caeaf02014-06-19 11:12:55 -07002667 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002668 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2669 if not (serializer.is_valid()):
2670 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2671 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07002672 obj.caller = request.user
2673 if obj.can_update(request.user):
2674 return super(ProjectList, self).create(request, *args, **kwargs)
2675 else:
Scott Baker08898c12014-10-29 23:41:11 -07002676 raise Exception("failed obj.can_update")
2677
2678 ret = super(ProjectList, self).create(request, *args, **kwargs)
2679 if (ret.status_code%100 != 200):
2680 raise Exception(ret.data)
2681
2682 return ret
2683
Scott Baker0caeaf02014-06-19 11:12:55 -07002684
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002685class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07002686 queryset = Project.objects.select_related().all()
2687 serializer_class = ProjectSerializer
Scott Baker46b58542014-08-11 17:26:12 -07002688 id_serializer_class = ProjectIdSerializer
2689
2690 def get_serializer_class(self):
2691 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2692 if (no_hyperlinks):
2693 return self.id_serializer_class
2694 else:
2695 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07002696
2697 def get_queryset(self):
2698 return Project.select_by_user(self.request.user)
2699
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002700 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2701
2702 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2703
Scott Bakerf3816ac2014-11-12 01:13:53 -08002704"""
2705 XXX smbaker: my intent was to create a view that would return 'new' objects
2706 filled with defaults. I solved it another way, so this code may soon be
2707 abandoned.
2708
2709class ProjectNew(GenericAPIView):
2710 serializer_class = ProjectSerializer
2711 id_serializer_class = ProjectIdSerializer
2712
2713 def get(self, request, *args, **kwargs):
2714 return self.makenew(request, *args, **kwargs)
2715
2716 def get_serializer_class(self):
2717 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2718 if (no_hyperlinks):
2719 return self.id_serializer_class
2720 else:
2721 return self.serializer_class
2722
2723 def makenew(self, request, *args, **kwargs):
2724 obj = Project()
2725 serializer = self.get_serializer(obj)
2726 return Response(serializer.data)
2727"""
2728
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002729
2730
2731class SliceList(generics.ListCreateAPIView):
2732 queryset = Slice.objects.select_related().all()
2733 serializer_class = SliceSerializer
2734 id_serializer_class = SliceIdSerializer
2735 filter_backends = (filters.DjangoFilterBackend,)
2736 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','availableNetworks','networks','networks',)
2737
2738 def get_serializer_class(self):
2739 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2740 if (no_hyperlinks):
2741 return self.id_serializer_class
2742 else:
2743 return self.serializer_class
2744
2745 def get_queryset(self):
2746 return Slice.select_by_user(self.request.user)
2747
2748 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002749 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2750 if not (serializer.is_valid()):
2751 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2752 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002753 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07002754 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002755 return super(SliceList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002756 else:
Scott Baker08898c12014-10-29 23:41:11 -07002757 raise Exception("failed obj.can_update")
2758
2759 ret = super(SliceList, self).create(request, *args, **kwargs)
2760 if (ret.status_code%100 != 200):
2761 raise Exception(ret.data)
2762
2763 return ret
2764
Scott Baker0caeaf02014-06-19 11:12:55 -07002765
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002766class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2767 queryset = Slice.objects.select_related().all()
2768 serializer_class = SliceSerializer
2769 id_serializer_class = SliceIdSerializer
2770
2771 def get_serializer_class(self):
2772 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2773 if (no_hyperlinks):
2774 return self.id_serializer_class
2775 else:
2776 return self.serializer_class
2777
2778 def get_queryset(self):
2779 return Slice.select_by_user(self.request.user)
2780
2781 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2782
2783 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2784
Scott Bakerf3816ac2014-11-12 01:13:53 -08002785"""
2786 XXX smbaker: my intent was to create a view that would return 'new' objects
2787 filled with defaults. I solved it another way, so this code may soon be
2788 abandoned.
2789
2790class SliceNew(GenericAPIView):
2791 serializer_class = SliceSerializer
2792 id_serializer_class = SliceIdSerializer
2793
2794 def get(self, request, *args, **kwargs):
2795 return self.makenew(request, *args, **kwargs)
2796
2797 def get_serializer_class(self):
2798 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2799 if (no_hyperlinks):
2800 return self.id_serializer_class
2801 else:
2802 return self.serializer_class
2803
2804 def makenew(self, request, *args, **kwargs):
2805 obj = Slice()
2806 serializer = self.get_serializer(obj)
2807 return Response(serializer.data)
2808"""
2809
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002810
2811
2812class NetworkList(generics.ListCreateAPIView):
2813 queryset = Network.objects.select_related().all()
2814 serializer_class = NetworkSerializer
2815 id_serializer_class = NetworkIdSerializer
2816 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker645dc9d2014-11-17 22:32:19 -08002817 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','routers','availableRouters','routers','routers',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002818
2819 def get_serializer_class(self):
2820 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2821 if (no_hyperlinks):
2822 return self.id_serializer_class
2823 else:
2824 return self.serializer_class
2825
2826 def get_queryset(self):
2827 return Network.select_by_user(self.request.user)
2828
2829 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002830 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2831 if not (serializer.is_valid()):
2832 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2833 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002834 obj.caller = request.user
Scott Baker0caeaf02014-06-19 11:12:55 -07002835 if obj.can_update(request.user):
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002836 return super(NetworkList, self).create(request, *args, **kwargs)
Scott Baker0caeaf02014-06-19 11:12:55 -07002837 else:
Scott Baker08898c12014-10-29 23:41:11 -07002838 raise Exception("failed obj.can_update")
2839
2840 ret = super(NetworkList, self).create(request, *args, **kwargs)
2841 if (ret.status_code%100 != 200):
2842 raise Exception(ret.data)
2843
2844 return ret
2845
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002846
2847class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2848 queryset = Network.objects.select_related().all()
2849 serializer_class = NetworkSerializer
2850 id_serializer_class = NetworkIdSerializer
2851
2852 def get_serializer_class(self):
2853 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2854 if (no_hyperlinks):
2855 return self.id_serializer_class
2856 else:
2857 return self.serializer_class
2858
2859 def get_queryset(self):
2860 return Network.select_by_user(self.request.user)
2861
2862 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2863
2864 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2865
Scott Bakerf3816ac2014-11-12 01:13:53 -08002866"""
2867 XXX smbaker: my intent was to create a view that would return 'new' objects
2868 filled with defaults. I solved it another way, so this code may soon be
2869 abandoned.
2870
2871class NetworkNew(GenericAPIView):
2872 serializer_class = NetworkSerializer
2873 id_serializer_class = NetworkIdSerializer
2874
2875 def get(self, request, *args, **kwargs):
2876 return self.makenew(request, *args, **kwargs)
2877
2878 def get_serializer_class(self):
2879 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2880 if (no_hyperlinks):
2881 return self.id_serializer_class
2882 else:
2883 return self.serializer_class
2884
2885 def makenew(self, request, *args, **kwargs):
2886 obj = Network()
2887 serializer = self.get_serializer(obj)
2888 return Response(serializer.data)
2889"""
2890
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002891
2892
2893class ServiceList(generics.ListCreateAPIView):
2894 queryset = Service.objects.select_related().all()
2895 serializer_class = ServiceSerializer
2896 id_serializer_class = ServiceIdSerializer
2897 filter_backends = (filters.DjangoFilterBackend,)
2898 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',)
2899
2900 def get_serializer_class(self):
2901 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2902 if (no_hyperlinks):
2903 return self.id_serializer_class
2904 else:
2905 return self.serializer_class
2906
2907 def get_queryset(self):
2908 return Service.select_by_user(self.request.user)
2909
2910 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002911 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2912 if not (serializer.is_valid()):
2913 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2914 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002915 obj.caller = request.user
2916 if obj.can_update(request.user):
2917 return super(ServiceList, self).create(request, *args, **kwargs)
2918 else:
Scott Baker08898c12014-10-29 23:41:11 -07002919 raise Exception("failed obj.can_update")
2920
2921 ret = super(ServiceList, self).create(request, *args, **kwargs)
2922 if (ret.status_code%100 != 200):
2923 raise Exception(ret.data)
2924
2925 return ret
2926
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002927
2928class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
2929 queryset = Service.objects.select_related().all()
2930 serializer_class = ServiceSerializer
2931 id_serializer_class = ServiceIdSerializer
2932
2933 def get_serializer_class(self):
2934 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2935 if (no_hyperlinks):
2936 return self.id_serializer_class
2937 else:
2938 return self.serializer_class
2939
2940 def get_queryset(self):
2941 return Service.select_by_user(self.request.user)
2942
2943 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2944
2945 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
2946
Scott Bakerf3816ac2014-11-12 01:13:53 -08002947"""
2948 XXX smbaker: my intent was to create a view that would return 'new' objects
2949 filled with defaults. I solved it another way, so this code may soon be
2950 abandoned.
2951
2952class ServiceNew(GenericAPIView):
2953 serializer_class = ServiceSerializer
2954 id_serializer_class = ServiceIdSerializer
2955
2956 def get(self, request, *args, **kwargs):
2957 return self.makenew(request, *args, **kwargs)
2958
2959 def get_serializer_class(self):
2960 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2961 if (no_hyperlinks):
2962 return self.id_serializer_class
2963 else:
2964 return self.serializer_class
2965
2966 def makenew(self, request, *args, **kwargs):
2967 obj = Service()
2968 serializer = self.get_serializer(obj)
2969 return Response(serializer.data)
2970"""
2971
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002972
2973
2974class ServiceClassList(generics.ListCreateAPIView):
2975 queryset = ServiceClass.objects.select_related().all()
2976 serializer_class = ServiceClassSerializer
2977 id_serializer_class = ServiceClassIdSerializer
2978 filter_backends = (filters.DjangoFilterBackend,)
2979 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',)
2980
2981 def get_serializer_class(self):
2982 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
2983 if (no_hyperlinks):
2984 return self.id_serializer_class
2985 else:
2986 return self.serializer_class
2987
2988 def get_queryset(self):
2989 return ServiceClass.select_by_user(self.request.user)
2990
2991 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08002992 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
2993 if not (serializer.is_valid()):
2994 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
2995 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07002996 obj.caller = request.user
2997 if obj.can_update(request.user):
2998 return super(ServiceClassList, self).create(request, *args, **kwargs)
2999 else:
Scott Baker08898c12014-10-29 23:41:11 -07003000 raise Exception("failed obj.can_update")
3001
3002 ret = super(ServiceClassList, self).create(request, *args, **kwargs)
3003 if (ret.status_code%100 != 200):
3004 raise Exception(ret.data)
3005
3006 return ret
3007
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003008
3009class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3010 queryset = ServiceClass.objects.select_related().all()
3011 serializer_class = ServiceClassSerializer
3012 id_serializer_class = ServiceClassIdSerializer
3013
3014 def get_serializer_class(self):
3015 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3016 if (no_hyperlinks):
3017 return self.id_serializer_class
3018 else:
3019 return self.serializer_class
3020
3021 def get_queryset(self):
3022 return ServiceClass.select_by_user(self.request.user)
3023
3024 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3025
3026 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3027
Scott Bakerf3816ac2014-11-12 01:13:53 -08003028"""
3029 XXX smbaker: my intent was to create a view that would return 'new' objects
3030 filled with defaults. I solved it another way, so this code may soon be
3031 abandoned.
3032
3033class ServiceClassNew(GenericAPIView):
3034 serializer_class = ServiceClassSerializer
3035 id_serializer_class = ServiceClassIdSerializer
3036
3037 def get(self, request, *args, **kwargs):
3038 return self.makenew(request, *args, **kwargs)
3039
3040 def get_serializer_class(self):
3041 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3042 if (no_hyperlinks):
3043 return self.id_serializer_class
3044 else:
3045 return self.serializer_class
3046
3047 def makenew(self, request, *args, **kwargs):
3048 obj = ServiceClass()
3049 serializer = self.get_serializer(obj)
3050 return Response(serializer.data)
3051"""
3052
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003053
3054
Scott Baker196ffef2014-11-21 11:32:24 -08003055class PaymentList(generics.ListCreateAPIView):
3056 queryset = Payment.objects.select_related().all()
3057 serializer_class = PaymentSerializer
3058 id_serializer_class = PaymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003059 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker196ffef2014-11-21 11:32:24 -08003060 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003061
3062 def get_serializer_class(self):
3063 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3064 if (no_hyperlinks):
3065 return self.id_serializer_class
3066 else:
3067 return self.serializer_class
3068
3069 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08003070 return Payment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003071
3072 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003073 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3074 if not (serializer.is_valid()):
3075 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3076 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003077 obj.caller = request.user
3078 if obj.can_update(request.user):
Scott Baker196ffef2014-11-21 11:32:24 -08003079 return super(PaymentList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003080 else:
Scott Baker08898c12014-10-29 23:41:11 -07003081 raise Exception("failed obj.can_update")
3082
Scott Baker196ffef2014-11-21 11:32:24 -08003083 ret = super(PaymentList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07003084 if (ret.status_code%100 != 200):
3085 raise Exception(ret.data)
3086
3087 return ret
3088
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003089
Scott Baker196ffef2014-11-21 11:32:24 -08003090class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3091 queryset = Payment.objects.select_related().all()
3092 serializer_class = PaymentSerializer
3093 id_serializer_class = PaymentIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003094
3095 def get_serializer_class(self):
3096 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3097 if (no_hyperlinks):
3098 return self.id_serializer_class
3099 else:
3100 return self.serializer_class
3101
3102 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08003103 return Payment.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003104
3105 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3106
3107 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3108
Scott Bakerf3816ac2014-11-12 01:13:53 -08003109"""
3110 XXX smbaker: my intent was to create a view that would return 'new' objects
3111 filled with defaults. I solved it another way, so this code may soon be
3112 abandoned.
3113
Scott Baker196ffef2014-11-21 11:32:24 -08003114class PaymentNew(GenericAPIView):
3115 serializer_class = PaymentSerializer
3116 id_serializer_class = PaymentIdSerializer
Scott Bakerf3816ac2014-11-12 01:13:53 -08003117
3118 def get(self, request, *args, **kwargs):
3119 return self.makenew(request, *args, **kwargs)
3120
3121 def get_serializer_class(self):
3122 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3123 if (no_hyperlinks):
3124 return self.id_serializer_class
3125 else:
3126 return self.serializer_class
3127
3128 def makenew(self, request, *args, **kwargs):
Scott Baker196ffef2014-11-21 11:32:24 -08003129 obj = Payment()
Scott Bakerf3816ac2014-11-12 01:13:53 -08003130 serializer = self.get_serializer(obj)
3131 return Response(serializer.data)
3132"""
3133
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003134
3135
3136class ChargeList(generics.ListCreateAPIView):
3137 queryset = Charge.objects.select_related().all()
3138 serializer_class = ChargeSerializer
3139 id_serializer_class = ChargeIdSerializer
3140 filter_backends = (filters.DjangoFilterBackend,)
3141 filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',)
3142
3143 def get_serializer_class(self):
3144 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3145 if (no_hyperlinks):
3146 return self.id_serializer_class
3147 else:
3148 return self.serializer_class
3149
3150 def get_queryset(self):
3151 return Charge.select_by_user(self.request.user)
3152
3153 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003154 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3155 if not (serializer.is_valid()):
3156 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3157 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003158 obj.caller = request.user
3159 if obj.can_update(request.user):
3160 return super(ChargeList, self).create(request, *args, **kwargs)
3161 else:
Scott Baker08898c12014-10-29 23:41:11 -07003162 raise Exception("failed obj.can_update")
3163
3164 ret = super(ChargeList, self).create(request, *args, **kwargs)
3165 if (ret.status_code%100 != 200):
3166 raise Exception(ret.data)
3167
3168 return ret
3169
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003170
3171class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3172 queryset = Charge.objects.select_related().all()
3173 serializer_class = ChargeSerializer
3174 id_serializer_class = ChargeIdSerializer
3175
3176 def get_serializer_class(self):
3177 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3178 if (no_hyperlinks):
3179 return self.id_serializer_class
3180 else:
3181 return self.serializer_class
3182
3183 def get_queryset(self):
3184 return Charge.select_by_user(self.request.user)
3185
3186 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3187
3188 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3189
Scott Bakerf3816ac2014-11-12 01:13:53 -08003190"""
3191 XXX smbaker: my intent was to create a view that would return 'new' objects
3192 filled with defaults. I solved it another way, so this code may soon be
3193 abandoned.
3194
3195class ChargeNew(GenericAPIView):
3196 serializer_class = ChargeSerializer
3197 id_serializer_class = ChargeIdSerializer
3198
3199 def get(self, request, *args, **kwargs):
3200 return self.makenew(request, *args, **kwargs)
3201
3202 def get_serializer_class(self):
3203 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3204 if (no_hyperlinks):
3205 return self.id_serializer_class
3206 else:
3207 return self.serializer_class
3208
3209 def makenew(self, request, *args, **kwargs):
3210 obj = Charge()
3211 serializer = self.get_serializer(obj)
3212 return Response(serializer.data)
3213"""
3214
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003215
3216
3217class RoleList(generics.ListCreateAPIView):
3218 queryset = Role.objects.select_related().all()
3219 serializer_class = RoleSerializer
3220 id_serializer_class = RoleIdSerializer
3221 filter_backends = (filters.DjangoFilterBackend,)
3222 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',)
3223
3224 def get_serializer_class(self):
3225 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3226 if (no_hyperlinks):
3227 return self.id_serializer_class
3228 else:
3229 return self.serializer_class
3230
3231 def get_queryset(self):
3232 return Role.select_by_user(self.request.user)
3233
3234 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003235 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3236 if not (serializer.is_valid()):
3237 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3238 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003239 obj.caller = request.user
3240 if obj.can_update(request.user):
3241 return super(RoleList, self).create(request, *args, **kwargs)
3242 else:
Scott Baker08898c12014-10-29 23:41:11 -07003243 raise Exception("failed obj.can_update")
3244
3245 ret = super(RoleList, self).create(request, *args, **kwargs)
3246 if (ret.status_code%100 != 200):
3247 raise Exception(ret.data)
3248
3249 return ret
3250
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003251
3252class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3253 queryset = Role.objects.select_related().all()
3254 serializer_class = RoleSerializer
3255 id_serializer_class = RoleIdSerializer
3256
3257 def get_serializer_class(self):
3258 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3259 if (no_hyperlinks):
3260 return self.id_serializer_class
3261 else:
3262 return self.serializer_class
3263
3264 def get_queryset(self):
3265 return Role.select_by_user(self.request.user)
3266
3267 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3268
3269 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3270
Scott Bakerf3816ac2014-11-12 01:13:53 -08003271"""
3272 XXX smbaker: my intent was to create a view that would return 'new' objects
3273 filled with defaults. I solved it another way, so this code may soon be
3274 abandoned.
3275
3276class RoleNew(GenericAPIView):
3277 serializer_class = RoleSerializer
3278 id_serializer_class = RoleIdSerializer
3279
3280 def get(self, request, *args, **kwargs):
3281 return self.makenew(request, *args, **kwargs)
3282
3283 def get_serializer_class(self):
3284 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3285 if (no_hyperlinks):
3286 return self.id_serializer_class
3287 else:
3288 return self.serializer_class
3289
3290 def makenew(self, request, *args, **kwargs):
3291 obj = Role()
3292 serializer = self.get_serializer(obj)
3293 return Response(serializer.data)
3294"""
3295
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003296
3297
3298class UsableObjectList(generics.ListCreateAPIView):
3299 queryset = UsableObject.objects.select_related().all()
3300 serializer_class = UsableObjectSerializer
3301 id_serializer_class = UsableObjectIdSerializer
3302 filter_backends = (filters.DjangoFilterBackend,)
3303 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',)
3304
3305 def get_serializer_class(self):
3306 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3307 if (no_hyperlinks):
3308 return self.id_serializer_class
3309 else:
3310 return self.serializer_class
3311
3312 def get_queryset(self):
3313 return UsableObject.select_by_user(self.request.user)
3314
3315 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003316 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3317 if not (serializer.is_valid()):
3318 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3319 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003320 obj.caller = request.user
3321 if obj.can_update(request.user):
3322 return super(UsableObjectList, self).create(request, *args, **kwargs)
3323 else:
Scott Baker08898c12014-10-29 23:41:11 -07003324 raise Exception("failed obj.can_update")
3325
3326 ret = super(UsableObjectList, self).create(request, *args, **kwargs)
3327 if (ret.status_code%100 != 200):
3328 raise Exception(ret.data)
3329
3330 return ret
3331
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003332
3333class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3334 queryset = UsableObject.objects.select_related().all()
3335 serializer_class = UsableObjectSerializer
3336 id_serializer_class = UsableObjectIdSerializer
3337
3338 def get_serializer_class(self):
3339 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3340 if (no_hyperlinks):
3341 return self.id_serializer_class
3342 else:
3343 return self.serializer_class
3344
3345 def get_queryset(self):
3346 return UsableObject.select_by_user(self.request.user)
3347
3348 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3349
3350 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3351
Scott Bakerf3816ac2014-11-12 01:13:53 -08003352"""
3353 XXX smbaker: my intent was to create a view that would return 'new' objects
3354 filled with defaults. I solved it another way, so this code may soon be
3355 abandoned.
3356
3357class UsableObjectNew(GenericAPIView):
3358 serializer_class = UsableObjectSerializer
3359 id_serializer_class = UsableObjectIdSerializer
3360
3361 def get(self, request, *args, **kwargs):
3362 return self.makenew(request, *args, **kwargs)
3363
3364 def get_serializer_class(self):
3365 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3366 if (no_hyperlinks):
3367 return self.id_serializer_class
3368 else:
3369 return self.serializer_class
3370
3371 def makenew(self, request, *args, **kwargs):
3372 obj = UsableObject()
3373 serializer = self.get_serializer(obj)
3374 return Response(serializer.data)
3375"""
3376
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003377
3378
3379class SiteRoleList(generics.ListCreateAPIView):
3380 queryset = SiteRole.objects.select_related().all()
3381 serializer_class = SiteRoleSerializer
3382 id_serializer_class = SiteRoleIdSerializer
3383 filter_backends = (filters.DjangoFilterBackend,)
3384 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
3385
3386 def get_serializer_class(self):
3387 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3388 if (no_hyperlinks):
3389 return self.id_serializer_class
3390 else:
3391 return self.serializer_class
3392
3393 def get_queryset(self):
3394 return SiteRole.select_by_user(self.request.user)
3395
3396 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003397 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3398 if not (serializer.is_valid()):
3399 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3400 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003401 obj.caller = request.user
3402 if obj.can_update(request.user):
3403 return super(SiteRoleList, self).create(request, *args, **kwargs)
3404 else:
Scott Baker08898c12014-10-29 23:41:11 -07003405 raise Exception("failed obj.can_update")
3406
3407 ret = super(SiteRoleList, self).create(request, *args, **kwargs)
3408 if (ret.status_code%100 != 200):
3409 raise Exception(ret.data)
3410
3411 return ret
3412
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003413
3414class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3415 queryset = SiteRole.objects.select_related().all()
3416 serializer_class = SiteRoleSerializer
3417 id_serializer_class = SiteRoleIdSerializer
3418
3419 def get_serializer_class(self):
3420 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3421 if (no_hyperlinks):
3422 return self.id_serializer_class
3423 else:
3424 return self.serializer_class
3425
3426 def get_queryset(self):
3427 return SiteRole.select_by_user(self.request.user)
3428
3429 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3430
3431 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3432
Scott Bakerf3816ac2014-11-12 01:13:53 -08003433"""
3434 XXX smbaker: my intent was to create a view that would return 'new' objects
3435 filled with defaults. I solved it another way, so this code may soon be
3436 abandoned.
3437
3438class SiteRoleNew(GenericAPIView):
3439 serializer_class = SiteRoleSerializer
3440 id_serializer_class = SiteRoleIdSerializer
3441
3442 def get(self, request, *args, **kwargs):
3443 return self.makenew(request, *args, **kwargs)
3444
3445 def get_serializer_class(self):
3446 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3447 if (no_hyperlinks):
3448 return self.id_serializer_class
3449 else:
3450 return self.serializer_class
3451
3452 def makenew(self, request, *args, **kwargs):
3453 obj = SiteRole()
3454 serializer = self.get_serializer(obj)
3455 return Response(serializer.data)
3456"""
3457
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003458
3459
3460class SliceCredentialList(generics.ListCreateAPIView):
3461 queryset = SliceCredential.objects.select_related().all()
3462 serializer_class = SliceCredentialSerializer
3463 id_serializer_class = SliceCredentialIdSerializer
3464 filter_backends = (filters.DjangoFilterBackend,)
3465 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',)
3466
3467 def get_serializer_class(self):
3468 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3469 if (no_hyperlinks):
3470 return self.id_serializer_class
3471 else:
3472 return self.serializer_class
3473
3474 def get_queryset(self):
3475 return SliceCredential.select_by_user(self.request.user)
3476
3477 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003478 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3479 if not (serializer.is_valid()):
3480 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3481 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003482 obj.caller = request.user
3483 if obj.can_update(request.user):
3484 return super(SliceCredentialList, self).create(request, *args, **kwargs)
3485 else:
Scott Baker08898c12014-10-29 23:41:11 -07003486 raise Exception("failed obj.can_update")
3487
3488 ret = super(SliceCredentialList, self).create(request, *args, **kwargs)
3489 if (ret.status_code%100 != 200):
3490 raise Exception(ret.data)
3491
3492 return ret
3493
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003494
3495class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3496 queryset = SliceCredential.objects.select_related().all()
3497 serializer_class = SliceCredentialSerializer
3498 id_serializer_class = SliceCredentialIdSerializer
3499
3500 def get_serializer_class(self):
3501 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3502 if (no_hyperlinks):
3503 return self.id_serializer_class
3504 else:
3505 return self.serializer_class
3506
3507 def get_queryset(self):
3508 return SliceCredential.select_by_user(self.request.user)
3509
3510 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3511
3512 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3513
Scott Bakerf3816ac2014-11-12 01:13:53 -08003514"""
3515 XXX smbaker: my intent was to create a view that would return 'new' objects
3516 filled with defaults. I solved it another way, so this code may soon be
3517 abandoned.
3518
3519class SliceCredentialNew(GenericAPIView):
3520 serializer_class = SliceCredentialSerializer
3521 id_serializer_class = SliceCredentialIdSerializer
3522
3523 def get(self, request, *args, **kwargs):
3524 return self.makenew(request, *args, **kwargs)
3525
3526 def get_serializer_class(self):
3527 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3528 if (no_hyperlinks):
3529 return self.id_serializer_class
3530 else:
3531 return self.serializer_class
3532
3533 def makenew(self, request, *args, **kwargs):
3534 obj = SliceCredential()
3535 serializer = self.get_serializer(obj)
3536 return Response(serializer.data)
3537"""
3538
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003539
3540
3541class SliverList(generics.ListCreateAPIView):
3542 queryset = Sliver.objects.select_related().all()
3543 serializer_class = SliverSerializer
3544 id_serializer_class = SliverIdSerializer
3545 filter_backends = (filters.DjangoFilterBackend,)
3546 filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','deploymentNetwork','numberCores','flavor','userData','networks','networks',)
3547
3548 def get_serializer_class(self):
3549 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3550 if (no_hyperlinks):
3551 return self.id_serializer_class
3552 else:
3553 return self.serializer_class
3554
3555 def get_queryset(self):
3556 return Sliver.select_by_user(self.request.user)
3557
3558 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003559 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3560 if not (serializer.is_valid()):
3561 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3562 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003563 obj.caller = request.user
3564 if obj.can_update(request.user):
3565 return super(SliverList, self).create(request, *args, **kwargs)
3566 else:
Scott Baker08898c12014-10-29 23:41:11 -07003567 raise Exception("failed obj.can_update")
3568
3569 ret = super(SliverList, self).create(request, *args, **kwargs)
3570 if (ret.status_code%100 != 200):
3571 raise Exception(ret.data)
3572
3573 return ret
3574
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003575
3576class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3577 queryset = Sliver.objects.select_related().all()
3578 serializer_class = SliverSerializer
3579 id_serializer_class = SliverIdSerializer
3580
3581 def get_serializer_class(self):
3582 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3583 if (no_hyperlinks):
3584 return self.id_serializer_class
3585 else:
3586 return self.serializer_class
3587
3588 def get_queryset(self):
3589 return Sliver.select_by_user(self.request.user)
3590
3591 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3592
3593 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3594
Scott Bakerf3816ac2014-11-12 01:13:53 -08003595"""
3596 XXX smbaker: my intent was to create a view that would return 'new' objects
3597 filled with defaults. I solved it another way, so this code may soon be
3598 abandoned.
3599
3600class SliverNew(GenericAPIView):
3601 serializer_class = SliverSerializer
3602 id_serializer_class = SliverIdSerializer
3603
3604 def get(self, request, *args, **kwargs):
3605 return self.makenew(request, *args, **kwargs)
3606
3607 def get_serializer_class(self):
3608 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3609 if (no_hyperlinks):
3610 return self.id_serializer_class
3611 else:
3612 return self.serializer_class
3613
3614 def makenew(self, request, *args, **kwargs):
3615 obj = Sliver()
3616 serializer = self.get_serializer(obj)
3617 return Response(serializer.data)
3618"""
3619
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003620
3621
3622class NodeList(generics.ListCreateAPIView):
3623 queryset = Node.objects.select_related().all()
3624 serializer_class = NodeSerializer
3625 id_serializer_class = NodeIdSerializer
3626 filter_backends = (filters.DjangoFilterBackend,)
3627 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site','deployment',)
3628
3629 def get_serializer_class(self):
3630 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3631 if (no_hyperlinks):
3632 return self.id_serializer_class
3633 else:
3634 return self.serializer_class
3635
3636 def get_queryset(self):
3637 return Node.select_by_user(self.request.user)
3638
3639 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003640 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3641 if not (serializer.is_valid()):
3642 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3643 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003644 obj.caller = request.user
3645 if obj.can_update(request.user):
3646 return super(NodeList, self).create(request, *args, **kwargs)
3647 else:
Scott Baker08898c12014-10-29 23:41:11 -07003648 raise Exception("failed obj.can_update")
3649
3650 ret = super(NodeList, self).create(request, *args, **kwargs)
3651 if (ret.status_code%100 != 200):
3652 raise Exception(ret.data)
3653
3654 return ret
3655
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003656
3657class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3658 queryset = Node.objects.select_related().all()
3659 serializer_class = NodeSerializer
3660 id_serializer_class = NodeIdSerializer
3661
3662 def get_serializer_class(self):
3663 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3664 if (no_hyperlinks):
3665 return self.id_serializer_class
3666 else:
3667 return self.serializer_class
3668
3669 def get_queryset(self):
3670 return Node.select_by_user(self.request.user)
3671
3672 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3673
3674 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3675
Scott Bakerf3816ac2014-11-12 01:13:53 -08003676"""
3677 XXX smbaker: my intent was to create a view that would return 'new' objects
3678 filled with defaults. I solved it another way, so this code may soon be
3679 abandoned.
3680
3681class NodeNew(GenericAPIView):
3682 serializer_class = NodeSerializer
3683 id_serializer_class = NodeIdSerializer
3684
3685 def get(self, request, *args, **kwargs):
3686 return self.makenew(request, *args, **kwargs)
3687
3688 def get_serializer_class(self):
3689 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3690 if (no_hyperlinks):
3691 return self.id_serializer_class
3692 else:
3693 return self.serializer_class
3694
3695 def makenew(self, request, *args, **kwargs):
3696 obj = Node()
3697 serializer = self.get_serializer(obj)
3698 return Response(serializer.data)
3699"""
3700
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003701
3702
3703class DashboardViewList(generics.ListCreateAPIView):
3704 queryset = DashboardView.objects.select_related().all()
3705 serializer_class = DashboardViewSerializer
3706 id_serializer_class = DashboardViewIdSerializer
3707 filter_backends = (filters.DjangoFilterBackend,)
3708 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url',)
3709
3710 def get_serializer_class(self):
3711 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3712 if (no_hyperlinks):
3713 return self.id_serializer_class
3714 else:
3715 return self.serializer_class
3716
3717 def get_queryset(self):
3718 return DashboardView.select_by_user(self.request.user)
3719
3720 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003721 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3722 if not (serializer.is_valid()):
3723 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3724 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003725 obj.caller = request.user
3726 if obj.can_update(request.user):
3727 return super(DashboardViewList, self).create(request, *args, **kwargs)
3728 else:
Scott Baker08898c12014-10-29 23:41:11 -07003729 raise Exception("failed obj.can_update")
3730
3731 ret = super(DashboardViewList, self).create(request, *args, **kwargs)
3732 if (ret.status_code%100 != 200):
3733 raise Exception(ret.data)
3734
3735 return ret
3736
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003737
3738class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3739 queryset = DashboardView.objects.select_related().all()
3740 serializer_class = DashboardViewSerializer
3741 id_serializer_class = DashboardViewIdSerializer
3742
3743 def get_serializer_class(self):
3744 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3745 if (no_hyperlinks):
3746 return self.id_serializer_class
3747 else:
3748 return self.serializer_class
3749
3750 def get_queryset(self):
3751 return DashboardView.select_by_user(self.request.user)
3752
3753 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3754
3755 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3756
Scott Bakerf3816ac2014-11-12 01:13:53 -08003757"""
3758 XXX smbaker: my intent was to create a view that would return 'new' objects
3759 filled with defaults. I solved it another way, so this code may soon be
3760 abandoned.
3761
3762class DashboardViewNew(GenericAPIView):
3763 serializer_class = DashboardViewSerializer
3764 id_serializer_class = DashboardViewIdSerializer
3765
3766 def get(self, request, *args, **kwargs):
3767 return self.makenew(request, *args, **kwargs)
3768
3769 def get_serializer_class(self):
3770 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3771 if (no_hyperlinks):
3772 return self.id_serializer_class
3773 else:
3774 return self.serializer_class
3775
3776 def makenew(self, request, *args, **kwargs):
3777 obj = DashboardView()
3778 serializer = self.get_serializer(obj)
3779 return Response(serializer.data)
3780"""
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003781
3782
Scott Bakerf3816ac2014-11-12 01:13:53 -08003783
Scott Baker196ffef2014-11-21 11:32:24 -08003784class ImageDeploymentsList(generics.ListCreateAPIView):
3785 queryset = ImageDeployments.objects.select_related().all()
3786 serializer_class = ImageDeploymentsSerializer
3787 id_serializer_class = ImageDeploymentsIdSerializer
3788 filter_backends = (filters.DjangoFilterBackend,)
3789 filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment','glance_image_id',)
3790
3791 def get_serializer_class(self):
3792 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3793 if (no_hyperlinks):
3794 return self.id_serializer_class
3795 else:
3796 return self.serializer_class
3797
3798 def get_queryset(self):
3799 return ImageDeployments.select_by_user(self.request.user)
3800
3801 def create(self, request, *args, **kwargs):
3802 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3803 if not (serializer.is_valid()):
3804 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3805 obj = serializer.object
3806 obj.caller = request.user
3807 if obj.can_update(request.user):
3808 return super(ImageDeploymentsList, self).create(request, *args, **kwargs)
3809 else:
3810 raise Exception("failed obj.can_update")
3811
3812 ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs)
3813 if (ret.status_code%100 != 200):
3814 raise Exception(ret.data)
3815
3816 return ret
3817
3818
3819class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3820 queryset = ImageDeployments.objects.select_related().all()
3821 serializer_class = ImageDeploymentsSerializer
3822 id_serializer_class = ImageDeploymentsIdSerializer
3823
3824 def get_serializer_class(self):
3825 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3826 if (no_hyperlinks):
3827 return self.id_serializer_class
3828 else:
3829 return self.serializer_class
3830
3831 def get_queryset(self):
3832 return ImageDeployments.select_by_user(self.request.user)
3833
3834 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3835
3836 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3837
3838"""
3839 XXX smbaker: my intent was to create a view that would return 'new' objects
3840 filled with defaults. I solved it another way, so this code may soon be
3841 abandoned.
3842
3843class ImageDeploymentsNew(GenericAPIView):
3844 serializer_class = ImageDeploymentsSerializer
3845 id_serializer_class = ImageDeploymentsIdSerializer
3846
3847 def get(self, request, *args, **kwargs):
3848 return self.makenew(request, *args, **kwargs)
3849
3850 def get_serializer_class(self):
3851 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3852 if (no_hyperlinks):
3853 return self.id_serializer_class
3854 else:
3855 return self.serializer_class
3856
3857 def makenew(self, request, *args, **kwargs):
3858 obj = ImageDeployments()
3859 serializer = self.get_serializer(obj)
3860 return Response(serializer.data)
3861"""
3862
3863
3864
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003865class ReservedResourceList(generics.ListCreateAPIView):
3866 queryset = ReservedResource.objects.select_related().all()
3867 serializer_class = ReservedResourceSerializer
3868 id_serializer_class = ReservedResourceIdSerializer
3869 filter_backends = (filters.DjangoFilterBackend,)
3870 filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',)
3871
3872 def get_serializer_class(self):
3873 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3874 if (no_hyperlinks):
3875 return self.id_serializer_class
3876 else:
3877 return self.serializer_class
3878
3879 def get_queryset(self):
3880 return ReservedResource.select_by_user(self.request.user)
3881
3882 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003883 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3884 if not (serializer.is_valid()):
3885 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3886 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003887 obj.caller = request.user
3888 if obj.can_update(request.user):
3889 return super(ReservedResourceList, self).create(request, *args, **kwargs)
3890 else:
Scott Baker08898c12014-10-29 23:41:11 -07003891 raise Exception("failed obj.can_update")
3892
3893 ret = super(ReservedResourceList, self).create(request, *args, **kwargs)
3894 if (ret.status_code%100 != 200):
3895 raise Exception(ret.data)
3896
3897 return ret
3898
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003899
3900class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3901 queryset = ReservedResource.objects.select_related().all()
3902 serializer_class = ReservedResourceSerializer
3903 id_serializer_class = ReservedResourceIdSerializer
3904
3905 def get_serializer_class(self):
3906 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3907 if (no_hyperlinks):
3908 return self.id_serializer_class
3909 else:
3910 return self.serializer_class
3911
3912 def get_queryset(self):
3913 return ReservedResource.select_by_user(self.request.user)
3914
3915 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3916
3917 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3918
Scott Bakerf3816ac2014-11-12 01:13:53 -08003919"""
3920 XXX smbaker: my intent was to create a view that would return 'new' objects
3921 filled with defaults. I solved it another way, so this code may soon be
3922 abandoned.
3923
3924class ReservedResourceNew(GenericAPIView):
3925 serializer_class = ReservedResourceSerializer
3926 id_serializer_class = ReservedResourceIdSerializer
3927
3928 def get(self, request, *args, **kwargs):
3929 return self.makenew(request, *args, **kwargs)
3930
3931 def get_serializer_class(self):
3932 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3933 if (no_hyperlinks):
3934 return self.id_serializer_class
3935 else:
3936 return self.serializer_class
3937
3938 def makenew(self, request, *args, **kwargs):
3939 obj = ReservedResource()
3940 serializer = self.get_serializer(obj)
3941 return Response(serializer.data)
3942"""
3943
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003944
3945
3946class NetworkSliceList(generics.ListCreateAPIView):
3947 queryset = NetworkSlice.objects.select_related().all()
3948 serializer_class = NetworkSliceSerializer
3949 id_serializer_class = NetworkSliceIdSerializer
3950 filter_backends = (filters.DjangoFilterBackend,)
3951 filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',)
3952
3953 def get_serializer_class(self):
3954 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3955 if (no_hyperlinks):
3956 return self.id_serializer_class
3957 else:
3958 return self.serializer_class
3959
3960 def get_queryset(self):
3961 return NetworkSlice.select_by_user(self.request.user)
3962
3963 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08003964 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
3965 if not (serializer.is_valid()):
3966 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
3967 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003968 obj.caller = request.user
3969 if obj.can_update(request.user):
3970 return super(NetworkSliceList, self).create(request, *args, **kwargs)
3971 else:
Scott Baker08898c12014-10-29 23:41:11 -07003972 raise Exception("failed obj.can_update")
3973
3974 ret = super(NetworkSliceList, self).create(request, *args, **kwargs)
3975 if (ret.status_code%100 != 200):
3976 raise Exception(ret.data)
3977
3978 return ret
3979
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07003980
3981class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
3982 queryset = NetworkSlice.objects.select_related().all()
3983 serializer_class = NetworkSliceSerializer
3984 id_serializer_class = NetworkSliceIdSerializer
3985
3986 def get_serializer_class(self):
3987 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
3988 if (no_hyperlinks):
3989 return self.id_serializer_class
3990 else:
3991 return self.serializer_class
3992
3993 def get_queryset(self):
3994 return NetworkSlice.select_by_user(self.request.user)
3995
3996 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3997
3998 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
3999
Scott Bakerf3816ac2014-11-12 01:13:53 -08004000"""
4001 XXX smbaker: my intent was to create a view that would return 'new' objects
4002 filled with defaults. I solved it another way, so this code may soon be
4003 abandoned.
4004
4005class NetworkSliceNew(GenericAPIView):
4006 serializer_class = NetworkSliceSerializer
4007 id_serializer_class = NetworkSliceIdSerializer
4008
4009 def get(self, request, *args, **kwargs):
4010 return self.makenew(request, *args, **kwargs)
4011
4012 def get_serializer_class(self):
4013 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4014 if (no_hyperlinks):
4015 return self.id_serializer_class
4016 else:
4017 return self.serializer_class
4018
4019 def makenew(self, request, *args, **kwargs):
4020 obj = NetworkSlice()
4021 serializer = self.get_serializer(obj)
4022 return Response(serializer.data)
4023"""
4024
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004025
4026
4027class UserDashboardViewList(generics.ListCreateAPIView):
4028 queryset = UserDashboardView.objects.select_related().all()
4029 serializer_class = UserDashboardViewSerializer
4030 id_serializer_class = UserDashboardViewIdSerializer
4031 filter_backends = (filters.DjangoFilterBackend,)
4032 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',)
4033
4034 def get_serializer_class(self):
4035 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4036 if (no_hyperlinks):
4037 return self.id_serializer_class
4038 else:
4039 return self.serializer_class
4040
4041 def get_queryset(self):
4042 return UserDashboardView.select_by_user(self.request.user)
4043
4044 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004045 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4046 if not (serializer.is_valid()):
4047 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4048 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004049 obj.caller = request.user
4050 if obj.can_update(request.user):
4051 return super(UserDashboardViewList, self).create(request, *args, **kwargs)
4052 else:
Scott Baker08898c12014-10-29 23:41:11 -07004053 raise Exception("failed obj.can_update")
4054
4055 ret = super(UserDashboardViewList, self).create(request, *args, **kwargs)
4056 if (ret.status_code%100 != 200):
4057 raise Exception(ret.data)
4058
4059 return ret
4060
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004061
4062class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4063 queryset = UserDashboardView.objects.select_related().all()
4064 serializer_class = UserDashboardViewSerializer
4065 id_serializer_class = UserDashboardViewIdSerializer
4066
4067 def get_serializer_class(self):
4068 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4069 if (no_hyperlinks):
4070 return self.id_serializer_class
4071 else:
4072 return self.serializer_class
4073
4074 def get_queryset(self):
4075 return UserDashboardView.select_by_user(self.request.user)
4076
4077 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4078
4079 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4080
Scott Bakerf3816ac2014-11-12 01:13:53 -08004081"""
4082 XXX smbaker: my intent was to create a view that would return 'new' objects
4083 filled with defaults. I solved it another way, so this code may soon be
4084 abandoned.
4085
4086class UserDashboardViewNew(GenericAPIView):
4087 serializer_class = UserDashboardViewSerializer
4088 id_serializer_class = UserDashboardViewIdSerializer
4089
4090 def get(self, request, *args, **kwargs):
4091 return self.makenew(request, *args, **kwargs)
4092
4093 def get_serializer_class(self):
4094 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4095 if (no_hyperlinks):
4096 return self.id_serializer_class
4097 else:
4098 return self.serializer_class
4099
4100 def makenew(self, request, *args, **kwargs):
4101 obj = UserDashboardView()
4102 serializer = self.get_serializer(obj)
4103 return Response(serializer.data)
4104"""
4105
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004106
4107
4108class PlanetStackPrivilegeList(generics.ListCreateAPIView):
4109 queryset = PlanetStackPrivilege.objects.select_related().all()
4110 serializer_class = PlanetStackPrivilegeSerializer
4111 id_serializer_class = PlanetStackPrivilegeIdSerializer
4112 filter_backends = (filters.DjangoFilterBackend,)
4113 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',)
4114
4115 def get_serializer_class(self):
4116 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4117 if (no_hyperlinks):
4118 return self.id_serializer_class
4119 else:
4120 return self.serializer_class
4121
4122 def get_queryset(self):
4123 return PlanetStackPrivilege.select_by_user(self.request.user)
4124
4125 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004126 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4127 if not (serializer.is_valid()):
4128 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4129 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004130 obj.caller = request.user
4131 if obj.can_update(request.user):
4132 return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4133 else:
Scott Baker08898c12014-10-29 23:41:11 -07004134 raise Exception("failed obj.can_update")
4135
4136 ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs)
4137 if (ret.status_code%100 != 200):
4138 raise Exception(ret.data)
4139
4140 return ret
4141
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004142
4143class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4144 queryset = PlanetStackPrivilege.objects.select_related().all()
4145 serializer_class = PlanetStackPrivilegeSerializer
4146 id_serializer_class = PlanetStackPrivilegeIdSerializer
4147
4148 def get_serializer_class(self):
4149 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4150 if (no_hyperlinks):
4151 return self.id_serializer_class
4152 else:
4153 return self.serializer_class
4154
4155 def get_queryset(self):
4156 return PlanetStackPrivilege.select_by_user(self.request.user)
4157
4158 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4159
4160 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4161
Scott Bakerf3816ac2014-11-12 01:13:53 -08004162"""
4163 XXX smbaker: my intent was to create a view that would return 'new' objects
4164 filled with defaults. I solved it another way, so this code may soon be
4165 abandoned.
4166
4167class PlanetStackPrivilegeNew(GenericAPIView):
4168 serializer_class = PlanetStackPrivilegeSerializer
4169 id_serializer_class = PlanetStackPrivilegeIdSerializer
4170
4171 def get(self, request, *args, **kwargs):
4172 return self.makenew(request, *args, **kwargs)
4173
4174 def get_serializer_class(self):
4175 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4176 if (no_hyperlinks):
4177 return self.id_serializer_class
4178 else:
4179 return self.serializer_class
4180
4181 def makenew(self, request, *args, **kwargs):
4182 obj = PlanetStackPrivilege()
4183 serializer = self.get_serializer(obj)
4184 return Response(serializer.data)
4185"""
4186
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004187
4188
4189class UserList(generics.ListCreateAPIView):
4190 queryset = User.objects.select_related().all()
4191 serializer_class = UserSerializer
4192 id_serializer_class = UserIdSerializer
4193 filter_backends = (filters.DjangoFilterBackend,)
4194 filter_fields = ('id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',)
4195
4196 def get_serializer_class(self):
4197 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4198 if (no_hyperlinks):
4199 return self.id_serializer_class
4200 else:
4201 return self.serializer_class
4202
4203 def get_queryset(self):
4204 return User.select_by_user(self.request.user)
4205
4206 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004207 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4208 if not (serializer.is_valid()):
4209 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4210 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004211 obj.caller = request.user
4212 if obj.can_update(request.user):
4213 return super(UserList, self).create(request, *args, **kwargs)
4214 else:
Scott Baker08898c12014-10-29 23:41:11 -07004215 raise Exception("failed obj.can_update")
4216
4217 ret = super(UserList, self).create(request, *args, **kwargs)
4218 if (ret.status_code%100 != 200):
4219 raise Exception(ret.data)
4220
4221 return ret
4222
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004223
4224class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4225 queryset = User.objects.select_related().all()
4226 serializer_class = UserSerializer
4227 id_serializer_class = UserIdSerializer
4228
4229 def get_serializer_class(self):
4230 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4231 if (no_hyperlinks):
4232 return self.id_serializer_class
4233 else:
4234 return self.serializer_class
4235
4236 def get_queryset(self):
4237 return User.select_by_user(self.request.user)
4238
4239 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4240
4241 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4242
Scott Bakerf3816ac2014-11-12 01:13:53 -08004243"""
4244 XXX smbaker: my intent was to create a view that would return 'new' objects
4245 filled with defaults. I solved it another way, so this code may soon be
4246 abandoned.
4247
4248class UserNew(GenericAPIView):
4249 serializer_class = UserSerializer
4250 id_serializer_class = UserIdSerializer
4251
4252 def get(self, request, *args, **kwargs):
4253 return self.makenew(request, *args, **kwargs)
4254
4255 def get_serializer_class(self):
4256 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4257 if (no_hyperlinks):
4258 return self.id_serializer_class
4259 else:
4260 return self.serializer_class
4261
4262 def makenew(self, request, *args, **kwargs):
4263 obj = User()
4264 serializer = self.get_serializer(obj)
4265 return Response(serializer.data)
4266"""
4267
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004268
4269
4270class DeploymentList(generics.ListCreateAPIView):
4271 queryset = Deployment.objects.select_related().all()
4272 serializer_class = DeploymentSerializer
4273 id_serializer_class = DeploymentIdSerializer
4274 filter_backends = (filters.DjangoFilterBackend,)
4275 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','admin_user','admin_password','admin_tenant','auth_url','backend_type','availability_zone','accessControl','sites','sites','flavors','flavors',)
4276
4277 def get_serializer_class(self):
4278 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4279 if (no_hyperlinks):
4280 return self.id_serializer_class
4281 else:
4282 return self.serializer_class
4283
4284 def get_queryset(self):
4285 return Deployment.select_by_user(self.request.user)
4286
4287 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004288 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4289 if not (serializer.is_valid()):
4290 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4291 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004292 obj.caller = request.user
4293 if obj.can_update(request.user):
4294 return super(DeploymentList, self).create(request, *args, **kwargs)
4295 else:
Scott Baker08898c12014-10-29 23:41:11 -07004296 raise Exception("failed obj.can_update")
4297
4298 ret = super(DeploymentList, self).create(request, *args, **kwargs)
4299 if (ret.status_code%100 != 200):
4300 raise Exception(ret.data)
4301
4302 return ret
4303
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004304
4305class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4306 queryset = Deployment.objects.select_related().all()
4307 serializer_class = DeploymentSerializer
4308 id_serializer_class = DeploymentIdSerializer
4309
4310 def get_serializer_class(self):
4311 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4312 if (no_hyperlinks):
4313 return self.id_serializer_class
4314 else:
4315 return self.serializer_class
4316
4317 def get_queryset(self):
4318 return Deployment.select_by_user(self.request.user)
4319
4320 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4321
4322 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4323
Scott Bakerf3816ac2014-11-12 01:13:53 -08004324"""
4325 XXX smbaker: my intent was to create a view that would return 'new' objects
4326 filled with defaults. I solved it another way, so this code may soon be
4327 abandoned.
4328
4329class DeploymentNew(GenericAPIView):
4330 serializer_class = DeploymentSerializer
4331 id_serializer_class = DeploymentIdSerializer
4332
4333 def get(self, request, *args, **kwargs):
4334 return self.makenew(request, *args, **kwargs)
4335
4336 def get_serializer_class(self):
4337 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4338 if (no_hyperlinks):
4339 return self.id_serializer_class
4340 else:
4341 return self.serializer_class
4342
4343 def makenew(self, request, *args, **kwargs):
4344 obj = Deployment()
4345 serializer = self.get_serializer(obj)
4346 return Response(serializer.data)
4347"""
4348
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004349
4350
4351class ReservationList(generics.ListCreateAPIView):
4352 queryset = Reservation.objects.select_related().all()
4353 serializer_class = ReservationSerializer
4354 id_serializer_class = ReservationIdSerializer
4355 filter_backends = (filters.DjangoFilterBackend,)
4356 filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',)
4357
4358 def get_serializer_class(self):
4359 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4360 if (no_hyperlinks):
4361 return self.id_serializer_class
4362 else:
4363 return self.serializer_class
4364
4365 def get_queryset(self):
4366 return Reservation.select_by_user(self.request.user)
4367
4368 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004369 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4370 if not (serializer.is_valid()):
4371 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4372 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004373 obj.caller = request.user
4374 if obj.can_update(request.user):
4375 return super(ReservationList, self).create(request, *args, **kwargs)
4376 else:
Scott Baker08898c12014-10-29 23:41:11 -07004377 raise Exception("failed obj.can_update")
4378
4379 ret = super(ReservationList, self).create(request, *args, **kwargs)
4380 if (ret.status_code%100 != 200):
4381 raise Exception(ret.data)
4382
4383 return ret
4384
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004385
4386class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4387 queryset = Reservation.objects.select_related().all()
4388 serializer_class = ReservationSerializer
4389 id_serializer_class = ReservationIdSerializer
4390
4391 def get_serializer_class(self):
4392 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4393 if (no_hyperlinks):
4394 return self.id_serializer_class
4395 else:
4396 return self.serializer_class
4397
4398 def get_queryset(self):
4399 return Reservation.select_by_user(self.request.user)
4400
4401 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4402
4403 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4404
Scott Bakerf3816ac2014-11-12 01:13:53 -08004405"""
4406 XXX smbaker: my intent was to create a view that would return 'new' objects
4407 filled with defaults. I solved it another way, so this code may soon be
4408 abandoned.
4409
4410class ReservationNew(GenericAPIView):
4411 serializer_class = ReservationSerializer
4412 id_serializer_class = ReservationIdSerializer
4413
4414 def get(self, request, *args, **kwargs):
4415 return self.makenew(request, *args, **kwargs)
4416
4417 def get_serializer_class(self):
4418 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4419 if (no_hyperlinks):
4420 return self.id_serializer_class
4421 else:
4422 return self.serializer_class
4423
4424 def makenew(self, request, *args, **kwargs):
4425 obj = Reservation()
4426 serializer = self.get_serializer(obj)
4427 return Response(serializer.data)
4428"""
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004429
4430
Scott Bakerf3816ac2014-11-12 01:13:53 -08004431
Scott Baker196ffef2014-11-21 11:32:24 -08004432class SliceDeploymentsList(generics.ListCreateAPIView):
4433 queryset = SliceDeployments.objects.select_related().all()
4434 serializer_class = SliceDeploymentsSerializer
4435 id_serializer_class = SliceDeploymentsIdSerializer
4436 filter_backends = (filters.DjangoFilterBackend,)
4437 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','deployment','tenant_id','network_id','router_id','subnet_id',)
4438
4439 def get_serializer_class(self):
4440 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4441 if (no_hyperlinks):
4442 return self.id_serializer_class
4443 else:
4444 return self.serializer_class
4445
4446 def get_queryset(self):
4447 return SliceDeployments.select_by_user(self.request.user)
4448
4449 def create(self, request, *args, **kwargs):
4450 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4451 if not (serializer.is_valid()):
4452 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4453 obj = serializer.object
4454 obj.caller = request.user
4455 if obj.can_update(request.user):
4456 return super(SliceDeploymentsList, self).create(request, *args, **kwargs)
4457 else:
4458 raise Exception("failed obj.can_update")
4459
4460 ret = super(SliceDeploymentsList, self).create(request, *args, **kwargs)
4461 if (ret.status_code%100 != 200):
4462 raise Exception(ret.data)
4463
4464 return ret
4465
4466
4467class SliceDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4468 queryset = SliceDeployments.objects.select_related().all()
4469 serializer_class = SliceDeploymentsSerializer
4470 id_serializer_class = SliceDeploymentsIdSerializer
4471
4472 def get_serializer_class(self):
4473 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4474 if (no_hyperlinks):
4475 return self.id_serializer_class
4476 else:
4477 return self.serializer_class
4478
4479 def get_queryset(self):
4480 return SliceDeployments.select_by_user(self.request.user)
4481
4482 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4483
4484 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4485
4486"""
4487 XXX smbaker: my intent was to create a view that would return 'new' objects
4488 filled with defaults. I solved it another way, so this code may soon be
4489 abandoned.
4490
4491class SliceDeploymentsNew(GenericAPIView):
4492 serializer_class = SliceDeploymentsSerializer
4493 id_serializer_class = SliceDeploymentsIdSerializer
4494
4495 def get(self, request, *args, **kwargs):
4496 return self.makenew(request, *args, **kwargs)
4497
4498 def get_serializer_class(self):
4499 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4500 if (no_hyperlinks):
4501 return self.id_serializer_class
4502 else:
4503 return self.serializer_class
4504
4505 def makenew(self, request, *args, **kwargs):
4506 obj = SliceDeployments()
4507 serializer = self.get_serializer(obj)
4508 return Response(serializer.data)
4509"""
4510
4511
4512
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004513class SitePrivilegeList(generics.ListCreateAPIView):
4514 queryset = SitePrivilege.objects.select_related().all()
4515 serializer_class = SitePrivilegeSerializer
4516 id_serializer_class = SitePrivilegeIdSerializer
4517 filter_backends = (filters.DjangoFilterBackend,)
4518 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',)
4519
4520 def get_serializer_class(self):
4521 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4522 if (no_hyperlinks):
4523 return self.id_serializer_class
4524 else:
4525 return self.serializer_class
4526
4527 def get_queryset(self):
4528 return SitePrivilege.select_by_user(self.request.user)
4529
4530 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004531 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4532 if not (serializer.is_valid()):
4533 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4534 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004535 obj.caller = request.user
4536 if obj.can_update(request.user):
4537 return super(SitePrivilegeList, self).create(request, *args, **kwargs)
4538 else:
Scott Baker08898c12014-10-29 23:41:11 -07004539 raise Exception("failed obj.can_update")
4540
4541 ret = super(SitePrivilegeList, self).create(request, *args, **kwargs)
4542 if (ret.status_code%100 != 200):
4543 raise Exception(ret.data)
4544
4545 return ret
4546
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004547
4548class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4549 queryset = SitePrivilege.objects.select_related().all()
4550 serializer_class = SitePrivilegeSerializer
4551 id_serializer_class = SitePrivilegeIdSerializer
4552
4553 def get_serializer_class(self):
4554 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4555 if (no_hyperlinks):
4556 return self.id_serializer_class
4557 else:
4558 return self.serializer_class
4559
4560 def get_queryset(self):
4561 return SitePrivilege.select_by_user(self.request.user)
4562
4563 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4564
4565 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4566
Scott Bakerf3816ac2014-11-12 01:13:53 -08004567"""
4568 XXX smbaker: my intent was to create a view that would return 'new' objects
4569 filled with defaults. I solved it another way, so this code may soon be
4570 abandoned.
4571
4572class SitePrivilegeNew(GenericAPIView):
4573 serializer_class = SitePrivilegeSerializer
4574 id_serializer_class = SitePrivilegeIdSerializer
4575
4576 def get(self, request, *args, **kwargs):
4577 return self.makenew(request, *args, **kwargs)
4578
4579 def get_serializer_class(self):
4580 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4581 if (no_hyperlinks):
4582 return self.id_serializer_class
4583 else:
4584 return self.serializer_class
4585
4586 def makenew(self, request, *args, **kwargs):
4587 obj = SitePrivilege()
4588 serializer = self.get_serializer(obj)
4589 return Response(serializer.data)
4590"""
4591
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004592
4593
Scott Baker196ffef2014-11-21 11:32:24 -08004594class PlanetStackList(generics.ListCreateAPIView):
4595 queryset = PlanetStack.objects.select_related().all()
4596 serializer_class = PlanetStackSerializer
4597 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004598 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker196ffef2014-11-21 11:32:24 -08004599 filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004600
4601 def get_serializer_class(self):
4602 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4603 if (no_hyperlinks):
4604 return self.id_serializer_class
4605 else:
4606 return self.serializer_class
4607
4608 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004609 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004610
4611 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004612 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4613 if not (serializer.is_valid()):
4614 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4615 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004616 obj.caller = request.user
4617 if obj.can_update(request.user):
Scott Baker196ffef2014-11-21 11:32:24 -08004618 return super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004619 else:
Scott Baker08898c12014-10-29 23:41:11 -07004620 raise Exception("failed obj.can_update")
4621
Scott Baker196ffef2014-11-21 11:32:24 -08004622 ret = super(PlanetStackList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004623 if (ret.status_code%100 != 200):
4624 raise Exception(ret.data)
4625
4626 return ret
4627
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004628
Scott Baker196ffef2014-11-21 11:32:24 -08004629class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4630 queryset = PlanetStack.objects.select_related().all()
4631 serializer_class = PlanetStackSerializer
4632 id_serializer_class = PlanetStackIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004633
4634 def get_serializer_class(self):
4635 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4636 if (no_hyperlinks):
4637 return self.id_serializer_class
4638 else:
4639 return self.serializer_class
4640
4641 def get_queryset(self):
Scott Baker196ffef2014-11-21 11:32:24 -08004642 return PlanetStack.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004643
4644 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4645
4646 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4647
Scott Bakerf3816ac2014-11-12 01:13:53 -08004648"""
4649 XXX smbaker: my intent was to create a view that would return 'new' objects
4650 filled with defaults. I solved it another way, so this code may soon be
4651 abandoned.
4652
Scott Baker196ffef2014-11-21 11:32:24 -08004653class PlanetStackNew(GenericAPIView):
4654 serializer_class = PlanetStackSerializer
4655 id_serializer_class = PlanetStackIdSerializer
Scott Bakerf3816ac2014-11-12 01:13:53 -08004656
4657 def get(self, request, *args, **kwargs):
4658 return self.makenew(request, *args, **kwargs)
4659
4660 def get_serializer_class(self):
4661 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4662 if (no_hyperlinks):
4663 return self.id_serializer_class
4664 else:
4665 return self.serializer_class
4666
4667 def makenew(self, request, *args, **kwargs):
Scott Baker196ffef2014-11-21 11:32:24 -08004668 obj = PlanetStack()
Scott Bakerf3816ac2014-11-12 01:13:53 -08004669 serializer = self.get_serializer(obj)
4670 return Response(serializer.data)
4671"""
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004672
4673
Scott Bakerf3816ac2014-11-12 01:13:53 -08004674
Sapan Bhatia3f879692014-11-19 15:10:51 -05004675class UserDeploymentsList(generics.ListCreateAPIView):
4676 queryset = UserDeployments.objects.select_related().all()
4677 serializer_class = UserDeploymentsSerializer
4678 id_serializer_class = UserDeploymentsIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004679 filter_backends = (filters.DjangoFilterBackend,)
4680 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','kuser_id',)
4681
4682 def get_serializer_class(self):
4683 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4684 if (no_hyperlinks):
4685 return self.id_serializer_class
4686 else:
4687 return self.serializer_class
4688
4689 def get_queryset(self):
Sapan Bhatia3f879692014-11-19 15:10:51 -05004690 return UserDeployments.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004691
4692 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004693 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4694 if not (serializer.is_valid()):
4695 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4696 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004697 obj.caller = request.user
4698 if obj.can_update(request.user):
Sapan Bhatia3f879692014-11-19 15:10:51 -05004699 return super(UserDeploymentsList, self).create(request, *args, **kwargs)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004700 else:
Scott Baker08898c12014-10-29 23:41:11 -07004701 raise Exception("failed obj.can_update")
4702
Sapan Bhatia3f879692014-11-19 15:10:51 -05004703 ret = super(UserDeploymentsList, self).create(request, *args, **kwargs)
Scott Baker08898c12014-10-29 23:41:11 -07004704 if (ret.status_code%100 != 200):
4705 raise Exception(ret.data)
4706
4707 return ret
4708
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004709
Sapan Bhatia3f879692014-11-19 15:10:51 -05004710class UserDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4711 queryset = UserDeployments.objects.select_related().all()
4712 serializer_class = UserDeploymentsSerializer
4713 id_serializer_class = UserDeploymentsIdSerializer
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004714
4715 def get_serializer_class(self):
4716 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4717 if (no_hyperlinks):
4718 return self.id_serializer_class
4719 else:
4720 return self.serializer_class
4721
4722 def get_queryset(self):
Sapan Bhatia3f879692014-11-19 15:10:51 -05004723 return UserDeployments.select_by_user(self.request.user)
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004724
4725 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4726
4727 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4728
Scott Bakerf3816ac2014-11-12 01:13:53 -08004729"""
4730 XXX smbaker: my intent was to create a view that would return 'new' objects
4731 filled with defaults. I solved it another way, so this code may soon be
4732 abandoned.
4733
Sapan Bhatia3f879692014-11-19 15:10:51 -05004734class UserDeploymentsNew(GenericAPIView):
4735 serializer_class = UserDeploymentsSerializer
4736 id_serializer_class = UserDeploymentsIdSerializer
Scott Bakerf3816ac2014-11-12 01:13:53 -08004737
4738 def get(self, request, *args, **kwargs):
4739 return self.makenew(request, *args, **kwargs)
4740
4741 def get_serializer_class(self):
4742 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4743 if (no_hyperlinks):
4744 return self.id_serializer_class
4745 else:
4746 return self.serializer_class
4747
4748 def makenew(self, request, *args, **kwargs):
Sapan Bhatia3f879692014-11-19 15:10:51 -05004749 obj = UserDeployments()
Scott Bakerf3816ac2014-11-12 01:13:53 -08004750 serializer = self.get_serializer(obj)
4751 return Response(serializer.data)
4752"""
4753
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004754
4755
4756class AccountList(generics.ListCreateAPIView):
4757 queryset = Account.objects.select_related().all()
4758 serializer_class = AccountSerializer
4759 id_serializer_class = AccountIdSerializer
4760 filter_backends = (filters.DjangoFilterBackend,)
4761 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',)
4762
4763 def get_serializer_class(self):
4764 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4765 if (no_hyperlinks):
4766 return self.id_serializer_class
4767 else:
4768 return self.serializer_class
4769
4770 def get_queryset(self):
4771 return Account.select_by_user(self.request.user)
4772
4773 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004774 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4775 if not (serializer.is_valid()):
4776 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4777 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004778 obj.caller = request.user
4779 if obj.can_update(request.user):
4780 return super(AccountList, self).create(request, *args, **kwargs)
4781 else:
Scott Baker08898c12014-10-29 23:41:11 -07004782 raise Exception("failed obj.can_update")
4783
4784 ret = super(AccountList, self).create(request, *args, **kwargs)
4785 if (ret.status_code%100 != 200):
4786 raise Exception(ret.data)
4787
4788 return ret
4789
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004790
4791class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4792 queryset = Account.objects.select_related().all()
4793 serializer_class = AccountSerializer
4794 id_serializer_class = AccountIdSerializer
4795
4796 def get_serializer_class(self):
4797 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4798 if (no_hyperlinks):
4799 return self.id_serializer_class
4800 else:
4801 return self.serializer_class
4802
4803 def get_queryset(self):
4804 return Account.select_by_user(self.request.user)
4805
4806 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4807
4808 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4809
Scott Bakerf3816ac2014-11-12 01:13:53 -08004810"""
4811 XXX smbaker: my intent was to create a view that would return 'new' objects
4812 filled with defaults. I solved it another way, so this code may soon be
4813 abandoned.
4814
4815class AccountNew(GenericAPIView):
4816 serializer_class = AccountSerializer
4817 id_serializer_class = AccountIdSerializer
4818
4819 def get(self, request, *args, **kwargs):
4820 return self.makenew(request, *args, **kwargs)
4821
4822 def get_serializer_class(self):
4823 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4824 if (no_hyperlinks):
4825 return self.id_serializer_class
4826 else:
4827 return self.serializer_class
4828
4829 def makenew(self, request, *args, **kwargs):
4830 obj = Account()
4831 serializer = self.get_serializer(obj)
4832 return Response(serializer.data)
4833"""
4834
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004835
4836
4837class NetworkParameterTypeList(generics.ListCreateAPIView):
4838 queryset = NetworkParameterType.objects.select_related().all()
4839 serializer_class = NetworkParameterTypeSerializer
4840 id_serializer_class = NetworkParameterTypeIdSerializer
4841 filter_backends = (filters.DjangoFilterBackend,)
4842 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',)
4843
4844 def get_serializer_class(self):
4845 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4846 if (no_hyperlinks):
4847 return self.id_serializer_class
4848 else:
4849 return self.serializer_class
4850
4851 def get_queryset(self):
4852 return NetworkParameterType.select_by_user(self.request.user)
4853
4854 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004855 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4856 if not (serializer.is_valid()):
4857 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4858 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004859 obj.caller = request.user
4860 if obj.can_update(request.user):
4861 return super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4862 else:
Scott Baker08898c12014-10-29 23:41:11 -07004863 raise Exception("failed obj.can_update")
4864
4865 ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs)
4866 if (ret.status_code%100 != 200):
4867 raise Exception(ret.data)
4868
4869 return ret
4870
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004871
4872class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4873 queryset = NetworkParameterType.objects.select_related().all()
4874 serializer_class = NetworkParameterTypeSerializer
4875 id_serializer_class = NetworkParameterTypeIdSerializer
4876
4877 def get_serializer_class(self):
4878 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4879 if (no_hyperlinks):
4880 return self.id_serializer_class
4881 else:
4882 return self.serializer_class
4883
4884 def get_queryset(self):
4885 return NetworkParameterType.select_by_user(self.request.user)
4886
4887 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4888
4889 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4890
Scott Bakerf3816ac2014-11-12 01:13:53 -08004891"""
4892 XXX smbaker: my intent was to create a view that would return 'new' objects
4893 filled with defaults. I solved it another way, so this code may soon be
4894 abandoned.
4895
4896class NetworkParameterTypeNew(GenericAPIView):
4897 serializer_class = NetworkParameterTypeSerializer
4898 id_serializer_class = NetworkParameterTypeIdSerializer
4899
4900 def get(self, request, *args, **kwargs):
4901 return self.makenew(request, *args, **kwargs)
4902
4903 def get_serializer_class(self):
4904 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4905 if (no_hyperlinks):
4906 return self.id_serializer_class
4907 else:
4908 return self.serializer_class
4909
4910 def makenew(self, request, *args, **kwargs):
4911 obj = NetworkParameterType()
4912 serializer = self.get_serializer(obj)
4913 return Response(serializer.data)
4914"""
4915
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004916
4917
4918class SiteCredentialList(generics.ListCreateAPIView):
4919 queryset = SiteCredential.objects.select_related().all()
4920 serializer_class = SiteCredentialSerializer
4921 id_serializer_class = SiteCredentialIdSerializer
4922 filter_backends = (filters.DjangoFilterBackend,)
4923 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',)
4924
4925 def get_serializer_class(self):
4926 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4927 if (no_hyperlinks):
4928 return self.id_serializer_class
4929 else:
4930 return self.serializer_class
4931
4932 def get_queryset(self):
4933 return SiteCredential.select_by_user(self.request.user)
4934
4935 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08004936 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
4937 if not (serializer.is_valid()):
4938 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
4939 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004940 obj.caller = request.user
4941 if obj.can_update(request.user):
4942 return super(SiteCredentialList, self).create(request, *args, **kwargs)
4943 else:
Scott Baker08898c12014-10-29 23:41:11 -07004944 raise Exception("failed obj.can_update")
4945
4946 ret = super(SiteCredentialList, self).create(request, *args, **kwargs)
4947 if (ret.status_code%100 != 200):
4948 raise Exception(ret.data)
4949
4950 return ret
4951
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004952
4953class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
4954 queryset = SiteCredential.objects.select_related().all()
4955 serializer_class = SiteCredentialSerializer
4956 id_serializer_class = SiteCredentialIdSerializer
4957
4958 def get_serializer_class(self):
4959 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4960 if (no_hyperlinks):
4961 return self.id_serializer_class
4962 else:
4963 return self.serializer_class
4964
4965 def get_queryset(self):
4966 return SiteCredential.select_by_user(self.request.user)
4967
4968 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4969
4970 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
4971
Scott Bakerf3816ac2014-11-12 01:13:53 -08004972"""
4973 XXX smbaker: my intent was to create a view that would return 'new' objects
4974 filled with defaults. I solved it another way, so this code may soon be
4975 abandoned.
4976
4977class SiteCredentialNew(GenericAPIView):
4978 serializer_class = SiteCredentialSerializer
4979 id_serializer_class = SiteCredentialIdSerializer
4980
4981 def get(self, request, *args, **kwargs):
4982 return self.makenew(request, *args, **kwargs)
4983
4984 def get_serializer_class(self):
4985 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
4986 if (no_hyperlinks):
4987 return self.id_serializer_class
4988 else:
4989 return self.serializer_class
4990
4991 def makenew(self, request, *args, **kwargs):
4992 obj = SiteCredential()
4993 serializer = self.get_serializer(obj)
4994 return Response(serializer.data)
4995"""
4996
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07004997
4998
4999class DeploymentPrivilegeList(generics.ListCreateAPIView):
5000 queryset = DeploymentPrivilege.objects.select_related().all()
5001 serializer_class = DeploymentPrivilegeSerializer
5002 id_serializer_class = DeploymentPrivilegeIdSerializer
5003 filter_backends = (filters.DjangoFilterBackend,)
5004 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',)
5005
5006 def get_serializer_class(self):
5007 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5008 if (no_hyperlinks):
5009 return self.id_serializer_class
5010 else:
5011 return self.serializer_class
5012
5013 def get_queryset(self):
5014 return DeploymentPrivilege.select_by_user(self.request.user)
5015
5016 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005017 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5018 if not (serializer.is_valid()):
5019 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
5020 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005021 obj.caller = request.user
5022 if obj.can_update(request.user):
5023 return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
5024 else:
Scott Baker08898c12014-10-29 23:41:11 -07005025 raise Exception("failed obj.can_update")
5026
5027 ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs)
5028 if (ret.status_code%100 != 200):
5029 raise Exception(ret.data)
5030
5031 return ret
5032
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005033
5034class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5035 queryset = DeploymentPrivilege.objects.select_related().all()
5036 serializer_class = DeploymentPrivilegeSerializer
5037 id_serializer_class = DeploymentPrivilegeIdSerializer
5038
5039 def get_serializer_class(self):
5040 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5041 if (no_hyperlinks):
5042 return self.id_serializer_class
5043 else:
5044 return self.serializer_class
5045
5046 def get_queryset(self):
5047 return DeploymentPrivilege.select_by_user(self.request.user)
5048
5049 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5050
5051 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5052
Scott Bakerf3816ac2014-11-12 01:13:53 -08005053"""
5054 XXX smbaker: my intent was to create a view that would return 'new' objects
5055 filled with defaults. I solved it another way, so this code may soon be
5056 abandoned.
5057
5058class DeploymentPrivilegeNew(GenericAPIView):
5059 serializer_class = DeploymentPrivilegeSerializer
5060 id_serializer_class = DeploymentPrivilegeIdSerializer
5061
5062 def get(self, request, *args, **kwargs):
5063 return self.makenew(request, *args, **kwargs)
5064
5065 def get_serializer_class(self):
5066 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5067 if (no_hyperlinks):
5068 return self.id_serializer_class
5069 else:
5070 return self.serializer_class
5071
5072 def makenew(self, request, *args, **kwargs):
5073 obj = DeploymentPrivilege()
5074 serializer = self.get_serializer(obj)
5075 return Response(serializer.data)
5076"""
5077
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005078
5079
5080class DeploymentRoleList(generics.ListCreateAPIView):
5081 queryset = DeploymentRole.objects.select_related().all()
5082 serializer_class = DeploymentRoleSerializer
5083 id_serializer_class = DeploymentRoleIdSerializer
5084 filter_backends = (filters.DjangoFilterBackend,)
5085 filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',)
5086
5087 def get_serializer_class(self):
5088 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5089 if (no_hyperlinks):
5090 return self.id_serializer_class
5091 else:
5092 return self.serializer_class
5093
5094 def get_queryset(self):
5095 return DeploymentRole.select_by_user(self.request.user)
5096
5097 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005098 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5099 if not (serializer.is_valid()):
5100 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
5101 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005102 obj.caller = request.user
5103 if obj.can_update(request.user):
5104 return super(DeploymentRoleList, self).create(request, *args, **kwargs)
5105 else:
Scott Baker08898c12014-10-29 23:41:11 -07005106 raise Exception("failed obj.can_update")
5107
5108 ret = super(DeploymentRoleList, self).create(request, *args, **kwargs)
5109 if (ret.status_code%100 != 200):
5110 raise Exception(ret.data)
5111
5112 return ret
5113
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005114
5115class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5116 queryset = DeploymentRole.objects.select_related().all()
5117 serializer_class = DeploymentRoleSerializer
5118 id_serializer_class = DeploymentRoleIdSerializer
5119
5120 def get_serializer_class(self):
5121 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5122 if (no_hyperlinks):
5123 return self.id_serializer_class
5124 else:
5125 return self.serializer_class
5126
5127 def get_queryset(self):
5128 return DeploymentRole.select_by_user(self.request.user)
5129
5130 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5131
5132 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5133
Scott Bakerf3816ac2014-11-12 01:13:53 -08005134"""
5135 XXX smbaker: my intent was to create a view that would return 'new' objects
5136 filled with defaults. I solved it another way, so this code may soon be
5137 abandoned.
5138
5139class DeploymentRoleNew(GenericAPIView):
5140 serializer_class = DeploymentRoleSerializer
5141 id_serializer_class = DeploymentRoleIdSerializer
5142
5143 def get(self, request, *args, **kwargs):
5144 return self.makenew(request, *args, **kwargs)
5145
5146 def get_serializer_class(self):
5147 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5148 if (no_hyperlinks):
5149 return self.id_serializer_class
5150 else:
5151 return self.serializer_class
5152
5153 def makenew(self, request, *args, **kwargs):
5154 obj = DeploymentRole()
5155 serializer = self.get_serializer(obj)
5156 return Response(serializer.data)
5157"""
5158
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005159
5160
5161class UserCredentialList(generics.ListCreateAPIView):
5162 queryset = UserCredential.objects.select_related().all()
5163 serializer_class = UserCredentialSerializer
5164 id_serializer_class = UserCredentialIdSerializer
5165 filter_backends = (filters.DjangoFilterBackend,)
5166 filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',)
5167
5168 def get_serializer_class(self):
5169 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5170 if (no_hyperlinks):
5171 return self.id_serializer_class
5172 else:
5173 return self.serializer_class
5174
5175 def get_queryset(self):
5176 return UserCredential.select_by_user(self.request.user)
5177
5178 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005179 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5180 if not (serializer.is_valid()):
5181 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
5182 obj = serializer.object
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005183 obj.caller = request.user
5184 if obj.can_update(request.user):
5185 return super(UserCredentialList, self).create(request, *args, **kwargs)
5186 else:
Scott Baker08898c12014-10-29 23:41:11 -07005187 raise Exception("failed obj.can_update")
5188
5189 ret = super(UserCredentialList, self).create(request, *args, **kwargs)
5190 if (ret.status_code%100 != 200):
5191 raise Exception(ret.data)
5192
5193 return ret
5194
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005195
5196class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5197 queryset = UserCredential.objects.select_related().all()
5198 serializer_class = UserCredentialSerializer
5199 id_serializer_class = UserCredentialIdSerializer
5200
5201 def get_serializer_class(self):
5202 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5203 if (no_hyperlinks):
5204 return self.id_serializer_class
5205 else:
5206 return self.serializer_class
5207
5208 def get_queryset(self):
5209 return UserCredential.select_by_user(self.request.user)
5210
5211 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5212
5213 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5214
Scott Bakerf3816ac2014-11-12 01:13:53 -08005215"""
5216 XXX smbaker: my intent was to create a view that would return 'new' objects
5217 filled with defaults. I solved it another way, so this code may soon be
5218 abandoned.
5219
5220class UserCredentialNew(GenericAPIView):
5221 serializer_class = UserCredentialSerializer
5222 id_serializer_class = UserCredentialIdSerializer
5223
5224 def get(self, request, *args, **kwargs):
5225 return self.makenew(request, *args, **kwargs)
5226
5227 def get_serializer_class(self):
5228 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5229 if (no_hyperlinks):
5230 return self.id_serializer_class
5231 else:
5232 return self.serializer_class
5233
5234 def makenew(self, request, *args, **kwargs):
5235 obj = UserCredential()
5236 serializer = self.get_serializer(obj)
5237 return Response(serializer.data)
5238"""
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005239
5240
Scott Bakerf3816ac2014-11-12 01:13:53 -08005241
Scott Baker196ffef2014-11-21 11:32:24 -08005242class SiteDeploymentsList(generics.ListCreateAPIView):
5243 queryset = SiteDeployments.objects.select_related().all()
5244 serializer_class = SiteDeploymentsSerializer
5245 id_serializer_class = SiteDeploymentsIdSerializer
5246 filter_backends = (filters.DjangoFilterBackend,)
5247 filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','tenant_id',)
5248
5249 def get_serializer_class(self):
5250 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5251 if (no_hyperlinks):
5252 return self.id_serializer_class
5253 else:
5254 return self.serializer_class
5255
5256 def get_queryset(self):
5257 return SiteDeployments.select_by_user(self.request.user)
5258
5259 def create(self, request, *args, **kwargs):
5260 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5261 if not (serializer.is_valid()):
5262 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
5263 obj = serializer.object
5264 obj.caller = request.user
5265 if obj.can_update(request.user):
5266 return super(SiteDeploymentsList, self).create(request, *args, **kwargs)
5267 else:
5268 raise Exception("failed obj.can_update")
5269
5270 ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs)
5271 if (ret.status_code%100 != 200):
5272 raise Exception(ret.data)
5273
5274 return ret
5275
5276
5277class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView):
5278 queryset = SiteDeployments.objects.select_related().all()
5279 serializer_class = SiteDeploymentsSerializer
5280 id_serializer_class = SiteDeploymentsIdSerializer
5281
5282 def get_serializer_class(self):
5283 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5284 if (no_hyperlinks):
5285 return self.id_serializer_class
5286 else:
5287 return self.serializer_class
5288
5289 def get_queryset(self):
5290 return SiteDeployments.select_by_user(self.request.user)
5291
5292 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5293
5294 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
5295
5296"""
5297 XXX smbaker: my intent was to create a view that would return 'new' objects
5298 filled with defaults. I solved it another way, so this code may soon be
5299 abandoned.
5300
5301class SiteDeploymentsNew(GenericAPIView):
5302 serializer_class = SiteDeploymentsSerializer
5303 id_serializer_class = SiteDeploymentsIdSerializer
5304
5305 def get(self, request, *args, **kwargs):
5306 return self.makenew(request, *args, **kwargs)
5307
5308 def get_serializer_class(self):
5309 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5310 if (no_hyperlinks):
5311 return self.id_serializer_class
5312 else:
5313 return self.serializer_class
5314
5315 def makenew(self, request, *args, **kwargs):
5316 obj = SiteDeployments()
5317 serializer = self.get_serializer(obj)
5318 return Response(serializer.data)
5319"""
5320
5321
5322
Scott Baker0caeaf02014-06-19 11:12:55 -07005323class SliceTagList(generics.ListCreateAPIView):
5324 queryset = SliceTag.objects.select_related().all()
5325 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005326 id_serializer_class = SliceTagIdSerializer
5327 filter_backends = (filters.DjangoFilterBackend,)
5328 filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',)
5329
5330 def get_serializer_class(self):
5331 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5332 if (no_hyperlinks):
5333 return self.id_serializer_class
5334 else:
5335 return self.serializer_class
5336
Scott Baker0caeaf02014-06-19 11:12:55 -07005337 def get_queryset(self):
5338 return SliceTag.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005339
Scott Baker0caeaf02014-06-19 11:12:55 -07005340 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005341 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5342 if not (serializer.is_valid()):
5343 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
5344 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005345 obj.caller = request.user
5346 if obj.can_update(request.user):
5347 return super(SliceTagList, self).create(request, *args, **kwargs)
5348 else:
Scott Baker08898c12014-10-29 23:41:11 -07005349 raise Exception("failed obj.can_update")
5350
5351 ret = super(SliceTagList, self).create(request, *args, **kwargs)
5352 if (ret.status_code%100 != 200):
5353 raise Exception(ret.data)
5354
5355 return ret
5356
Scott Baker0caeaf02014-06-19 11:12:55 -07005357
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005358class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005359 queryset = SliceTag.objects.select_related().all()
5360 serializer_class = SliceTagSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005361 id_serializer_class = SliceTagIdSerializer
5362
5363 def get_serializer_class(self):
5364 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5365 if (no_hyperlinks):
5366 return self.id_serializer_class
5367 else:
5368 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005369
5370 def get_queryset(self):
5371 return SliceTag.select_by_user(self.request.user)
5372
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005373 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005374
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005375 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005376
Scott Bakerf3816ac2014-11-12 01:13:53 -08005377"""
5378 XXX smbaker: my intent was to create a view that would return 'new' objects
5379 filled with defaults. I solved it another way, so this code may soon be
5380 abandoned.
5381
5382class SliceTagNew(GenericAPIView):
5383 serializer_class = SliceTagSerializer
5384 id_serializer_class = SliceTagIdSerializer
5385
5386 def get(self, request, *args, **kwargs):
5387 return self.makenew(request, *args, **kwargs)
5388
5389 def get_serializer_class(self):
5390 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5391 if (no_hyperlinks):
5392 return self.id_serializer_class
5393 else:
5394 return self.serializer_class
5395
5396 def makenew(self, request, *args, **kwargs):
5397 obj = SliceTag()
5398 serializer = self.get_serializer(obj)
5399 return Response(serializer.data)
5400"""
5401
Sapan Bhatiadea39432014-06-13 03:10:36 -04005402
5403
Scott Baker0caeaf02014-06-19 11:12:55 -07005404class NetworkTemplateList(generics.ListCreateAPIView):
5405 queryset = NetworkTemplate.objects.select_related().all()
5406 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005407 id_serializer_class = NetworkTemplateIdSerializer
5408 filter_backends = (filters.DjangoFilterBackend,)
Scott Baker645dc9d2014-11-17 22:32:19 -08005409 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',)
Scott Baker46b58542014-08-11 17:26:12 -07005410
5411 def get_serializer_class(self):
5412 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5413 if (no_hyperlinks):
5414 return self.id_serializer_class
5415 else:
5416 return self.serializer_class
5417
Scott Baker0caeaf02014-06-19 11:12:55 -07005418 def get_queryset(self):
5419 return NetworkTemplate.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005420
Scott Baker0caeaf02014-06-19 11:12:55 -07005421 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005422 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5423 if not (serializer.is_valid()):
5424 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
5425 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005426 obj.caller = request.user
5427 if obj.can_update(request.user):
5428 return super(NetworkTemplateList, self).create(request, *args, **kwargs)
5429 else:
Scott Baker08898c12014-10-29 23:41:11 -07005430 raise Exception("failed obj.can_update")
5431
5432 ret = super(NetworkTemplateList, self).create(request, *args, **kwargs)
5433 if (ret.status_code%100 != 200):
5434 raise Exception(ret.data)
5435
5436 return ret
5437
Scott Baker0caeaf02014-06-19 11:12:55 -07005438
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005439class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005440 queryset = NetworkTemplate.objects.select_related().all()
5441 serializer_class = NetworkTemplateSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005442 id_serializer_class = NetworkTemplateIdSerializer
5443
5444 def get_serializer_class(self):
5445 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5446 if (no_hyperlinks):
5447 return self.id_serializer_class
5448 else:
5449 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005450
5451 def get_queryset(self):
5452 return NetworkTemplate.select_by_user(self.request.user)
5453
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005454 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005455
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005456 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005457
Scott Bakerf3816ac2014-11-12 01:13:53 -08005458"""
5459 XXX smbaker: my intent was to create a view that would return 'new' objects
5460 filled with defaults. I solved it another way, so this code may soon be
5461 abandoned.
5462
5463class NetworkTemplateNew(GenericAPIView):
5464 serializer_class = NetworkTemplateSerializer
5465 id_serializer_class = NetworkTemplateIdSerializer
5466
5467 def get(self, request, *args, **kwargs):
5468 return self.makenew(request, *args, **kwargs)
5469
5470 def get_serializer_class(self):
5471 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5472 if (no_hyperlinks):
5473 return self.id_serializer_class
5474 else:
5475 return self.serializer_class
5476
5477 def makenew(self, request, *args, **kwargs):
5478 obj = NetworkTemplate()
5479 serializer = self.get_serializer(obj)
5480 return Response(serializer.data)
5481"""
5482
Sapan Bhatiadea39432014-06-13 03:10:36 -04005483
5484
5485class RouterList(generics.ListCreateAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005486 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005487 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005488 id_serializer_class = RouterIdSerializer
5489 filter_backends = (filters.DjangoFilterBackend,)
5490 filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner',)
5491
5492 def get_serializer_class(self):
5493 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5494 if (no_hyperlinks):
5495 return self.id_serializer_class
5496 else:
5497 return self.serializer_class
5498
Scott Baker0caeaf02014-06-19 11:12:55 -07005499 def get_queryset(self):
5500 return Router.select_by_user(self.request.user)
5501
5502 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005503 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5504 if not (serializer.is_valid()):
5505 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
5506 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005507 obj.caller = request.user
5508 if obj.can_update(request.user):
5509 return super(RouterList, self).create(request, *args, **kwargs)
5510 else:
Scott Baker08898c12014-10-29 23:41:11 -07005511 raise Exception("failed obj.can_update")
5512
5513 ret = super(RouterList, self).create(request, *args, **kwargs)
5514 if (ret.status_code%100 != 200):
5515 raise Exception(ret.data)
5516
5517 return ret
5518
Sapan Bhatiadea39432014-06-13 03:10:36 -04005519
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005520class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005521 queryset = Router.objects.select_related().all()
Sapan Bhatiadea39432014-06-13 03:10:36 -04005522 serializer_class = RouterSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005523 id_serializer_class = RouterIdSerializer
5524
5525 def get_serializer_class(self):
5526 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5527 if (no_hyperlinks):
5528 return self.id_serializer_class
5529 else:
5530 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005531
5532 def get_queryset(self):
5533 return Router.select_by_user(self.request.user)
5534
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005535 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005536
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005537 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005538
Scott Bakerf3816ac2014-11-12 01:13:53 -08005539"""
5540 XXX smbaker: my intent was to create a view that would return 'new' objects
5541 filled with defaults. I solved it another way, so this code may soon be
5542 abandoned.
5543
5544class RouterNew(GenericAPIView):
5545 serializer_class = RouterSerializer
5546 id_serializer_class = RouterIdSerializer
5547
5548 def get(self, request, *args, **kwargs):
5549 return self.makenew(request, *args, **kwargs)
5550
5551 def get_serializer_class(self):
5552 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5553 if (no_hyperlinks):
5554 return self.id_serializer_class
5555 else:
5556 return self.serializer_class
5557
5558 def makenew(self, request, *args, **kwargs):
5559 obj = Router()
5560 serializer = self.get_serializer(obj)
5561 return Response(serializer.data)
5562"""
5563
Sapan Bhatiadea39432014-06-13 03:10:36 -04005564
5565
Scott Baker0caeaf02014-06-19 11:12:55 -07005566class ServiceResourceList(generics.ListCreateAPIView):
5567 queryset = ServiceResource.objects.select_related().all()
5568 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005569 id_serializer_class = ServiceResourceIdSerializer
5570 filter_backends = (filters.DjangoFilterBackend,)
5571 filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',)
5572
5573 def get_serializer_class(self):
5574 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5575 if (no_hyperlinks):
5576 return self.id_serializer_class
5577 else:
5578 return self.serializer_class
5579
Scott Baker0caeaf02014-06-19 11:12:55 -07005580 def get_queryset(self):
5581 return ServiceResource.select_by_user(self.request.user)
Sapan Bhatiadea39432014-06-13 03:10:36 -04005582
Scott Baker0caeaf02014-06-19 11:12:55 -07005583 def create(self, request, *args, **kwargs):
Scott Bakerf3816ac2014-11-12 01:13:53 -08005584 serializer = self.get_serializer(data=request.DATA, files=request.FILES)
5585 if not (serializer.is_valid()):
5586 raise Exception("failed serializer.is_valid: " + str(serializer.errors))
5587 obj = serializer.object
Scott Baker0caeaf02014-06-19 11:12:55 -07005588 obj.caller = request.user
5589 if obj.can_update(request.user):
5590 return super(ServiceResourceList, self).create(request, *args, **kwargs)
5591 else:
Scott Baker08898c12014-10-29 23:41:11 -07005592 raise Exception("failed obj.can_update")
5593
5594 ret = super(ServiceResourceList, self).create(request, *args, **kwargs)
5595 if (ret.status_code%100 != 200):
5596 raise Exception(ret.data)
5597
5598 return ret
5599
Scott Baker0caeaf02014-06-19 11:12:55 -07005600
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005601class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView):
Scott Baker0caeaf02014-06-19 11:12:55 -07005602 queryset = ServiceResource.objects.select_related().all()
5603 serializer_class = ServiceResourceSerializer
Scott Baker46b58542014-08-11 17:26:12 -07005604 id_serializer_class = ServiceResourceIdSerializer
5605
5606 def get_serializer_class(self):
5607 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5608 if (no_hyperlinks):
5609 return self.id_serializer_class
5610 else:
5611 return self.serializer_class
Scott Baker0caeaf02014-06-19 11:12:55 -07005612
5613 def get_queryset(self):
5614 return ServiceResource.select_by_user(self.request.user)
5615
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005616 # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Scott Baker0caeaf02014-06-19 11:12:55 -07005617
Scott Bakerdcb9b5d2014-10-07 00:10:17 -07005618 # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView
Sapan Bhatiadea39432014-06-13 03:10:36 -04005619
Scott Bakerf3816ac2014-11-12 01:13:53 -08005620"""
5621 XXX smbaker: my intent was to create a view that would return 'new' objects
5622 filled with defaults. I solved it another way, so this code may soon be
5623 abandoned.
5624
5625class ServiceResourceNew(GenericAPIView):
5626 serializer_class = ServiceResourceSerializer
5627 id_serializer_class = ServiceResourceIdSerializer
5628
5629 def get(self, request, *args, **kwargs):
5630 return self.makenew(request, *args, **kwargs)
5631
5632 def get_serializer_class(self):
5633 no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
5634 if (no_hyperlinks):
5635 return self.id_serializer_class
5636 else:
5637 return self.serializer_class
5638
5639 def makenew(self, request, *args, **kwargs):
5640 obj = ServiceResource()
5641 serializer = self.get_serializer(obj)
5642 return Response(serializer.data)
5643"""
5644
Sapan Bhatiadea39432014-06-13 03:10:36 -04005645
5646