Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1 | from rest_framework.decorators import api_view |
| 2 | from rest_framework.response import Response |
| 3 | from rest_framework.reverse import reverse |
| 4 | from rest_framework import serializers |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5 | from rest_framework import generics |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 6 | from rest_framework import status |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 7 | from rest_framework.generics import GenericAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 8 | from core.models import * |
| 9 | from django.forms import widgets |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 10 | from rest_framework import filters |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 11 | from django.conf.urls import patterns, url |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 12 | |
| 13 | """ |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 14 | Schema of the generator object: |
| 15 | all: Set of all Model objects |
| 16 | all_if(regex): Set of Model objects that match regex |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 17 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 18 | 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 Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 23 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 24 | TODO: Deal with subnets |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 25 | """ |
| 26 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 27 | def get_REST_patterns(): |
| 28 | return patterns('', |
| 29 | url(r'^plstackapi/$', api_root), |
| 30 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 31 | url(r'plstackapi/flavors/$', FlavorList.as_view(), name='flavor-list'), |
| 32 | url(r'plstackapi/flavors/(?P<pk>[a-zA-Z0-9\-]+)/$', FlavorDetail.as_view(), name ='flavor-detail'), |
| 33 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 34 | url(r'plstackapi/serviceattributes/$', ServiceAttributeList.as_view(), name='serviceattribute-list'), |
| 35 | url(r'plstackapi/serviceattributes/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceAttributeDetail.as_view(), name ='serviceattribute-detail'), |
| 36 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 37 | url(r'plstackapi/controllerimages/$', ControllerImagesList.as_view(), name='controllerimages-list'), |
| 38 | url(r'plstackapi/controllerimages/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerImagesDetail.as_view(), name ='controllerimages-detail'), |
| 39 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 40 | url(r'plstackapi/images/$', ImageList.as_view(), name='image-list'), |
| 41 | url(r'plstackapi/images/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDetail.as_view(), name ='image-detail'), |
| 42 | |
| 43 | url(r'plstackapi/networkparameters/$', NetworkParameterList.as_view(), name='networkparameter-list'), |
| 44 | url(r'plstackapi/networkparameters/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterDetail.as_view(), name ='networkparameter-detail'), |
| 45 | |
| 46 | url(r'plstackapi/sites/$', SiteList.as_view(), name='site-list'), |
| 47 | url(r'plstackapi/sites/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDetail.as_view(), name ='site-detail'), |
| 48 | |
| 49 | url(r'plstackapi/slice_roles/$', SliceRoleList.as_view(), name='slicerole-list'), |
| 50 | url(r'plstackapi/slice_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceRoleDetail.as_view(), name ='slicerole-detail'), |
| 51 | |
| 52 | url(r'plstackapi/tags/$', TagList.as_view(), name='tag-list'), |
| 53 | url(r'plstackapi/tags/(?P<pk>[a-zA-Z0-9\-]+)/$', TagDetail.as_view(), name ='tag-detail'), |
| 54 | |
| 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'), |
| 57 | |
| 58 | url(r'plstackapi/slice_privileges/$', SlicePrivilegeList.as_view(), name='sliceprivilege-list'), |
| 59 | url(r'plstackapi/slice_privileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SlicePrivilegeDetail.as_view(), name ='sliceprivilege-detail'), |
| 60 | |
| 61 | url(r'plstackapi/planetstackroles/$', PlanetStackRoleList.as_view(), name='planetstackrole-list'), |
| 62 | url(r'plstackapi/planetstackroles/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackRoleDetail.as_view(), name ='planetstackrole-detail'), |
| 63 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 64 | url(r'plstackapi/controllerprivileges/$', ControllerPrivilegeList.as_view(), name='controllerprivilege-list'), |
| 65 | url(r'plstackapi/controllerprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerPrivilegeDetail.as_view(), name ='controllerprivilege-detail'), |
| 66 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 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'), |
| 69 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 70 | url(r'plstackapi/projects/$', ProjectList.as_view(), name='project-list'), |
| 71 | url(r'plstackapi/projects/(?P<pk>[a-zA-Z0-9\-]+)/$', ProjectDetail.as_view(), name ='project-detail'), |
| 72 | |
| 73 | url(r'plstackapi/slices/$', SliceList.as_view(), name='slice-list'), |
| 74 | url(r'plstackapi/slices/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceDetail.as_view(), name ='slice-detail'), |
| 75 | |
| 76 | url(r'plstackapi/networks/$', NetworkList.as_view(), name='network-list'), |
| 77 | url(r'plstackapi/networks/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkDetail.as_view(), name ='network-detail'), |
| 78 | |
| 79 | url(r'plstackapi/services/$', ServiceList.as_view(), name='service-list'), |
| 80 | url(r'plstackapi/services/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceDetail.as_view(), name ='service-detail'), |
| 81 | |
| 82 | url(r'plstackapi/serviceclasses/$', ServiceClassList.as_view(), name='serviceclass-list'), |
| 83 | url(r'plstackapi/serviceclasses/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceClassDetail.as_view(), name ='serviceclass-detail'), |
| 84 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 85 | url(r'plstackapi/controllernetworks/$', ControllerNetworksList.as_view(), name='controllernetworks-list'), |
| 86 | url(r'plstackapi/controllernetworks/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerNetworksDetail.as_view(), name ='controllernetworks-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 87 | |
| 88 | url(r'plstackapi/charges/$', ChargeList.as_view(), name='charge-list'), |
| 89 | url(r'plstackapi/charges/(?P<pk>[a-zA-Z0-9\-]+)/$', ChargeDetail.as_view(), name ='charge-detail'), |
| 90 | |
| 91 | url(r'plstackapi/roles/$', RoleList.as_view(), name='role-list'), |
| 92 | url(r'plstackapi/roles/(?P<pk>[a-zA-Z0-9\-]+)/$', RoleDetail.as_view(), name ='role-detail'), |
| 93 | |
| 94 | url(r'plstackapi/usableobjects/$', UsableObjectList.as_view(), name='usableobject-list'), |
| 95 | url(r'plstackapi/usableobjects/(?P<pk>[a-zA-Z0-9\-]+)/$', UsableObjectDetail.as_view(), name ='usableobject-detail'), |
| 96 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 97 | url(r'plstackapi/controllersitedeploymentses/$', ControllerSiteDeploymentsList.as_view(), name='controllersitedeployments-list'), |
| 98 | url(r'plstackapi/controllersitedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSiteDeploymentsDetail.as_view(), name ='controllersitedeployments-detail'), |
| 99 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 100 | url(r'plstackapi/site_roles/$', SiteRoleList.as_view(), name='siterole-list'), |
| 101 | url(r'plstackapi/site_roles/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteRoleDetail.as_view(), name ='siterole-detail'), |
| 102 | |
| 103 | url(r'plstackapi/slicecredentials/$', SliceCredentialList.as_view(), name='slicecredential-list'), |
| 104 | url(r'plstackapi/slicecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceCredentialDetail.as_view(), name ='slicecredential-detail'), |
| 105 | |
| 106 | url(r'plstackapi/slivers/$', SliverList.as_view(), name='sliver-list'), |
| 107 | url(r'plstackapi/slivers/(?P<pk>[a-zA-Z0-9\-]+)/$', SliverDetail.as_view(), name ='sliver-detail'), |
| 108 | |
| 109 | url(r'plstackapi/nodes/$', NodeList.as_view(), name='node-list'), |
| 110 | url(r'plstackapi/nodes/(?P<pk>[a-zA-Z0-9\-]+)/$', NodeDetail.as_view(), name ='node-detail'), |
| 111 | |
| 112 | url(r'plstackapi/dashboardviews/$', DashboardViewList.as_view(), name='dashboardview-list'), |
| 113 | url(r'plstackapi/dashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', DashboardViewDetail.as_view(), name ='dashboardview-detail'), |
| 114 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 115 | url(r'plstackapi/imagedeploymentses/$', ImageDeploymentsList.as_view(), name='imagedeployments-list'), |
| 116 | url(r'plstackapi/imagedeploymentses/(?P<pk>[a-zA-Z0-9\-]+)/$', ImageDeploymentsDetail.as_view(), name ='imagedeployments-detail'), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 117 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 118 | url(r'plstackapi/reservedresources/$', ReservedResourceList.as_view(), name='reservedresource-list'), |
| 119 | url(r'plstackapi/reservedresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservedResourceDetail.as_view(), name ='reservedresource-detail'), |
| 120 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 121 | url(r'plstackapi/payments/$', PaymentList.as_view(), name='payment-list'), |
| 122 | url(r'plstackapi/payments/(?P<pk>[a-zA-Z0-9\-]+)/$', PaymentDetail.as_view(), name ='payment-detail'), |
| 123 | |
| 124 | url(r'plstackapi/networktemplates/$', NetworkTemplateList.as_view(), name='networktemplate-list'), |
| 125 | url(r'plstackapi/networktemplates/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkTemplateDetail.as_view(), name ='networktemplate-detail'), |
| 126 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 127 | url(r'plstackapi/networkslices/$', NetworkSliceList.as_view(), name='networkslice-list'), |
| 128 | url(r'plstackapi/networkslices/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkSliceDetail.as_view(), name ='networkslice-detail'), |
| 129 | |
| 130 | url(r'plstackapi/userdashboardviews/$', UserDashboardViewList.as_view(), name='userdashboardview-list'), |
| 131 | url(r'plstackapi/userdashboardviews/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDashboardViewDetail.as_view(), name ='userdashboardview-detail'), |
| 132 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 133 | url(r'plstackapi/controllers/$', ControllerList.as_view(), name='controller-list'), |
| 134 | url(r'plstackapi/controllers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDetail.as_view(), name ='controller-detail'), |
| 135 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 136 | url(r'plstackapi/planetstackprivileges/$', PlanetStackPrivilegeList.as_view(), name='planetstackprivilege-list'), |
| 137 | url(r'plstackapi/planetstackprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackPrivilegeDetail.as_view(), name ='planetstackprivilege-detail'), |
| 138 | |
| 139 | url(r'plstackapi/users/$', UserList.as_view(), name='user-list'), |
| 140 | url(r'plstackapi/users/(?P<pk>[a-zA-Z0-9\-]+)/$', UserDetail.as_view(), name ='user-detail'), |
| 141 | |
| 142 | url(r'plstackapi/deployments/$', DeploymentList.as_view(), name='deployment-list'), |
| 143 | url(r'plstackapi/deployments/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentDetail.as_view(), name ='deployment-detail'), |
| 144 | |
| 145 | url(r'plstackapi/reservations/$', ReservationList.as_view(), name='reservation-list'), |
| 146 | url(r'plstackapi/reservations/(?P<pk>[a-zA-Z0-9\-]+)/$', ReservationDetail.as_view(), name ='reservation-detail'), |
| 147 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 148 | url(r'plstackapi/siteprivileges/$', SitePrivilegeList.as_view(), name='siteprivilege-list'), |
| 149 | url(r'plstackapi/siteprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', SitePrivilegeDetail.as_view(), name ='siteprivilege-detail'), |
| 150 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 151 | url(r'plstackapi/planetstacks/$', PlanetStackList.as_view(), name='planetstack-list'), |
| 152 | url(r'plstackapi/planetstacks/(?P<pk>[a-zA-Z0-9\-]+)/$', PlanetStackDetail.as_view(), name ='planetstack-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 153 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 154 | url(r'plstackapi/accounts/$', AccountList.as_view(), name='account-list'), |
| 155 | url(r'plstackapi/accounts/(?P<pk>[a-zA-Z0-9\-]+)/$', AccountDetail.as_view(), name ='account-detail'), |
| 156 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 157 | url(r'plstackapi/controllerroles/$', ControllerRoleList.as_view(), name='controllerrole-list'), |
| 158 | url(r'plstackapi/controllerroles/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerRoleDetail.as_view(), name ='controllerrole-detail'), |
| 159 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 160 | url(r'plstackapi/networkparametertypes/$', NetworkParameterTypeList.as_view(), name='networkparametertype-list'), |
| 161 | url(r'plstackapi/networkparametertypes/(?P<pk>[a-zA-Z0-9\-]+)/$', NetworkParameterTypeDetail.as_view(), name ='networkparametertype-detail'), |
| 162 | |
| 163 | url(r'plstackapi/sitecredentials/$', SiteCredentialList.as_view(), name='sitecredential-list'), |
| 164 | url(r'plstackapi/sitecredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteCredentialDetail.as_view(), name ='sitecredential-detail'), |
| 165 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 166 | url(r'plstackapi/deploymentprivileges/$', DeploymentPrivilegeList.as_view(), name='deploymentprivilege-list'), |
| 167 | url(r'plstackapi/deploymentprivileges/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentPrivilegeDetail.as_view(), name ='deploymentprivilege-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 168 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 169 | url(r'plstackapi/controllerusers/$', ControllerUsersList.as_view(), name='controllerusers-list'), |
| 170 | url(r'plstackapi/controllerusers/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerUsersDetail.as_view(), name ='controllerusers-detail'), |
| 171 | |
| 172 | url(r'plstackapi/deploymentroles/$', DeploymentRoleList.as_view(), name='deploymentrole-list'), |
| 173 | url(r'plstackapi/deploymentroles/(?P<pk>[a-zA-Z0-9\-]+)/$', DeploymentRoleDetail.as_view(), name ='deploymentrole-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 174 | |
| 175 | url(r'plstackapi/usercredentials/$', UserCredentialList.as_view(), name='usercredential-list'), |
| 176 | url(r'plstackapi/usercredentials/(?P<pk>[a-zA-Z0-9\-]+)/$', UserCredentialDetail.as_view(), name ='usercredential-detail'), |
| 177 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 178 | url(r'plstackapi/sitedeployments/$', SiteDeploymentsList.as_view(), name='sitedeployments-list'), |
| 179 | url(r'plstackapi/sitedeployments/(?P<pk>[a-zA-Z0-9\-]+)/$', SiteDeploymentsDetail.as_view(), name ='sitedeployments-detail'), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 180 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 181 | url(r'plstackapi/slicetags/$', SliceTagList.as_view(), name='slicetag-list'), |
| 182 | url(r'plstackapi/slicetags/(?P<pk>[a-zA-Z0-9\-]+)/$', SliceTagDetail.as_view(), name ='slicetag-detail'), |
| 183 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 184 | url(r'plstackapi/controllerdashboards/$', ControllerDashboardList.as_view(), name='controllerdashboard-list'), |
| 185 | url(r'plstackapi/controllerdashboards/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerDashboardDetail.as_view(), name ='controllerdashboard-detail'), |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 186 | |
| 187 | url(r'plstackapi/routers/$', RouterList.as_view(), name='router-list'), |
| 188 | url(r'plstackapi/routers/(?P<pk>[a-zA-Z0-9\-]+)/$', RouterDetail.as_view(), name ='router-detail'), |
| 189 | |
| 190 | url(r'plstackapi/serviceresources/$', ServiceResourceList.as_view(), name='serviceresource-list'), |
| 191 | url(r'plstackapi/serviceresources/(?P<pk>[a-zA-Z0-9\-]+)/$', ServiceResourceDetail.as_view(), name ='serviceresource-detail'), |
| 192 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 193 | url(r'plstackapi/controllerslices/$', ControllerSlicesList.as_view(), name='controllerslices-list'), |
| 194 | url(r'plstackapi/controllerslices/(?P<pk>[a-zA-Z0-9\-]+)/$', ControllerSlicesDetail.as_view(), name ='controllerslices-detail'), |
| 195 | |
Scott Baker | d51d0bd | 2014-11-10 16:31:15 -0800 | [diff] [blame] | 196 | ) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 197 | |
| 198 | @api_view(['GET']) |
| 199 | def api_root(request, format=None): |
| 200 | return Response({ |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 201 | 'flavors': reverse('flavor-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 202 | 'serviceattributes': reverse('serviceattribute-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 203 | 'controllerimageses': reverse('controllerimages-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 204 | 'images': reverse('image-list', request=request, format=format), |
| 205 | 'networkparameters': reverse('networkparameter-list', request=request, format=format), |
| 206 | 'sites': reverse('site-list', request=request, format=format), |
| 207 | 'sliceroles': reverse('slicerole-list', request=request, format=format), |
| 208 | 'tags': reverse('tag-list', request=request, format=format), |
| 209 | 'invoices': reverse('invoice-list', request=request, format=format), |
| 210 | 'sliceprivileges': reverse('sliceprivilege-list', request=request, format=format), |
| 211 | 'planetstackroles': reverse('planetstackrole-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 212 | 'controllerprivileges': reverse('controllerprivilege-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 213 | 'networkslivers': reverse('networksliver-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 214 | 'projects': reverse('project-list', request=request, format=format), |
| 215 | 'slices': reverse('slice-list', request=request, format=format), |
| 216 | 'networks': reverse('network-list', request=request, format=format), |
| 217 | 'services': reverse('service-list', request=request, format=format), |
| 218 | 'serviceclasses': reverse('serviceclass-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 219 | 'controllernetworkses': reverse('controllernetworks-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 220 | 'charges': reverse('charge-list', request=request, format=format), |
| 221 | 'roles': reverse('role-list', request=request, format=format), |
| 222 | 'usableobjects': reverse('usableobject-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 223 | 'controllersitedeploymentses': reverse('controllersitedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 224 | 'siteroles': reverse('siterole-list', request=request, format=format), |
| 225 | 'slicecredentials': reverse('slicecredential-list', request=request, format=format), |
| 226 | 'slivers': reverse('sliver-list', request=request, format=format), |
| 227 | 'nodes': reverse('node-list', request=request, format=format), |
| 228 | 'dashboardviews': reverse('dashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 229 | 'imagedeploymentses': reverse('imagedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 230 | 'reservedresources': reverse('reservedresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 231 | 'payments': reverse('payment-list', request=request, format=format), |
| 232 | 'networktemplates': reverse('networktemplate-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 233 | 'networkslices': reverse('networkslice-list', request=request, format=format), |
| 234 | 'userdashboardviews': reverse('userdashboardview-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 235 | 'controllers': reverse('controller-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 236 | 'planetstackprivileges': reverse('planetstackprivilege-list', request=request, format=format), |
| 237 | 'users': reverse('user-list', request=request, format=format), |
| 238 | 'deployments': reverse('deployment-list', request=request, format=format), |
| 239 | 'reservations': reverse('reservation-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 240 | 'siteprivileges': reverse('siteprivilege-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 241 | 'planetstacks': reverse('planetstack-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 242 | 'accounts': reverse('account-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 243 | 'controllerroles': reverse('controllerrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 244 | 'networkparametertypes': reverse('networkparametertype-list', request=request, format=format), |
| 245 | 'sitecredentials': reverse('sitecredential-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 246 | 'deploymentprivileges': reverse('deploymentprivilege-list', request=request, format=format), |
| 247 | 'controlleruserses': reverse('controllerusers-list', request=request, format=format), |
| 248 | 'deploymentroles': reverse('deploymentrole-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 249 | 'usercredentials': reverse('usercredential-list', request=request, format=format), |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 250 | 'sitedeploymentses': reverse('sitedeployments-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 251 | 'slicetags': reverse('slicetag-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 252 | 'controllerdashboards': reverse('controllerdashboard-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 253 | 'routers': reverse('router-list', request=request, format=format), |
| 254 | 'serviceresources': reverse('serviceresource-list', request=request, format=format), |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 255 | 'controllersliceses': reverse('controllerslices-list', request=request, format=format), |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 256 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 257 | }) |
| 258 | |
| 259 | # Based on serializers.py |
| 260 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 261 | class XOSModelSerializer(serializers.ModelSerializer): |
| 262 | def save_object(self, obj, **kwargs): |
| 263 | |
| 264 | """ rest_framework can't deal with ManyToMany relations that have a |
| 265 | through table. In plstackapi, most of the through tables we have |
| 266 | use defaults or blank fields, so there's no reason why we shouldn't |
| 267 | be able to save these objects. |
| 268 | |
| 269 | So, let's strip out these m2m relations, and deal with them ourself. |
| 270 | """ |
| 271 | obj._complex_m2m_data={};
|
| 272 | if getattr(obj, '_m2m_data', None):
|
| 273 | for relatedObject in obj._meta.get_all_related_many_to_many_objects():
|
| 274 | if (relatedObject.field.rel.through._meta.auto_created):
|
| 275 | # These are non-trough ManyToMany relations and
|
| 276 | # can be updated just fine
|
| 277 | continue
|
| 278 | fieldName = relatedObject.get_accessor_name()
|
| 279 | if fieldName in obj._m2m_data.keys():
|
| 280 | obj._complex_m2m_data[fieldName] = (relatedObject, obj._m2m_data[fieldName])
|
| 281 | del obj._m2m_data[fieldName]
|
| 282 |
|
| 283 | serializers.ModelSerializer.save_object(self, obj, **kwargs); |
| 284 | |
| 285 | for (accessor, stuff) in obj._complex_m2m_data.items(): |
| 286 | (relatedObject, data) = stuff |
| 287 | through = relatedObject.field.rel.through |
| 288 | local_fieldName = relatedObject.field.m2m_reverse_field_name() |
| 289 | remote_fieldName = relatedObject.field.m2m_field_name() |
| 290 | |
| 291 | # get the current set of existing relations |
| 292 | existing = through.objects.filter(**{local_fieldName: obj}); |
| 293 | |
| 294 | data_ids = [item.id for item in data] |
| 295 | existing_ids = [getattr(item,remote_fieldName).id for item in existing] |
| 296 | |
| 297 | #print "data_ids", data_ids |
| 298 | #print "existing_ids", existing_ids |
| 299 | |
| 300 | # remove relations that are in 'existing' but not in 'data' |
| 301 | for item in list(existing): |
| 302 | if (getattr(item,remote_fieldName).id not in data_ids): |
| 303 | print "delete", getattr(item,remote_fieldName) |
| 304 | item.delete() #(purge=True) |
| 305 | |
| 306 | # add relations that are in 'data' but not in 'existing' |
| 307 | for item in data: |
| 308 | if (item.id not in existing_ids): |
| 309 | #print "add", item |
| 310 | newModel = through(**{local_fieldName: obj, remote_fieldName: item}) |
| 311 | newModel.save() |
| 312 | |
| 313 | |
| 314 | |
| 315 | class FlavorSerializer(serializers.HyperlinkedModelSerializer): |
| 316 | id = serializers.Field() |
| 317 | |
| 318 | |
| 319 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 320 | |
| 321 | |
| 322 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 323 | validators = serializers.SerializerMethodField("getValidators") |
| 324 | def getHumanReadableName(self, obj):
|
| 325 | return str(obj) |
| 326 | def getValidators(self, obj): |
| 327 | try: |
| 328 | return obj.getValidators() |
| 329 | except: |
| 330 | return None |
| 331 | class Meta: |
| 332 | model = Flavor |
| 333 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 334 | |
| 335 | class FlavorIdSerializer(XOSModelSerializer): |
| 336 | id = serializers.Field() |
| 337 | |
| 338 | |
| 339 | deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail') |
| 340 | |
| 341 | |
| 342 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 343 | validators = serializers.SerializerMethodField("getValidators") |
| 344 | def getHumanReadableName(self, obj):
|
| 345 | return str(obj)
|
| 346 | def getValidators(self, obj):
|
| 347 | try: |
| 348 | return obj.getValidators() |
| 349 | except: |
| 350 | return None
|
| 351 | class Meta:
|
| 352 | model = Flavor |
| 353 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 354 | |
| 355 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 356 | |
| 357 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 358 | class ServiceAttributeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 359 | id = serializers.Field() |
| 360 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 361 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 362 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 363 | def getHumanReadableName(self, obj):
|
| 364 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 365 | def getValidators(self, obj): |
| 366 | try: |
| 367 | return obj.getValidators() |
| 368 | except: |
| 369 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 370 | class Meta: |
| 371 | model = ServiceAttribute |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 372 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 373 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 374 | class ServiceAttributeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 375 | id = serializers.Field() |
| 376 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 377 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 378 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 379 | def getHumanReadableName(self, obj):
|
| 380 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 381 | def getValidators(self, obj):
|
| 382 | try: |
| 383 | return obj.getValidators() |
| 384 | except: |
| 385 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 386 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 387 | model = ServiceAttribute |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 388 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','value','service',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 389 | |
| 390 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 391 | |
| 392 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 393 | class ControllerImagesSerializer(serializers.HyperlinkedModelSerializer): |
| 394 | id = serializers.Field() |
| 395 | |
| 396 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 397 | validators = serializers.SerializerMethodField("getValidators") |
| 398 | def getHumanReadableName(self, obj):
|
| 399 | return str(obj) |
| 400 | def getValidators(self, obj): |
| 401 | try: |
| 402 | return obj.getValidators() |
| 403 | except: |
| 404 | return None |
| 405 | class Meta: |
| 406 | model = ControllerImages |
| 407 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 408 | |
| 409 | class ControllerImagesIdSerializer(XOSModelSerializer): |
| 410 | id = serializers.Field() |
| 411 | |
| 412 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 413 | validators = serializers.SerializerMethodField("getValidators") |
| 414 | def getHumanReadableName(self, obj):
|
| 415 | return str(obj)
|
| 416 | def getValidators(self, obj):
|
| 417 | try: |
| 418 | return obj.getValidators() |
| 419 | except: |
| 420 | return None
|
| 421 | class Meta:
|
| 422 | model = ControllerImages |
| 423 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 428 | class ImageSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 429 | id = serializers.Field() |
| 430 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 431 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 432 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 433 | def getHumanReadableName(self, obj):
|
| 434 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 435 | def getValidators(self, obj): |
| 436 | try: |
| 437 | return obj.getValidators() |
| 438 | except: |
| 439 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 440 | class Meta: |
| 441 | model = Image |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 442 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 443 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 444 | class ImageIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 445 | id = serializers.Field() |
| 446 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 447 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 448 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 449 | def getHumanReadableName(self, obj):
|
| 450 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 451 | def getValidators(self, obj):
|
| 452 | try: |
| 453 | return obj.getValidators() |
| 454 | except: |
| 455 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 456 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 457 | model = Image |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 458 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 459 | |
| 460 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 461 | |
| 462 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 463 | class NetworkParameterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 464 | id = serializers.Field() |
| 465 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 466 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 467 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 468 | def getHumanReadableName(self, obj):
|
| 469 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 470 | def getValidators(self, obj): |
| 471 | try: |
| 472 | return obj.getValidators() |
| 473 | except: |
| 474 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 475 | class Meta: |
| 476 | model = NetworkParameter |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 477 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 478 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 479 | class NetworkParameterIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 480 | id = serializers.Field() |
| 481 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 482 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 483 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 484 | def getHumanReadableName(self, obj):
|
| 485 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 486 | def getValidators(self, obj):
|
| 487 | try: |
| 488 | return obj.getValidators() |
| 489 | except: |
| 490 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 491 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 492 | model = NetworkParameter |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 493 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 494 | |
| 495 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 496 | |
| 497 | |
| 498 | class SiteSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 499 | id = serializers.Field() |
| 500 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 501 | |
| 502 | deployments = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='deployment-detail') |
| 503 | |
| 504 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 505 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 506 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 507 | def getHumanReadableName(self, obj):
|
| 508 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 509 | def getValidators(self, obj): |
| 510 | try: |
| 511 | return obj.getValidators() |
| 512 | except: |
| 513 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 514 | class Meta: |
| 515 | model = Site |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 516 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 517 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 518 | class SiteIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 519 | id = serializers.Field() |
| 520 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 521 | |
| 522 | deployments = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='deployment-detail') |
| 523 | |
| 524 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 525 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 526 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 527 | def getHumanReadableName(self, obj):
|
| 528 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 529 | def getValidators(self, obj):
|
| 530 | try: |
| 531 | return obj.getValidators() |
| 532 | except: |
| 533 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 534 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 535 | model = Site |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 536 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 537 | |
| 538 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 539 | |
| 540 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 541 | class SliceRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 542 | id = serializers.Field() |
| 543 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 544 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 545 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 546 | def getHumanReadableName(self, obj):
|
| 547 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 548 | def getValidators(self, obj): |
| 549 | try: |
| 550 | return obj.getValidators() |
| 551 | except: |
| 552 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 553 | class Meta: |
| 554 | model = SliceRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 555 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 556 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 557 | class SliceRoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 558 | id = serializers.Field() |
| 559 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 560 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 561 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 562 | def getHumanReadableName(self, obj):
|
| 563 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 564 | def getValidators(self, obj):
|
| 565 | try: |
| 566 | return obj.getValidators() |
| 567 | except: |
| 568 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 569 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 570 | model = SliceRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 571 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 572 | |
| 573 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 574 | |
| 575 | |
| 576 | class TagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 577 | id = serializers.Field() |
| 578 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 579 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 580 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 581 | def getHumanReadableName(self, obj):
|
| 582 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 583 | def getValidators(self, obj): |
| 584 | try: |
| 585 | return obj.getValidators() |
| 586 | except: |
| 587 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 588 | class Meta: |
| 589 | model = Tag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 590 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 591 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 592 | class TagIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 593 | id = serializers.Field() |
| 594 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 595 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 596 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 597 | def getHumanReadableName(self, obj):
|
| 598 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 599 | def getValidators(self, obj):
|
| 600 | try: |
| 601 | return obj.getValidators() |
| 602 | except: |
| 603 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 604 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 605 | model = Tag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 606 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 607 | |
| 608 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 609 | |
| 610 | |
| 611 | class InvoiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 612 | id = serializers.Field() |
| 613 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 614 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 615 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 616 | def getHumanReadableName(self, obj):
|
| 617 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 618 | def getValidators(self, obj): |
| 619 | try: |
| 620 | return obj.getValidators() |
| 621 | except: |
| 622 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 623 | class Meta: |
| 624 | model = Invoice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 625 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 626 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 627 | class InvoiceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 628 | id = serializers.Field() |
| 629 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 630 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 631 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 632 | def getHumanReadableName(self, obj):
|
| 633 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 634 | def getValidators(self, obj):
|
| 635 | try: |
| 636 | return obj.getValidators() |
| 637 | except: |
| 638 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 639 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 640 | model = Invoice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 641 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','date','account',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 642 | |
| 643 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 644 | |
| 645 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 646 | class SlicePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 647 | id = serializers.Field() |
| 648 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 649 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 650 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 651 | def getHumanReadableName(self, obj):
|
| 652 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 653 | def getValidators(self, obj): |
| 654 | try: |
| 655 | return obj.getValidators() |
| 656 | except: |
| 657 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 658 | class Meta: |
| 659 | model = SlicePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 660 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 661 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 662 | class SlicePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 663 | id = serializers.Field() |
| 664 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 665 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 666 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 667 | def getHumanReadableName(self, obj):
|
| 668 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 669 | def getValidators(self, obj):
|
| 670 | try: |
| 671 | return obj.getValidators() |
| 672 | except: |
| 673 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 674 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 675 | model = SlicePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 676 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 677 | |
| 678 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 679 | |
| 680 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 681 | class PlanetStackRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 682 | id = serializers.Field() |
| 683 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 684 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 685 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 686 | def getHumanReadableName(self, obj):
|
| 687 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 688 | def getValidators(self, obj): |
| 689 | try: |
| 690 | return obj.getValidators() |
| 691 | except: |
| 692 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 693 | class Meta: |
| 694 | model = PlanetStackRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 695 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 696 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 697 | class PlanetStackRoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 698 | id = serializers.Field() |
| 699 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 700 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 701 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 702 | def getHumanReadableName(self, obj):
|
| 703 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 704 | def getValidators(self, obj):
|
| 705 | try: |
| 706 | return obj.getValidators() |
| 707 | except: |
| 708 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 709 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 710 | model = PlanetStackRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 711 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 712 | |
| 713 | |
| 714 | |
| 715 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 716 | class ControllerPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 717 | id = serializers.Field() |
| 718 | |
| 719 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 720 | validators = serializers.SerializerMethodField("getValidators") |
| 721 | def getHumanReadableName(self, obj):
|
| 722 | return str(obj) |
| 723 | def getValidators(self, obj): |
| 724 | try: |
| 725 | return obj.getValidators() |
| 726 | except: |
| 727 | return None |
| 728 | class Meta: |
| 729 | model = ControllerPrivilege |
| 730 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 731 | |
| 732 | class ControllerPrivilegeIdSerializer(XOSModelSerializer): |
| 733 | id = serializers.Field() |
| 734 | |
| 735 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 736 | validators = serializers.SerializerMethodField("getValidators") |
| 737 | def getHumanReadableName(self, obj):
|
| 738 | return str(obj)
|
| 739 | def getValidators(self, obj):
|
| 740 | try: |
| 741 | return obj.getValidators() |
| 742 | except: |
| 743 | return None
|
| 744 | class Meta:
|
| 745 | model = ControllerPrivilege |
| 746 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 747 | |
| 748 | |
| 749 | |
| 750 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 751 | class NetworkSliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 752 | id = serializers.Field() |
| 753 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 754 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 755 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 756 | def getHumanReadableName(self, obj):
|
| 757 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 758 | def getValidators(self, obj): |
| 759 | try: |
| 760 | return obj.getValidators() |
| 761 | except: |
| 762 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 763 | class Meta: |
| 764 | model = NetworkSliver |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 765 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 766 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 767 | class NetworkSliverIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 768 | id = serializers.Field() |
| 769 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 770 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 771 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 772 | def getHumanReadableName(self, obj):
|
| 773 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 774 | def getValidators(self, obj):
|
| 775 | try: |
| 776 | return obj.getValidators() |
| 777 | except: |
| 778 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 779 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 780 | model = NetworkSliver |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 781 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 782 | |
| 783 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 784 | |
| 785 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 786 | class ProjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 787 | id = serializers.Field() |
| 788 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 789 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 790 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 791 | def getHumanReadableName(self, obj):
|
| 792 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 793 | def getValidators(self, obj): |
| 794 | try: |
| 795 | return obj.getValidators() |
| 796 | except: |
| 797 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 798 | class Meta: |
| 799 | model = Project |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 800 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 801 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 802 | class ProjectIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 803 | id = serializers.Field() |
| 804 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 805 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 806 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 807 | def getHumanReadableName(self, obj):
|
| 808 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 809 | def getValidators(self, obj):
|
| 810 | try: |
| 811 | return obj.getValidators() |
| 812 | except: |
| 813 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 814 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 815 | model = Project |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 816 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 817 | |
| 818 | |
| 819 | |
| 820 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 821 | class SliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 822 | id = serializers.Field() |
| 823 | |
| 824 | |
| 825 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 826 | |
| 827 | |
| 828 | |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 829 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 830 | |
| 831 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 832 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 833 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 834 | def getHumanReadableName(self, obj):
|
| 835 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 836 | def getValidators(self, obj): |
| 837 | try: |
| 838 | return obj.getValidators() |
| 839 | except: |
| 840 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 841 | class Meta: |
| 842 | model = Slice |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 843 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 844 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 845 | class SliceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 846 | id = serializers.Field() |
| 847 | |
| 848 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 849 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 850 | |
| 851 | |
| 852 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 853 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 854 | |
| 855 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 856 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 857 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 858 | def getHumanReadableName(self, obj):
|
| 859 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 860 | def getValidators(self, obj):
|
| 861 | try: |
| 862 | return obj.getValidators() |
| 863 | except: |
| 864 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 865 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 866 | model = Slice |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 867 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','enabled','omf_friendly','description','slice_url','site','max_slivers','imagePreference','service','network','mountDataSets','serviceClass','creator','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 868 | |
| 869 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 870 | |
| 871 | |
| 872 | class NetworkSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 873 | id = serializers.Field() |
| 874 | |
| 875 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 876 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 877 | |
| 878 | |
| 879 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 880 | slices = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='slice-detail') |
| 881 | |
| 882 | |
| 883 | |
| 884 | slivers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='sliver-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 885 | |
| 886 | |
| 887 | |
| 888 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 889 | |
| 890 | |
| 891 | |
| 892 | routers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='router-detail') |
| 893 | |
| 894 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 895 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 896 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 897 | def getHumanReadableName(self, obj):
|
| 898 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 899 | def getValidators(self, obj): |
| 900 | try: |
| 901 | return obj.getValidators() |
| 902 | except: |
| 903 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 904 | class Meta: |
| 905 | model = Network |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 906 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 907 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 908 | class NetworkIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 909 | id = serializers.Field() |
| 910 | |
| 911 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 912 | slices = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 913 | |
| 914 | |
| 915 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 916 | slices = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='slice-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 917 | |
| 918 | |
| 919 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 920 | slivers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='sliver-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 921 | |
| 922 | |
| 923 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 924 | routers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='router-detail') |
| 925 | |
| 926 | |
| 927 | |
| 928 | routers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='router-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 929 | |
| 930 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 931 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 932 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 933 | def getHumanReadableName(self, obj):
|
| 934 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 935 | def getValidators(self, obj):
|
| 936 | try: |
| 937 | return obj.getValidators() |
| 938 | except: |
| 939 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 940 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 941 | model = Network |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 942 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','template','subnet','ports','labels','owner','guaranteedBandwidth','permitAllSlices','topologyParameters','controllerUrl','controllerParameters','network_id','router_id','subnet_id','slices','slices','slivers','routers','routers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 943 | |
| 944 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 945 | |
| 946 | |
| 947 | class ServiceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 948 | id = serializers.Field() |
| 949 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 950 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 951 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 952 | def getHumanReadableName(self, obj):
|
| 953 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 954 | def getValidators(self, obj): |
| 955 | try: |
| 956 | return obj.getValidators() |
| 957 | except: |
| 958 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 959 | class Meta: |
| 960 | model = Service |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 961 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 962 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 963 | class ServiceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 964 | id = serializers.Field() |
| 965 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 966 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 967 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 968 | def getHumanReadableName(self, obj):
|
| 969 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 970 | def getValidators(self, obj):
|
| 971 | try: |
| 972 | return obj.getValidators() |
| 973 | except: |
| 974 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 975 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 976 | model = Service |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 977 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 978 | |
| 979 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 980 | |
| 981 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 982 | class ServiceClassSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 983 | id = serializers.Field() |
| 984 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 985 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 986 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 987 | def getHumanReadableName(self, obj):
|
| 988 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 989 | def getValidators(self, obj): |
| 990 | try: |
| 991 | return obj.getValidators() |
| 992 | except: |
| 993 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 994 | class Meta: |
| 995 | model = ServiceClass |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 996 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 997 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 998 | class ServiceClassIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 999 | id = serializers.Field() |
| 1000 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1001 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1002 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1003 | def getHumanReadableName(self, obj):
|
| 1004 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1005 | def getValidators(self, obj):
|
| 1006 | try: |
| 1007 | return obj.getValidators() |
| 1008 | except: |
| 1009 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1010 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1011 | model = ServiceClass |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1012 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1013 | |
| 1014 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1015 | |
| 1016 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1017 | class ControllerNetworksSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1018 | id = serializers.Field() |
| 1019 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1020 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1021 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1022 | def getHumanReadableName(self, obj):
|
| 1023 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1024 | def getValidators(self, obj): |
| 1025 | try: |
| 1026 | return obj.getValidators() |
| 1027 | except: |
| 1028 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1029 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1030 | model = ControllerNetworks |
| 1031 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1032 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1033 | class ControllerNetworksIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1034 | id = serializers.Field() |
| 1035 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1036 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1037 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1038 | def getHumanReadableName(self, obj):
|
| 1039 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1040 | def getValidators(self, obj):
|
| 1041 | try: |
| 1042 | return obj.getValidators() |
| 1043 | except: |
| 1044 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1045 | class Meta:
|
| 1046 | model = ControllerNetworks |
| 1047 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1048 | |
| 1049 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1050 | |
| 1051 | |
| 1052 | class ChargeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1053 | id = serializers.Field() |
| 1054 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1055 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1056 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1057 | def getHumanReadableName(self, obj):
|
| 1058 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1059 | def getValidators(self, obj): |
| 1060 | try: |
| 1061 | return obj.getValidators() |
| 1062 | except: |
| 1063 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1064 | class Meta: |
| 1065 | model = Charge |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1066 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1067 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1068 | class ChargeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1069 | id = serializers.Field() |
| 1070 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1071 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1072 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1073 | def getHumanReadableName(self, obj):
|
| 1074 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1075 | def getValidators(self, obj):
|
| 1076 | try: |
| 1077 | return obj.getValidators() |
| 1078 | except: |
| 1079 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1080 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1081 | model = Charge |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1082 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1083 | |
| 1084 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1085 | |
| 1086 | |
| 1087 | class RoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1088 | id = serializers.Field() |
| 1089 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1090 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1091 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1092 | def getHumanReadableName(self, obj):
|
| 1093 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1094 | def getValidators(self, obj): |
| 1095 | try: |
| 1096 | return obj.getValidators() |
| 1097 | except: |
| 1098 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1099 | class Meta: |
| 1100 | model = Role |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1101 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1102 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1103 | class RoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1104 | id = serializers.Field() |
| 1105 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1106 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1107 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1108 | def getHumanReadableName(self, obj):
|
| 1109 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1110 | def getValidators(self, obj):
|
| 1111 | try: |
| 1112 | return obj.getValidators() |
| 1113 | except: |
| 1114 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1115 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1116 | model = Role |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1117 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1118 | |
| 1119 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1120 | |
| 1121 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1122 | class UsableObjectSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1123 | id = serializers.Field() |
| 1124 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1125 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1126 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1127 | def getHumanReadableName(self, obj):
|
| 1128 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1129 | def getValidators(self, obj): |
| 1130 | try: |
| 1131 | return obj.getValidators() |
| 1132 | except: |
| 1133 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1134 | class Meta: |
| 1135 | model = UsableObject |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1136 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1137 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1138 | class UsableObjectIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1139 | id = serializers.Field() |
| 1140 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1141 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1142 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1143 | def getHumanReadableName(self, obj):
|
| 1144 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1145 | def getValidators(self, obj):
|
| 1146 | try: |
| 1147 | return obj.getValidators() |
| 1148 | except: |
| 1149 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1150 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1151 | model = UsableObject |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1152 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1153 | |
| 1154 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1155 | |
| 1156 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1157 | class ControllerSiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 1158 | id = serializers.Field() |
| 1159 | |
| 1160 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1161 | validators = serializers.SerializerMethodField("getValidators") |
| 1162 | def getHumanReadableName(self, obj):
|
| 1163 | return str(obj) |
| 1164 | def getValidators(self, obj): |
| 1165 | try: |
| 1166 | return obj.getValidators() |
| 1167 | except: |
| 1168 | return None |
| 1169 | class Meta: |
| 1170 | model = ControllerSiteDeployments |
| 1171 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 1172 | |
| 1173 | class ControllerSiteDeploymentsIdSerializer(XOSModelSerializer): |
| 1174 | id = serializers.Field() |
| 1175 | |
| 1176 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1177 | validators = serializers.SerializerMethodField("getValidators") |
| 1178 | def getHumanReadableName(self, obj):
|
| 1179 | return str(obj)
|
| 1180 | def getValidators(self, obj):
|
| 1181 | try: |
| 1182 | return obj.getValidators() |
| 1183 | except: |
| 1184 | return None
|
| 1185 | class Meta:
|
| 1186 | model = ControllerSiteDeployments |
| 1187 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 1188 | |
| 1189 | |
| 1190 | |
| 1191 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1192 | class SiteRoleSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1193 | id = serializers.Field() |
| 1194 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1195 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1196 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1197 | def getHumanReadableName(self, obj):
|
| 1198 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1199 | def getValidators(self, obj): |
| 1200 | try: |
| 1201 | return obj.getValidators() |
| 1202 | except: |
| 1203 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1204 | class Meta: |
| 1205 | model = SiteRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1206 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1207 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1208 | class SiteRoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1209 | id = serializers.Field() |
| 1210 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1211 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1212 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1213 | def getHumanReadableName(self, obj):
|
| 1214 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1215 | def getValidators(self, obj):
|
| 1216 | try: |
| 1217 | return obj.getValidators() |
| 1218 | except: |
| 1219 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1220 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1221 | model = SiteRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1222 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1223 | |
| 1224 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1225 | |
| 1226 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1227 | class SliceCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1228 | id = serializers.Field() |
| 1229 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1230 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1231 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1232 | def getHumanReadableName(self, obj):
|
| 1233 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1234 | def getValidators(self, obj): |
| 1235 | try: |
| 1236 | return obj.getValidators() |
| 1237 | except: |
| 1238 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1239 | class Meta: |
| 1240 | model = SliceCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1241 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1242 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1243 | class SliceCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1244 | id = serializers.Field() |
| 1245 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1246 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1247 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1248 | def getHumanReadableName(self, obj):
|
| 1249 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1250 | def getValidators(self, obj):
|
| 1251 | try: |
| 1252 | return obj.getValidators() |
| 1253 | except: |
| 1254 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1255 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1256 | model = SliceCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1257 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1258 | |
| 1259 | |
| 1260 | |
| 1261 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1262 | class SliverSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1263 | id = serializers.Field() |
| 1264 | |
| 1265 | |
| 1266 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 1267 | |
| 1268 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1269 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1270 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1271 | def getHumanReadableName(self, obj):
|
| 1272 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1273 | def getValidators(self, obj): |
| 1274 | try: |
| 1275 | return obj.getValidators() |
| 1276 | except: |
| 1277 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1278 | class Meta: |
| 1279 | model = Sliver |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1280 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1281 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1282 | class SliverIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1283 | id = serializers.Field() |
| 1284 | |
| 1285 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1286 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1287 | |
| 1288 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1289 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1290 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1291 | def getHumanReadableName(self, obj):
|
| 1292 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1293 | def getValidators(self, obj):
|
| 1294 | try: |
| 1295 | return obj.getValidators() |
| 1296 | except: |
| 1297 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1298 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1299 | model = Sliver |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1300 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1301 | |
| 1302 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1303 | |
| 1304 | |
| 1305 | class NodeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1306 | id = serializers.Field() |
| 1307 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1308 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1309 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1310 | def getHumanReadableName(self, obj):
|
| 1311 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1312 | def getValidators(self, obj): |
| 1313 | try: |
| 1314 | return obj.getValidators() |
| 1315 | except: |
| 1316 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1317 | class Meta: |
| 1318 | model = Node |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1319 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1320 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1321 | class NodeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1322 | id = serializers.Field() |
| 1323 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1324 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1325 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1326 | def getHumanReadableName(self, obj):
|
| 1327 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1328 | def getValidators(self, obj):
|
| 1329 | try: |
| 1330 | return obj.getValidators() |
| 1331 | except: |
| 1332 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1333 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1334 | model = Node |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1335 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1336 | |
| 1337 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1338 | |
| 1339 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1340 | class DashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1341 | id = serializers.Field() |
| 1342 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1343 | |
| 1344 | controllers = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='controller-detail') |
| 1345 | |
| 1346 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1347 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1348 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1349 | def getHumanReadableName(self, obj):
|
| 1350 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1351 | def getValidators(self, obj): |
| 1352 | try: |
| 1353 | return obj.getValidators() |
| 1354 | except: |
| 1355 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1356 | class Meta: |
| 1357 | model = DashboardView |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1358 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1359 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1360 | class DashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1361 | id = serializers.Field() |
| 1362 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1363 | |
| 1364 | controllers = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='controller-detail') |
| 1365 | |
| 1366 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1367 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1368 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1369 | def getHumanReadableName(self, obj):
|
| 1370 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1371 | def getValidators(self, obj):
|
| 1372 | try: |
| 1373 | return obj.getValidators() |
| 1374 | except: |
| 1375 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1376 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1377 | model = DashboardView |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1378 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1379 | |
| 1380 | |
| 1381 | |
| 1382 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1383 | class ImageDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1384 | id = serializers.Field() |
| 1385 | |
| 1386 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1387 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1388 | def getHumanReadableName(self, obj):
|
| 1389 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1390 | def getValidators(self, obj): |
| 1391 | try: |
| 1392 | return obj.getValidators() |
| 1393 | except: |
| 1394 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1395 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1396 | model = ImageDeployments |
| 1397 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1398 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1399 | class ImageDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1400 | id = serializers.Field() |
| 1401 | |
| 1402 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1403 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1404 | def getHumanReadableName(self, obj):
|
| 1405 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1406 | def getValidators(self, obj):
|
| 1407 | try: |
| 1408 | return obj.getValidators() |
| 1409 | except: |
| 1410 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1411 | class Meta:
|
| 1412 | model = ImageDeployments |
| 1413 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1414 | |
| 1415 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1416 | |
| 1417 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1418 | class ReservedResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1419 | id = serializers.Field() |
| 1420 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1421 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1422 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1423 | def getHumanReadableName(self, obj):
|
| 1424 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1425 | def getValidators(self, obj): |
| 1426 | try: |
| 1427 | return obj.getValidators() |
| 1428 | except: |
| 1429 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1430 | class Meta: |
| 1431 | model = ReservedResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1432 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1433 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1434 | class ReservedResourceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1435 | id = serializers.Field() |
| 1436 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1437 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1438 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1439 | def getHumanReadableName(self, obj):
|
| 1440 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1441 | def getValidators(self, obj):
|
| 1442 | try: |
| 1443 | return obj.getValidators() |
| 1444 | except: |
| 1445 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1446 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1447 | model = ReservedResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1448 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1449 | |
| 1450 | |
| 1451 | |
| 1452 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1453 | class PaymentSerializer(serializers.HyperlinkedModelSerializer): |
| 1454 | id = serializers.Field() |
| 1455 | |
| 1456 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1457 | validators = serializers.SerializerMethodField("getValidators") |
| 1458 | def getHumanReadableName(self, obj):
|
| 1459 | return str(obj) |
| 1460 | def getValidators(self, obj): |
| 1461 | try: |
| 1462 | return obj.getValidators() |
| 1463 | except: |
| 1464 | return None |
| 1465 | class Meta: |
| 1466 | model = Payment |
| 1467 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1468 | |
| 1469 | class PaymentIdSerializer(XOSModelSerializer): |
| 1470 | id = serializers.Field() |
| 1471 | |
| 1472 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1473 | validators = serializers.SerializerMethodField("getValidators") |
| 1474 | def getHumanReadableName(self, obj):
|
| 1475 | return str(obj)
|
| 1476 | def getValidators(self, obj):
|
| 1477 | try: |
| 1478 | return obj.getValidators() |
| 1479 | except: |
| 1480 | return None
|
| 1481 | class Meta:
|
| 1482 | model = Payment |
| 1483 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 1484 | |
| 1485 | |
| 1486 | |
| 1487 | |
| 1488 | class NetworkTemplateSerializer(serializers.HyperlinkedModelSerializer): |
| 1489 | id = serializers.Field() |
| 1490 | |
| 1491 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1492 | validators = serializers.SerializerMethodField("getValidators") |
| 1493 | def getHumanReadableName(self, obj):
|
| 1494 | return str(obj) |
| 1495 | def getValidators(self, obj): |
| 1496 | try: |
| 1497 | return obj.getValidators() |
| 1498 | except: |
| 1499 | return None |
| 1500 | class Meta: |
| 1501 | model = NetworkTemplate |
| 1502 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
| 1503 | |
| 1504 | class NetworkTemplateIdSerializer(XOSModelSerializer): |
| 1505 | id = serializers.Field() |
| 1506 | |
| 1507 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1508 | validators = serializers.SerializerMethodField("getValidators") |
| 1509 | def getHumanReadableName(self, obj):
|
| 1510 | return str(obj)
|
| 1511 | def getValidators(self, obj):
|
| 1512 | try: |
| 1513 | return obj.getValidators() |
| 1514 | except: |
| 1515 | return None
|
| 1516 | class Meta:
|
| 1517 | model = NetworkTemplate |
| 1518 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
| 1519 | |
| 1520 | |
| 1521 | |
| 1522 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1523 | class NetworkSliceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1524 | id = serializers.Field() |
| 1525 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1526 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1527 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1528 | def getHumanReadableName(self, obj):
|
| 1529 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1530 | def getValidators(self, obj): |
| 1531 | try: |
| 1532 | return obj.getValidators() |
| 1533 | except: |
| 1534 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1535 | class Meta: |
| 1536 | model = NetworkSlice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1537 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1538 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1539 | class NetworkSliceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1540 | id = serializers.Field() |
| 1541 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1542 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1543 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1544 | def getHumanReadableName(self, obj):
|
| 1545 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1546 | def getValidators(self, obj):
|
| 1547 | try: |
| 1548 | return obj.getValidators() |
| 1549 | except: |
| 1550 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1551 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1552 | model = NetworkSlice |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1553 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','network','slice',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1554 | |
| 1555 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1556 | |
| 1557 | |
| 1558 | class UserDashboardViewSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1559 | id = serializers.Field() |
| 1560 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1561 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1562 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1563 | def getHumanReadableName(self, obj):
|
| 1564 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1565 | def getValidators(self, obj): |
| 1566 | try: |
| 1567 | return obj.getValidators() |
| 1568 | except: |
| 1569 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1570 | class Meta: |
| 1571 | model = UserDashboardView |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1572 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1573 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1574 | class UserDashboardViewIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1575 | id = serializers.Field() |
| 1576 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1577 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1578 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1579 | def getHumanReadableName(self, obj):
|
| 1580 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1581 | def getValidators(self, obj):
|
| 1582 | try: |
| 1583 | return obj.getValidators() |
| 1584 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1585 | return None
|
| 1586 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1587 | model = UserDashboardView |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1588 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 1589 | |
| 1590 | |
| 1591 | |
| 1592 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1593 | class ControllerSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1594 | id = serializers.Field() |
| 1595 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1596 | |
| 1597 | dashboardviews = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dashboardview-detail') |
| 1598 | |
| 1599 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1600 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1601 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1602 | def getHumanReadableName(self, obj):
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1603 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1604 | def getValidators(self, obj): |
| 1605 | try: |
| 1606 | return obj.getValidators() |
| 1607 | except: |
| 1608 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1609 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1610 | model = Controller |
| 1611 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1612 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1613 | class ControllerIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1614 | id = serializers.Field() |
| 1615 | |
| 1616 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1617 | dashboardviews = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='dashboardview-detail') |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1618 | |
| 1619 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1620 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1621 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1622 | def getHumanReadableName(self, obj):
|
| 1623 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1624 | def getValidators(self, obj):
|
| 1625 | try: |
| 1626 | return obj.getValidators() |
| 1627 | except: |
| 1628 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1629 | class Meta:
|
| 1630 | model = Controller |
| 1631 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 1632 | |
| 1633 | |
| 1634 | |
| 1635 | |
| 1636 | class PlanetStackPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 1637 | id = serializers.Field() |
| 1638 | |
| 1639 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1640 | validators = serializers.SerializerMethodField("getValidators") |
| 1641 | def getHumanReadableName(self, obj):
|
| 1642 | return str(obj) |
| 1643 | def getValidators(self, obj): |
| 1644 | try: |
| 1645 | return obj.getValidators() |
| 1646 | except: |
| 1647 | return None |
| 1648 | class Meta: |
| 1649 | model = PlanetStackPrivilege |
| 1650 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1651 | |
| 1652 | class PlanetStackPrivilegeIdSerializer(XOSModelSerializer): |
| 1653 | id = serializers.Field() |
| 1654 | |
| 1655 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1656 | validators = serializers.SerializerMethodField("getValidators") |
| 1657 | def getHumanReadableName(self, obj):
|
| 1658 | return str(obj)
|
| 1659 | def getValidators(self, obj):
|
| 1660 | try: |
| 1661 | return obj.getValidators() |
| 1662 | except: |
| 1663 | return None
|
| 1664 | class Meta:
|
| 1665 | model = PlanetStackPrivilege |
| 1666 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 1667 | |
| 1668 | |
| 1669 | |
| 1670 | |
| 1671 | class UserSerializer(serializers.HyperlinkedModelSerializer): |
| 1672 | id = serializers.Field() |
| 1673 | |
| 1674 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1675 | validators = serializers.SerializerMethodField("getValidators") |
| 1676 | def getHumanReadableName(self, obj):
|
| 1677 | return str(obj) |
| 1678 | def getValidators(self, obj): |
| 1679 | try: |
| 1680 | return obj.getValidators() |
| 1681 | except: |
| 1682 | return None |
| 1683 | class Meta: |
| 1684 | model = User |
| 1685 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',) |
| 1686 | |
| 1687 | class UserIdSerializer(XOSModelSerializer): |
| 1688 | id = serializers.Field() |
| 1689 | |
| 1690 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1691 | validators = serializers.SerializerMethodField("getValidators") |
| 1692 | def getHumanReadableName(self, obj):
|
| 1693 | return str(obj)
|
| 1694 | def getValidators(self, obj):
|
| 1695 | try: |
| 1696 | return obj.getValidators() |
| 1697 | except: |
| 1698 | return None
|
| 1699 | class Meta:
|
| 1700 | model = User |
| 1701 | fields = ('humanReadableName', 'validators', 'id','password','last_login','email','username','firstname','lastname','phone','user_url','site','public_key','is_active','is_admin','is_staff','is_readonly','created','updated','enacted','backend_status','deleted','timezone',) |
| 1702 | |
| 1703 | |
| 1704 | |
| 1705 | |
| 1706 | class DeploymentSerializer(serializers.HyperlinkedModelSerializer): |
| 1707 | id = serializers.Field() |
| 1708 | |
| 1709 | |
| 1710 | flavors = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='flavor-detail') |
| 1711 | |
| 1712 | |
| 1713 | |
| 1714 | sites = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='site-detail') |
| 1715 | |
| 1716 | |
| 1717 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1718 | validators = serializers.SerializerMethodField("getValidators") |
| 1719 | def getHumanReadableName(self, obj):
|
| 1720 | return str(obj) |
| 1721 | def getValidators(self, obj): |
| 1722 | try: |
| 1723 | return obj.getValidators() |
| 1724 | except: |
| 1725 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1726 | class Meta: |
| 1727 | model = Deployment |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1728 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','sites',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1729 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1730 | class DeploymentIdSerializer(XOSModelSerializer): |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1731 | id = serializers.Field() |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1732 | |
| 1733 | |
| 1734 | flavors = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='flavor-detail') |
| 1735 | |
| 1736 | |
| 1737 | |
| 1738 | sites = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='site-detail') |
| 1739 | |
| 1740 | |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1741 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1742 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1743 | def getHumanReadableName(self, obj):
|
| 1744 | return str(obj)
|
| 1745 | def getValidators(self, obj):
|
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1746 | try: |
| 1747 | return obj.getValidators() |
| 1748 | except: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1749 | return None
|
| 1750 | class Meta:
|
| 1751 | model = Deployment |
| 1752 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','sites',) |
Tony Mack | 06c8e47 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 1753 | |
| 1754 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1755 | |
| 1756 | |
| 1757 | class ReservationSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1758 | id = serializers.Field() |
| 1759 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1760 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1761 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1762 | def getHumanReadableName(self, obj):
|
| 1763 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1764 | def getValidators(self, obj): |
| 1765 | try: |
| 1766 | return obj.getValidators() |
| 1767 | except: |
| 1768 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1769 | class Meta: |
| 1770 | model = Reservation |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1771 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1772 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1773 | class ReservationIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1774 | id = serializers.Field() |
| 1775 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1776 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1777 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1778 | def getHumanReadableName(self, obj):
|
| 1779 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1780 | def getValidators(self, obj):
|
| 1781 | try: |
| 1782 | return obj.getValidators() |
| 1783 | except: |
| 1784 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1785 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1786 | model = Reservation |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1787 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1788 | |
| 1789 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1790 | |
| 1791 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1792 | class SitePrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
| 1793 | id = serializers.Field() |
| 1794 | |
| 1795 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1796 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1797 | def getHumanReadableName(self, obj):
|
| 1798 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1799 | def getValidators(self, obj): |
| 1800 | try: |
| 1801 | return obj.getValidators() |
| 1802 | except: |
| 1803 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1804 | class Meta: |
| 1805 | model = SitePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1806 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1807 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1808 | class SitePrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1809 | id = serializers.Field() |
| 1810 | |
| 1811 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1812 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1813 | def getHumanReadableName(self, obj):
|
| 1814 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1815 | def getValidators(self, obj):
|
| 1816 | try: |
| 1817 | return obj.getValidators() |
| 1818 | except: |
| 1819 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1820 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1821 | model = SitePrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1822 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','site','role',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1823 | |
| 1824 | |
| 1825 | |
| 1826 | |
| 1827 | class PlanetStackSerializer(serializers.HyperlinkedModelSerializer): |
| 1828 | id = serializers.Field() |
| 1829 | |
| 1830 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1831 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1832 | def getHumanReadableName(self, obj):
|
| 1833 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1834 | def getValidators(self, obj): |
| 1835 | try: |
| 1836 | return obj.getValidators() |
| 1837 | except: |
| 1838 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1839 | class Meta: |
| 1840 | model = PlanetStack |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1841 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1842 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1843 | class PlanetStackIdSerializer(XOSModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1844 | id = serializers.Field() |
| 1845 | |
| 1846 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1847 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1848 | def getHumanReadableName(self, obj):
|
| 1849 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1850 | def getValidators(self, obj):
|
| 1851 | try: |
| 1852 | return obj.getValidators() |
| 1853 | except: |
| 1854 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1855 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1856 | model = PlanetStack |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1857 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1858 | |
| 1859 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1860 | |
| 1861 | |
| 1862 | class AccountSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1863 | id = serializers.Field() |
| 1864 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1865 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1866 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1867 | def getHumanReadableName(self, obj):
|
| 1868 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1869 | def getValidators(self, obj): |
| 1870 | try: |
| 1871 | return obj.getValidators() |
| 1872 | except: |
| 1873 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1874 | class Meta: |
| 1875 | model = Account |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1876 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1877 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1878 | class AccountIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1879 | id = serializers.Field() |
| 1880 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1881 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1882 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1883 | def getHumanReadableName(self, obj):
|
| 1884 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1885 | def getValidators(self, obj):
|
| 1886 | try: |
| 1887 | return obj.getValidators() |
| 1888 | except: |
| 1889 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1890 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1891 | model = Account |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1892 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1893 | |
| 1894 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1895 | |
| 1896 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1897 | class ControllerRoleSerializer(serializers.HyperlinkedModelSerializer): |
| 1898 | id = serializers.Field() |
| 1899 | |
| 1900 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1901 | validators = serializers.SerializerMethodField("getValidators") |
| 1902 | def getHumanReadableName(self, obj):
|
| 1903 | return str(obj) |
| 1904 | def getValidators(self, obj): |
| 1905 | try: |
| 1906 | return obj.getValidators() |
| 1907 | except: |
| 1908 | return None |
| 1909 | class Meta: |
| 1910 | model = ControllerRole |
| 1911 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1912 | |
| 1913 | class ControllerRoleIdSerializer(XOSModelSerializer): |
| 1914 | id = serializers.Field() |
| 1915 | |
| 1916 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 1917 | validators = serializers.SerializerMethodField("getValidators") |
| 1918 | def getHumanReadableName(self, obj):
|
| 1919 | return str(obj)
|
| 1920 | def getValidators(self, obj):
|
| 1921 | try: |
| 1922 | return obj.getValidators() |
| 1923 | except: |
| 1924 | return None
|
| 1925 | class Meta:
|
| 1926 | model = ControllerRole |
| 1927 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
| 1928 | |
| 1929 | |
| 1930 | |
| 1931 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 1932 | class NetworkParameterTypeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1933 | id = serializers.Field() |
| 1934 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1935 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1936 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1937 | def getHumanReadableName(self, obj):
|
| 1938 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1939 | def getValidators(self, obj): |
| 1940 | try: |
| 1941 | return obj.getValidators() |
| 1942 | except: |
| 1943 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1944 | class Meta: |
| 1945 | model = NetworkParameterType |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1946 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1947 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1948 | class NetworkParameterTypeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1949 | id = serializers.Field() |
| 1950 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1951 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1952 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1953 | def getHumanReadableName(self, obj):
|
| 1954 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1955 | def getValidators(self, obj):
|
| 1956 | try: |
| 1957 | return obj.getValidators() |
| 1958 | except: |
| 1959 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1960 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1961 | model = NetworkParameterType |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1962 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','description',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1963 | |
| 1964 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 1965 | |
| 1966 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 1967 | class SiteCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1968 | id = serializers.Field() |
| 1969 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1970 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1971 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1972 | def getHumanReadableName(self, obj):
|
| 1973 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1974 | def getValidators(self, obj): |
| 1975 | try: |
| 1976 | return obj.getValidators() |
| 1977 | except: |
| 1978 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1979 | class Meta: |
| 1980 | model = SiteCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1981 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1982 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1983 | class SiteCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1984 | id = serializers.Field() |
| 1985 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1986 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1987 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 1988 | def getHumanReadableName(self, obj):
|
| 1989 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1990 | def getValidators(self, obj):
|
| 1991 | try: |
| 1992 | return obj.getValidators() |
| 1993 | except: |
| 1994 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 1995 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 1996 | model = SiteCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 1997 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 1998 | |
| 1999 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2000 | |
| 2001 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2002 | class DeploymentPrivilegeSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2003 | id = serializers.Field() |
| 2004 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2005 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2006 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2007 | def getHumanReadableName(self, obj):
|
| 2008 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2009 | def getValidators(self, obj): |
| 2010 | try: |
| 2011 | return obj.getValidators() |
| 2012 | except: |
| 2013 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2014 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2015 | model = DeploymentPrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2016 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2017 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2018 | class DeploymentPrivilegeIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2019 | id = serializers.Field() |
| 2020 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2021 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2022 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2023 | def getHumanReadableName(self, obj):
|
| 2024 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2025 | def getValidators(self, obj):
|
| 2026 | try: |
| 2027 | return obj.getValidators() |
| 2028 | except: |
| 2029 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2030 | class Meta:
|
| 2031 | model = DeploymentPrivilege |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2032 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2033 | |
| 2034 | |
| 2035 | |
| 2036 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2037 | class ControllerUsersSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2038 | id = serializers.Field() |
| 2039 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2040 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2041 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2042 | def getHumanReadableName(self, obj):
|
| 2043 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2044 | def getValidators(self, obj): |
| 2045 | try: |
| 2046 | return obj.getValidators() |
| 2047 | except: |
| 2048 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2049 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2050 | model = ControllerUsers |
| 2051 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2052 | |
| 2053 | class ControllerUsersIdSerializer(XOSModelSerializer): |
| 2054 | id = serializers.Field() |
| 2055 | |
| 2056 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2057 | validators = serializers.SerializerMethodField("getValidators") |
| 2058 | def getHumanReadableName(self, obj):
|
| 2059 | return str(obj)
|
| 2060 | def getValidators(self, obj):
|
| 2061 | try: |
| 2062 | return obj.getValidators() |
| 2063 | except: |
| 2064 | return None
|
| 2065 | class Meta:
|
| 2066 | model = ControllerUsers |
| 2067 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 2068 | |
| 2069 | |
| 2070 | |
| 2071 | |
| 2072 | class DeploymentRoleSerializer(serializers.HyperlinkedModelSerializer): |
| 2073 | id = serializers.Field() |
| 2074 | |
| 2075 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2076 | validators = serializers.SerializerMethodField("getValidators") |
| 2077 | def getHumanReadableName(self, obj):
|
| 2078 | return str(obj) |
| 2079 | def getValidators(self, obj): |
| 2080 | try: |
| 2081 | return obj.getValidators() |
| 2082 | except: |
| 2083 | return None |
| 2084 | class Meta: |
| 2085 | model = DeploymentRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2086 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2087 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2088 | class DeploymentRoleIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2089 | id = serializers.Field() |
| 2090 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2091 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2092 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2093 | def getHumanReadableName(self, obj):
|
| 2094 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2095 | def getValidators(self, obj):
|
| 2096 | try: |
| 2097 | return obj.getValidators() |
| 2098 | except: |
| 2099 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2100 | class Meta:
|
| 2101 | model = DeploymentRole |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2102 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','role',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2103 | |
| 2104 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2105 | |
| 2106 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2107 | class UserCredentialSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2108 | id = serializers.Field() |
| 2109 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2110 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2111 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2112 | def getHumanReadableName(self, obj):
|
| 2113 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2114 | def getValidators(self, obj): |
| 2115 | try: |
| 2116 | return obj.getValidators() |
| 2117 | except: |
| 2118 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2119 | class Meta: |
| 2120 | model = UserCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2121 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2122 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2123 | class UserCredentialIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2124 | id = serializers.Field() |
| 2125 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2126 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2127 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2128 | def getHumanReadableName(self, obj):
|
| 2129 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2130 | def getValidators(self, obj):
|
| 2131 | try: |
| 2132 | return obj.getValidators() |
| 2133 | except: |
| 2134 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2135 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2136 | model = UserCredential |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2137 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2138 | |
| 2139 | |
| 2140 | |
| 2141 | |
| 2142 | class SiteDeploymentsSerializer(serializers.HyperlinkedModelSerializer): |
| 2143 | id = serializers.Field() |
| 2144 | |
| 2145 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2146 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2147 | def getHumanReadableName(self, obj):
|
| 2148 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2149 | def getValidators(self, obj): |
| 2150 | try: |
| 2151 | return obj.getValidators() |
| 2152 | except: |
| 2153 | return None |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2154 | class Meta: |
| 2155 | model = SiteDeployments |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2156 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2157 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2158 | class SiteDeploymentsIdSerializer(XOSModelSerializer): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2159 | id = serializers.Field() |
| 2160 | |
| 2161 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2162 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2163 | def getHumanReadableName(self, obj):
|
| 2164 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2165 | def getValidators(self, obj):
|
| 2166 | try: |
| 2167 | return obj.getValidators() |
| 2168 | except: |
| 2169 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2170 | class Meta:
|
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2171 | model = SiteDeployments |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2172 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
| 2173 | |
| 2174 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2175 | |
| 2176 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2177 | class SliceTagSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2178 | id = serializers.Field() |
| 2179 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2180 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2181 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2182 | def getHumanReadableName(self, obj):
|
| 2183 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2184 | def getValidators(self, obj): |
| 2185 | try: |
| 2186 | return obj.getValidators() |
| 2187 | except: |
| 2188 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2189 | class Meta: |
| 2190 | model = SliceTag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2191 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2192 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2193 | class SliceTagIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2194 | id = serializers.Field() |
| 2195 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2196 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2197 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2198 | def getHumanReadableName(self, obj):
|
| 2199 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2200 | def getValidators(self, obj):
|
| 2201 | try: |
| 2202 | return obj.getValidators() |
| 2203 | except: |
| 2204 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2205 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2206 | model = SliceTag |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2207 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2208 | |
| 2209 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2210 | |
| 2211 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2212 | class ControllerDashboardSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2213 | id = serializers.Field() |
| 2214 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2215 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2216 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2217 | def getHumanReadableName(self, obj):
|
| 2218 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2219 | def getValidators(self, obj): |
| 2220 | try: |
| 2221 | return obj.getValidators() |
| 2222 | except: |
| 2223 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2224 | class Meta: |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2225 | model = ControllerDashboard |
| 2226 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2227 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2228 | class ControllerDashboardIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2229 | id = serializers.Field() |
| 2230 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2231 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2232 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2233 | def getHumanReadableName(self, obj):
|
| 2234 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2235 | def getValidators(self, obj):
|
| 2236 | try: |
| 2237 | return obj.getValidators() |
| 2238 | except: |
| 2239 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2240 | class Meta:
|
| 2241 | model = ControllerDashboard |
| 2242 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2243 | |
| 2244 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2245 | |
| 2246 | |
| 2247 | class RouterSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2248 | id = serializers.Field() |
| 2249 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2250 | |
| 2251 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2252 | |
| 2253 | |
| 2254 | |
| 2255 | networks = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='network-detail') |
| 2256 | |
| 2257 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2258 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2259 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2260 | def getHumanReadableName(self, obj):
|
| 2261 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2262 | def getValidators(self, obj): |
| 2263 | try: |
| 2264 | return obj.getValidators() |
| 2265 | except: |
| 2266 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2267 | class Meta: |
| 2268 | model = Router |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2269 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2270 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2271 | class RouterIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2272 | id = serializers.Field() |
| 2273 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2274 | |
| 2275 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
| 2276 | |
| 2277 | |
| 2278 | |
| 2279 | networks = serializers.PrimaryKeyRelatedField(many=True) #, read_only=True) #, view_name='network-detail') |
| 2280 | |
| 2281 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2282 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2283 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2284 | def getHumanReadableName(self, obj):
|
| 2285 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2286 | def getValidators(self, obj):
|
| 2287 | try: |
| 2288 | return obj.getValidators() |
| 2289 | except: |
| 2290 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2291 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2292 | model = Router |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2293 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2294 | |
| 2295 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2296 | |
| 2297 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2298 | class ServiceResourceSerializer(serializers.HyperlinkedModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2299 | id = serializers.Field() |
| 2300 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2301 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2302 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2303 | def getHumanReadableName(self, obj):
|
| 2304 | return str(obj) |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2305 | def getValidators(self, obj): |
| 2306 | try: |
| 2307 | return obj.getValidators() |
| 2308 | except: |
| 2309 | return None |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2310 | class Meta: |
| 2311 | model = ServiceResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2312 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2313 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2314 | class ServiceResourceIdSerializer(XOSModelSerializer): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2315 | id = serializers.Field() |
| 2316 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2317 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2318 | validators = serializers.SerializerMethodField("getValidators") |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2319 | def getHumanReadableName(self, obj):
|
| 2320 | return str(obj)
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2321 | def getValidators(self, obj):
|
| 2322 | try: |
| 2323 | return obj.getValidators() |
| 2324 | except: |
| 2325 | return None
|
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2326 | class Meta:
|
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2327 | model = ServiceResource |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2328 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2329 | |
| 2330 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2331 | |
| 2332 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2333 | class ControllerSlicesSerializer(serializers.HyperlinkedModelSerializer): |
| 2334 | id = serializers.Field() |
| 2335 | |
| 2336 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2337 | validators = serializers.SerializerMethodField("getValidators") |
| 2338 | def getHumanReadableName(self, obj):
|
| 2339 | return str(obj) |
| 2340 | def getValidators(self, obj): |
| 2341 | try: |
| 2342 | return obj.getValidators() |
| 2343 | except: |
| 2344 | return None |
| 2345 | class Meta: |
| 2346 | model = ControllerSlices |
| 2347 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2348 | |
| 2349 | class ControllerSlicesIdSerializer(XOSModelSerializer): |
| 2350 | id = serializers.Field() |
| 2351 | |
| 2352 | humanReadableName = serializers.SerializerMethodField("getHumanReadableName") |
| 2353 | validators = serializers.SerializerMethodField("getValidators") |
| 2354 | def getHumanReadableName(self, obj):
|
| 2355 | return str(obj)
|
| 2356 | def getValidators(self, obj):
|
| 2357 | try: |
| 2358 | return obj.getValidators() |
| 2359 | except: |
| 2360 | return None
|
| 2361 | class Meta:
|
| 2362 | model = ControllerSlices |
| 2363 | fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 2364 | |
| 2365 | |
| 2366 | |
| 2367 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2368 | serializerLookUp = { |
| 2369 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2370 | Flavor: FlavorSerializer, |
| 2371 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2372 | ServiceAttribute: ServiceAttributeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2373 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2374 | ControllerImages: ControllerImagesSerializer, |
| 2375 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2376 | Image: ImageSerializer, |
| 2377 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2378 | NetworkParameter: NetworkParameterSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2379 | |
| 2380 | Site: SiteSerializer, |
| 2381 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2382 | SliceRole: SliceRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2383 | |
| 2384 | Tag: TagSerializer, |
| 2385 | |
| 2386 | Invoice: InvoiceSerializer, |
| 2387 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2388 | SlicePrivilege: SlicePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2389 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2390 | PlanetStackRole: PlanetStackRoleSerializer, |
| 2391 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2392 | ControllerPrivilege: ControllerPrivilegeSerializer, |
| 2393 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2394 | NetworkSliver: NetworkSliverSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2395 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2396 | Project: ProjectSerializer, |
| 2397 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2398 | Slice: SliceSerializer, |
| 2399 | |
| 2400 | Network: NetworkSerializer, |
| 2401 | |
| 2402 | Service: ServiceSerializer, |
| 2403 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2404 | ServiceClass: ServiceClassSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2405 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2406 | ControllerNetworks: ControllerNetworksSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2407 | |
| 2408 | Charge: ChargeSerializer, |
| 2409 | |
| 2410 | Role: RoleSerializer, |
| 2411 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2412 | UsableObject: UsableObjectSerializer, |
| 2413 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2414 | ControllerSiteDeployments: ControllerSiteDeploymentsSerializer, |
| 2415 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2416 | SiteRole: SiteRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2417 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2418 | SliceCredential: SliceCredentialSerializer, |
| 2419 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2420 | Sliver: SliverSerializer, |
| 2421 | |
| 2422 | Node: NodeSerializer, |
| 2423 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2424 | DashboardView: DashboardViewSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2425 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2426 | ImageDeployments: ImageDeploymentsSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2427 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2428 | ReservedResource: ReservedResourceSerializer, |
Scott Baker | 8b53319 | 2014-11-17 22:32:19 -0800 | [diff] [blame] | 2429 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2430 | Payment: PaymentSerializer, |
| 2431 | |
| 2432 | NetworkTemplate: NetworkTemplateSerializer, |
| 2433 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2434 | NetworkSlice: NetworkSliceSerializer, |
| 2435 | |
| 2436 | UserDashboardView: UserDashboardViewSerializer, |
| 2437 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2438 | Controller: ControllerSerializer, |
| 2439 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2440 | PlanetStackPrivilege: PlanetStackPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2441 | |
| 2442 | User: UserSerializer, |
| 2443 | |
| 2444 | Deployment: DeploymentSerializer, |
| 2445 | |
| 2446 | Reservation: ReservationSerializer, |
| 2447 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2448 | SitePrivilege: SitePrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2449 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2450 | PlanetStack: PlanetStackSerializer, |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2451 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2452 | Account: AccountSerializer, |
| 2453 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2454 | ControllerRole: ControllerRoleSerializer, |
| 2455 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2456 | NetworkParameterType: NetworkParameterTypeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2457 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2458 | SiteCredential: SiteCredentialSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2459 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2460 | DeploymentPrivilege: DeploymentPrivilegeSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2461 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2462 | ControllerUsers: ControllerUsersSerializer, |
| 2463 | |
| 2464 | DeploymentRole: DeploymentRoleSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2465 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2466 | UserCredential: UserCredentialSerializer, |
| 2467 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 2468 | SiteDeployments: SiteDeploymentsSerializer, |
| 2469 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2470 | SliceTag: SliceTagSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2471 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2472 | ControllerDashboard: ControllerDashboardSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2473 | |
| 2474 | Router: RouterSerializer, |
| 2475 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2476 | ServiceResource: ServiceResourceSerializer, |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2477 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2478 | ControllerSlices: ControllerSlicesSerializer, |
| 2479 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2480 | None: None, |
| 2481 | } |
| 2482 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2483 | class PlanetStackRetrieveUpdateDestroyAPIView(generics.RetrieveUpdateDestroyAPIView): |
| 2484 | |
| 2485 | # To handle fine-grained field permissions, we have to check can_update |
| 2486 | # the object has been updated but before it has been saved. |
| 2487 | |
| 2488 | def update(self, request, *args, **kwargs):
|
| 2489 | partial = kwargs.pop('partial', False)
|
| 2490 | self.object = self.get_object_or_none()
|
| 2491 |
|
| 2492 | serializer = self.get_serializer(self.object, data=request.DATA,
|
| 2493 | files=request.FILES, partial=partial)
|
| 2494 |
|
| 2495 | if not serializer.is_valid():
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2496 | response = {"error": "validation",
|
| 2497 | "specific_error": "not serializer.is_valid()",
|
| 2498 | "reasons": serializer.errors}
|
| 2499 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2500 |
|
| 2501 | try:
|
| 2502 | self.pre_save(serializer.object)
|
| 2503 | except ValidationError as err:
|
| 2504 | # full_clean on model instance may be called in pre_save,
|
| 2505 | # so we have to handle eventual errors.
|
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2506 | response = {"error": "validation",
|
| 2507 | "specific_error": "ValidationError in pre_save",
|
| 2508 | "reasons": err.message_dict}
|
| 2509 | return Response(response, status=status.HTTP_400_BAD_REQUEST)
|
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2510 |
|
| 2511 | if serializer.object is not None:
|
| 2512 | if not serializer.object.can_update(request.user):
|
| 2513 | return Response(status=status.HTTP_400_BAD_REQUEST)
|
| 2514 |
|
| 2515 | if self.object is None:
|
| 2516 | self.object = serializer.save(force_insert=True)
|
| 2517 | self.post_save(self.object, created=True)
|
| 2518 | return Response(serializer.data, status=status.HTTP_201_CREATED)
|
| 2519 |
|
| 2520 | self.object = serializer.save(force_update=True)
|
| 2521 | self.post_save(self.object, created=False)
|
| 2522 | return Response(serializer.data, status=status.HTTP_200_OK) |
| 2523 | |
| 2524 | def destroy(self, request, *args, **kwargs): |
| 2525 | obj = self.get_object() |
| 2526 | if obj.can_update(request.user): |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2527 | return super(generics.RetrieveUpdateDestroyAPIView, self).destroy(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2528 | else: |
| 2529 | return Response(status=status.HTTP_400_BAD_REQUEST) |
| 2530 | |
| 2531 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2532 | # Based on core/views/*.py |
| 2533 | |
| 2534 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2535 | class FlavorList(generics.ListCreateAPIView): |
| 2536 | queryset = Flavor.objects.select_related().all() |
| 2537 | serializer_class = FlavorSerializer |
| 2538 | id_serializer_class = FlavorIdSerializer |
| 2539 | filter_backends = (filters.DjangoFilterBackend,) |
| 2540 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','flavor','order','default','deployments',) |
| 2541 | |
| 2542 | def get_serializer_class(self): |
| 2543 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2544 | if (no_hyperlinks): |
| 2545 | return self.id_serializer_class |
| 2546 | else: |
| 2547 | return self.serializer_class |
| 2548 | |
| 2549 | def get_queryset(self): |
| 2550 | return Flavor.select_by_user(self.request.user) |
| 2551 | |
| 2552 | def create(self, request, *args, **kwargs): |
| 2553 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2554 | if not (serializer.is_valid()): |
| 2555 | response = {"error": "validation", |
| 2556 | "specific_error": "not serializer.is_valid()",
|
| 2557 | "reasons": serializer.errors}
|
| 2558 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2559 | obj = serializer.object |
| 2560 | obj.caller = request.user |
| 2561 | if obj.can_update(request.user): |
| 2562 | return super(FlavorList, self).create(request, *args, **kwargs) |
| 2563 | else: |
| 2564 | raise Exception("failed obj.can_update") |
| 2565 | |
| 2566 | ret = super(FlavorList, self).create(request, *args, **kwargs) |
| 2567 | if (ret.status_code%100 != 200): |
| 2568 | raise Exception(ret.data) |
| 2569 | |
| 2570 | return ret |
| 2571 | |
| 2572 | |
| 2573 | class FlavorDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2574 | queryset = Flavor.objects.select_related().all() |
| 2575 | serializer_class = FlavorSerializer |
| 2576 | id_serializer_class = FlavorIdSerializer |
| 2577 | |
| 2578 | def get_serializer_class(self): |
| 2579 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2580 | if (no_hyperlinks): |
| 2581 | return self.id_serializer_class |
| 2582 | else: |
| 2583 | return self.serializer_class |
| 2584 | |
| 2585 | def get_queryset(self): |
| 2586 | return Flavor.select_by_user(self.request.user) |
| 2587 | |
| 2588 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2589 | |
| 2590 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2591 | |
| 2592 | |
| 2593 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2594 | class ServiceAttributeList(generics.ListCreateAPIView): |
| 2595 | queryset = ServiceAttribute.objects.select_related().all() |
| 2596 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2597 | id_serializer_class = ServiceAttributeIdSerializer |
| 2598 | filter_backends = (filters.DjangoFilterBackend,) |
| 2599 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','value','service',) |
| 2600 | |
| 2601 | def get_serializer_class(self): |
| 2602 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2603 | if (no_hyperlinks): |
| 2604 | return self.id_serializer_class |
| 2605 | else: |
| 2606 | return self.serializer_class |
| 2607 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2608 | def get_queryset(self): |
| 2609 | return ServiceAttribute.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2610 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2611 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2612 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2613 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2614 | response = {"error": "validation", |
| 2615 | "specific_error": "not serializer.is_valid()",
|
| 2616 | "reasons": serializer.errors}
|
| 2617 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2618 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2619 | obj.caller = request.user |
| 2620 | if obj.can_update(request.user): |
| 2621 | return super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2622 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2623 | raise Exception("failed obj.can_update") |
| 2624 | |
| 2625 | ret = super(ServiceAttributeList, self).create(request, *args, **kwargs) |
| 2626 | if (ret.status_code%100 != 200): |
| 2627 | raise Exception(ret.data) |
| 2628 | |
| 2629 | return ret |
| 2630 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2631 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2632 | class ServiceAttributeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2633 | queryset = ServiceAttribute.objects.select_related().all() |
| 2634 | serializer_class = ServiceAttributeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2635 | id_serializer_class = ServiceAttributeIdSerializer |
| 2636 | |
| 2637 | def get_serializer_class(self): |
| 2638 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2639 | if (no_hyperlinks): |
| 2640 | return self.id_serializer_class |
| 2641 | else: |
| 2642 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2643 | |
| 2644 | def get_queryset(self): |
| 2645 | return ServiceAttribute.select_by_user(self.request.user) |
| 2646 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2647 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2648 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2649 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2650 | |
| 2651 | |
| 2652 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2653 | class ControllerImagesList(generics.ListCreateAPIView): |
| 2654 | queryset = ControllerImages.objects.select_related().all() |
| 2655 | serializer_class = ControllerImagesSerializer |
| 2656 | id_serializer_class = ControllerImagesIdSerializer |
| 2657 | filter_backends = (filters.DjangoFilterBackend,) |
| 2658 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','controller','glance_image_id',) |
| 2659 | |
| 2660 | def get_serializer_class(self): |
| 2661 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2662 | if (no_hyperlinks): |
| 2663 | return self.id_serializer_class |
| 2664 | else: |
| 2665 | return self.serializer_class |
| 2666 | |
| 2667 | def get_queryset(self): |
| 2668 | return ControllerImages.select_by_user(self.request.user) |
| 2669 | |
| 2670 | def create(self, request, *args, **kwargs): |
| 2671 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2672 | if not (serializer.is_valid()): |
| 2673 | response = {"error": "validation", |
| 2674 | "specific_error": "not serializer.is_valid()",
|
| 2675 | "reasons": serializer.errors}
|
| 2676 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 2677 | obj = serializer.object |
| 2678 | obj.caller = request.user |
| 2679 | if obj.can_update(request.user): |
| 2680 | return super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2681 | else: |
| 2682 | raise Exception("failed obj.can_update") |
| 2683 | |
| 2684 | ret = super(ControllerImagesList, self).create(request, *args, **kwargs) |
| 2685 | if (ret.status_code%100 != 200): |
| 2686 | raise Exception(ret.data) |
| 2687 | |
| 2688 | return ret |
| 2689 | |
| 2690 | |
| 2691 | class ControllerImagesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 2692 | queryset = ControllerImages.objects.select_related().all() |
| 2693 | serializer_class = ControllerImagesSerializer |
| 2694 | id_serializer_class = ControllerImagesIdSerializer |
| 2695 | |
| 2696 | def get_serializer_class(self): |
| 2697 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2698 | if (no_hyperlinks): |
| 2699 | return self.id_serializer_class |
| 2700 | else: |
| 2701 | return self.serializer_class |
| 2702 | |
| 2703 | def get_queryset(self): |
| 2704 | return ControllerImages.select_by_user(self.request.user) |
| 2705 | |
| 2706 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2707 | |
| 2708 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 2709 | |
| 2710 | |
| 2711 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2712 | class ImageList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2713 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2714 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2715 | id_serializer_class = ImageIdSerializer |
| 2716 | filter_backends = (filters.DjangoFilterBackend,) |
| 2717 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','disk_format','container_format','path',) |
| 2718 | |
| 2719 | def get_serializer_class(self): |
| 2720 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2721 | if (no_hyperlinks): |
| 2722 | return self.id_serializer_class |
| 2723 | else: |
| 2724 | return self.serializer_class |
| 2725 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2726 | def get_queryset(self): |
| 2727 | return Image.select_by_user(self.request.user) |
| 2728 | |
| 2729 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2730 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2731 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2732 | response = {"error": "validation", |
| 2733 | "specific_error": "not serializer.is_valid()",
|
| 2734 | "reasons": serializer.errors}
|
| 2735 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2736 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2737 | obj.caller = request.user |
| 2738 | if obj.can_update(request.user): |
| 2739 | return super(ImageList, self).create(request, *args, **kwargs) |
| 2740 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2741 | raise Exception("failed obj.can_update") |
| 2742 | |
| 2743 | ret = super(ImageList, self).create(request, *args, **kwargs) |
| 2744 | if (ret.status_code%100 != 200): |
| 2745 | raise Exception(ret.data) |
| 2746 | |
| 2747 | return ret |
| 2748 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2749 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2750 | class ImageDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2751 | queryset = Image.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2752 | serializer_class = ImageSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2753 | id_serializer_class = ImageIdSerializer |
| 2754 | |
| 2755 | def get_serializer_class(self): |
| 2756 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2757 | if (no_hyperlinks): |
| 2758 | return self.id_serializer_class |
| 2759 | else: |
| 2760 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2761 | |
| 2762 | def get_queryset(self): |
| 2763 | return Image.select_by_user(self.request.user) |
| 2764 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2765 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2766 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2767 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2768 | |
| 2769 | |
| 2770 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2771 | class NetworkParameterList(generics.ListCreateAPIView): |
| 2772 | queryset = NetworkParameter.objects.select_related().all() |
| 2773 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2774 | id_serializer_class = NetworkParameterIdSerializer |
| 2775 | filter_backends = (filters.DjangoFilterBackend,) |
| 2776 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','parameter','value','content_type','object_id',) |
| 2777 | |
| 2778 | def get_serializer_class(self): |
| 2779 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2780 | if (no_hyperlinks): |
| 2781 | return self.id_serializer_class |
| 2782 | else: |
| 2783 | return self.serializer_class |
| 2784 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2785 | def get_queryset(self): |
| 2786 | return NetworkParameter.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2787 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2788 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2789 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2790 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2791 | response = {"error": "validation", |
| 2792 | "specific_error": "not serializer.is_valid()",
|
| 2793 | "reasons": serializer.errors}
|
| 2794 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2795 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2796 | obj.caller = request.user |
| 2797 | if obj.can_update(request.user): |
| 2798 | return super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2799 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2800 | raise Exception("failed obj.can_update") |
| 2801 | |
| 2802 | ret = super(NetworkParameterList, self).create(request, *args, **kwargs) |
| 2803 | if (ret.status_code%100 != 200): |
| 2804 | raise Exception(ret.data) |
| 2805 | |
| 2806 | return ret |
| 2807 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2808 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2809 | class NetworkParameterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2810 | queryset = NetworkParameter.objects.select_related().all() |
| 2811 | serializer_class = NetworkParameterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2812 | id_serializer_class = NetworkParameterIdSerializer |
| 2813 | |
| 2814 | def get_serializer_class(self): |
| 2815 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2816 | if (no_hyperlinks): |
| 2817 | return self.id_serializer_class |
| 2818 | else: |
| 2819 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2820 | |
| 2821 | def get_queryset(self): |
| 2822 | return NetworkParameter.select_by_user(self.request.user) |
| 2823 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2824 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2825 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2826 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2827 | |
| 2828 | |
| 2829 | |
| 2830 | class SiteList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2831 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2832 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2833 | id_serializer_class = SiteIdSerializer |
| 2834 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 2835 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_url','enabled','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2836 | |
| 2837 | def get_serializer_class(self): |
| 2838 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2839 | if (no_hyperlinks): |
| 2840 | return self.id_serializer_class |
| 2841 | else: |
| 2842 | return self.serializer_class |
| 2843 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2844 | def get_queryset(self): |
| 2845 | return Site.select_by_user(self.request.user) |
| 2846 | |
| 2847 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2848 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2849 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2850 | response = {"error": "validation", |
| 2851 | "specific_error": "not serializer.is_valid()",
|
| 2852 | "reasons": serializer.errors}
|
| 2853 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2854 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2855 | obj.caller = request.user |
| 2856 | if obj.can_update(request.user): |
| 2857 | return super(SiteList, self).create(request, *args, **kwargs) |
| 2858 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2859 | raise Exception("failed obj.can_update") |
| 2860 | |
| 2861 | ret = super(SiteList, self).create(request, *args, **kwargs) |
| 2862 | if (ret.status_code%100 != 200): |
| 2863 | raise Exception(ret.data) |
| 2864 | |
| 2865 | return ret |
| 2866 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2867 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2868 | class SiteDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2869 | queryset = Site.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2870 | serializer_class = SiteSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2871 | id_serializer_class = SiteIdSerializer |
| 2872 | |
| 2873 | def get_serializer_class(self): |
| 2874 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2875 | if (no_hyperlinks): |
| 2876 | return self.id_serializer_class |
| 2877 | else: |
| 2878 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2879 | |
| 2880 | def get_queryset(self): |
| 2881 | return Site.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2882 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2883 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2884 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2885 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2886 | |
| 2887 | |
| 2888 | |
| 2889 | class SliceRoleList(generics.ListCreateAPIView): |
| 2890 | queryset = SliceRole.objects.select_related().all() |
| 2891 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2892 | id_serializer_class = SliceRoleIdSerializer |
| 2893 | filter_backends = (filters.DjangoFilterBackend,) |
| 2894 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 2895 | |
| 2896 | def get_serializer_class(self): |
| 2897 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2898 | if (no_hyperlinks): |
| 2899 | return self.id_serializer_class |
| 2900 | else: |
| 2901 | return self.serializer_class |
| 2902 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2903 | def get_queryset(self): |
| 2904 | return SliceRole.select_by_user(self.request.user) |
| 2905 | |
| 2906 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2907 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2908 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2909 | response = {"error": "validation", |
| 2910 | "specific_error": "not serializer.is_valid()",
|
| 2911 | "reasons": serializer.errors}
|
| 2912 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2913 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2914 | obj.caller = request.user |
| 2915 | if obj.can_update(request.user): |
| 2916 | return super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2917 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2918 | raise Exception("failed obj.can_update") |
| 2919 | |
| 2920 | ret = super(SliceRoleList, self).create(request, *args, **kwargs) |
| 2921 | if (ret.status_code%100 != 200): |
| 2922 | raise Exception(ret.data) |
| 2923 | |
| 2924 | return ret |
| 2925 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2926 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2927 | class SliceRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2928 | queryset = SliceRole.objects.select_related().all() |
| 2929 | serializer_class = SliceRoleSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2930 | id_serializer_class = SliceRoleIdSerializer |
| 2931 | |
| 2932 | def get_serializer_class(self): |
| 2933 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2934 | if (no_hyperlinks): |
| 2935 | return self.id_serializer_class |
| 2936 | else: |
| 2937 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2938 | |
| 2939 | def get_queryset(self): |
| 2940 | return SliceRole.select_by_user(self.request.user) |
| 2941 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2942 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2943 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2944 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2945 | |
| 2946 | |
| 2947 | |
| 2948 | class TagList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2949 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2950 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2951 | id_serializer_class = TagIdSerializer |
| 2952 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2953 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','service','name','value','content_type','object_id',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2954 | |
| 2955 | def get_serializer_class(self): |
| 2956 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2957 | if (no_hyperlinks): |
| 2958 | return self.id_serializer_class |
| 2959 | else: |
| 2960 | return self.serializer_class |
| 2961 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2962 | def get_queryset(self): |
| 2963 | return Tag.select_by_user(self.request.user) |
| 2964 | |
| 2965 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2966 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 2967 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 2968 | response = {"error": "validation", |
| 2969 | "specific_error": "not serializer.is_valid()",
|
| 2970 | "reasons": serializer.errors}
|
| 2971 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 2972 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2973 | obj.caller = request.user |
| 2974 | if obj.can_update(request.user): |
| 2975 | return super(TagList, self).create(request, *args, **kwargs) |
| 2976 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 2977 | raise Exception("failed obj.can_update") |
| 2978 | |
| 2979 | ret = super(TagList, self).create(request, *args, **kwargs) |
| 2980 | if (ret.status_code%100 != 200): |
| 2981 | raise Exception(ret.data) |
| 2982 | |
| 2983 | return ret |
| 2984 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2985 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 2986 | class TagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2987 | queryset = Tag.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 2988 | serializer_class = TagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 2989 | id_serializer_class = TagIdSerializer |
| 2990 | |
| 2991 | def get_serializer_class(self): |
| 2992 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 2993 | if (no_hyperlinks): |
| 2994 | return self.id_serializer_class |
| 2995 | else: |
| 2996 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 2997 | |
| 2998 | def get_queryset(self): |
| 2999 | return Tag.select_by_user(self.request.user) |
| 3000 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3001 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3002 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3003 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3004 | |
| 3005 | |
| 3006 | |
| 3007 | class InvoiceList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3008 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3009 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3010 | id_serializer_class = InvoiceIdSerializer |
| 3011 | filter_backends = (filters.DjangoFilterBackend,) |
| 3012 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','date','account',) |
| 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 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3021 | def get_queryset(self): |
| 3022 | return Invoice.select_by_user(self.request.user) |
| 3023 | |
| 3024 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3025 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3026 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3027 | response = {"error": "validation", |
| 3028 | "specific_error": "not serializer.is_valid()",
|
| 3029 | "reasons": serializer.errors}
|
| 3030 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3031 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3032 | obj.caller = request.user |
| 3033 | if obj.can_update(request.user): |
| 3034 | return super(InvoiceList, self).create(request, *args, **kwargs) |
| 3035 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3036 | raise Exception("failed obj.can_update") |
| 3037 | |
| 3038 | ret = super(InvoiceList, self).create(request, *args, **kwargs) |
| 3039 | if (ret.status_code%100 != 200): |
| 3040 | raise Exception(ret.data) |
| 3041 | |
| 3042 | return ret |
| 3043 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3044 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3045 | class InvoiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3046 | queryset = Invoice.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3047 | serializer_class = InvoiceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3048 | id_serializer_class = InvoiceIdSerializer |
| 3049 | |
| 3050 | def get_serializer_class(self): |
| 3051 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3052 | if (no_hyperlinks): |
| 3053 | return self.id_serializer_class |
| 3054 | else: |
| 3055 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3056 | |
| 3057 | def get_queryset(self): |
| 3058 | return Invoice.select_by_user(self.request.user) |
| 3059 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3060 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3061 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3062 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3063 | |
| 3064 | |
| 3065 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3066 | class SlicePrivilegeList(generics.ListCreateAPIView): |
| 3067 | queryset = SlicePrivilege.objects.select_related().all() |
| 3068 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3069 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3070 | filter_backends = (filters.DjangoFilterBackend,) |
| 3071 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','slice','role',) |
| 3072 | |
| 3073 | def get_serializer_class(self): |
| 3074 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3075 | if (no_hyperlinks): |
| 3076 | return self.id_serializer_class |
| 3077 | else: |
| 3078 | return self.serializer_class |
| 3079 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3080 | def get_queryset(self): |
| 3081 | return SlicePrivilege.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3082 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3083 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3084 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3085 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3086 | response = {"error": "validation", |
| 3087 | "specific_error": "not serializer.is_valid()",
|
| 3088 | "reasons": serializer.errors}
|
| 3089 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3090 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3091 | obj.caller = request.user |
| 3092 | if obj.can_update(request.user): |
| 3093 | return super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3094 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3095 | raise Exception("failed obj.can_update") |
| 3096 | |
| 3097 | ret = super(SlicePrivilegeList, self).create(request, *args, **kwargs) |
| 3098 | if (ret.status_code%100 != 200): |
| 3099 | raise Exception(ret.data) |
| 3100 | |
| 3101 | return ret |
| 3102 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3103 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3104 | class SlicePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3105 | queryset = SlicePrivilege.objects.select_related().all() |
| 3106 | serializer_class = SlicePrivilegeSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3107 | id_serializer_class = SlicePrivilegeIdSerializer |
| 3108 | |
| 3109 | def get_serializer_class(self): |
| 3110 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3111 | if (no_hyperlinks): |
| 3112 | return self.id_serializer_class |
| 3113 | else: |
| 3114 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3115 | |
| 3116 | def get_queryset(self): |
| 3117 | return SlicePrivilege.select_by_user(self.request.user) |
| 3118 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3119 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3120 | |
| 3121 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3122 | |
| 3123 | |
| 3124 | |
| 3125 | class PlanetStackRoleList(generics.ListCreateAPIView): |
| 3126 | queryset = PlanetStackRole.objects.select_related().all() |
| 3127 | serializer_class = PlanetStackRoleSerializer |
| 3128 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3129 | filter_backends = (filters.DjangoFilterBackend,) |
| 3130 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3131 | |
| 3132 | def get_serializer_class(self): |
| 3133 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3134 | if (no_hyperlinks): |
| 3135 | return self.id_serializer_class |
| 3136 | else: |
| 3137 | return self.serializer_class |
| 3138 | |
| 3139 | def get_queryset(self): |
| 3140 | return PlanetStackRole.select_by_user(self.request.user) |
| 3141 | |
| 3142 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3143 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3144 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3145 | response = {"error": "validation", |
| 3146 | "specific_error": "not serializer.is_valid()",
|
| 3147 | "reasons": serializer.errors}
|
| 3148 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3149 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3150 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3151 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3152 | return super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3153 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3154 | raise Exception("failed obj.can_update") |
| 3155 | |
| 3156 | ret = super(PlanetStackRoleList, self).create(request, *args, **kwargs) |
| 3157 | if (ret.status_code%100 != 200): |
| 3158 | raise Exception(ret.data) |
| 3159 | |
| 3160 | return ret |
| 3161 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3162 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3163 | class PlanetStackRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3164 | queryset = PlanetStackRole.objects.select_related().all() |
| 3165 | serializer_class = PlanetStackRoleSerializer |
| 3166 | id_serializer_class = PlanetStackRoleIdSerializer |
| 3167 | |
| 3168 | def get_serializer_class(self): |
| 3169 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3170 | if (no_hyperlinks): |
| 3171 | return self.id_serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3172 | else: |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3173 | return self.serializer_class |
| 3174 | |
| 3175 | def get_queryset(self): |
| 3176 | return PlanetStackRole.select_by_user(self.request.user) |
| 3177 | |
| 3178 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3179 | |
| 3180 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3181 | |
| 3182 | |
| 3183 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3184 | class ControllerPrivilegeList(generics.ListCreateAPIView): |
| 3185 | queryset = ControllerPrivilege.objects.select_related().all() |
| 3186 | serializer_class = ControllerPrivilegeSerializer |
| 3187 | id_serializer_class = ControllerPrivilegeIdSerializer |
| 3188 | filter_backends = (filters.DjangoFilterBackend,) |
| 3189 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','role',) |
| 3190 | |
| 3191 | def get_serializer_class(self): |
| 3192 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3193 | if (no_hyperlinks): |
| 3194 | return self.id_serializer_class |
| 3195 | else: |
| 3196 | return self.serializer_class |
| 3197 | |
| 3198 | def get_queryset(self): |
| 3199 | return ControllerPrivilege.select_by_user(self.request.user) |
| 3200 | |
| 3201 | def create(self, request, *args, **kwargs): |
| 3202 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3203 | if not (serializer.is_valid()): |
| 3204 | response = {"error": "validation", |
| 3205 | "specific_error": "not serializer.is_valid()",
|
| 3206 | "reasons": serializer.errors}
|
| 3207 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3208 | obj = serializer.object |
| 3209 | obj.caller = request.user |
| 3210 | if obj.can_update(request.user): |
| 3211 | return super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
| 3212 | else: |
| 3213 | raise Exception("failed obj.can_update") |
| 3214 | |
| 3215 | ret = super(ControllerPrivilegeList, self).create(request, *args, **kwargs) |
| 3216 | if (ret.status_code%100 != 200): |
| 3217 | raise Exception(ret.data) |
| 3218 | |
| 3219 | return ret |
| 3220 | |
| 3221 | |
| 3222 | class ControllerPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3223 | queryset = ControllerPrivilege.objects.select_related().all() |
| 3224 | serializer_class = ControllerPrivilegeSerializer |
| 3225 | id_serializer_class = ControllerPrivilegeIdSerializer |
| 3226 | |
| 3227 | def get_serializer_class(self): |
| 3228 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3229 | if (no_hyperlinks): |
| 3230 | return self.id_serializer_class |
| 3231 | else: |
| 3232 | return self.serializer_class |
| 3233 | |
| 3234 | def get_queryset(self): |
| 3235 | return ControllerPrivilege.select_by_user(self.request.user) |
| 3236 | |
| 3237 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3238 | |
| 3239 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3240 | |
| 3241 | |
| 3242 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3243 | class NetworkSliverList(generics.ListCreateAPIView): |
| 3244 | queryset = NetworkSliver.objects.select_related().all() |
| 3245 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3246 | id_serializer_class = NetworkSliverIdSerializer |
| 3247 | filter_backends = (filters.DjangoFilterBackend,) |
| 3248 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','sliver','ip','port_id',) |
| 3249 | |
| 3250 | def get_serializer_class(self): |
| 3251 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3252 | if (no_hyperlinks): |
| 3253 | return self.id_serializer_class |
| 3254 | else: |
| 3255 | return self.serializer_class |
| 3256 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3257 | def get_queryset(self): |
| 3258 | return NetworkSliver.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3259 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3260 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3261 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3262 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3263 | response = {"error": "validation", |
| 3264 | "specific_error": "not serializer.is_valid()",
|
| 3265 | "reasons": serializer.errors}
|
| 3266 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3267 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3268 | obj.caller = request.user |
| 3269 | if obj.can_update(request.user): |
| 3270 | return super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3271 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3272 | raise Exception("failed obj.can_update") |
| 3273 | |
| 3274 | ret = super(NetworkSliverList, self).create(request, *args, **kwargs) |
| 3275 | if (ret.status_code%100 != 200): |
| 3276 | raise Exception(ret.data) |
| 3277 | |
| 3278 | return ret |
| 3279 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3280 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3281 | class NetworkSliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3282 | queryset = NetworkSliver.objects.select_related().all() |
| 3283 | serializer_class = NetworkSliverSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3284 | id_serializer_class = NetworkSliverIdSerializer |
| 3285 | |
| 3286 | def get_serializer_class(self): |
| 3287 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3288 | if (no_hyperlinks): |
| 3289 | return self.id_serializer_class |
| 3290 | else: |
| 3291 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3292 | |
| 3293 | def get_queryset(self): |
| 3294 | return NetworkSliver.select_by_user(self.request.user) |
| 3295 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3296 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3297 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3298 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3299 | |
| 3300 | |
| 3301 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3302 | class ProjectList(generics.ListCreateAPIView): |
| 3303 | queryset = Project.objects.select_related().all() |
| 3304 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3305 | id_serializer_class = ProjectIdSerializer |
| 3306 | filter_backends = (filters.DjangoFilterBackend,) |
| 3307 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3308 | |
| 3309 | def get_serializer_class(self): |
| 3310 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3311 | if (no_hyperlinks): |
| 3312 | return self.id_serializer_class |
| 3313 | else: |
| 3314 | return self.serializer_class |
| 3315 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3316 | def get_queryset(self): |
| 3317 | return Project.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 3318 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3319 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3320 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3321 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3322 | response = {"error": "validation", |
| 3323 | "specific_error": "not serializer.is_valid()",
|
| 3324 | "reasons": serializer.errors}
|
| 3325 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3326 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3327 | obj.caller = request.user |
| 3328 | if obj.can_update(request.user): |
| 3329 | return super(ProjectList, self).create(request, *args, **kwargs) |
| 3330 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3331 | raise Exception("failed obj.can_update") |
| 3332 | |
| 3333 | ret = super(ProjectList, self).create(request, *args, **kwargs) |
| 3334 | if (ret.status_code%100 != 200): |
| 3335 | raise Exception(ret.data) |
| 3336 | |
| 3337 | return ret |
| 3338 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3339 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3340 | class ProjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3341 | queryset = Project.objects.select_related().all() |
| 3342 | serializer_class = ProjectSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 3343 | id_serializer_class = ProjectIdSerializer |
| 3344 | |
| 3345 | def get_serializer_class(self): |
| 3346 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3347 | if (no_hyperlinks): |
| 3348 | return self.id_serializer_class |
| 3349 | else: |
| 3350 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3351 | |
| 3352 | def get_queryset(self): |
| 3353 | return Project.select_by_user(self.request.user) |
| 3354 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3355 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3356 | |
| 3357 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3358 | |
| 3359 | |
| 3360 | |
| 3361 | class SliceList(generics.ListCreateAPIView): |
| 3362 | queryset = Slice.objects.select_related().all() |
| 3363 | serializer_class = SliceSerializer |
| 3364 | id_serializer_class = SliceIdSerializer |
| 3365 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3366 | 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','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3367 | |
| 3368 | def get_serializer_class(self): |
| 3369 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3370 | if (no_hyperlinks): |
| 3371 | return self.id_serializer_class |
| 3372 | else: |
| 3373 | return self.serializer_class |
| 3374 | |
| 3375 | def get_queryset(self): |
| 3376 | return Slice.select_by_user(self.request.user) |
| 3377 | |
| 3378 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3379 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3380 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3381 | response = {"error": "validation", |
| 3382 | "specific_error": "not serializer.is_valid()",
|
| 3383 | "reasons": serializer.errors}
|
| 3384 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3385 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3386 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3387 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3388 | return super(SliceList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3389 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3390 | raise Exception("failed obj.can_update") |
| 3391 | |
| 3392 | ret = super(SliceList, self).create(request, *args, **kwargs) |
| 3393 | if (ret.status_code%100 != 200): |
| 3394 | raise Exception(ret.data) |
| 3395 | |
| 3396 | return ret |
| 3397 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3398 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3399 | class SliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3400 | queryset = Slice.objects.select_related().all() |
| 3401 | serializer_class = SliceSerializer |
| 3402 | id_serializer_class = SliceIdSerializer |
| 3403 | |
| 3404 | def get_serializer_class(self): |
| 3405 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3406 | if (no_hyperlinks): |
| 3407 | return self.id_serializer_class |
| 3408 | else: |
| 3409 | return self.serializer_class |
| 3410 | |
| 3411 | def get_queryset(self): |
| 3412 | return Slice.select_by_user(self.request.user) |
| 3413 | |
| 3414 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3415 | |
| 3416 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3417 | |
| 3418 | |
| 3419 | |
| 3420 | class NetworkList(generics.ListCreateAPIView): |
| 3421 | queryset = Network.objects.select_related().all() |
| 3422 | serializer_class = NetworkSerializer |
| 3423 | id_serializer_class = NetworkIdSerializer |
| 3424 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3425 | 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','slices','slices','slivers','routers','routers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3426 | |
| 3427 | def get_serializer_class(self): |
| 3428 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3429 | if (no_hyperlinks): |
| 3430 | return self.id_serializer_class |
| 3431 | else: |
| 3432 | return self.serializer_class |
| 3433 | |
| 3434 | def get_queryset(self): |
| 3435 | return Network.select_by_user(self.request.user) |
| 3436 | |
| 3437 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3438 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3439 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3440 | response = {"error": "validation", |
| 3441 | "specific_error": "not serializer.is_valid()",
|
| 3442 | "reasons": serializer.errors}
|
| 3443 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3444 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3445 | obj.caller = request.user |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3446 | if obj.can_update(request.user): |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3447 | return super(NetworkList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 3448 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3449 | raise Exception("failed obj.can_update") |
| 3450 | |
| 3451 | ret = super(NetworkList, self).create(request, *args, **kwargs) |
| 3452 | if (ret.status_code%100 != 200): |
| 3453 | raise Exception(ret.data) |
| 3454 | |
| 3455 | return ret |
| 3456 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3457 | |
| 3458 | class NetworkDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3459 | queryset = Network.objects.select_related().all() |
| 3460 | serializer_class = NetworkSerializer |
| 3461 | id_serializer_class = NetworkIdSerializer |
| 3462 | |
| 3463 | def get_serializer_class(self): |
| 3464 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3465 | if (no_hyperlinks): |
| 3466 | return self.id_serializer_class |
| 3467 | else: |
| 3468 | return self.serializer_class |
| 3469 | |
| 3470 | def get_queryset(self): |
| 3471 | return Network.select_by_user(self.request.user) |
| 3472 | |
| 3473 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3474 | |
| 3475 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3476 | |
| 3477 | |
| 3478 | |
| 3479 | class ServiceList(generics.ListCreateAPIView): |
| 3480 | queryset = Service.objects.select_related().all() |
| 3481 | serializer_class = ServiceSerializer |
| 3482 | id_serializer_class = ServiceIdSerializer |
| 3483 | filter_backends = (filters.DjangoFilterBackend,) |
| 3484 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description','enabled','name','versionNumber','published',) |
| 3485 | |
| 3486 | def get_serializer_class(self): |
| 3487 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3488 | if (no_hyperlinks): |
| 3489 | return self.id_serializer_class |
| 3490 | else: |
| 3491 | return self.serializer_class |
| 3492 | |
| 3493 | def get_queryset(self): |
| 3494 | return Service.select_by_user(self.request.user) |
| 3495 | |
| 3496 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3497 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3498 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3499 | response = {"error": "validation", |
| 3500 | "specific_error": "not serializer.is_valid()",
|
| 3501 | "reasons": serializer.errors}
|
| 3502 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3503 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3504 | obj.caller = request.user |
| 3505 | if obj.can_update(request.user): |
| 3506 | return super(ServiceList, self).create(request, *args, **kwargs) |
| 3507 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3508 | raise Exception("failed obj.can_update") |
| 3509 | |
| 3510 | ret = super(ServiceList, self).create(request, *args, **kwargs) |
| 3511 | if (ret.status_code%100 != 200): |
| 3512 | raise Exception(ret.data) |
| 3513 | |
| 3514 | return ret |
| 3515 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3516 | |
| 3517 | class ServiceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3518 | queryset = Service.objects.select_related().all() |
| 3519 | serializer_class = ServiceSerializer |
| 3520 | id_serializer_class = ServiceIdSerializer |
| 3521 | |
| 3522 | def get_serializer_class(self): |
| 3523 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3524 | if (no_hyperlinks): |
| 3525 | return self.id_serializer_class |
| 3526 | else: |
| 3527 | return self.serializer_class |
| 3528 | |
| 3529 | def get_queryset(self): |
| 3530 | return Service.select_by_user(self.request.user) |
| 3531 | |
| 3532 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3533 | |
| 3534 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3535 | |
| 3536 | |
| 3537 | |
| 3538 | class ServiceClassList(generics.ListCreateAPIView): |
| 3539 | queryset = ServiceClass.objects.select_related().all() |
| 3540 | serializer_class = ServiceClassSerializer |
| 3541 | id_serializer_class = ServiceClassIdSerializer |
| 3542 | filter_backends = (filters.DjangoFilterBackend,) |
| 3543 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','commitment','membershipFee','membershipFeeMonths','upgradeRequiresApproval',) |
| 3544 | |
| 3545 | def get_serializer_class(self): |
| 3546 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3547 | if (no_hyperlinks): |
| 3548 | return self.id_serializer_class |
| 3549 | else: |
| 3550 | return self.serializer_class |
| 3551 | |
| 3552 | def get_queryset(self): |
| 3553 | return ServiceClass.select_by_user(self.request.user) |
| 3554 | |
| 3555 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3556 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3557 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3558 | response = {"error": "validation", |
| 3559 | "specific_error": "not serializer.is_valid()",
|
| 3560 | "reasons": serializer.errors}
|
| 3561 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3562 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3563 | obj.caller = request.user |
| 3564 | if obj.can_update(request.user): |
| 3565 | return super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3566 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3567 | raise Exception("failed obj.can_update") |
| 3568 | |
| 3569 | ret = super(ServiceClassList, self).create(request, *args, **kwargs) |
| 3570 | if (ret.status_code%100 != 200): |
| 3571 | raise Exception(ret.data) |
| 3572 | |
| 3573 | return ret |
| 3574 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3575 | |
| 3576 | class ServiceClassDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3577 | queryset = ServiceClass.objects.select_related().all() |
| 3578 | serializer_class = ServiceClassSerializer |
| 3579 | id_serializer_class = ServiceClassIdSerializer |
| 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 ServiceClass.select_by_user(self.request.user) |
| 3590 | |
| 3591 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3592 | |
| 3593 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3594 | |
| 3595 | |
| 3596 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3597 | class ControllerNetworksList(generics.ListCreateAPIView): |
| 3598 | queryset = ControllerNetworks.objects.select_related().all() |
| 3599 | serializer_class = ControllerNetworksSerializer |
| 3600 | id_serializer_class = ControllerNetworksIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3601 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3602 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','controller','net_id','router_id','subnet_id','subnet',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3603 | |
| 3604 | def get_serializer_class(self): |
| 3605 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3606 | if (no_hyperlinks): |
| 3607 | return self.id_serializer_class |
| 3608 | else: |
| 3609 | return self.serializer_class |
| 3610 | |
| 3611 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3612 | return ControllerNetworks.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3613 | |
| 3614 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3615 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3616 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3617 | response = {"error": "validation", |
| 3618 | "specific_error": "not serializer.is_valid()",
|
| 3619 | "reasons": serializer.errors}
|
| 3620 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3621 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3622 | obj.caller = request.user |
| 3623 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3624 | return super(ControllerNetworksList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3625 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3626 | raise Exception("failed obj.can_update") |
| 3627 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3628 | ret = super(ControllerNetworksList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3629 | if (ret.status_code%100 != 200): |
| 3630 | raise Exception(ret.data) |
| 3631 | |
| 3632 | return ret |
| 3633 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3634 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3635 | class ControllerNetworksDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3636 | queryset = ControllerNetworks.objects.select_related().all() |
| 3637 | serializer_class = ControllerNetworksSerializer |
| 3638 | id_serializer_class = ControllerNetworksIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3639 | |
| 3640 | def get_serializer_class(self): |
| 3641 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3642 | if (no_hyperlinks): |
| 3643 | return self.id_serializer_class |
| 3644 | else: |
| 3645 | return self.serializer_class |
| 3646 | |
| 3647 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3648 | return ControllerNetworks.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3649 | |
| 3650 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3651 | |
| 3652 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3653 | |
| 3654 | |
| 3655 | |
| 3656 | class ChargeList(generics.ListCreateAPIView): |
| 3657 | queryset = Charge.objects.select_related().all() |
| 3658 | serializer_class = ChargeSerializer |
| 3659 | id_serializer_class = ChargeIdSerializer |
| 3660 | filter_backends = (filters.DjangoFilterBackend,) |
| 3661 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','slice','kind','state','date','object','amount','coreHours','invoice',) |
| 3662 | |
| 3663 | def get_serializer_class(self): |
| 3664 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3665 | if (no_hyperlinks): |
| 3666 | return self.id_serializer_class |
| 3667 | else: |
| 3668 | return self.serializer_class |
| 3669 | |
| 3670 | def get_queryset(self): |
| 3671 | return Charge.select_by_user(self.request.user) |
| 3672 | |
| 3673 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3674 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3675 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3676 | response = {"error": "validation", |
| 3677 | "specific_error": "not serializer.is_valid()",
|
| 3678 | "reasons": serializer.errors}
|
| 3679 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3680 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3681 | obj.caller = request.user |
| 3682 | if obj.can_update(request.user): |
| 3683 | return super(ChargeList, self).create(request, *args, **kwargs) |
| 3684 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3685 | raise Exception("failed obj.can_update") |
| 3686 | |
| 3687 | ret = super(ChargeList, self).create(request, *args, **kwargs) |
| 3688 | if (ret.status_code%100 != 200): |
| 3689 | raise Exception(ret.data) |
| 3690 | |
| 3691 | return ret |
| 3692 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3693 | |
| 3694 | class ChargeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3695 | queryset = Charge.objects.select_related().all() |
| 3696 | serializer_class = ChargeSerializer |
| 3697 | id_serializer_class = ChargeIdSerializer |
| 3698 | |
| 3699 | def get_serializer_class(self): |
| 3700 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3701 | if (no_hyperlinks): |
| 3702 | return self.id_serializer_class |
| 3703 | else: |
| 3704 | return self.serializer_class |
| 3705 | |
| 3706 | def get_queryset(self): |
| 3707 | return Charge.select_by_user(self.request.user) |
| 3708 | |
| 3709 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3710 | |
| 3711 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3712 | |
| 3713 | |
| 3714 | |
| 3715 | class RoleList(generics.ListCreateAPIView): |
| 3716 | queryset = Role.objects.select_related().all() |
| 3717 | serializer_class = RoleSerializer |
| 3718 | id_serializer_class = RoleIdSerializer |
| 3719 | filter_backends = (filters.DjangoFilterBackend,) |
| 3720 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role_type','role','description','content_type',) |
| 3721 | |
| 3722 | def get_serializer_class(self): |
| 3723 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3724 | if (no_hyperlinks): |
| 3725 | return self.id_serializer_class |
| 3726 | else: |
| 3727 | return self.serializer_class |
| 3728 | |
| 3729 | def get_queryset(self): |
| 3730 | return Role.select_by_user(self.request.user) |
| 3731 | |
| 3732 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3733 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3734 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3735 | response = {"error": "validation", |
| 3736 | "specific_error": "not serializer.is_valid()",
|
| 3737 | "reasons": serializer.errors}
|
| 3738 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3739 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3740 | obj.caller = request.user |
| 3741 | if obj.can_update(request.user): |
| 3742 | return super(RoleList, self).create(request, *args, **kwargs) |
| 3743 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3744 | raise Exception("failed obj.can_update") |
| 3745 | |
| 3746 | ret = super(RoleList, self).create(request, *args, **kwargs) |
| 3747 | if (ret.status_code%100 != 200): |
| 3748 | raise Exception(ret.data) |
| 3749 | |
| 3750 | return ret |
| 3751 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3752 | |
| 3753 | class RoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3754 | queryset = Role.objects.select_related().all() |
| 3755 | serializer_class = RoleSerializer |
| 3756 | id_serializer_class = RoleIdSerializer |
| 3757 | |
| 3758 | def get_serializer_class(self): |
| 3759 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3760 | if (no_hyperlinks): |
| 3761 | return self.id_serializer_class |
| 3762 | else: |
| 3763 | return self.serializer_class |
| 3764 | |
| 3765 | def get_queryset(self): |
| 3766 | return Role.select_by_user(self.request.user) |
| 3767 | |
| 3768 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3769 | |
| 3770 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3771 | |
| 3772 | |
| 3773 | |
| 3774 | class UsableObjectList(generics.ListCreateAPIView): |
| 3775 | queryset = UsableObject.objects.select_related().all() |
| 3776 | serializer_class = UsableObjectSerializer |
| 3777 | id_serializer_class = UsableObjectIdSerializer |
| 3778 | filter_backends = (filters.DjangoFilterBackend,) |
| 3779 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name',) |
| 3780 | |
| 3781 | def get_serializer_class(self): |
| 3782 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3783 | if (no_hyperlinks): |
| 3784 | return self.id_serializer_class |
| 3785 | else: |
| 3786 | return self.serializer_class |
| 3787 | |
| 3788 | def get_queryset(self): |
| 3789 | return UsableObject.select_by_user(self.request.user) |
| 3790 | |
| 3791 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3792 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3793 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3794 | response = {"error": "validation", |
| 3795 | "specific_error": "not serializer.is_valid()",
|
| 3796 | "reasons": serializer.errors}
|
| 3797 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3798 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3799 | obj.caller = request.user |
| 3800 | if obj.can_update(request.user): |
| 3801 | return super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3802 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3803 | raise Exception("failed obj.can_update") |
| 3804 | |
| 3805 | ret = super(UsableObjectList, self).create(request, *args, **kwargs) |
| 3806 | if (ret.status_code%100 != 200): |
| 3807 | raise Exception(ret.data) |
| 3808 | |
| 3809 | return ret |
| 3810 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3811 | |
| 3812 | class UsableObjectDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3813 | queryset = UsableObject.objects.select_related().all() |
| 3814 | serializer_class = UsableObjectSerializer |
| 3815 | id_serializer_class = UsableObjectIdSerializer |
| 3816 | |
| 3817 | def get_serializer_class(self): |
| 3818 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3819 | if (no_hyperlinks): |
| 3820 | return self.id_serializer_class |
| 3821 | else: |
| 3822 | return self.serializer_class |
| 3823 | |
| 3824 | def get_queryset(self): |
| 3825 | return UsableObject.select_by_user(self.request.user) |
| 3826 | |
| 3827 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3828 | |
| 3829 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3830 | |
| 3831 | |
| 3832 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 3833 | class ControllerSiteDeploymentsList(generics.ListCreateAPIView): |
| 3834 | queryset = ControllerSiteDeployments.objects.select_related().all() |
| 3835 | serializer_class = ControllerSiteDeploymentsSerializer |
| 3836 | id_serializer_class = ControllerSiteDeploymentsIdSerializer |
| 3837 | filter_backends = (filters.DjangoFilterBackend,) |
| 3838 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','site_deployment','tenant_id',) |
| 3839 | |
| 3840 | def get_serializer_class(self): |
| 3841 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3842 | if (no_hyperlinks): |
| 3843 | return self.id_serializer_class |
| 3844 | else: |
| 3845 | return self.serializer_class |
| 3846 | |
| 3847 | def get_queryset(self): |
| 3848 | return ControllerSiteDeployments.select_by_user(self.request.user) |
| 3849 | |
| 3850 | def create(self, request, *args, **kwargs): |
| 3851 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3852 | if not (serializer.is_valid()): |
| 3853 | response = {"error": "validation", |
| 3854 | "specific_error": "not serializer.is_valid()",
|
| 3855 | "reasons": serializer.errors}
|
| 3856 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 3857 | obj = serializer.object |
| 3858 | obj.caller = request.user |
| 3859 | if obj.can_update(request.user): |
| 3860 | return super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs) |
| 3861 | else: |
| 3862 | raise Exception("failed obj.can_update") |
| 3863 | |
| 3864 | ret = super(ControllerSiteDeploymentsList, self).create(request, *args, **kwargs) |
| 3865 | if (ret.status_code%100 != 200): |
| 3866 | raise Exception(ret.data) |
| 3867 | |
| 3868 | return ret |
| 3869 | |
| 3870 | |
| 3871 | class ControllerSiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3872 | queryset = ControllerSiteDeployments.objects.select_related().all() |
| 3873 | serializer_class = ControllerSiteDeploymentsSerializer |
| 3874 | id_serializer_class = ControllerSiteDeploymentsIdSerializer |
| 3875 | |
| 3876 | def get_serializer_class(self): |
| 3877 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3878 | if (no_hyperlinks): |
| 3879 | return self.id_serializer_class |
| 3880 | else: |
| 3881 | return self.serializer_class |
| 3882 | |
| 3883 | def get_queryset(self): |
| 3884 | return ControllerSiteDeployments.select_by_user(self.request.user) |
| 3885 | |
| 3886 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3887 | |
| 3888 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3889 | |
| 3890 | |
| 3891 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3892 | class SiteRoleList(generics.ListCreateAPIView): |
| 3893 | queryset = SiteRole.objects.select_related().all() |
| 3894 | serializer_class = SiteRoleSerializer |
| 3895 | id_serializer_class = SiteRoleIdSerializer |
| 3896 | filter_backends = (filters.DjangoFilterBackend,) |
| 3897 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 3898 | |
| 3899 | def get_serializer_class(self): |
| 3900 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3901 | if (no_hyperlinks): |
| 3902 | return self.id_serializer_class |
| 3903 | else: |
| 3904 | return self.serializer_class |
| 3905 | |
| 3906 | def get_queryset(self): |
| 3907 | return SiteRole.select_by_user(self.request.user) |
| 3908 | |
| 3909 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3910 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3911 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3912 | response = {"error": "validation", |
| 3913 | "specific_error": "not serializer.is_valid()",
|
| 3914 | "reasons": serializer.errors}
|
| 3915 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3916 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3917 | obj.caller = request.user |
| 3918 | if obj.can_update(request.user): |
| 3919 | return super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3920 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3921 | raise Exception("failed obj.can_update") |
| 3922 | |
| 3923 | ret = super(SiteRoleList, self).create(request, *args, **kwargs) |
| 3924 | if (ret.status_code%100 != 200): |
| 3925 | raise Exception(ret.data) |
| 3926 | |
| 3927 | return ret |
| 3928 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3929 | |
| 3930 | class SiteRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3931 | queryset = SiteRole.objects.select_related().all() |
| 3932 | serializer_class = SiteRoleSerializer |
| 3933 | id_serializer_class = SiteRoleIdSerializer |
| 3934 | |
| 3935 | def get_serializer_class(self): |
| 3936 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3937 | if (no_hyperlinks): |
| 3938 | return self.id_serializer_class |
| 3939 | else: |
| 3940 | return self.serializer_class |
| 3941 | |
| 3942 | def get_queryset(self): |
| 3943 | return SiteRole.select_by_user(self.request.user) |
| 3944 | |
| 3945 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3946 | |
| 3947 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 3948 | |
| 3949 | |
| 3950 | |
| 3951 | class SliceCredentialList(generics.ListCreateAPIView): |
| 3952 | queryset = SliceCredential.objects.select_related().all() |
| 3953 | serializer_class = SliceCredentialSerializer |
| 3954 | id_serializer_class = SliceCredentialIdSerializer |
| 3955 | filter_backends = (filters.DjangoFilterBackend,) |
| 3956 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','key_id','enc_value',) |
| 3957 | |
| 3958 | def get_serializer_class(self): |
| 3959 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3960 | if (no_hyperlinks): |
| 3961 | return self.id_serializer_class |
| 3962 | else: |
| 3963 | return self.serializer_class |
| 3964 | |
| 3965 | def get_queryset(self): |
| 3966 | return SliceCredential.select_by_user(self.request.user) |
| 3967 | |
| 3968 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3969 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 3970 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 3971 | response = {"error": "validation", |
| 3972 | "specific_error": "not serializer.is_valid()",
|
| 3973 | "reasons": serializer.errors}
|
| 3974 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 3975 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3976 | obj.caller = request.user |
| 3977 | if obj.can_update(request.user): |
| 3978 | return super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3979 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 3980 | raise Exception("failed obj.can_update") |
| 3981 | |
| 3982 | ret = super(SliceCredentialList, self).create(request, *args, **kwargs) |
| 3983 | if (ret.status_code%100 != 200): |
| 3984 | raise Exception(ret.data) |
| 3985 | |
| 3986 | return ret |
| 3987 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 3988 | |
| 3989 | class SliceCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 3990 | queryset = SliceCredential.objects.select_related().all() |
| 3991 | serializer_class = SliceCredentialSerializer |
| 3992 | id_serializer_class = SliceCredentialIdSerializer |
| 3993 | |
| 3994 | def get_serializer_class(self): |
| 3995 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 3996 | if (no_hyperlinks): |
| 3997 | return self.id_serializer_class |
| 3998 | else: |
| 3999 | return self.serializer_class |
| 4000 | |
| 4001 | def get_queryset(self): |
| 4002 | return SliceCredential.select_by_user(self.request.user) |
| 4003 | |
| 4004 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4005 | |
| 4006 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4007 | |
| 4008 | |
| 4009 | |
| 4010 | class SliverList(generics.ListCreateAPIView): |
| 4011 | queryset = Sliver.objects.select_related().all() |
| 4012 | serializer_class = SliverSerializer |
| 4013 | id_serializer_class = SliverIdSerializer |
| 4014 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4015 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','instance_id','name','instance_name','ip','image','creator','slice','node','controllerNetwork','numberCores','flavor','userData','networks',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4016 | |
| 4017 | def get_serializer_class(self): |
| 4018 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4019 | if (no_hyperlinks): |
| 4020 | return self.id_serializer_class |
| 4021 | else: |
| 4022 | return self.serializer_class |
| 4023 | |
| 4024 | def get_queryset(self): |
| 4025 | return Sliver.select_by_user(self.request.user) |
| 4026 | |
| 4027 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4028 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4029 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4030 | response = {"error": "validation", |
| 4031 | "specific_error": "not serializer.is_valid()",
|
| 4032 | "reasons": serializer.errors}
|
| 4033 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4034 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4035 | obj.caller = request.user |
| 4036 | if obj.can_update(request.user): |
| 4037 | return super(SliverList, self).create(request, *args, **kwargs) |
| 4038 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4039 | raise Exception("failed obj.can_update") |
| 4040 | |
| 4041 | ret = super(SliverList, self).create(request, *args, **kwargs) |
| 4042 | if (ret.status_code%100 != 200): |
| 4043 | raise Exception(ret.data) |
| 4044 | |
| 4045 | return ret |
| 4046 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4047 | |
| 4048 | class SliverDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4049 | queryset = Sliver.objects.select_related().all() |
| 4050 | serializer_class = SliverSerializer |
| 4051 | id_serializer_class = SliverIdSerializer |
| 4052 | |
| 4053 | def get_serializer_class(self): |
| 4054 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4055 | if (no_hyperlinks): |
| 4056 | return self.id_serializer_class |
| 4057 | else: |
| 4058 | return self.serializer_class |
| 4059 | |
| 4060 | def get_queryset(self): |
| 4061 | return Sliver.select_by_user(self.request.user) |
| 4062 | |
| 4063 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4064 | |
| 4065 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4066 | |
| 4067 | |
| 4068 | |
| 4069 | class NodeList(generics.ListCreateAPIView): |
| 4070 | queryset = Node.objects.select_related().all() |
| 4071 | serializer_class = NodeSerializer |
| 4072 | id_serializer_class = NodeIdSerializer |
| 4073 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4074 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','site_deployment',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4075 | |
| 4076 | def get_serializer_class(self): |
| 4077 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4078 | if (no_hyperlinks): |
| 4079 | return self.id_serializer_class |
| 4080 | else: |
| 4081 | return self.serializer_class |
| 4082 | |
| 4083 | def get_queryset(self): |
| 4084 | return Node.select_by_user(self.request.user) |
| 4085 | |
| 4086 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4087 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4088 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4089 | response = {"error": "validation", |
| 4090 | "specific_error": "not serializer.is_valid()",
|
| 4091 | "reasons": serializer.errors}
|
| 4092 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4093 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4094 | obj.caller = request.user |
| 4095 | if obj.can_update(request.user): |
| 4096 | return super(NodeList, self).create(request, *args, **kwargs) |
| 4097 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4098 | raise Exception("failed obj.can_update") |
| 4099 | |
| 4100 | ret = super(NodeList, self).create(request, *args, **kwargs) |
| 4101 | if (ret.status_code%100 != 200): |
| 4102 | raise Exception(ret.data) |
| 4103 | |
| 4104 | return ret |
| 4105 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4106 | |
| 4107 | class NodeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4108 | queryset = Node.objects.select_related().all() |
| 4109 | serializer_class = NodeSerializer |
| 4110 | id_serializer_class = NodeIdSerializer |
| 4111 | |
| 4112 | def get_serializer_class(self): |
| 4113 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4114 | if (no_hyperlinks): |
| 4115 | return self.id_serializer_class |
| 4116 | else: |
| 4117 | return self.serializer_class |
| 4118 | |
| 4119 | def get_queryset(self): |
| 4120 | return Node.select_by_user(self.request.user) |
| 4121 | |
| 4122 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4123 | |
| 4124 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4125 | |
| 4126 | |
| 4127 | |
| 4128 | class DashboardViewList(generics.ListCreateAPIView): |
| 4129 | queryset = DashboardView.objects.select_related().all() |
| 4130 | serializer_class = DashboardViewSerializer |
| 4131 | id_serializer_class = DashboardViewIdSerializer |
| 4132 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4133 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','url','controllers',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4134 | |
| 4135 | def get_serializer_class(self): |
| 4136 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4137 | if (no_hyperlinks): |
| 4138 | return self.id_serializer_class |
| 4139 | else: |
| 4140 | return self.serializer_class |
| 4141 | |
| 4142 | def get_queryset(self): |
| 4143 | return DashboardView.select_by_user(self.request.user) |
| 4144 | |
| 4145 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4146 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4147 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4148 | response = {"error": "validation", |
| 4149 | "specific_error": "not serializer.is_valid()",
|
| 4150 | "reasons": serializer.errors}
|
| 4151 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4152 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4153 | obj.caller = request.user |
| 4154 | if obj.can_update(request.user): |
| 4155 | return super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4156 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4157 | raise Exception("failed obj.can_update") |
| 4158 | |
| 4159 | ret = super(DashboardViewList, self).create(request, *args, **kwargs) |
| 4160 | if (ret.status_code%100 != 200): |
| 4161 | raise Exception(ret.data) |
| 4162 | |
| 4163 | return ret |
| 4164 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4165 | |
| 4166 | class DashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4167 | queryset = DashboardView.objects.select_related().all() |
| 4168 | serializer_class = DashboardViewSerializer |
| 4169 | id_serializer_class = DashboardViewIdSerializer |
| 4170 | |
| 4171 | def get_serializer_class(self): |
| 4172 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4173 | if (no_hyperlinks): |
| 4174 | return self.id_serializer_class |
| 4175 | else: |
| 4176 | return self.serializer_class |
| 4177 | |
| 4178 | def get_queryset(self): |
| 4179 | return DashboardView.select_by_user(self.request.user) |
| 4180 | |
| 4181 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4182 | |
| 4183 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4184 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4185 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4186 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4187 | class ImageDeploymentsList(generics.ListCreateAPIView): |
| 4188 | queryset = ImageDeployments.objects.select_related().all() |
| 4189 | serializer_class = ImageDeploymentsSerializer |
| 4190 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4191 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4192 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','image','deployment',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4193 | |
| 4194 | def get_serializer_class(self): |
| 4195 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4196 | if (no_hyperlinks): |
| 4197 | return self.id_serializer_class |
| 4198 | else: |
| 4199 | return self.serializer_class |
| 4200 | |
| 4201 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4202 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4203 | |
| 4204 | def create(self, request, *args, **kwargs): |
| 4205 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4206 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4207 | response = {"error": "validation", |
| 4208 | "specific_error": "not serializer.is_valid()",
|
| 4209 | "reasons": serializer.errors}
|
| 4210 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4211 | obj = serializer.object |
| 4212 | obj.caller = request.user |
| 4213 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4214 | return super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4215 | else: |
| 4216 | raise Exception("failed obj.can_update") |
| 4217 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4218 | ret = super(ImageDeploymentsList, self).create(request, *args, **kwargs) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4219 | if (ret.status_code%100 != 200): |
| 4220 | raise Exception(ret.data) |
| 4221 | |
| 4222 | return ret |
| 4223 | |
| 4224 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4225 | class ImageDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4226 | queryset = ImageDeployments.objects.select_related().all() |
| 4227 | serializer_class = ImageDeploymentsSerializer |
| 4228 | id_serializer_class = ImageDeploymentsIdSerializer |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4229 | |
| 4230 | def get_serializer_class(self): |
| 4231 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4232 | if (no_hyperlinks): |
| 4233 | return self.id_serializer_class |
| 4234 | else: |
| 4235 | return self.serializer_class |
| 4236 | |
| 4237 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4238 | return ImageDeployments.select_by_user(self.request.user) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4239 | |
| 4240 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4241 | |
| 4242 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4243 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4244 | |
| 4245 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4246 | class ReservedResourceList(generics.ListCreateAPIView): |
| 4247 | queryset = ReservedResource.objects.select_related().all() |
| 4248 | serializer_class = ReservedResourceSerializer |
| 4249 | id_serializer_class = ReservedResourceIdSerializer |
| 4250 | filter_backends = (filters.DjangoFilterBackend,) |
| 4251 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','sliver','resource','quantity','reservationSet',) |
| 4252 | |
| 4253 | def get_serializer_class(self): |
| 4254 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4255 | if (no_hyperlinks): |
| 4256 | return self.id_serializer_class |
| 4257 | else: |
| 4258 | return self.serializer_class |
| 4259 | |
| 4260 | def get_queryset(self): |
| 4261 | return ReservedResource.select_by_user(self.request.user) |
| 4262 | |
| 4263 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4264 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4265 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4266 | response = {"error": "validation", |
| 4267 | "specific_error": "not serializer.is_valid()",
|
| 4268 | "reasons": serializer.errors}
|
| 4269 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4270 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4271 | obj.caller = request.user |
| 4272 | if obj.can_update(request.user): |
| 4273 | return super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4274 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4275 | raise Exception("failed obj.can_update") |
| 4276 | |
| 4277 | ret = super(ReservedResourceList, self).create(request, *args, **kwargs) |
| 4278 | if (ret.status_code%100 != 200): |
| 4279 | raise Exception(ret.data) |
| 4280 | |
| 4281 | return ret |
| 4282 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4283 | |
| 4284 | class ReservedResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4285 | queryset = ReservedResource.objects.select_related().all() |
| 4286 | serializer_class = ReservedResourceSerializer |
| 4287 | id_serializer_class = ReservedResourceIdSerializer |
| 4288 | |
| 4289 | def get_serializer_class(self): |
| 4290 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4291 | if (no_hyperlinks): |
| 4292 | return self.id_serializer_class |
| 4293 | else: |
| 4294 | return self.serializer_class |
| 4295 | |
| 4296 | def get_queryset(self): |
| 4297 | return ReservedResource.select_by_user(self.request.user) |
| 4298 | |
| 4299 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4300 | |
| 4301 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4302 | |
| 4303 | |
| 4304 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4305 | class PaymentList(generics.ListCreateAPIView): |
| 4306 | queryset = Payment.objects.select_related().all() |
| 4307 | serializer_class = PaymentSerializer |
| 4308 | id_serializer_class = PaymentIdSerializer |
| 4309 | filter_backends = (filters.DjangoFilterBackend,) |
| 4310 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','account','amount','date',) |
| 4311 | |
| 4312 | def get_serializer_class(self): |
| 4313 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4314 | if (no_hyperlinks): |
| 4315 | return self.id_serializer_class |
| 4316 | else: |
| 4317 | return self.serializer_class |
| 4318 | |
| 4319 | def get_queryset(self): |
| 4320 | return Payment.select_by_user(self.request.user) |
| 4321 | |
| 4322 | def create(self, request, *args, **kwargs): |
| 4323 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4324 | if not (serializer.is_valid()): |
| 4325 | response = {"error": "validation", |
| 4326 | "specific_error": "not serializer.is_valid()",
|
| 4327 | "reasons": serializer.errors}
|
| 4328 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4329 | obj = serializer.object |
| 4330 | obj.caller = request.user |
| 4331 | if obj.can_update(request.user): |
| 4332 | return super(PaymentList, self).create(request, *args, **kwargs) |
| 4333 | else: |
| 4334 | raise Exception("failed obj.can_update") |
| 4335 | |
| 4336 | ret = super(PaymentList, self).create(request, *args, **kwargs) |
| 4337 | if (ret.status_code%100 != 200): |
| 4338 | raise Exception(ret.data) |
| 4339 | |
| 4340 | return ret |
| 4341 | |
| 4342 | |
| 4343 | class PaymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4344 | queryset = Payment.objects.select_related().all() |
| 4345 | serializer_class = PaymentSerializer |
| 4346 | id_serializer_class = PaymentIdSerializer |
| 4347 | |
| 4348 | def get_serializer_class(self): |
| 4349 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4350 | if (no_hyperlinks): |
| 4351 | return self.id_serializer_class |
| 4352 | else: |
| 4353 | return self.serializer_class |
| 4354 | |
| 4355 | def get_queryset(self): |
| 4356 | return Payment.select_by_user(self.request.user) |
| 4357 | |
| 4358 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4359 | |
| 4360 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4361 | |
| 4362 | |
| 4363 | |
| 4364 | class NetworkTemplateList(generics.ListCreateAPIView): |
| 4365 | queryset = NetworkTemplate.objects.select_related().all() |
| 4366 | serializer_class = NetworkTemplateSerializer |
| 4367 | id_serializer_class = NetworkTemplateIdSerializer |
| 4368 | filter_backends = (filters.DjangoFilterBackend,) |
| 4369 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description','guaranteedBandwidth','visibility','translation','sharedNetworkName','sharedNetworkId','topologyKind','controllerKind',) |
| 4370 | |
| 4371 | def get_serializer_class(self): |
| 4372 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4373 | if (no_hyperlinks): |
| 4374 | return self.id_serializer_class |
| 4375 | else: |
| 4376 | return self.serializer_class |
| 4377 | |
| 4378 | def get_queryset(self): |
| 4379 | return NetworkTemplate.select_by_user(self.request.user) |
| 4380 | |
| 4381 | def create(self, request, *args, **kwargs): |
| 4382 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4383 | if not (serializer.is_valid()): |
| 4384 | response = {"error": "validation", |
| 4385 | "specific_error": "not serializer.is_valid()",
|
| 4386 | "reasons": serializer.errors}
|
| 4387 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4388 | obj = serializer.object |
| 4389 | obj.caller = request.user |
| 4390 | if obj.can_update(request.user): |
| 4391 | return super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 4392 | else: |
| 4393 | raise Exception("failed obj.can_update") |
| 4394 | |
| 4395 | ret = super(NetworkTemplateList, self).create(request, *args, **kwargs) |
| 4396 | if (ret.status_code%100 != 200): |
| 4397 | raise Exception(ret.data) |
| 4398 | |
| 4399 | return ret |
| 4400 | |
| 4401 | |
| 4402 | class NetworkTemplateDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4403 | queryset = NetworkTemplate.objects.select_related().all() |
| 4404 | serializer_class = NetworkTemplateSerializer |
| 4405 | id_serializer_class = NetworkTemplateIdSerializer |
| 4406 | |
| 4407 | def get_serializer_class(self): |
| 4408 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4409 | if (no_hyperlinks): |
| 4410 | return self.id_serializer_class |
| 4411 | else: |
| 4412 | return self.serializer_class |
| 4413 | |
| 4414 | def get_queryset(self): |
| 4415 | return NetworkTemplate.select_by_user(self.request.user) |
| 4416 | |
| 4417 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4418 | |
| 4419 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4420 | |
| 4421 | |
| 4422 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4423 | class NetworkSliceList(generics.ListCreateAPIView): |
| 4424 | queryset = NetworkSlice.objects.select_related().all() |
| 4425 | serializer_class = NetworkSliceSerializer |
| 4426 | id_serializer_class = NetworkSliceIdSerializer |
| 4427 | filter_backends = (filters.DjangoFilterBackend,) |
| 4428 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','network','slice',) |
| 4429 | |
| 4430 | def get_serializer_class(self): |
| 4431 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4432 | if (no_hyperlinks): |
| 4433 | return self.id_serializer_class |
| 4434 | else: |
| 4435 | return self.serializer_class |
| 4436 | |
| 4437 | def get_queryset(self): |
| 4438 | return NetworkSlice.select_by_user(self.request.user) |
| 4439 | |
| 4440 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4441 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4442 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4443 | response = {"error": "validation", |
| 4444 | "specific_error": "not serializer.is_valid()",
|
| 4445 | "reasons": serializer.errors}
|
| 4446 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4447 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4448 | obj.caller = request.user |
| 4449 | if obj.can_update(request.user): |
| 4450 | return super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4451 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4452 | raise Exception("failed obj.can_update") |
| 4453 | |
| 4454 | ret = super(NetworkSliceList, self).create(request, *args, **kwargs) |
| 4455 | if (ret.status_code%100 != 200): |
| 4456 | raise Exception(ret.data) |
| 4457 | |
| 4458 | return ret |
| 4459 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4460 | |
| 4461 | class NetworkSliceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4462 | queryset = NetworkSlice.objects.select_related().all() |
| 4463 | serializer_class = NetworkSliceSerializer |
| 4464 | id_serializer_class = NetworkSliceIdSerializer |
| 4465 | |
| 4466 | def get_serializer_class(self): |
| 4467 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4468 | if (no_hyperlinks): |
| 4469 | return self.id_serializer_class |
| 4470 | else: |
| 4471 | return self.serializer_class |
| 4472 | |
| 4473 | def get_queryset(self): |
| 4474 | return NetworkSlice.select_by_user(self.request.user) |
| 4475 | |
| 4476 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4477 | |
| 4478 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4479 | |
| 4480 | |
| 4481 | |
| 4482 | class UserDashboardViewList(generics.ListCreateAPIView): |
| 4483 | queryset = UserDashboardView.objects.select_related().all() |
| 4484 | serializer_class = UserDashboardViewSerializer |
| 4485 | id_serializer_class = UserDashboardViewIdSerializer |
| 4486 | filter_backends = (filters.DjangoFilterBackend,) |
| 4487 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','dashboardView','order',) |
| 4488 | |
| 4489 | def get_serializer_class(self): |
| 4490 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4491 | if (no_hyperlinks): |
| 4492 | return self.id_serializer_class |
| 4493 | else: |
| 4494 | return self.serializer_class |
| 4495 | |
| 4496 | def get_queryset(self): |
| 4497 | return UserDashboardView.select_by_user(self.request.user) |
| 4498 | |
| 4499 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4500 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4501 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4502 | response = {"error": "validation", |
| 4503 | "specific_error": "not serializer.is_valid()",
|
| 4504 | "reasons": serializer.errors}
|
| 4505 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4506 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4507 | obj.caller = request.user |
| 4508 | if obj.can_update(request.user): |
| 4509 | return super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4510 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4511 | raise Exception("failed obj.can_update") |
| 4512 | |
| 4513 | ret = super(UserDashboardViewList, self).create(request, *args, **kwargs) |
| 4514 | if (ret.status_code%100 != 200): |
| 4515 | raise Exception(ret.data) |
| 4516 | |
| 4517 | return ret |
| 4518 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4519 | |
| 4520 | class UserDashboardViewDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4521 | queryset = UserDashboardView.objects.select_related().all() |
| 4522 | serializer_class = UserDashboardViewSerializer |
| 4523 | id_serializer_class = UserDashboardViewIdSerializer |
| 4524 | |
| 4525 | def get_serializer_class(self): |
| 4526 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4527 | if (no_hyperlinks): |
| 4528 | return self.id_serializer_class |
| 4529 | else: |
| 4530 | return self.serializer_class |
| 4531 | |
| 4532 | def get_queryset(self): |
| 4533 | return UserDashboardView.select_by_user(self.request.user) |
| 4534 | |
| 4535 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4536 | |
| 4537 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4538 | |
| 4539 | |
| 4540 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4541 | class ControllerList(generics.ListCreateAPIView): |
| 4542 | queryset = Controller.objects.select_related().all() |
| 4543 | serializer_class = ControllerSerializer |
| 4544 | id_serializer_class = ControllerIdSerializer |
| 4545 | filter_backends = (filters.DjangoFilterBackend,) |
| 4546 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','version','backend_type','auth_url','admin_user','admin_password','admin_tenant','dashboardviews',) |
| 4547 | |
| 4548 | def get_serializer_class(self): |
| 4549 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4550 | if (no_hyperlinks): |
| 4551 | return self.id_serializer_class |
| 4552 | else: |
| 4553 | return self.serializer_class |
| 4554 | |
| 4555 | def get_queryset(self): |
| 4556 | return Controller.select_by_user(self.request.user) |
| 4557 | |
| 4558 | def create(self, request, *args, **kwargs): |
| 4559 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4560 | if not (serializer.is_valid()): |
| 4561 | response = {"error": "validation", |
| 4562 | "specific_error": "not serializer.is_valid()",
|
| 4563 | "reasons": serializer.errors}
|
| 4564 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 4565 | obj = serializer.object |
| 4566 | obj.caller = request.user |
| 4567 | if obj.can_update(request.user): |
| 4568 | return super(ControllerList, self).create(request, *args, **kwargs) |
| 4569 | else: |
| 4570 | raise Exception("failed obj.can_update") |
| 4571 | |
| 4572 | ret = super(ControllerList, self).create(request, *args, **kwargs) |
| 4573 | if (ret.status_code%100 != 200): |
| 4574 | raise Exception(ret.data) |
| 4575 | |
| 4576 | return ret |
| 4577 | |
| 4578 | |
| 4579 | class ControllerDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4580 | queryset = Controller.objects.select_related().all() |
| 4581 | serializer_class = ControllerSerializer |
| 4582 | id_serializer_class = ControllerIdSerializer |
| 4583 | |
| 4584 | def get_serializer_class(self): |
| 4585 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4586 | if (no_hyperlinks): |
| 4587 | return self.id_serializer_class |
| 4588 | else: |
| 4589 | return self.serializer_class |
| 4590 | |
| 4591 | def get_queryset(self): |
| 4592 | return Controller.select_by_user(self.request.user) |
| 4593 | |
| 4594 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4595 | |
| 4596 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4597 | |
| 4598 | |
| 4599 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4600 | class PlanetStackPrivilegeList(generics.ListCreateAPIView): |
| 4601 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4602 | serializer_class = PlanetStackPrivilegeSerializer |
| 4603 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4604 | filter_backends = (filters.DjangoFilterBackend,) |
| 4605 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','planetstack','role',) |
| 4606 | |
| 4607 | def get_serializer_class(self): |
| 4608 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4609 | if (no_hyperlinks): |
| 4610 | return self.id_serializer_class |
| 4611 | else: |
| 4612 | return self.serializer_class |
| 4613 | |
| 4614 | def get_queryset(self): |
| 4615 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4616 | |
| 4617 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4618 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4619 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4620 | response = {"error": "validation", |
| 4621 | "specific_error": "not serializer.is_valid()",
|
| 4622 | "reasons": serializer.errors}
|
| 4623 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4624 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4625 | obj.caller = request.user |
| 4626 | if obj.can_update(request.user): |
| 4627 | return super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4628 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4629 | raise Exception("failed obj.can_update") |
| 4630 | |
| 4631 | ret = super(PlanetStackPrivilegeList, self).create(request, *args, **kwargs) |
| 4632 | if (ret.status_code%100 != 200): |
| 4633 | raise Exception(ret.data) |
| 4634 | |
| 4635 | return ret |
| 4636 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4637 | |
| 4638 | class PlanetStackPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4639 | queryset = PlanetStackPrivilege.objects.select_related().all() |
| 4640 | serializer_class = PlanetStackPrivilegeSerializer |
| 4641 | id_serializer_class = PlanetStackPrivilegeIdSerializer |
| 4642 | |
| 4643 | def get_serializer_class(self): |
| 4644 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4645 | if (no_hyperlinks): |
| 4646 | return self.id_serializer_class |
| 4647 | else: |
| 4648 | return self.serializer_class |
| 4649 | |
| 4650 | def get_queryset(self): |
| 4651 | return PlanetStackPrivilege.select_by_user(self.request.user) |
| 4652 | |
| 4653 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4654 | |
| 4655 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4656 | |
| 4657 | |
| 4658 | |
| 4659 | class UserList(generics.ListCreateAPIView): |
| 4660 | queryset = User.objects.select_related().all() |
| 4661 | serializer_class = UserSerializer |
| 4662 | id_serializer_class = UserIdSerializer |
| 4663 | filter_backends = (filters.DjangoFilterBackend,) |
| 4664 | 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',) |
| 4665 | |
| 4666 | def get_serializer_class(self): |
| 4667 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4668 | if (no_hyperlinks): |
| 4669 | return self.id_serializer_class |
| 4670 | else: |
| 4671 | return self.serializer_class |
| 4672 | |
| 4673 | def get_queryset(self): |
| 4674 | return User.select_by_user(self.request.user) |
| 4675 | |
| 4676 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4677 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4678 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4679 | response = {"error": "validation", |
| 4680 | "specific_error": "not serializer.is_valid()",
|
| 4681 | "reasons": serializer.errors}
|
| 4682 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4683 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4684 | obj.caller = request.user |
| 4685 | if obj.can_update(request.user): |
| 4686 | return super(UserList, self).create(request, *args, **kwargs) |
| 4687 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4688 | raise Exception("failed obj.can_update") |
| 4689 | |
| 4690 | ret = super(UserList, self).create(request, *args, **kwargs) |
| 4691 | if (ret.status_code%100 != 200): |
| 4692 | raise Exception(ret.data) |
| 4693 | |
| 4694 | return ret |
| 4695 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4696 | |
| 4697 | class UserDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4698 | queryset = User.objects.select_related().all() |
| 4699 | serializer_class = UserSerializer |
| 4700 | id_serializer_class = UserIdSerializer |
| 4701 | |
| 4702 | def get_serializer_class(self): |
| 4703 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4704 | if (no_hyperlinks): |
| 4705 | return self.id_serializer_class |
| 4706 | else: |
| 4707 | return self.serializer_class |
| 4708 | |
| 4709 | def get_queryset(self): |
| 4710 | return User.select_by_user(self.request.user) |
| 4711 | |
| 4712 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4713 | |
| 4714 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4715 | |
| 4716 | |
| 4717 | |
| 4718 | class DeploymentList(generics.ListCreateAPIView): |
| 4719 | queryset = Deployment.objects.select_related().all() |
| 4720 | serializer_class = DeploymentSerializer |
| 4721 | id_serializer_class = DeploymentIdSerializer |
| 4722 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 4723 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','accessControl','flavors','sites',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4724 | |
| 4725 | def get_serializer_class(self): |
| 4726 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4727 | if (no_hyperlinks): |
| 4728 | return self.id_serializer_class |
| 4729 | else: |
| 4730 | return self.serializer_class |
| 4731 | |
| 4732 | def get_queryset(self): |
| 4733 | return Deployment.select_by_user(self.request.user) |
| 4734 | |
| 4735 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4736 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4737 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4738 | response = {"error": "validation", |
| 4739 | "specific_error": "not serializer.is_valid()",
|
| 4740 | "reasons": serializer.errors}
|
| 4741 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4742 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4743 | obj.caller = request.user |
| 4744 | if obj.can_update(request.user): |
| 4745 | return super(DeploymentList, self).create(request, *args, **kwargs) |
| 4746 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4747 | raise Exception("failed obj.can_update") |
| 4748 | |
| 4749 | ret = super(DeploymentList, self).create(request, *args, **kwargs) |
| 4750 | if (ret.status_code%100 != 200): |
| 4751 | raise Exception(ret.data) |
| 4752 | |
| 4753 | return ret |
| 4754 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4755 | |
| 4756 | class DeploymentDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4757 | queryset = Deployment.objects.select_related().all() |
| 4758 | serializer_class = DeploymentSerializer |
| 4759 | id_serializer_class = DeploymentIdSerializer |
| 4760 | |
| 4761 | def get_serializer_class(self): |
| 4762 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4763 | if (no_hyperlinks): |
| 4764 | return self.id_serializer_class |
| 4765 | else: |
| 4766 | return self.serializer_class |
| 4767 | |
| 4768 | def get_queryset(self): |
| 4769 | return Deployment.select_by_user(self.request.user) |
| 4770 | |
| 4771 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4772 | |
| 4773 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4774 | |
| 4775 | |
| 4776 | |
| 4777 | class ReservationList(generics.ListCreateAPIView): |
| 4778 | queryset = Reservation.objects.select_related().all() |
| 4779 | serializer_class = ReservationSerializer |
| 4780 | id_serializer_class = ReservationIdSerializer |
| 4781 | filter_backends = (filters.DjangoFilterBackend,) |
| 4782 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','startTime','slice','duration',) |
| 4783 | |
| 4784 | def get_serializer_class(self): |
| 4785 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4786 | if (no_hyperlinks): |
| 4787 | return self.id_serializer_class |
| 4788 | else: |
| 4789 | return self.serializer_class |
| 4790 | |
| 4791 | def get_queryset(self): |
| 4792 | return Reservation.select_by_user(self.request.user) |
| 4793 | |
| 4794 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4795 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4796 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4797 | response = {"error": "validation", |
| 4798 | "specific_error": "not serializer.is_valid()",
|
| 4799 | "reasons": serializer.errors}
|
| 4800 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4801 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4802 | obj.caller = request.user |
| 4803 | if obj.can_update(request.user): |
| 4804 | return super(ReservationList, self).create(request, *args, **kwargs) |
| 4805 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4806 | raise Exception("failed obj.can_update") |
| 4807 | |
| 4808 | ret = super(ReservationList, self).create(request, *args, **kwargs) |
| 4809 | if (ret.status_code%100 != 200): |
| 4810 | raise Exception(ret.data) |
| 4811 | |
| 4812 | return ret |
| 4813 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4814 | |
| 4815 | class ReservationDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4816 | queryset = Reservation.objects.select_related().all() |
| 4817 | serializer_class = ReservationSerializer |
| 4818 | id_serializer_class = ReservationIdSerializer |
| 4819 | |
| 4820 | def get_serializer_class(self): |
| 4821 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4822 | if (no_hyperlinks): |
| 4823 | return self.id_serializer_class |
| 4824 | else: |
| 4825 | return self.serializer_class |
| 4826 | |
| 4827 | def get_queryset(self): |
| 4828 | return Reservation.select_by_user(self.request.user) |
| 4829 | |
| 4830 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4831 | |
| 4832 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4833 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4834 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4835 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4836 | class SitePrivilegeList(generics.ListCreateAPIView): |
| 4837 | queryset = SitePrivilege.objects.select_related().all() |
| 4838 | serializer_class = SitePrivilegeSerializer |
| 4839 | id_serializer_class = SitePrivilegeIdSerializer |
| 4840 | filter_backends = (filters.DjangoFilterBackend,) |
| 4841 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','site','role',) |
| 4842 | |
| 4843 | def get_serializer_class(self): |
| 4844 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4845 | if (no_hyperlinks): |
| 4846 | return self.id_serializer_class |
| 4847 | else: |
| 4848 | return self.serializer_class |
| 4849 | |
| 4850 | def get_queryset(self): |
| 4851 | return SitePrivilege.select_by_user(self.request.user) |
| 4852 | |
| 4853 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4854 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4855 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4856 | response = {"error": "validation", |
| 4857 | "specific_error": "not serializer.is_valid()",
|
| 4858 | "reasons": serializer.errors}
|
| 4859 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4860 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4861 | obj.caller = request.user |
| 4862 | if obj.can_update(request.user): |
| 4863 | return super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4864 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4865 | raise Exception("failed obj.can_update") |
| 4866 | |
| 4867 | ret = super(SitePrivilegeList, self).create(request, *args, **kwargs) |
| 4868 | if (ret.status_code%100 != 200): |
| 4869 | raise Exception(ret.data) |
| 4870 | |
| 4871 | return ret |
| 4872 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4873 | |
| 4874 | class SitePrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4875 | queryset = SitePrivilege.objects.select_related().all() |
| 4876 | serializer_class = SitePrivilegeSerializer |
| 4877 | id_serializer_class = SitePrivilegeIdSerializer |
| 4878 | |
| 4879 | def get_serializer_class(self): |
| 4880 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4881 | if (no_hyperlinks): |
| 4882 | return self.id_serializer_class |
| 4883 | else: |
| 4884 | return self.serializer_class |
| 4885 | |
| 4886 | def get_queryset(self): |
| 4887 | return SitePrivilege.select_by_user(self.request.user) |
| 4888 | |
| 4889 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4890 | |
| 4891 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4892 | |
| 4893 | |
| 4894 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4895 | class PlanetStackList(generics.ListCreateAPIView): |
| 4896 | queryset = PlanetStack.objects.select_related().all() |
| 4897 | serializer_class = PlanetStackSerializer |
| 4898 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4899 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4900 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','description',) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4901 | |
| 4902 | def get_serializer_class(self): |
| 4903 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4904 | if (no_hyperlinks): |
| 4905 | return self.id_serializer_class |
| 4906 | else: |
| 4907 | return self.serializer_class |
| 4908 | |
| 4909 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4910 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4911 | |
| 4912 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4913 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4914 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4915 | response = {"error": "validation", |
| 4916 | "specific_error": "not serializer.is_valid()",
|
| 4917 | "reasons": serializer.errors}
|
| 4918 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4919 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4920 | obj.caller = request.user |
| 4921 | if obj.can_update(request.user): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4922 | return super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4923 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4924 | raise Exception("failed obj.can_update") |
| 4925 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4926 | ret = super(PlanetStackList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4927 | if (ret.status_code%100 != 200): |
| 4928 | raise Exception(ret.data) |
| 4929 | |
| 4930 | return ret |
| 4931 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4932 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4933 | class PlanetStackDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4934 | queryset = PlanetStack.objects.select_related().all() |
| 4935 | serializer_class = PlanetStackSerializer |
| 4936 | id_serializer_class = PlanetStackIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4937 | |
| 4938 | def get_serializer_class(self): |
| 4939 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4940 | if (no_hyperlinks): |
| 4941 | return self.id_serializer_class |
| 4942 | else: |
| 4943 | return self.serializer_class |
| 4944 | |
| 4945 | def get_queryset(self): |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 4946 | return PlanetStack.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4947 | |
| 4948 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4949 | |
| 4950 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 4951 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4952 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4953 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4954 | class AccountList(generics.ListCreateAPIView): |
| 4955 | queryset = Account.objects.select_related().all() |
| 4956 | serializer_class = AccountSerializer |
| 4957 | id_serializer_class = AccountIdSerializer |
| 4958 | filter_backends = (filters.DjangoFilterBackend,) |
| 4959 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site',) |
| 4960 | |
| 4961 | def get_serializer_class(self): |
| 4962 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4963 | if (no_hyperlinks): |
| 4964 | return self.id_serializer_class |
| 4965 | else: |
| 4966 | return self.serializer_class |
| 4967 | |
| 4968 | def get_queryset(self): |
| 4969 | return Account.select_by_user(self.request.user) |
| 4970 | |
| 4971 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4972 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 4973 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 4974 | response = {"error": "validation", |
| 4975 | "specific_error": "not serializer.is_valid()",
|
| 4976 | "reasons": serializer.errors}
|
| 4977 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 4978 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4979 | obj.caller = request.user |
| 4980 | if obj.can_update(request.user): |
| 4981 | return super(AccountList, self).create(request, *args, **kwargs) |
| 4982 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 4983 | raise Exception("failed obj.can_update") |
| 4984 | |
| 4985 | ret = super(AccountList, self).create(request, *args, **kwargs) |
| 4986 | if (ret.status_code%100 != 200): |
| 4987 | raise Exception(ret.data) |
| 4988 | |
| 4989 | return ret |
| 4990 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 4991 | |
| 4992 | class AccountDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 4993 | queryset = Account.objects.select_related().all() |
| 4994 | serializer_class = AccountSerializer |
| 4995 | id_serializer_class = AccountIdSerializer |
| 4996 | |
| 4997 | def get_serializer_class(self): |
| 4998 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 4999 | if (no_hyperlinks): |
| 5000 | return self.id_serializer_class |
| 5001 | else: |
| 5002 | return self.serializer_class |
| 5003 | |
| 5004 | def get_queryset(self): |
| 5005 | return Account.select_by_user(self.request.user) |
| 5006 | |
| 5007 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5008 | |
| 5009 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5010 | |
| 5011 | |
| 5012 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5013 | class ControllerRoleList(generics.ListCreateAPIView): |
| 5014 | queryset = ControllerRole.objects.select_related().all() |
| 5015 | serializer_class = ControllerRoleSerializer |
| 5016 | id_serializer_class = ControllerRoleIdSerializer |
| 5017 | filter_backends = (filters.DjangoFilterBackend,) |
| 5018 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5019 | |
| 5020 | def get_serializer_class(self): |
| 5021 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5022 | if (no_hyperlinks): |
| 5023 | return self.id_serializer_class |
| 5024 | else: |
| 5025 | return self.serializer_class |
| 5026 | |
| 5027 | def get_queryset(self): |
| 5028 | return ControllerRole.select_by_user(self.request.user) |
| 5029 | |
| 5030 | def create(self, request, *args, **kwargs): |
| 5031 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5032 | if not (serializer.is_valid()): |
| 5033 | response = {"error": "validation", |
| 5034 | "specific_error": "not serializer.is_valid()",
|
| 5035 | "reasons": serializer.errors}
|
| 5036 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5037 | obj = serializer.object |
| 5038 | obj.caller = request.user |
| 5039 | if obj.can_update(request.user): |
| 5040 | return super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5041 | else: |
| 5042 | raise Exception("failed obj.can_update") |
| 5043 | |
| 5044 | ret = super(ControllerRoleList, self).create(request, *args, **kwargs) |
| 5045 | if (ret.status_code%100 != 200): |
| 5046 | raise Exception(ret.data) |
| 5047 | |
| 5048 | return ret |
| 5049 | |
| 5050 | |
| 5051 | class ControllerRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5052 | queryset = ControllerRole.objects.select_related().all() |
| 5053 | serializer_class = ControllerRoleSerializer |
| 5054 | id_serializer_class = ControllerRoleIdSerializer |
| 5055 | |
| 5056 | def get_serializer_class(self): |
| 5057 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5058 | if (no_hyperlinks): |
| 5059 | return self.id_serializer_class |
| 5060 | else: |
| 5061 | return self.serializer_class |
| 5062 | |
| 5063 | def get_queryset(self): |
| 5064 | return ControllerRole.select_by_user(self.request.user) |
| 5065 | |
| 5066 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5067 | |
| 5068 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5069 | |
| 5070 | |
| 5071 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5072 | class NetworkParameterTypeList(generics.ListCreateAPIView): |
| 5073 | queryset = NetworkParameterType.objects.select_related().all() |
| 5074 | serializer_class = NetworkParameterTypeSerializer |
| 5075 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5076 | filter_backends = (filters.DjangoFilterBackend,) |
| 5077 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','description',) |
| 5078 | |
| 5079 | def get_serializer_class(self): |
| 5080 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5081 | if (no_hyperlinks): |
| 5082 | return self.id_serializer_class |
| 5083 | else: |
| 5084 | return self.serializer_class |
| 5085 | |
| 5086 | def get_queryset(self): |
| 5087 | return NetworkParameterType.select_by_user(self.request.user) |
| 5088 | |
| 5089 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5090 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5091 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5092 | response = {"error": "validation", |
| 5093 | "specific_error": "not serializer.is_valid()",
|
| 5094 | "reasons": serializer.errors}
|
| 5095 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5096 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5097 | obj.caller = request.user |
| 5098 | if obj.can_update(request.user): |
| 5099 | return super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5100 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5101 | raise Exception("failed obj.can_update") |
| 5102 | |
| 5103 | ret = super(NetworkParameterTypeList, self).create(request, *args, **kwargs) |
| 5104 | if (ret.status_code%100 != 200): |
| 5105 | raise Exception(ret.data) |
| 5106 | |
| 5107 | return ret |
| 5108 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5109 | |
| 5110 | class NetworkParameterTypeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5111 | queryset = NetworkParameterType.objects.select_related().all() |
| 5112 | serializer_class = NetworkParameterTypeSerializer |
| 5113 | id_serializer_class = NetworkParameterTypeIdSerializer |
| 5114 | |
| 5115 | def get_serializer_class(self): |
| 5116 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5117 | if (no_hyperlinks): |
| 5118 | return self.id_serializer_class |
| 5119 | else: |
| 5120 | return self.serializer_class |
| 5121 | |
| 5122 | def get_queryset(self): |
| 5123 | return NetworkParameterType.select_by_user(self.request.user) |
| 5124 | |
| 5125 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5126 | |
| 5127 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5128 | |
| 5129 | |
| 5130 | |
| 5131 | class SiteCredentialList(generics.ListCreateAPIView): |
| 5132 | queryset = SiteCredential.objects.select_related().all() |
| 5133 | serializer_class = SiteCredentialSerializer |
| 5134 | id_serializer_class = SiteCredentialIdSerializer |
| 5135 | filter_backends = (filters.DjangoFilterBackend,) |
| 5136 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','name','key_id','enc_value',) |
| 5137 | |
| 5138 | def get_serializer_class(self): |
| 5139 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5140 | if (no_hyperlinks): |
| 5141 | return self.id_serializer_class |
| 5142 | else: |
| 5143 | return self.serializer_class |
| 5144 | |
| 5145 | def get_queryset(self): |
| 5146 | return SiteCredential.select_by_user(self.request.user) |
| 5147 | |
| 5148 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5149 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5150 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5151 | response = {"error": "validation", |
| 5152 | "specific_error": "not serializer.is_valid()",
|
| 5153 | "reasons": serializer.errors}
|
| 5154 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5155 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5156 | obj.caller = request.user |
| 5157 | if obj.can_update(request.user): |
| 5158 | return super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5159 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5160 | raise Exception("failed obj.can_update") |
| 5161 | |
| 5162 | ret = super(SiteCredentialList, self).create(request, *args, **kwargs) |
| 5163 | if (ret.status_code%100 != 200): |
| 5164 | raise Exception(ret.data) |
| 5165 | |
| 5166 | return ret |
| 5167 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5168 | |
| 5169 | class SiteCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5170 | queryset = SiteCredential.objects.select_related().all() |
| 5171 | serializer_class = SiteCredentialSerializer |
| 5172 | id_serializer_class = SiteCredentialIdSerializer |
| 5173 | |
| 5174 | def get_serializer_class(self): |
| 5175 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5176 | if (no_hyperlinks): |
| 5177 | return self.id_serializer_class |
| 5178 | else: |
| 5179 | return self.serializer_class |
| 5180 | |
| 5181 | def get_queryset(self): |
| 5182 | return SiteCredential.select_by_user(self.request.user) |
| 5183 | |
| 5184 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5185 | |
| 5186 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5187 | |
| 5188 | |
| 5189 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5190 | class DeploymentPrivilegeList(generics.ListCreateAPIView): |
| 5191 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5192 | serializer_class = DeploymentPrivilegeSerializer |
| 5193 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5194 | filter_backends = (filters.DjangoFilterBackend,) |
| 5195 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','deployment','role',) |
| 5196 | |
| 5197 | def get_serializer_class(self): |
| 5198 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5199 | if (no_hyperlinks): |
| 5200 | return self.id_serializer_class |
| 5201 | else: |
| 5202 | return self.serializer_class |
| 5203 | |
| 5204 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5205 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5206 | |
| 5207 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5208 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5209 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5210 | response = {"error": "validation", |
| 5211 | "specific_error": "not serializer.is_valid()",
|
| 5212 | "reasons": serializer.errors}
|
| 5213 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5214 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5215 | obj.caller = request.user |
| 5216 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5217 | return super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5218 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5219 | raise Exception("failed obj.can_update") |
| 5220 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5221 | ret = super(DeploymentPrivilegeList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5222 | if (ret.status_code%100 != 200): |
| 5223 | raise Exception(ret.data) |
| 5224 | |
| 5225 | return ret |
| 5226 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5227 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5228 | class DeploymentPrivilegeDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5229 | queryset = DeploymentPrivilege.objects.select_related().all() |
| 5230 | serializer_class = DeploymentPrivilegeSerializer |
| 5231 | id_serializer_class = DeploymentPrivilegeIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5232 | |
| 5233 | def get_serializer_class(self): |
| 5234 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5235 | if (no_hyperlinks): |
| 5236 | return self.id_serializer_class |
| 5237 | else: |
| 5238 | return self.serializer_class |
| 5239 | |
| 5240 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5241 | return DeploymentPrivilege.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5242 | |
| 5243 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5244 | |
| 5245 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5246 | |
| 5247 | |
| 5248 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5249 | class ControllerUsersList(generics.ListCreateAPIView): |
| 5250 | queryset = ControllerUsers.objects.select_related().all() |
| 5251 | serializer_class = ControllerUsersSerializer |
| 5252 | id_serializer_class = ControllerUsersIdSerializer |
| 5253 | filter_backends = (filters.DjangoFilterBackend,) |
| 5254 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','controller','kuser_id',) |
| 5255 | |
| 5256 | def get_serializer_class(self): |
| 5257 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5258 | if (no_hyperlinks): |
| 5259 | return self.id_serializer_class |
| 5260 | else: |
| 5261 | return self.serializer_class |
| 5262 | |
| 5263 | def get_queryset(self): |
| 5264 | return ControllerUsers.select_by_user(self.request.user) |
| 5265 | |
| 5266 | def create(self, request, *args, **kwargs): |
| 5267 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5268 | if not (serializer.is_valid()): |
| 5269 | response = {"error": "validation", |
| 5270 | "specific_error": "not serializer.is_valid()",
|
| 5271 | "reasons": serializer.errors}
|
| 5272 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5273 | obj = serializer.object |
| 5274 | obj.caller = request.user |
| 5275 | if obj.can_update(request.user): |
| 5276 | return super(ControllerUsersList, self).create(request, *args, **kwargs) |
| 5277 | else: |
| 5278 | raise Exception("failed obj.can_update") |
| 5279 | |
| 5280 | ret = super(ControllerUsersList, self).create(request, *args, **kwargs) |
| 5281 | if (ret.status_code%100 != 200): |
| 5282 | raise Exception(ret.data) |
| 5283 | |
| 5284 | return ret |
| 5285 | |
| 5286 | |
| 5287 | class ControllerUsersDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5288 | queryset = ControllerUsers.objects.select_related().all() |
| 5289 | serializer_class = ControllerUsersSerializer |
| 5290 | id_serializer_class = ControllerUsersIdSerializer |
| 5291 | |
| 5292 | def get_serializer_class(self): |
| 5293 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5294 | if (no_hyperlinks): |
| 5295 | return self.id_serializer_class |
| 5296 | else: |
| 5297 | return self.serializer_class |
| 5298 | |
| 5299 | def get_queryset(self): |
| 5300 | return ControllerUsers.select_by_user(self.request.user) |
| 5301 | |
| 5302 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5303 | |
| 5304 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5305 | |
| 5306 | |
| 5307 | |
| 5308 | class DeploymentRoleList(generics.ListCreateAPIView): |
| 5309 | queryset = DeploymentRole.objects.select_related().all() |
| 5310 | serializer_class = DeploymentRoleSerializer |
| 5311 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5312 | filter_backends = (filters.DjangoFilterBackend,) |
| 5313 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','role',) |
| 5314 | |
| 5315 | def get_serializer_class(self): |
| 5316 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5317 | if (no_hyperlinks): |
| 5318 | return self.id_serializer_class |
| 5319 | else: |
| 5320 | return self.serializer_class |
| 5321 | |
| 5322 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5323 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5324 | |
| 5325 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5326 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5327 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5328 | response = {"error": "validation", |
| 5329 | "specific_error": "not serializer.is_valid()",
|
| 5330 | "reasons": serializer.errors}
|
| 5331 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5332 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5333 | obj.caller = request.user |
| 5334 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5335 | return super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5336 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5337 | raise Exception("failed obj.can_update") |
| 5338 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5339 | ret = super(DeploymentRoleList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5340 | if (ret.status_code%100 != 200): |
| 5341 | raise Exception(ret.data) |
| 5342 | |
| 5343 | return ret |
| 5344 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5345 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5346 | class DeploymentRoleDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5347 | queryset = DeploymentRole.objects.select_related().all() |
| 5348 | serializer_class = DeploymentRoleSerializer |
| 5349 | id_serializer_class = DeploymentRoleIdSerializer |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5350 | |
| 5351 | def get_serializer_class(self): |
| 5352 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5353 | if (no_hyperlinks): |
| 5354 | return self.id_serializer_class |
| 5355 | else: |
| 5356 | return self.serializer_class |
| 5357 | |
| 5358 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5359 | return DeploymentRole.select_by_user(self.request.user) |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5360 | |
| 5361 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5362 | |
| 5363 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5364 | |
| 5365 | |
| 5366 | |
| 5367 | class UserCredentialList(generics.ListCreateAPIView): |
| 5368 | queryset = UserCredential.objects.select_related().all() |
| 5369 | serializer_class = UserCredentialSerializer |
| 5370 | id_serializer_class = UserCredentialIdSerializer |
| 5371 | filter_backends = (filters.DjangoFilterBackend,) |
| 5372 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','user','name','key_id','enc_value',) |
| 5373 | |
| 5374 | def get_serializer_class(self): |
| 5375 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5376 | if (no_hyperlinks): |
| 5377 | return self.id_serializer_class |
| 5378 | else: |
| 5379 | return self.serializer_class |
| 5380 | |
| 5381 | def get_queryset(self): |
| 5382 | return UserCredential.select_by_user(self.request.user) |
| 5383 | |
| 5384 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5385 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5386 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5387 | response = {"error": "validation", |
| 5388 | "specific_error": "not serializer.is_valid()",
|
| 5389 | "reasons": serializer.errors}
|
| 5390 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5391 | obj = serializer.object |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5392 | obj.caller = request.user |
| 5393 | if obj.can_update(request.user): |
| 5394 | return super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5395 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5396 | raise Exception("failed obj.can_update") |
| 5397 | |
| 5398 | ret = super(UserCredentialList, self).create(request, *args, **kwargs) |
| 5399 | if (ret.status_code%100 != 200): |
| 5400 | raise Exception(ret.data) |
| 5401 | |
| 5402 | return ret |
| 5403 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5404 | |
| 5405 | class UserCredentialDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5406 | queryset = UserCredential.objects.select_related().all() |
| 5407 | serializer_class = UserCredentialSerializer |
| 5408 | id_serializer_class = UserCredentialIdSerializer |
| 5409 | |
| 5410 | def get_serializer_class(self): |
| 5411 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5412 | if (no_hyperlinks): |
| 5413 | return self.id_serializer_class |
| 5414 | else: |
| 5415 | return self.serializer_class |
| 5416 | |
| 5417 | def get_queryset(self): |
| 5418 | return UserCredential.select_by_user(self.request.user) |
| 5419 | |
| 5420 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5421 | |
| 5422 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5423 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5424 | |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5425 | |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5426 | class SiteDeploymentsList(generics.ListCreateAPIView): |
| 5427 | queryset = SiteDeployments.objects.select_related().all() |
| 5428 | serializer_class = SiteDeploymentsSerializer |
| 5429 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5430 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5431 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','site','deployment','controller','availability_zone',) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5432 | |
| 5433 | def get_serializer_class(self): |
| 5434 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5435 | if (no_hyperlinks): |
| 5436 | return self.id_serializer_class |
| 5437 | else: |
| 5438 | return self.serializer_class |
| 5439 | |
| 5440 | def get_queryset(self): |
| 5441 | return SiteDeployments.select_by_user(self.request.user) |
| 5442 | |
| 5443 | def create(self, request, *args, **kwargs): |
| 5444 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5445 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5446 | response = {"error": "validation", |
| 5447 | "specific_error": "not serializer.is_valid()",
|
| 5448 | "reasons": serializer.errors}
|
| 5449 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | b744f1c | 2014-11-21 11:32:24 -0800 | [diff] [blame] | 5450 | obj = serializer.object |
| 5451 | obj.caller = request.user |
| 5452 | if obj.can_update(request.user): |
| 5453 | return super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 5454 | else: |
| 5455 | raise Exception("failed obj.can_update") |
| 5456 | |
| 5457 | ret = super(SiteDeploymentsList, self).create(request, *args, **kwargs) |
| 5458 | if (ret.status_code%100 != 200): |
| 5459 | raise Exception(ret.data) |
| 5460 | |
| 5461 | return ret |
| 5462 | |
| 5463 | |
| 5464 | class SiteDeploymentsDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5465 | queryset = SiteDeployments.objects.select_related().all() |
| 5466 | serializer_class = SiteDeploymentsSerializer |
| 5467 | id_serializer_class = SiteDeploymentsIdSerializer |
| 5468 | |
| 5469 | def get_serializer_class(self): |
| 5470 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5471 | if (no_hyperlinks): |
| 5472 | return self.id_serializer_class |
| 5473 | else: |
| 5474 | return self.serializer_class |
| 5475 | |
| 5476 | def get_queryset(self): |
| 5477 | return SiteDeployments.select_by_user(self.request.user) |
| 5478 | |
| 5479 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5480 | |
| 5481 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5482 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5483 | |
| 5484 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5485 | class SliceTagList(generics.ListCreateAPIView): |
| 5486 | queryset = SliceTag.objects.select_related().all() |
| 5487 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5488 | id_serializer_class = SliceTagIdSerializer |
| 5489 | filter_backends = (filters.DjangoFilterBackend,) |
| 5490 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','slice','name','value',) |
| 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 Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5499 | def get_queryset(self): |
| 5500 | return SliceTag.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5501 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5502 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5503 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5504 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5505 | response = {"error": "validation", |
| 5506 | "specific_error": "not serializer.is_valid()",
|
| 5507 | "reasons": serializer.errors}
|
| 5508 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5509 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5510 | obj.caller = request.user |
| 5511 | if obj.can_update(request.user): |
| 5512 | return super(SliceTagList, self).create(request, *args, **kwargs) |
| 5513 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5514 | raise Exception("failed obj.can_update") |
| 5515 | |
| 5516 | ret = super(SliceTagList, self).create(request, *args, **kwargs) |
| 5517 | if (ret.status_code%100 != 200): |
| 5518 | raise Exception(ret.data) |
| 5519 | |
| 5520 | return ret |
| 5521 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5522 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5523 | class SliceTagDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5524 | queryset = SliceTag.objects.select_related().all() |
| 5525 | serializer_class = SliceTagSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5526 | id_serializer_class = SliceTagIdSerializer |
| 5527 | |
| 5528 | def get_serializer_class(self): |
| 5529 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5530 | if (no_hyperlinks): |
| 5531 | return self.id_serializer_class |
| 5532 | else: |
| 5533 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5534 | |
| 5535 | def get_queryset(self): |
| 5536 | return SliceTag.select_by_user(self.request.user) |
| 5537 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5538 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5539 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5540 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5541 | |
| 5542 | |
| 5543 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5544 | class ControllerDashboardList(generics.ListCreateAPIView): |
| 5545 | queryset = ControllerDashboard.objects.select_related().all() |
| 5546 | serializer_class = ControllerDashboardSerializer |
| 5547 | id_serializer_class = ControllerDashboardIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5548 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5549 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','dashboardView','url',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 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 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5558 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5559 | return ControllerDashboard.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5560 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5561 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5562 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5563 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5564 | response = {"error": "validation", |
| 5565 | "specific_error": "not serializer.is_valid()",
|
| 5566 | "reasons": serializer.errors}
|
| 5567 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5568 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5569 | obj.caller = request.user |
| 5570 | if obj.can_update(request.user): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5571 | return super(ControllerDashboardList, self).create(request, *args, **kwargs) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5572 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5573 | raise Exception("failed obj.can_update") |
| 5574 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5575 | ret = super(ControllerDashboardList, self).create(request, *args, **kwargs) |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5576 | if (ret.status_code%100 != 200): |
| 5577 | raise Exception(ret.data) |
| 5578 | |
| 5579 | return ret |
| 5580 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5581 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5582 | class ControllerDashboardDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5583 | queryset = ControllerDashboard.objects.select_related().all() |
| 5584 | serializer_class = ControllerDashboardSerializer |
| 5585 | id_serializer_class = ControllerDashboardIdSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5586 | |
| 5587 | def get_serializer_class(self): |
| 5588 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5589 | if (no_hyperlinks): |
| 5590 | return self.id_serializer_class |
| 5591 | else: |
| 5592 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5593 | |
| 5594 | def get_queryset(self): |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5595 | return ControllerDashboard.select_by_user(self.request.user) |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5596 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5597 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5598 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5599 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5600 | |
| 5601 | |
| 5602 | |
| 5603 | class RouterList(generics.ListCreateAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5604 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5605 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5606 | id_serializer_class = RouterIdSerializer |
| 5607 | filter_backends = (filters.DjangoFilterBackend,) |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5608 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','name','owner','networks','networks',) |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5609 | |
| 5610 | def get_serializer_class(self): |
| 5611 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5612 | if (no_hyperlinks): |
| 5613 | return self.id_serializer_class |
| 5614 | else: |
| 5615 | return self.serializer_class |
| 5616 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5617 | def get_queryset(self): |
| 5618 | return Router.select_by_user(self.request.user) |
| 5619 | |
| 5620 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5621 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5622 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5623 | response = {"error": "validation", |
| 5624 | "specific_error": "not serializer.is_valid()",
|
| 5625 | "reasons": serializer.errors}
|
| 5626 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5627 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5628 | obj.caller = request.user |
| 5629 | if obj.can_update(request.user): |
| 5630 | return super(RouterList, self).create(request, *args, **kwargs) |
| 5631 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5632 | raise Exception("failed obj.can_update") |
| 5633 | |
| 5634 | ret = super(RouterList, self).create(request, *args, **kwargs) |
| 5635 | if (ret.status_code%100 != 200): |
| 5636 | raise Exception(ret.data) |
| 5637 | |
| 5638 | return ret |
| 5639 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5640 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5641 | class RouterDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5642 | queryset = Router.objects.select_related().all() |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5643 | serializer_class = RouterSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5644 | id_serializer_class = RouterIdSerializer |
| 5645 | |
| 5646 | def get_serializer_class(self): |
| 5647 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5648 | if (no_hyperlinks): |
| 5649 | return self.id_serializer_class |
| 5650 | else: |
| 5651 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5652 | |
| 5653 | def get_queryset(self): |
| 5654 | return Router.select_by_user(self.request.user) |
| 5655 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5656 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5657 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5658 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5659 | |
| 5660 | |
| 5661 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5662 | class ServiceResourceList(generics.ListCreateAPIView): |
| 5663 | queryset = ServiceResource.objects.select_related().all() |
| 5664 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5665 | id_serializer_class = ServiceResourceIdSerializer |
| 5666 | filter_backends = (filters.DjangoFilterBackend,) |
| 5667 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','serviceClass','name','maxUnitsDeployment','maxUnitsNode','maxDuration','bucketInRate','bucketMaxSize','cost','calendarReservable',) |
| 5668 | |
| 5669 | def get_serializer_class(self): |
| 5670 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5671 | if (no_hyperlinks): |
| 5672 | return self.id_serializer_class |
| 5673 | else: |
| 5674 | return self.serializer_class |
| 5675 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5676 | def get_queryset(self): |
| 5677 | return ServiceResource.select_by_user(self.request.user) |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5678 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5679 | def create(self, request, *args, **kwargs): |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5680 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5681 | if not (serializer.is_valid()): |
Scott Baker | 96eb3fd | 2014-11-25 00:53:25 -0800 | [diff] [blame] | 5682 | response = {"error": "validation", |
| 5683 | "specific_error": "not serializer.is_valid()",
|
| 5684 | "reasons": serializer.errors}
|
| 5685 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
Scott Baker | 57c725c | 2014-11-12 01:13:53 -0800 | [diff] [blame] | 5686 | obj = serializer.object |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5687 | obj.caller = request.user |
| 5688 | if obj.can_update(request.user): |
| 5689 | return super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5690 | else: |
Scott Baker | 2bcbf37 | 2014-10-29 23:41:11 -0700 | [diff] [blame] | 5691 | raise Exception("failed obj.can_update") |
| 5692 | |
| 5693 | ret = super(ServiceResourceList, self).create(request, *args, **kwargs) |
| 5694 | if (ret.status_code%100 != 200): |
| 5695 | raise Exception(ret.data) |
| 5696 | |
| 5697 | return ret |
| 5698 | |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5699 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5700 | class ServiceResourceDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5701 | queryset = ServiceResource.objects.select_related().all() |
| 5702 | serializer_class = ServiceResourceSerializer |
Scott Baker | 46b5854 | 2014-08-11 17:26:12 -0700 | [diff] [blame] | 5703 | id_serializer_class = ServiceResourceIdSerializer |
| 5704 | |
| 5705 | def get_serializer_class(self): |
| 5706 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5707 | if (no_hyperlinks): |
| 5708 | return self.id_serializer_class |
| 5709 | else: |
| 5710 | return self.serializer_class |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5711 | |
| 5712 | def get_queryset(self): |
| 5713 | return ServiceResource.select_by_user(self.request.user) |
| 5714 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5715 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Scott Baker | 0caeaf0 | 2014-06-19 11:12:55 -0700 | [diff] [blame] | 5716 | |
Scott Baker | 89a7b7c | 2014-10-07 00:10:17 -0700 | [diff] [blame] | 5717 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5718 | |
Sapan Bhatia | dea3943 | 2014-06-13 03:10:36 -0400 | [diff] [blame] | 5719 | |
| 5720 | |
Scott Baker | 515dc9e | 2014-12-22 09:29:05 -0800 | [diff] [blame] | 5721 | class ControllerSlicesList(generics.ListCreateAPIView): |
| 5722 | queryset = ControllerSlices.objects.select_related().all() |
| 5723 | serializer_class = ControllerSlicesSerializer |
| 5724 | id_serializer_class = ControllerSlicesIdSerializer |
| 5725 | filter_backends = (filters.DjangoFilterBackend,) |
| 5726 | filter_fields = ('id','created','updated','enacted','backend_status','deleted','controller','slice','tenant_id',) |
| 5727 | |
| 5728 | def get_serializer_class(self): |
| 5729 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5730 | if (no_hyperlinks): |
| 5731 | return self.id_serializer_class |
| 5732 | else: |
| 5733 | return self.serializer_class |
| 5734 | |
| 5735 | def get_queryset(self): |
| 5736 | return ControllerSlices.select_by_user(self.request.user) |
| 5737 | |
| 5738 | def create(self, request, *args, **kwargs): |
| 5739 | serializer = self.get_serializer(data=request.DATA, files=request.FILES) |
| 5740 | if not (serializer.is_valid()): |
| 5741 | response = {"error": "validation", |
| 5742 | "specific_error": "not serializer.is_valid()",
|
| 5743 | "reasons": serializer.errors}
|
| 5744 | return Response(response, status=status.HTTP_400_BAD_REQUEST) |
| 5745 | obj = serializer.object |
| 5746 | obj.caller = request.user |
| 5747 | if obj.can_update(request.user): |
| 5748 | return super(ControllerSlicesList, self).create(request, *args, **kwargs) |
| 5749 | else: |
| 5750 | raise Exception("failed obj.can_update") |
| 5751 | |
| 5752 | ret = super(ControllerSlicesList, self).create(request, *args, **kwargs) |
| 5753 | if (ret.status_code%100 != 200): |
| 5754 | raise Exception(ret.data) |
| 5755 | |
| 5756 | return ret |
| 5757 | |
| 5758 | |
| 5759 | class ControllerSlicesDetail(PlanetStackRetrieveUpdateDestroyAPIView): |
| 5760 | queryset = ControllerSlices.objects.select_related().all() |
| 5761 | serializer_class = ControllerSlicesSerializer |
| 5762 | id_serializer_class = ControllerSlicesIdSerializer |
| 5763 | |
| 5764 | def get_serializer_class(self): |
| 5765 | no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False) |
| 5766 | if (no_hyperlinks): |
| 5767 | return self.id_serializer_class |
| 5768 | else: |
| 5769 | return self.serializer_class |
| 5770 | |
| 5771 | def get_queryset(self): |
| 5772 | return ControllerSlices.select_by_user(self.request.user) |
| 5773 | |
| 5774 | # update() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5775 | |
| 5776 | # destroy() is handled by PlanetStackRetrieveUpdateDestroyAPIView |
| 5777 | |
| 5778 | |
| 5779 | |